Merge pull request #33 from BrianPinsard/master

Pull request for implementation of #30
This commit is contained in:
Tibor Kaputa 2017-01-03 19:17:27 +01:00 committed by GitHub
commit dd3dd94752
3 changed files with 26 additions and 2 deletions

View File

@ -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();
}
}

View File

@ -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";
}

View File

@ -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);
}
});