diff --git a/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java b/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java index a9e5f2923473c2a64d4387b8ab7d36d8f754a5d4..34b8f719895a3defe6992eb13068cddf89dfdaaf 100644 --- a/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java +++ b/app/src/main/java/foundation/e/drive/widgets/EDriveWidget.java @@ -26,6 +26,7 @@ import android.content.Intent; import android.net.ConnectivityManager; import android.net.Network; import android.net.Uri; +import android.os.Bundle; import android.provider.Settings; import android.view.View; import android.widget.RemoteViews; @@ -61,6 +62,9 @@ public class EDriveWidget extends AppWidgetProvider { private final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault()); private RemoteViews views; private Account account = null; + private static final String DARK_TEXT_KEY = "foundation.e.blisslauncher.WIDGET_OPTION_DARK_TEXT"; + private static boolean isDarkText = false; + public static String dataForWeb(Long bytes) { final String space = CommonUtils.humanReadableByteCountBin(bytes); @@ -148,7 +152,12 @@ public class EDriveWidget extends AppWidgetProvider { return; } - views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_login); + if (isDarkText) { + views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_login_light); + } else { + views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_login); + } + Intent accountIntent = buildIntent("", "") .setComponent(new ComponentName(ACCOUNT_MANAGER_PACKAGE_NAME, GET_ACCOUNT_MANAGER_COMPONENT_NAME)) @@ -165,7 +174,11 @@ public class EDriveWidget extends AppWidgetProvider { private void noInternetView(Context context) { if (!isNetworkAvailable) { - views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_login); + if (isDarkText) { + views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_login_light); + } else { + views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_login); + } views.setViewVisibility(R.id.button_container, View.GONE); views.setTextViewText(R.id.summary, context.getString(R.string.no_internet_widget)); } @@ -180,9 +193,11 @@ public class EDriveWidget extends AppWidgetProvider { noAccountView(context); return; } - - views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget); - + if (isDarkText) { + views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget_light); + } else { + views = new RemoteViews(context.getPackageName(), R.layout.e_drive_widget); + } views.setTextViewText(R.id.email, email); views.setTextViewText(R.id.name, accountManager.getUserData(account, ACCOUNT_DATA_NAME)); @@ -278,4 +293,11 @@ public class EDriveWidget extends AppWidgetProvider { } }); } + + @Override + public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) { + super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions); + isDarkText = newOptions.getBoolean(DARK_TEXT_KEY); + updateAppWidget(context); + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/button_background_light.xml b/app/src/main/res/drawable/button_background_light.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a146ee343311301cbef4a7ef95b95d943f9c572 --- /dev/null +++ b/app/src/main/res/drawable/button_background_light.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/e_drive_widget_light.xml b/app/src/main/res/layout/e_drive_widget_light.xml new file mode 100644 index 0000000000000000000000000000000000000000..50e854bd712719de1a139fcb942232bca8488442 --- /dev/null +++ b/app/src/main/res/layout/e_drive_widget_light.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +