diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6f3409d4..13081390 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -10,7 +10,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
@@ -20,7 +20,7 @@
@@ -29,12 +29,12 @@
diff --git a/app/src/main/java/com/simplemobiletools/notes/MyWidgetProvider.java b/app/src/main/java/com/simplemobiletools/notes/MyWidgetProvider.java
index 4d9a75f4..a9603d3c 100644
--- a/app/src/main/java/com/simplemobiletools/notes/MyWidgetProvider.java
+++ b/app/src/main/java/com/simplemobiletools/notes/MyWidgetProvider.java
@@ -9,39 +9,41 @@ import android.content.SharedPreferences;
import android.graphics.Color;
import android.widget.RemoteViews;
+import com.simplemobiletools.notes.activities.MainActivity;
+
public class MyWidgetProvider extends AppWidgetProvider {
- private static SharedPreferences prefs;
- private RemoteViews remoteViews;
+ private static SharedPreferences mPrefs;
+ private static RemoteViews mRemoteViews;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
initVariables(context);
final int defaultColor = context.getResources().getColor(R.color.dark_grey);
- final int newBgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, defaultColor);
- final int newTextColor = prefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
- remoteViews.setInt(R.id.notes_view, "setBackgroundColor", newBgColor);
- remoteViews.setInt(R.id.notes_view, "setTextColor", newTextColor);
+ final int newBgColor = mPrefs.getInt(Constants.WIDGET_BG_COLOR, defaultColor);
+ final int newTextColor = mPrefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
+ mRemoteViews.setInt(R.id.notes_view, "setBackgroundColor", newBgColor);
+ mRemoteViews.setInt(R.id.notes_view, "setTextColor", newTextColor);
for (int widgetId : appWidgetIds) {
- updateWidget(appWidgetManager, widgetId, remoteViews);
+ updateWidget(appWidgetManager, widgetId, mRemoteViews);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
}
private void initVariables(Context context) {
- prefs = context.getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
- remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
+ mPrefs = context.getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
+ mRemoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
setupAppOpenIntent(R.id.notes_holder, context);
}
private void setupAppOpenIntent(int id, Context context) {
final Intent intent = new Intent(context, MainActivity.class);
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
- remoteViews.setOnClickPendingIntent(id, pendingIntent);
+ mRemoteViews.setOnClickPendingIntent(id, pendingIntent);
}
private void updateWidget(AppWidgetManager widgetManager, int widgetId, RemoteViews remoteViews) {
- final String text = prefs.getString(Constants.TEXT, "");
+ final String text = mPrefs.getString(Constants.TEXT, "");
remoteViews.setTextViewText(R.id.notes_view, text);
widgetManager.updateAppWidget(widgetId, remoteViews);
}
diff --git a/app/src/main/java/com/simplemobiletools/notes/AboutActivity.java b/app/src/main/java/com/simplemobiletools/notes/activities/AboutActivity.java
similarity index 58%
rename from app/src/main/java/com/simplemobiletools/notes/AboutActivity.java
rename to app/src/main/java/com/simplemobiletools/notes/activities/AboutActivity.java
index aa8940a5..4936f737 100644
--- a/app/src/main/java/com/simplemobiletools/notes/AboutActivity.java
+++ b/app/src/main/java/com/simplemobiletools/notes/activities/AboutActivity.java
@@ -1,4 +1,4 @@
-package com.simplemobiletools.notes;
+package com.simplemobiletools.notes.activities;
import android.content.Intent;
import android.content.res.Resources;
@@ -8,6 +8,9 @@ import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
+import com.simplemobiletools.notes.BuildConfig;
+import com.simplemobiletools.notes.R;
+
import java.util.Calendar;
import butterknife.BindView;
@@ -15,17 +18,18 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
public class AboutActivity extends AppCompatActivity {
- @BindView(R.id.about_copyright) TextView copyright;
- @BindView(R.id.about_version) TextView version;
- @BindView(R.id.about_email) TextView emailTV;
- private Resources res;
+ @BindView(R.id.about_copyright) TextView mCopyright;
+ @BindView(R.id.about_version) TextView mVersion;
+ @BindView(R.id.about_email) TextView mEmailTV;
+
+ private static Resources mRes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
- res = getResources();
+ mRes = getResources();
setupEmail();
setupVersion();
@@ -33,23 +37,23 @@ public class AboutActivity extends AppCompatActivity {
}
private void setupEmail() {
- final String email = res.getString(R.string.email);
- final String appName = res.getString(R.string.app_name);
+ final String email = mRes.getString(R.string.email);
+ final String appName = mRes.getString(R.string.app_name);
final String href = "" + email + "";
- emailTV.setText(Html.fromHtml(href));
- emailTV.setMovementMethod(LinkMovementMethod.getInstance());
+ mEmailTV.setText(Html.fromHtml(href));
+ mEmailTV.setMovementMethod(LinkMovementMethod.getInstance());
}
private void setupVersion() {
final String versionName = BuildConfig.VERSION_NAME;
- final String versionText = String.format(res.getString(R.string.version), versionName);
- version.setText(versionText);
+ final String versionText = String.format(mRes.getString(R.string.version), versionName);
+ mVersion.setText(versionText);
}
private void setupCopyright() {
final int year = Calendar.getInstance().get(Calendar.YEAR);
- final String copyrightText = String.format(res.getString(R.string.copyright), year);
- copyright.setText(copyrightText);
+ final String copyrightText = String.format(mRes.getString(R.string.copyright), year);
+ mCopyright.setText(copyrightText);
}
@OnClick(R.id.about_license)
diff --git a/app/src/main/java/com/simplemobiletools/notes/LicenseActivity.java b/app/src/main/java/com/simplemobiletools/notes/activities/LicenseActivity.java
similarity index 91%
rename from app/src/main/java/com/simplemobiletools/notes/LicenseActivity.java
rename to app/src/main/java/com/simplemobiletools/notes/activities/LicenseActivity.java
index d2a4274a..65e62ff0 100644
--- a/app/src/main/java/com/simplemobiletools/notes/LicenseActivity.java
+++ b/app/src/main/java/com/simplemobiletools/notes/activities/LicenseActivity.java
@@ -1,14 +1,17 @@
-package com.simplemobiletools.notes;
+package com.simplemobiletools.notes.activities;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
+import com.simplemobiletools.notes.R;
+
import butterknife.ButterKnife;
import butterknife.OnClick;
public class LicenseActivity extends AppCompatActivity {
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/app/src/main/java/com/simplemobiletools/notes/MainActivity.java b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java
similarity index 75%
rename from app/src/main/java/com/simplemobiletools/notes/MainActivity.java
rename to app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java
index b9c869f4..c158d425 100644
--- a/app/src/main/java/com/simplemobiletools/notes/MainActivity.java
+++ b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java
@@ -1,4 +1,4 @@
-package com.simplemobiletools.notes;
+package com.simplemobiletools.notes.activities;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
@@ -8,18 +8,22 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
-import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
+import com.simplemobiletools.notes.Constants;
+import com.simplemobiletools.notes.MyWidgetProvider;
+import com.simplemobiletools.notes.R;
+
import butterknife.BindView;
import butterknife.ButterKnife;
public class MainActivity extends AppCompatActivity {
- private SharedPreferences prefs;
- @BindView(R.id.notes_view) EditText notesView;
+ @BindView(R.id.notes_view) EditText mNotesView;
+
+ private SharedPreferences mPrefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -27,15 +31,14 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
- prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
- final String text = prefs.getString(Constants.TEXT, "");
- notesView.setText(text);
+ mPrefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
+ final String text = mPrefs.getString(Constants.TEXT, "");
+ mNotesView.setText(text);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
+ getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
@@ -55,8 +58,8 @@ public class MainActivity extends AppCompatActivity {
}
private void saveText() {
- final String text = notesView.getText().toString().trim();
- prefs.edit().putString(Constants.TEXT, text).apply();
+ final String text = mNotesView.getText().toString().trim();
+ mPrefs.edit().putString(Constants.TEXT, text).apply();
Toast.makeText(this, getResources().getString(R.string.text_saved), Toast.LENGTH_SHORT).show();
hideKeyboard();
@@ -65,7 +68,7 @@ public class MainActivity extends AppCompatActivity {
private void hideKeyboard() {
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(notesView.getWindowToken(), 0);
+ imm.hideSoftInputFromWindow(mNotesView.getWindowToken(), 0);
}
private void updateWidget() {
diff --git a/app/src/main/java/com/simplemobiletools/notes/MyWidgetConfigure.java b/app/src/main/java/com/simplemobiletools/notes/activities/WidgetConfigureActivity.java
similarity index 59%
rename from app/src/main/java/com/simplemobiletools/notes/MyWidgetConfigure.java
rename to app/src/main/java/com/simplemobiletools/notes/activities/WidgetConfigureActivity.java
index cb50871c..bd0f08d3 100644
--- a/app/src/main/java/com/simplemobiletools/notes/MyWidgetConfigure.java
+++ b/app/src/main/java/com/simplemobiletools/notes/activities/WidgetConfigureActivity.java
@@ -1,4 +1,4 @@
-package com.simplemobiletools.notes;
+package com.simplemobiletools.notes.activities;
import android.appwidget.AppWidgetManager;
import android.content.Context;
@@ -13,23 +13,27 @@ import android.widget.RemoteViews;
import android.widget.SeekBar;
import android.widget.TextView;
+import com.simplemobiletools.notes.Constants;
+import com.simplemobiletools.notes.MyWidgetProvider;
+import com.simplemobiletools.notes.R;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import yuku.ambilwarna.AmbilWarnaDialog;
-public class MyWidgetConfigure extends AppCompatActivity {
- @BindView(R.id.config_bg_color) View bgColorPicker;
- @BindView(R.id.config_bg_seekbar) SeekBar bgSeekBar;
- @BindView(R.id.config_text_color) View textColorPicker;
- @BindView(R.id.notes_view) TextView notesView;
- @BindView(R.id.config_save) Button saveBtn;
+public class WidgetConfigureActivity extends AppCompatActivity {
+ @BindView(R.id.config_bg_color) View mBgColorPicker;
+ @BindView(R.id.config_bg_seekbar) SeekBar mBgSeekBar;
+ @BindView(R.id.config_text_color) View mTextColorPicker;
+ @BindView(R.id.notes_view) TextView mNotesView;
+ @BindView(R.id.config_save) Button mSaveBtn;
- private int widgetId;
- private int bgColor;
- private int bgColorWithoutTransparency;
- private float bgAlpha;
- private int textColor;
+ private float mBgAlpha;
+ private int mWidgetId;
+ private int mBgColor;
+ private int mBgColorWithoutTransparency;
+ private int mTextColor;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -42,28 +46,28 @@ public class MyWidgetConfigure extends AppCompatActivity {
final Intent intent = getIntent();
final Bundle extras = intent.getExtras();
if (extras != null)
- widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
+ mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
- if (widgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
+ if (mWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
finish();
}
private void initVariables() {
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
- bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, 1);
- if (bgColor == 1) {
- bgColor = Color.BLACK;
- bgAlpha = .2f;
+ mBgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, 1);
+ if (mBgColor == 1) {
+ mBgColor = Color.BLACK;
+ mBgAlpha = .2f;
} else {
- bgAlpha = Color.alpha(bgColor) / (float) 255;
+ mBgAlpha = Color.alpha(mBgColor) / (float) 255;
}
- bgColorWithoutTransparency = Color.rgb(Color.red(bgColor), Color.green(bgColor), Color.blue(bgColor));
- bgSeekBar.setOnSeekBarChangeListener(bgSeekbarChangeListener);
- bgSeekBar.setProgress((int) (bgAlpha * 100));
+ mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor));
+ mBgSeekBar.setOnSeekBarChangeListener(bgSeekbarChangeListener);
+ mBgSeekBar.setProgress((int) (mBgAlpha * 100));
updateBackgroundColor();
- textColor = prefs.getInt(Constants.WIDGET_TEXT_COLOR, getResources().getColor(R.color.colorPrimary));
+ mTextColor = prefs.getInt(Constants.WIDGET_TEXT_COLOR, getResources().getColor(R.color.colorPrimary));
updateTextColor();
}
@@ -71,53 +75,53 @@ public class MyWidgetConfigure extends AppCompatActivity {
public void saveConfig() {
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
final RemoteViews views = new RemoteViews(getPackageName(), R.layout.activity_main);
- views.setInt(R.id.notes_view, "setBackgroundColor", bgColor);
- appWidgetManager.updateAppWidget(widgetId, views);
+ views.setInt(R.id.notes_view, "setBackgroundColor", mBgColor);
+ appWidgetManager.updateAppWidget(mWidgetId, views);
storeWidgetBackground();
requestWidgetUpdate();
final Intent resultValue = new Intent();
- resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
+ resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId);
setResult(RESULT_OK, resultValue);
finish();
}
private void storeWidgetBackground() {
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
- prefs.edit().putInt(Constants.WIDGET_BG_COLOR, bgColor).apply();
- prefs.edit().putInt(Constants.WIDGET_TEXT_COLOR, textColor).apply();
+ prefs.edit().putInt(Constants.WIDGET_BG_COLOR, mBgColor).apply();
+ prefs.edit().putInt(Constants.WIDGET_TEXT_COLOR, mTextColor).apply();
}
private void requestWidgetUpdate() {
final Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, this, MyWidgetProvider.class);
- intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{widgetId});
+ intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{mWidgetId});
sendBroadcast(intent);
}
private void updateBackgroundColor() {
- bgColor = adjustAlpha(bgColorWithoutTransparency, bgAlpha);
- notesView.setBackgroundColor(bgColor);
- bgColorPicker.setBackgroundColor(bgColor);
- saveBtn.setBackgroundColor(bgColor);
+ mBgColor = adjustAlpha(mBgColorWithoutTransparency, mBgAlpha);
+ mNotesView.setBackgroundColor(mBgColor);
+ mBgColorPicker.setBackgroundColor(mBgColor);
+ mSaveBtn.setBackgroundColor(mBgColor);
}
private void updateTextColor() {
- textColorPicker.setBackgroundColor(textColor);
- saveBtn.setTextColor(textColor);
- notesView.setTextColor(textColor);
+ mTextColorPicker.setBackgroundColor(mTextColor);
+ mSaveBtn.setTextColor(mTextColor);
+ mNotesView.setTextColor(mTextColor);
}
@OnClick(R.id.config_bg_color)
public void pickBackgroundColor() {
- AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, bgColorWithoutTransparency, new AmbilWarnaDialog.OnAmbilWarnaListener() {
+ AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, mBgColorWithoutTransparency, new AmbilWarnaDialog.OnAmbilWarnaListener() {
@Override
public void onCancel(AmbilWarnaDialog dialog) {
}
@Override
public void onOk(AmbilWarnaDialog dialog, int color) {
- bgColorWithoutTransparency = color;
+ mBgColorWithoutTransparency = color;
updateBackgroundColor();
}
});
@@ -127,14 +131,14 @@ public class MyWidgetConfigure extends AppCompatActivity {
@OnClick(R.id.config_text_color)
public void pickTextColor() {
- AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, textColor, new AmbilWarnaDialog.OnAmbilWarnaListener() {
+ AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, mTextColor, new AmbilWarnaDialog.OnAmbilWarnaListener() {
@Override
public void onCancel(AmbilWarnaDialog dialog) {
}
@Override
public void onOk(AmbilWarnaDialog dialog, int color) {
- textColor = color;
+ mTextColor = color;
updateTextColor();
}
});
@@ -145,7 +149,7 @@ public class MyWidgetConfigure extends AppCompatActivity {
private SeekBar.OnSeekBarChangeListener bgSeekbarChangeListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- bgAlpha = (float) progress / (float) 100;
+ mBgAlpha = (float) progress / (float) 100;
updateBackgroundColor();
}
diff --git a/app/src/main/res/xml/widget_info.xml b/app/src/main/res/xml/widget_info.xml
index bfe02fdc..1c230fc0 100644
--- a/app/src/main/res/xml/widget_info.xml
+++ b/app/src/main/res/xml/widget_info.xml
@@ -1,6 +1,6 @@