colored output, depending of days remaining
This commit is contained in:
parent
116485c22b
commit
e336b8edee
@ -1,10 +1,10 @@
|
|||||||
package de.schatenseite.android.waldemar;
|
package de.schatenseite.android.waldemar;
|
||||||
|
|
||||||
import static de.schatenseite.android.waldemar.WaldemarPreferences.PREFERENCES_UPDATED;
|
|
||||||
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_TIMETHEN;
|
|
||||||
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_TIMESTART_TIMETHEN;
|
|
||||||
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_DURATION_TIMETHEN;
|
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_DURATION_TIMETHEN;
|
||||||
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_TIMESTART_DURATION;
|
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_TIMESTART_DURATION;
|
||||||
|
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_TIMESTART_TIMETHEN;
|
||||||
|
import static de.schatenseite.android.waldemar.WaldemarPreferences.MODE_TIMETHEN;
|
||||||
|
import static de.schatenseite.android.waldemar.WaldemarPreferences.PREFERENCES_UPDATED;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -21,6 +21,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -140,6 +141,15 @@ public class WaldemarWidget extends AppWidgetProvider {
|
|||||||
Integer days = (int)Math.round((double)(timeThen - timeNow) / MILLISECONDS_PER_DAY);
|
Integer days = (int)Math.round((double)(timeThen - timeNow) / MILLISECONDS_PER_DAY);
|
||||||
remoteViews.setTextViewText(R.id.daycount, String.valueOf(days));
|
remoteViews.setTextViewText(R.id.daycount, String.valueOf(days));
|
||||||
|
|
||||||
|
int daycountColor = Color.WHITE;
|
||||||
|
if (days == 0) {
|
||||||
|
daycountColor = Color.GREEN;
|
||||||
|
} else if (days < 0) {
|
||||||
|
daycountColor = Color.RED;
|
||||||
|
}
|
||||||
|
remoteViews.setTextColor(R.id.daycount, daycountColor);
|
||||||
|
remoteViews.setTextColor(R.id.days, daycountColor);
|
||||||
|
|
||||||
Integer percent = (int)(((double)(duration - days) / (double)duration)*100);
|
Integer percent = (int)(((double)(duration - days) / (double)duration)*100);
|
||||||
String status = String.valueOf(duration - days)+"/"+String.valueOf(duration)+", "+String.valueOf(percent)+"%";
|
String status = String.valueOf(duration - days)+"/"+String.valueOf(duration)+", "+String.valueOf(percent)+"%";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user