diff --git a/app/src/main/java/com/simplemobiletools/draw/Config.java b/app/src/main/java/com/simplemobiletools/draw/Config.java index 2402242..7064c88 100644 --- a/app/src/main/java/com/simplemobiletools/draw/Config.java +++ b/app/src/main/java/com/simplemobiletools/draw/Config.java @@ -2,6 +2,7 @@ package com.simplemobiletools.draw; import android.content.Context; import android.content.SharedPreferences; +import android.graphics.Color; public class Config { private SharedPreferences mPrefs; @@ -29,4 +30,18 @@ public class Config { public void setIsDarkTheme(boolean isDarkTheme) { mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply(); } + + public int getBrushColor() { + return mPrefs.getInt(Constants.BRUSH_COLOR_KEY, Color.BLACK); + } + + public void setBrushColor(int color){ + mPrefs.edit().putInt(Constants.BRUSH_COLOR_KEY, color).apply(); + } + + public int getBackgroundColor() { return mPrefs.getInt(Constants.BACKGROUND_COLOR_KEY, Color.WHITE); } + + public void setBackgroundColor(int color){ + mPrefs.edit().putInt(Constants.BACKGROUND_COLOR_KEY, color).apply(); + } } diff --git a/app/src/main/java/com/simplemobiletools/draw/Constants.java b/app/src/main/java/com/simplemobiletools/draw/Constants.java index 4b9b796..64f7709 100644 --- a/app/src/main/java/com/simplemobiletools/draw/Constants.java +++ b/app/src/main/java/com/simplemobiletools/draw/Constants.java @@ -3,6 +3,8 @@ package com.simplemobiletools.draw; public class Constants { // shared preferences public static final String PREFS_KEY = "Draw"; + public static final String BRUSH_COLOR_KEY = "brush_color"; + public static final String BACKGROUND_COLOR_KEY = "background_color"; public static final String IS_FIRST_RUN = "is_first_run"; public static final String IS_DARK_THEME = "is_dark_theme"; } diff --git a/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java index 5e6833b..aed84ef 100644 --- a/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/draw/activities/MainActivity.java @@ -4,7 +4,6 @@ import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Bitmap; -import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.media.MediaScannerConnection; import android.net.Uri; @@ -59,7 +58,14 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange ButterKnife.bind(this); mMyCanvas.setListener(this); - setColor(Color.BLACK); + mMyCanvas.setBackgroundColor(mConfig.getBackgroundColor()); + setColor(mConfig.getBrushColor()); + } + + @Override + protected void onPause() { + super.onPause(); + mConfig.setBrushColor(color); } @Override @@ -105,6 +111,7 @@ public class MainActivity extends SimpleActivity implements MyCanvas.PathsChange ((ImageView) mUndoBtn).setImageResource(R.mipmap.undo_black); } mMyCanvas.setBackgroundColor(pickedColor); + mConfig.setBackgroundColor(pickedColor); } });