Skip to content

Commit bc02c56

Browse files
committed
use the picked color as the active color of the widget
1 parent 79c673e commit bc02c56

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/src/main/java/com/simplemobiletools/flashlight/MyWidgetProvider.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.ComponentName;
77
import android.content.Context;
88
import android.content.Intent;
9+
import android.content.SharedPreferences;
910
import android.content.res.Resources;
1011
import android.graphics.Bitmap;
1112
import android.widget.RemoteViews;
@@ -44,8 +45,10 @@ private void initVariables(Context context) {
4445
mRemoteViews.setOnClickPendingIntent(R.id.toggle_btn, pendingIntent);
4546
mCameraImpl = new MyCameraImpl(context);
4647

48+
final SharedPreferences prefs = initPrefs(context);
4749
final Resources res = context.getResources();
48-
final int appColor = res.getColor(R.color.colorPrimary);
50+
final int defaultColor = res.getColor(R.color.colorPrimary);
51+
final int appColor = prefs.getInt(Constants.WIDGET_COLOR, defaultColor);
4952
mColoredBmp = Utils.getColoredIcon(context.getResources(), appColor, R.mipmap.flashlight_small);
5053

5154
if (mBus == null) {
@@ -81,6 +84,10 @@ public void disableFlashlight() {
8184
}
8285
}
8386

87+
private SharedPreferences initPrefs(Context context) {
88+
return context.getSharedPreferences(Constants.PREFS_KEY, Context.MODE_PRIVATE);
89+
}
90+
8491
@Subscribe
8592
public void cameraUnavailable(Events.CameraUnavailable event) {
8693
if (mContext != null) {

0 commit comments

Comments
 (0)