Skip to content
Snippets Groups Projects
Commit ad88ff7f authored by Pogman's avatar Pogman
Browse files

Quick fix for default log text colors

parent 2b762ced
Branches
No related tags found
No related merge requests found
......@@ -447,7 +447,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
// userlog message at startup when no service is running
if (!mPrefs.getBoolean("EnableCgmService", false)) {
UserLogMessage.getInstance().add(UserLogMessage.TYPE.HEART, R.string.main_hello);
UserLogMessage.getInstance().add(UserLogMessage.TYPE.STARTUP, R.string.main_hello);
UserLogMessage.getInstance().add(UserLogMessage.TYPE.OPTION,
String.format("{id;%s} {id;%s}",
......@@ -494,7 +494,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private void shutdownMessage() {
// userlog message at shutdown when 'stop collecting data' selected
if (!mPrefs.getBoolean("EnableCgmService", false)) {
UserLogMessage.getInstance().add(UserLogMessage.TYPE.HEART, R.string.main_goodbye);
UserLogMessage.getInstance().add(UserLogMessage.TYPE.SHUTDOWN, R.string.main_goodbye);
UserLogMessage.getInstance().add("---------------------------------------------------");
}
}
......@@ -1051,6 +1051,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
fabCurrent = findViewById(R.id.fab_log_current);
fabCurrent.hide();
// return to most recent log entry
fabCurrent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -1076,6 +1077,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
fabSearch = findViewById(R.id.fab_log_search);
fabSearch.hide();
// search click: in normal mode will scroll to errors/warnings, in extended mode this includes notes
fabSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -1109,6 +1111,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
});
// search long click: in normal mode will scroll to the start of a session, in extended mode to notes
fabSearch.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
......@@ -1119,26 +1122,29 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
RealmResults<UserLog> rr = userLogResults.where()
.lessThan("timestamp", userLogResults.get(p).getTimestamp())
.equalTo("type", extended ? UserLogMessage.TYPE.NOTE.value() : UserLogMessage.TYPE.WARN.value())
.equalTo("type", extended ? UserLogMessage.TYPE.NOTE.value() : UserLogMessage.TYPE.STARTUP.value())
.sort("timestamp", Sort.DESCENDING)
.findAll();
int to = 0;
if (rr.size() > 0) {
int ss = userLogResults.indexOf(rr.first());
int c = realmRecyclerView.getRecycleView().getLayoutManager().getChildCount() / 4;
int to = ss - (c < 1 ? 1 : c);
to = ss - (c < 1 ? 1 : c);
if (to < 0) to = 0;
}
if (Math.abs(p - to) > 400)
realmRecyclerView.scrollToPosition(to);
else
realmRecyclerView.smoothScrollToPosition(to);
}
}
}
return true;
}
});
// show/hide the floating log buttons
RecyclerView rv = realmRecyclerView.getRecycleView();
rv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
......@@ -1160,6 +1166,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
});
// don't autoscroll the log when screen is being touched by user
rv.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
......
......@@ -30,6 +30,7 @@ public class UserLogAdapter
private final static int FADE_DURATION_MS = 400;
private final static int cDEFAULT = 0xFFC0C0C0;
private final static int cHIGHLIGHT = 0xFFE0E0E0;
private final static int cCLOCK = 0xFFA0A0A0;
private final static int cWARN = 0xFFE0E000;
......@@ -154,6 +155,8 @@ public class UserLogAdapter
ssb.setSpan(new ImageSpan(iSETTING, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.setSpan(new ForegroundColorSpan(cHIGHLIGHT), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
break;
case STARTUP:
case SHUTDOWN:
case HEART:
ssb.append(" * ").append(text);
ssb.setSpan(new ImageSpan(iHEART, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
......@@ -180,6 +183,7 @@ public class UserLogAdapter
break;
default:
ssb.append(" ").append(text);
ssb.setSpan(new ForegroundColorSpan(cDEFAULT), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
ssb.insert(0, clock);
......@@ -191,22 +195,20 @@ public class UserLogAdapter
private void initIcons(TextView tv) {
cDefault = tv.getCurrentTextColor();
iBounds = (int) (tv.getTextSize() * 1.2);
iOffsetXDp = 0;
iOffsetYDp = 3;
iWARN = icon("ion_alert_circled", cWARN);
iINFO = icon("ion_information_circled", cHIGHLIGHT);
//iNOTE = icon("ion_clipboard", cHIGHLIGHT);
iNOTE = icon("ion_document", cHIGHLIGHT);
//iNOTE = icon("ion_stats_bars", cHIGHLIGHT);
iHELP = icon("ion_ios_lightbulb", cHIGHLIGHT);
iCGM = icon("ion_ios_pulse_strong", cCGM);
iHEART = icon("ion_heart", cHEART);
iSHARE = icon("ion_android_share_alt", cHIGHLIGHT);
//iREFRESH = icon("ion_loop", cDefault);
iREFRESH = icon("ion_refresh", cDefault);
//iREFRESH = icon("ion_loop", cDEFAULT);
iREFRESH = icon("ion_refresh", cDEFAULT);
iSETTING = icon("ion_android_settings", cHIGHLIGHT);
}
......
......@@ -187,6 +187,8 @@ public class UserLogMessage {
REQUESTED(11),
RECEIVED(12),
SHARE(13),
STARTUP(14),
SHUTDOWN(15),
NA(-1);
private int value;
......
......@@ -258,9 +258,10 @@ public class MasterService extends Service {
statusNotification.initNotification(mContext);
startCgmService();
serviceActive = true;
uploadPollResults();
startCgmService();
}
return START_STICKY;
......
......@@ -513,7 +513,8 @@ CNL: unpaired PUMP: unpaired UPLOADER: unregistered = "Invalid message received
// skip if pump battery is low and interval time is higher then poll period, process history once per hour
if (!pumpRecord.isOldSgvWhenNewExpected() &&
!(pumpBatteryError > 0 && dataStore.getLowBatPollInterval() > POLL_PERIOD_MS
!(pumpBatteryError > 0
&& dataStore.getLowBatPollInterval() > POLL_PERIOD_MS
&& pumpHistoryHandler.pumpHistoryRecency() < 60 * 60000L)) {
if (dataStore.isRequestProfile()) {
......
......@@ -46,6 +46,12 @@ public class FormatKit {
return sInstance;
}
// set the language to use for formatting
public FormatKit mode(int mode) {
return this;
}
public String formatAsGrams(Double value) {
DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.getDefault()));
df.setMinimumFractionDigits(0);
......@@ -110,22 +116,6 @@ public class FormatKit {
DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.getDefault()));
return df.format(value);
}
/*
public String formatSecondsAsDiff(int seconds) {
int d = Math.abs(seconds) / 86400;
int h = (Math.abs(seconds) % 86400) / 3600;
int m = (Math.abs(seconds) % 3600) / 60;
int s = Math.abs(seconds) % 60;
String t = seconds < 0 ? "-" : "+";
if (d > 0) t += d + mApplication.getApplicationContext().getString(R.string.time_d);
else if (h > 0) t += h + mApplication.getApplicationContext().getString(R.string.time_h);
else if (m > 0) t += m + mApplication.getApplicationContext().getString(R.string.time_m);
else t += s + mApplication.getApplicationContext().getString(R.string.time_s);
return t;
}
*/
public String formatSecondsAsDiff(int seconds) {
return (seconds < 0 ? "-" : "+") + formatSecondsAsDHMS(Math.abs(seconds));
......@@ -151,14 +141,6 @@ public class FormatKit {
m + mApplication.getApplicationContext().getString(R.string.time_m);
}
/*
public String formatMinutesAsHM(int minutes) {
int h = minutes / 60;
int m = minutes % 60;
return (h > 0 ? h + mContext.getString(R.string.time_h) : "") +
m + mContext.getString(R.string.time_m);
}
*/
public String formatMinutesAsHM(int minutes) {
int h = minutes / 60;
int m = minutes % 60;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment