diff --git a/android/.project b/android/.project
new file mode 100644
index 0000000..3964dd3
--- /dev/null
+++ b/android/.project
@@ -0,0 +1,17 @@
+
+
+ android
+ Project android created by Buildship.
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectbuilder
+
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectnature
+
+
diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 0000000..e889521
--- /dev/null
+++ b/android/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,2 @@
+connection.project.dir=
+eclipse.preferences.version=1
diff --git a/android/src/main/java/co/potatoproject/androidflutterupdater/AndroidFlutterUpdaterPlugin.java b/android/src/main/java/co/potatoproject/androidflutterupdater/AndroidFlutterUpdaterPlugin.java
index 47ea35e..5db7278 100644
--- a/android/src/main/java/co/potatoproject/androidflutterupdater/AndroidFlutterUpdaterPlugin.java
+++ b/android/src/main/java/co/potatoproject/androidflutterupdater/AndroidFlutterUpdaterPlugin.java
@@ -11,6 +11,7 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.content.res.Configuration;
import android.icu.text.DateFormat;
import android.os.IBinder;
import android.preference.PreferenceManager;
@@ -332,8 +333,16 @@ public void onMethodCall(@NonNull MethodCall methodCall, @NonNull MethodChannel.
result.success(null);
break;
}
- case "getAccentColor": {
- result.success(getAccentColor());
+ case "getLightAccentColor": {
+ result.success(getLightAccentColor());
+ break;
+ }
+ case "getDarkAccentColor": {
+ result.success(getDarkAccentColor());
+ break;
+ }
+ case "isCurrentThemeDark": {
+ result.success(isCurrentThemeDark());
break;
}
default:
@@ -595,7 +604,20 @@ private void setAutoDelete(boolean enable) {
preferences.edit().putBoolean(Constants.PREF_AUTO_DELETE_UPDATES, enable).apply();
}
- private int getAccentColor() {
+ private Integer getLightAccentColor() {
+ String colResName = "accent_device_default_light";
+ Resources res = null;
+ try {
+ res = mActivity.getPackageManager().getResourcesForApplication("android");
+ int resId = res.getIdentifier("android:color/" + colResName, null, null);
+ return res.getColor(resId);
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
+
+ private Integer getDarkAccentColor() {
String colResName = "accent_device_default_dark";
Resources res = null;
try {
@@ -607,4 +629,15 @@ private int getAccentColor() {
}
return 0;
}
+
+ private boolean isCurrentThemeDark() {
+ switch (mActivity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) {
+ case Configuration.UI_MODE_NIGHT_YES:
+ return true;
+ case Configuration.UI_MODE_NIGHT_NO:
+ return false;
+ default:
+ return false;
+ }
+ }
}
diff --git a/lib/android_flutter_updater.dart b/lib/android_flutter_updater.dart
index ad67d88..02abe0a 100644
--- a/lib/android_flutter_updater.dart
+++ b/lib/android_flutter_updater.dart
@@ -160,8 +160,14 @@ class AndroidFlutterUpdater {
static Future startActivity({String pkg, String cls}) async =>
await _channel.invokeMethod('startActivity', {'pkg': pkg, 'cls': cls});
- static Future getAccentColor() async =>
- await _channel.invokeMethod('getAccentColor');
+ static Future getLightAccentColor() async =>
+ await _channel.invokeMethod('getLightAccentColor');
+
+ static Future getDarkAccentColor() async =>
+ await _channel.invokeMethod('getDarkAccentColor');
+
+ static Future isCurrentThemeDark() async =>
+ await _channel.invokeMethod('isCurrentThemeDark');
static UpdateStatus _strToStatusEnum(String value) =>
UpdateStatus.values.firstWhere((e) =>