forked from firka/student-legacy
feat: the Widget now gets it's colors from the app theme!
This commit is contained in:
parent
e2ac4303f3
commit
b2db424d20
@ -53,7 +53,7 @@ public class DBManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Cursor fetchTheme() {
|
public Cursor fetchTheme() {
|
||||||
Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.THEME, SQLiteHelper.ACCENT_COLOR}, null, null, null, null, null);
|
Cursor cursor = this.database.query(SQLiteHelper.TABLE_NAME_SETTINGS, new String[]{SQLiteHelper.THEME, SQLiteHelper.CUSTOM_ACCENT_COLOR, SQLiteHelper.CUSTOM_HIGHLIGHT_COLOR, SQLiteHelper.CUSTOM_BACKGROUND_COLOR}, null, null, null, null, null);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
}
|
}
|
||||||
@ -116,4 +116,4 @@ public class DBManager {
|
|||||||
con.put(SQLiteHelper.DAY_SEL, day_sel);
|
con.put(SQLiteHelper.DAY_SEL, day_sel);
|
||||||
return this.database.update(SQLiteHelper.TABLE_NAME_WIDGETS, con, SQLiteHelper._ID + " = " + _id, null);
|
return this.database.update(SQLiteHelper.TABLE_NAME_WIDGETS, con, SQLiteHelper._ID + " = " + _id, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,9 @@ public class SQLiteHelper extends SQLiteOpenHelper {
|
|||||||
public static final String PREMIUM_TOKEN = "premium_token";
|
public static final String PREMIUM_TOKEN = "premium_token";
|
||||||
public static final String PREMIUM_SCOPES = "premium_scopes";
|
public static final String PREMIUM_SCOPES = "premium_scopes";
|
||||||
public static final String LOCALE = "language";
|
public static final String LOCALE = "language";
|
||||||
public static final String ACCENT_COLOR = "accent_color";
|
public static final String CUSTOM_ACCENT_COLOR = "custom_accent_color";
|
||||||
|
public static final String CUSTOM_BACKGROUND_COLOR = "custom_background_color";
|
||||||
|
public static final String CUSTOM_HIGHLIGHT_COLOR = "custom_highlight_color";
|
||||||
public static final String TABLE_NAME_WIDGETS = "widgets";
|
public static final String TABLE_NAME_WIDGETS = "widgets";
|
||||||
public static final String TABLE_NAME_USER_DATA = "user_data";
|
public static final String TABLE_NAME_USER_DATA = "user_data";
|
||||||
public static final String TABLE_NAME_SETTINGS = "settings";
|
public static final String TABLE_NAME_SETTINGS = "settings";
|
||||||
@ -33,4 +35,4 @@ public class SQLiteHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL("DROP TABLE IF EXISTS widgets");
|
db.execSQL("DROP TABLE IF EXISTS widgets");
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package hu.refilc.naplo.widget_timetable;
|
package hu.refilc.naplo.widget_timetable;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.app.UiModeManager;
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.appwidget.AppWidgetProvider;
|
import android.appwidget.AppWidgetProvider;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -54,12 +55,16 @@ public class WidgetTimetable extends HomeWidgetProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, SharedPreferences widgetData) {
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, SharedPreferences widgetData) {
|
||||||
|
Integer[] fullTheme = getFullTheme(context);
|
||||||
|
Integer[] textColors = getTextColors(context, fullTheme);
|
||||||
|
|
||||||
for (int i = 0; i < appWidgetIds.length; i++) {
|
for (int i = 0; i < appWidgetIds.length; i++) {
|
||||||
RemoteViews views = generateView(context, appWidgetIds[i]);
|
RemoteViews views = generateView(context, appWidgetIds[i]);
|
||||||
|
|
||||||
if(userLoggedIn(context)) {
|
if(userLoggedIn(context)) {
|
||||||
int rday = selectDay(context, appWidgetIds[i], 0, true);
|
int rday = selectDay(context, appWidgetIds[i], 0, true);
|
||||||
views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
|
views.setTextViewText(R.id.nav_current, convertDayOfWeek(context, rday));
|
||||||
|
views.setInt(R.id.nav_current, "setTextColor", getColor(context, textColors[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
pushUpdate(context, views, appWidgetIds[i]);
|
pushUpdate(context, views, appWidgetIds[i]);
|
||||||
@ -73,7 +78,54 @@ public class WidgetTimetable extends HomeWidgetProvider {
|
|||||||
manager.notifyAppWidgetViewDataChanged(appWidgetSingleId, R.id.widget_list);
|
manager.notifyAppWidgetViewDataChanged(appWidgetSingleId, R.id.widget_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getColor(Context context, int color) {
|
||||||
|
return context.getResources().getColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer[] getTextColors(Context context, Integer[] fullTheme) {
|
||||||
|
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||||
|
int nightMode = uiModeManager.getNightMode();
|
||||||
|
|
||||||
|
int textColor;
|
||||||
|
int textDescColor;
|
||||||
|
|
||||||
|
if (fullTheme[0] == 0 && nightMode == UiModeManager.MODE_NIGHT_NO) {
|
||||||
|
textColor = R.color.text_light;
|
||||||
|
textDescColor = R.color.text_desc_light;
|
||||||
|
} else if (fullTheme[0] == 1) {
|
||||||
|
textColor = R.color.text_light;
|
||||||
|
textDescColor = R.color.text_desc_light;
|
||||||
|
} else {
|
||||||
|
textColor = R.color.text;
|
||||||
|
textDescColor = R.color.text_desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Integer[]{textColor, textDescColor};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer[] getFullTheme(Context context) {
|
||||||
|
DBManager dbManager = new DBManager(context.getApplicationContext());
|
||||||
|
|
||||||
|
try {
|
||||||
|
dbManager.open();
|
||||||
|
Cursor cursor = dbManager.fetchTheme();
|
||||||
|
dbManager.close();
|
||||||
|
|
||||||
|
int theme = cursor.getInt(0);
|
||||||
|
int customBackgroundColor = cursor.getInt(3);
|
||||||
|
|
||||||
|
return new Integer[]{theme, customBackgroundColor};
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Integer[]{0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
public static RemoteViews generateView(Context context, int appId) {
|
public static RemoteViews generateView(Context context, int appId) {
|
||||||
|
Integer[] fullTheme = getFullTheme(context);
|
||||||
|
Integer[] textColors = getTextColors(context, fullTheme);
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(context, WidgetTimetableService.class);
|
Intent serviceIntent = new Intent(context, WidgetTimetableService.class);
|
||||||
serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId);
|
serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId);
|
||||||
serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
|
serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
|
||||||
@ -82,18 +134,25 @@ public class WidgetTimetable extends HomeWidgetProvider {
|
|||||||
|
|
||||||
views.setViewVisibility(R.id.need_login, View.GONE);
|
views.setViewVisibility(R.id.need_login, View.GONE);
|
||||||
views.setViewVisibility(R.id.tt_grid_cont, View.GONE);
|
views.setViewVisibility(R.id.tt_grid_cont, View.GONE);
|
||||||
|
views.setInt(R.id.nav_to_left, "setColorFilter", getColor(context, textColors[1]));
|
||||||
|
views.setInt(R.id.nav_to_right, "setColorFilter", getColor(context, textColors[1]));
|
||||||
|
views.setInt(R.id.nav_refresh, "setColorFilter", getColor(context, textColors[1]));
|
||||||
|
views.setInt(R.id.empty_view, "setTextColor", getColor(context, textColors[0]));
|
||||||
|
|
||||||
if(!userLoggedIn(context)) {
|
if(!userLoggedIn(context)) {
|
||||||
views.setViewVisibility(R.id.need_login, View.VISIBLE);
|
views.setViewVisibility(R.id.need_login, View.VISIBLE);
|
||||||
views.setOnClickPendingIntent(R.id.open_login, makePending(context, ACTION_WIDGET_CLICK_BUY_PREMIUM, appId));
|
views.setOnClickPendingIntent(R.id.open_login, makePending(context, ACTION_WIDGET_CLICK_BUY_PREMIUM, appId));
|
||||||
} else {
|
} else {
|
||||||
views.setViewVisibility(R.id.tt_grid_cont, View.VISIBLE);
|
views.setViewVisibility(R.id.tt_grid_cont, View.VISIBLE);
|
||||||
|
views.setInt(R.id.widget_list, "setBackgroundColor", fullTheme[1]);
|
||||||
|
views.setInt(R.id.bottom_nav, "setBackgroundColor", fullTheme[1]);
|
||||||
views.setOnClickPendingIntent(R.id.nav_to_left, makePending(context, ACTION_WIDGET_CLICK_NAV_LEFT, appId));
|
views.setOnClickPendingIntent(R.id.nav_to_left, makePending(context, ACTION_WIDGET_CLICK_NAV_LEFT, appId));
|
||||||
views.setOnClickPendingIntent(R.id.nav_to_right, makePending(context, ACTION_WIDGET_CLICK_NAV_RIGHT, appId));
|
views.setOnClickPendingIntent(R.id.nav_to_right, makePending(context, ACTION_WIDGET_CLICK_NAV_RIGHT, appId));
|
||||||
views.setOnClickPendingIntent(R.id.nav_current, makePending(context, ACTION_WIDGET_CLICK_NAV_TODAY, appId));
|
views.setOnClickPendingIntent(R.id.nav_current, makePending(context, ACTION_WIDGET_CLICK_NAV_TODAY, appId));
|
||||||
views.setOnClickPendingIntent(R.id.nav_refresh, makePending(context, ACTION_WIDGET_CLICK_NAV_REFRESH, appId));
|
views.setOnClickPendingIntent(R.id.nav_refresh, makePending(context, ACTION_WIDGET_CLICK_NAV_REFRESH, appId));
|
||||||
views.setRemoteAdapter(R.id.widget_list, serviceIntent);
|
views.setRemoteAdapter(R.id.widget_list, serviceIntent);
|
||||||
views.setEmptyView(R.id.widget_list, R.id.empty_view);
|
views.setEmptyView(R.id.widget_list, R.id.empty_view);
|
||||||
|
views.setInt(R.id.empty_view, "setBackgroundColor", fullTheme[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return views;
|
return views;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package hu.refilc.naplo.widget_timetable;
|
package hu.refilc.naplo.widget_timetable;
|
||||||
|
|
||||||
|
import android.app.UiModeManager;
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -30,10 +31,14 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
|
|
||||||
private int rday = 0;
|
private int rday = 0;
|
||||||
|
|
||||||
private int theme;
|
private Integer[] fullTheme;
|
||||||
|
|
||||||
private Integer[] colorValues;
|
private Integer[] colorValues;
|
||||||
|
|
||||||
|
private UiModeManager uiModeManager;
|
||||||
|
|
||||||
|
private int nightMode;
|
||||||
|
|
||||||
List<Lesson> day_subjects = new ArrayList<>();
|
List<Lesson> day_subjects = new ArrayList<>();
|
||||||
List<Integer> lessonIndexes = new ArrayList<>();
|
List<Integer> lessonIndexes = new ArrayList<>();
|
||||||
|
|
||||||
@ -43,6 +48,7 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
|
|
||||||
static class Item {
|
static class Item {
|
||||||
int Layout;
|
int Layout;
|
||||||
|
int BackgroundColor;
|
||||||
|
|
||||||
int NumVisibility;
|
int NumVisibility;
|
||||||
int NameVisibility;
|
int NameVisibility;
|
||||||
@ -55,11 +61,14 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
int NameColor;
|
int NameColor;
|
||||||
int NameNodescColor;
|
int NameNodescColor;
|
||||||
int DescColor;
|
int DescColor;
|
||||||
|
int RoomColor;
|
||||||
|
int TimeColor;
|
||||||
|
|
||||||
Integer[] NameNodescPadding = {0, 0, 0, 0};
|
Integer[] NameNodescPadding = {0, 0, 0, 0};
|
||||||
|
|
||||||
public Item(int Layout, int NumVisibility,int NameVisibility,int NameNodescVisibility,int DescVisibility,int RoomVisibility,int TimeVisibility,int NumColor,int NameColor,int NameNodescColor,int DescColor) {
|
public Item(int Layout, int BackgroundColor, int NumVisibility,int NameVisibility,int NameNodescVisibility,int DescVisibility,int RoomVisibility,int TimeVisibility,int NumColor,int NameColor,int NameNodescColor,int DescColor,int RoomColor, int TimeColor) {
|
||||||
this.Layout = Layout;
|
this.Layout = Layout;
|
||||||
|
this.BackgroundColor = BackgroundColor;
|
||||||
this.NumVisibility = NumVisibility;
|
this.NumVisibility = NumVisibility;
|
||||||
this.NameVisibility = NameVisibility;
|
this.NameVisibility = NameVisibility;
|
||||||
this.NameNodescVisibility = NameNodescVisibility;
|
this.NameNodescVisibility = NameNodescVisibility;
|
||||||
@ -71,6 +80,8 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
this.NameColor = NameColor;
|
this.NameColor = NameColor;
|
||||||
this.NameNodescColor = NameNodescColor;
|
this.NameNodescColor = NameNodescColor;
|
||||||
this.DescColor = DescColor;
|
this.DescColor = DescColor;
|
||||||
|
this.RoomColor = RoomColor;
|
||||||
|
this.TimeColor = TimeColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,18 +113,25 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
this.appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
this.appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||||
|
|
||||||
this.theme = getThemeAccent(context);
|
this.fullTheme = getFullTheme(context);
|
||||||
|
|
||||||
this.colorValues = new Integer[]{R.color.filc,
|
this.uiModeManager = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||||
R.color.blue_shade300,
|
|
||||||
R.color.green_shade300,
|
|
||||||
R.color.lime_shade300,
|
|
||||||
R.color.yellow_shade300,
|
|
||||||
R.color.orange_shade300,
|
|
||||||
R.color.red_shade300,
|
|
||||||
R.color.pink_shade300,
|
|
||||||
R.color.purple_shade300};
|
|
||||||
|
|
||||||
|
this.nightMode = uiModeManager.getNightMode();
|
||||||
|
|
||||||
|
this.colorValues = new Integer[]{
|
||||||
|
R.color.filc,
|
||||||
|
R.color.blue_shade300,
|
||||||
|
R.color.green_shade300,
|
||||||
|
R.color.lime_shade300,
|
||||||
|
R.color.yellow_shade300,
|
||||||
|
R.color.orange_shade300,
|
||||||
|
R.color.red_shade300,
|
||||||
|
R.color.pink_shade300,
|
||||||
|
R.color.purple_shade300,
|
||||||
|
0,
|
||||||
|
R.color.teal_shade300
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -148,15 +166,18 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
|
|
||||||
/* backgroundResources */
|
/* backgroundResources */
|
||||||
view.setInt(R.id.main_lay, "setBackgroundResource", witem.Layout);
|
view.setInt(R.id.main_lay, "setBackgroundResource", witem.Layout);
|
||||||
|
view.setInt(R.id.main_lay, "setBackgroundColor", witem.BackgroundColor);
|
||||||
|
|
||||||
/* Paddings */
|
/* Paddings */
|
||||||
view.setViewPadding(R.id.tt_item_name_nodesc, witem.NameNodescPadding[0], witem.NameNodescPadding[1], witem.NameNodescPadding[2], witem.NameNodescPadding[3]);
|
view.setViewPadding(R.id.tt_item_name_nodesc, witem.NameNodescPadding[0], witem.NameNodescPadding[1], witem.NameNodescPadding[2], witem.NameNodescPadding[3]);
|
||||||
|
|
||||||
/* Text Colors */
|
/* Text Colors */
|
||||||
view.setInt(R.id.tt_item_num, "setTextColor", getColor(context, witem.NumColor));
|
view.setInt(R.id.tt_item_num, "setTextColor", witem.NumColor);
|
||||||
view.setInt(R.id.tt_item_name, "setTextColor", getColor(context, witem.NameColor));
|
view.setInt(R.id.tt_item_name, "setTextColor", getColor(context, witem.NameColor));
|
||||||
view.setInt(R.id.tt_item_name_nodesc, "setTextColor", getColor(context, witem.NameNodescColor));
|
view.setInt(R.id.tt_item_name_nodesc, "setTextColor", getColor(context, witem.NameNodescColor));
|
||||||
view.setInt(R.id.tt_item_desc, "setTextColor", getColor(context, witem.DescColor));
|
view.setInt(R.id.tt_item_desc, "setTextColor", getColor(context, witem.DescColor));
|
||||||
|
view.setInt(R.id.tt_item_room, "setTextColor", getColor(context, witem.RoomColor));
|
||||||
|
view.setInt(R.id.tt_item_time, "setTextColor", getColor(context, witem.TimeColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor(Context context, int color) {
|
public int getColor(Context context, int color) {
|
||||||
@ -167,12 +188,12 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
public RemoteViews getViewAt(int position) {
|
public RemoteViews getViewAt(int position) {
|
||||||
RemoteViews view = new RemoteViews(context.getPackageName(), R.layout.timetable_item);
|
RemoteViews view = new RemoteViews(context.getPackageName(), R.layout.timetable_item);
|
||||||
|
|
||||||
witem = defaultItem(theme);
|
witem = defaultItem(fullTheme, nightMode, context);
|
||||||
|
|
||||||
Lesson curr_subject = day_subjects.get(position);
|
Lesson curr_subject = day_subjects.get(position);
|
||||||
|
|
||||||
if (curr_subject.status.equals("empty")) {
|
if (curr_subject.status.equals("empty")) {
|
||||||
witem.NumColor = R.color.text_miss_num;
|
witem.NumColor = getColor(context, R.color.text_miss_num);
|
||||||
|
|
||||||
witem.TimeVisibility = View.GONE;
|
witem.TimeVisibility = View.GONE;
|
||||||
witem.RoomVisibility = View.GONE;
|
witem.RoomVisibility = View.GONE;
|
||||||
@ -181,12 +202,12 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!curr_subject.substituteTeacher.equals("null")) {
|
if (!curr_subject.substituteTeacher.equals("null")) {
|
||||||
witem.NumColor = R.color.yellow;
|
witem.NumColor = getColor(context, R.color.yellow);
|
||||||
witem.Layout = R.drawable.card_layout_tile_helyetesitett;
|
witem.Layout = R.drawable.card_layout_tile_helyetesitett;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curr_subject.status.equals("Elmaradt")) {
|
if (curr_subject.status.equals("Elmaradt")) {
|
||||||
witem.NumColor = R.color.red;
|
witem.NumColor = getColor(context, R.color.red);
|
||||||
witem.Layout = R.drawable.card_layout_tile_elmarad;
|
witem.Layout = R.drawable.card_layout_tile_elmarad;
|
||||||
} else if (curr_subject.status.equals("TanevRendjeEsemeny")) {
|
} else if (curr_subject.status.equals("TanevRendjeEsemeny")) {
|
||||||
witem.NumVisibility = View.GONE;
|
witem.NumVisibility = View.GONE;
|
||||||
@ -243,9 +264,6 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
|
|
||||||
theme = getThemeAccent(context);
|
|
||||||
|
|
||||||
rday = WidgetTimetable.selectDay(context, appWidgetId, 0, false);
|
rday = WidgetTimetable.selectDay(context, appWidgetId, 0, false);
|
||||||
|
|
||||||
day_subjects.clear();
|
day_subjects.clear();
|
||||||
@ -297,7 +315,7 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getThemeAccent(Context context) {
|
public static Integer[] getFullTheme(Context context) {
|
||||||
DBManager dbManager = new DBManager(context.getApplicationContext());
|
DBManager dbManager = new DBManager(context.getApplicationContext());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -305,27 +323,48 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
Cursor cursor = dbManager.fetchTheme();
|
Cursor cursor = dbManager.fetchTheme();
|
||||||
dbManager.close();
|
dbManager.close();
|
||||||
|
|
||||||
return cursor.getInt(1);
|
int theme = cursor.getInt(0);
|
||||||
|
int customAccentColor = cursor.getInt(1);
|
||||||
|
int customHighlightColor = cursor.getInt(2);
|
||||||
|
|
||||||
|
return new Integer[]{theme, customAccentColor, customHighlightColor};
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return new Integer[]{0, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item defaultItem(int theme) {
|
public Item defaultItem(Integer[] fullTheme, int nightMode, Context context) {
|
||||||
|
int textColor;
|
||||||
|
int textDescColor;
|
||||||
|
|
||||||
|
if (fullTheme[0] == 0 && nightMode == UiModeManager.MODE_NIGHT_NO) {
|
||||||
|
textColor = R.color.text_light;
|
||||||
|
textDescColor = R.color.text_desc_light;
|
||||||
|
} else if (fullTheme[0] == 1) {
|
||||||
|
textColor = R.color.text_light;
|
||||||
|
textDescColor = R.color.text_desc_light;
|
||||||
|
} else {
|
||||||
|
textColor = R.color.text;
|
||||||
|
textDescColor = R.color.text_desc;
|
||||||
|
}
|
||||||
|
|
||||||
return new Item(
|
return new Item(
|
||||||
R.drawable.card_layout_tile,
|
R.drawable.card_layout_tile,
|
||||||
|
fullTheme[2],
|
||||||
View.VISIBLE,
|
View.VISIBLE,
|
||||||
View.VISIBLE,
|
View.VISIBLE,
|
||||||
View.INVISIBLE,
|
View.INVISIBLE,
|
||||||
View.VISIBLE,
|
View.VISIBLE,
|
||||||
View.VISIBLE,
|
View.VISIBLE,
|
||||||
View.VISIBLE,
|
View.VISIBLE,
|
||||||
colorValues[theme >= colorValues.length ? 0 : theme],
|
fullTheme[1],
|
||||||
R.color.text,
|
textColor,
|
||||||
R.color.text,
|
textColor,
|
||||||
R.color.text_desc
|
textDescColor,
|
||||||
|
textDescColor,
|
||||||
|
textColor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,4 +392,4 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<solid android:color="@color/white"/>
|
<solid android:color="@color/highlight"/>
|
||||||
<stroke android:width="1dp" android:color="#D8E0E1" />
|
<stroke android:width="1dp" android:color="@color/highlight" />
|
||||||
<corners android:radius="10dp"/>
|
<corners android:radius="10dp"/>
|
||||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<solid android:color="@color/highlight"/>
|
<solid android:color="#00FFFFFF"/>
|
||||||
<stroke android:width="1dp" android:color="@color/highlight" />
|
<stroke android:width="1dp" android:color="#00FFFFFF" />
|
||||||
<corners android:bottomLeftRadius="14dp" android:bottomRightRadius="14dp"/>
|
<corners android:bottomLeftRadius="14dp" android:bottomRightRadius="14dp"/>
|
||||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<solid android:color="@color/highlight"/>
|
<solid android:color="#00FFFFFF"/>
|
||||||
<stroke android:width="1dp" android:color="@color/highlight" />
|
<stroke android:width="1dp" android:color="#00FFFFFF" />
|
||||||
<corners android:topLeftRadius="14dp" android:topRightRadius="14dp"/>
|
<corners android:topLeftRadius="14dp" android:topRightRadius="14dp"/>
|
||||||
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
<padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
android:id="@+id/tt_grid_cont"
|
android:id="@+id/tt_grid_cont"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:backgroundTint="#00000000"
|
|
||||||
android:background="@drawable/card_layout_bg"
|
android:background="@drawable/card_layout_bg"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<color name="shadow_light">#ffE8E8E8</color>
|
<color name="shadow_light">#ffE8E8E8</color>
|
||||||
<color name="text_light">#000000</color>
|
<color name="text_light">#000000</color>
|
||||||
<color name="text_desc_light">#B9B9B9</color>
|
<color name="text_desc_light">#888C8F</color>
|
||||||
<color name="text_desc_dark_light">#B9B9B9</color>
|
<color name="text_desc_dark_light">#B9B9B9</color>
|
||||||
<color name="text_miss_light">#888C8F</color>
|
<color name="text_miss_light">#888C8F</color>
|
||||||
<color name="background_light">#ffF4F9FF</color>
|
<color name="background_light">#ffF4F9FF</color>
|
||||||
@ -56,12 +56,13 @@
|
|||||||
<color name="purple">#ffBF5AF2</color>
|
<color name="purple">#ffBF5AF2</color>
|
||||||
<color name="pink">#ffFF375F</color>
|
<color name="pink">#ffFF375F</color>
|
||||||
|
|
||||||
<color name="blue_shade300">#FF64B5F6</color>
|
<color name="blue_shade300">#FF63B5F6</color>
|
||||||
<color name="green_shade300">#FF81C784</color>
|
<color name="green_shade300">#FF66BB6A</color>
|
||||||
<color name="lime_shade300">#FFDCE775</color>
|
<color name="lime_shade300">#FF9CCC65</color>
|
||||||
<color name="yellow_shade300">#FFFFF176</color>
|
<color name="yellow_shade300">#FFFFB74C</color>
|
||||||
<color name="orange_shade300">#FFFF8A65</color>
|
<color name="orange_shade300">#FFFF8A65</color>
|
||||||
<color name="red_shade300">#FFE57373</color>
|
<color name="red_shade300">#FFE57373</color>
|
||||||
<color name="pink_shade300">#FFF06292</color>
|
<color name="pink_shade300">#FFF06292</color>
|
||||||
<color name="purple_shade300">#FFBA68C8</color>
|
<color name="purple_shade300">#FFBA68C8</color>
|
||||||
</resources>
|
<color name="teal_shade300">#FF22AC9B</color>
|
||||||
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user