mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-22 03:07:25 +02:00
some refactoring, no functionality change
This commit is contained in:
parent
1e20777ffb
commit
f6ae35dd09
@ -10,7 +10,7 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".activities.MainActivity"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
@ -20,7 +20,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MyWidgetConfigure"
|
android:name=".activities.WidgetConfigureActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/MyWidgetConfigTheme">
|
android:theme="@style/MyWidgetConfigTheme">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@ -29,12 +29,12 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".AboutActivity"
|
android:name=".activities.AboutActivity"
|
||||||
android:label="@string/about"
|
android:label="@string/about"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".LicenseActivity"
|
android:name=".activities.LicenseActivity"
|
||||||
android:label="@string/third_party_licences"
|
android:label="@string/third_party_licences"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
|
@ -9,39 +9,41 @@ import android.content.SharedPreferences;
|
|||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
|
import com.simplemobiletools.notes.activities.MainActivity;
|
||||||
|
|
||||||
public class MyWidgetProvider extends AppWidgetProvider {
|
public class MyWidgetProvider extends AppWidgetProvider {
|
||||||
private static SharedPreferences prefs;
|
private static SharedPreferences mPrefs;
|
||||||
private RemoteViews remoteViews;
|
private static RemoteViews mRemoteViews;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
|
||||||
initVariables(context);
|
initVariables(context);
|
||||||
final int defaultColor = context.getResources().getColor(R.color.dark_grey);
|
final int defaultColor = context.getResources().getColor(R.color.dark_grey);
|
||||||
final int newBgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, defaultColor);
|
final int newBgColor = mPrefs.getInt(Constants.WIDGET_BG_COLOR, defaultColor);
|
||||||
final int newTextColor = prefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
|
final int newTextColor = mPrefs.getInt(Constants.WIDGET_TEXT_COLOR, Color.WHITE);
|
||||||
remoteViews.setInt(R.id.notes_view, "setBackgroundColor", newBgColor);
|
mRemoteViews.setInt(R.id.notes_view, "setBackgroundColor", newBgColor);
|
||||||
remoteViews.setInt(R.id.notes_view, "setTextColor", newTextColor);
|
mRemoteViews.setInt(R.id.notes_view, "setTextColor", newTextColor);
|
||||||
|
|
||||||
for (int widgetId : appWidgetIds) {
|
for (int widgetId : appWidgetIds) {
|
||||||
updateWidget(appWidgetManager, widgetId, remoteViews);
|
updateWidget(appWidgetManager, widgetId, mRemoteViews);
|
||||||
}
|
}
|
||||||
super.onUpdate(context, appWidgetManager, appWidgetIds);
|
super.onUpdate(context, appWidgetManager, appWidgetIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initVariables(Context context) {
|
private void initVariables(Context context) {
|
||||||
prefs = context.getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
mPrefs = context.getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||||
remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
|
mRemoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
|
||||||
setupAppOpenIntent(R.id.notes_holder, context);
|
setupAppOpenIntent(R.id.notes_holder, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupAppOpenIntent(int id, Context context) {
|
private void setupAppOpenIntent(int id, Context context) {
|
||||||
final Intent intent = new Intent(context, MainActivity.class);
|
final Intent intent = new Intent(context, MainActivity.class);
|
||||||
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
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) {
|
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);
|
remoteViews.setTextViewText(R.id.notes_view, text);
|
||||||
widgetManager.updateAppWidget(widgetId, remoteViews);
|
widgetManager.updateAppWidget(widgetId, remoteViews);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.simplemobiletools.notes;
|
package com.simplemobiletools.notes.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@ -8,6 +8,9 @@ import android.text.Html;
|
|||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.simplemobiletools.notes.BuildConfig;
|
||||||
|
import com.simplemobiletools.notes.R;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -15,17 +18,18 @@ import butterknife.ButterKnife;
|
|||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class AboutActivity extends AppCompatActivity {
|
public class AboutActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.about_copyright) TextView copyright;
|
@BindView(R.id.about_copyright) TextView mCopyright;
|
||||||
@BindView(R.id.about_version) TextView version;
|
@BindView(R.id.about_version) TextView mVersion;
|
||||||
@BindView(R.id.about_email) TextView emailTV;
|
@BindView(R.id.about_email) TextView mEmailTV;
|
||||||
private Resources res;
|
|
||||||
|
private static Resources mRes;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_about);
|
setContentView(R.layout.activity_about);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
res = getResources();
|
mRes = getResources();
|
||||||
|
|
||||||
setupEmail();
|
setupEmail();
|
||||||
setupVersion();
|
setupVersion();
|
||||||
@ -33,23 +37,23 @@ public class AboutActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupEmail() {
|
private void setupEmail() {
|
||||||
final String email = res.getString(R.string.email);
|
final String email = mRes.getString(R.string.email);
|
||||||
final String appName = res.getString(R.string.app_name);
|
final String appName = mRes.getString(R.string.app_name);
|
||||||
final String href = "<a href=\"mailto:" + email + "?subject=" + appName + "\">" + email + "</a>";
|
final String href = "<a href=\"mailto:" + email + "?subject=" + appName + "\">" + email + "</a>";
|
||||||
emailTV.setText(Html.fromHtml(href));
|
mEmailTV.setText(Html.fromHtml(href));
|
||||||
emailTV.setMovementMethod(LinkMovementMethod.getInstance());
|
mEmailTV.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupVersion() {
|
private void setupVersion() {
|
||||||
final String versionName = BuildConfig.VERSION_NAME;
|
final String versionName = BuildConfig.VERSION_NAME;
|
||||||
final String versionText = String.format(res.getString(R.string.version), versionName);
|
final String versionText = String.format(mRes.getString(R.string.version), versionName);
|
||||||
version.setText(versionText);
|
mVersion.setText(versionText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupCopyright() {
|
private void setupCopyright() {
|
||||||
final int year = Calendar.getInstance().get(Calendar.YEAR);
|
final int year = Calendar.getInstance().get(Calendar.YEAR);
|
||||||
final String copyrightText = String.format(res.getString(R.string.copyright), year);
|
final String copyrightText = String.format(mRes.getString(R.string.copyright), year);
|
||||||
copyright.setText(copyrightText);
|
mCopyright.setText(copyrightText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.about_license)
|
@OnClick(R.id.about_license)
|
@ -1,14 +1,17 @@
|
|||||||
package com.simplemobiletools.notes;
|
package com.simplemobiletools.notes.activities;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.simplemobiletools.notes.R;
|
||||||
|
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class LicenseActivity extends AppCompatActivity {
|
public class LicenseActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
@ -1,4 +1,4 @@
|
|||||||
package com.simplemobiletools.notes;
|
package com.simplemobiletools.notes.activities;
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@ -8,18 +8,22 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.simplemobiletools.notes.Constants;
|
||||||
|
import com.simplemobiletools.notes.MyWidgetProvider;
|
||||||
|
import com.simplemobiletools.notes.R;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private SharedPreferences prefs;
|
@BindView(R.id.notes_view) EditText mNotesView;
|
||||||
@BindView(R.id.notes_view) EditText notesView;
|
|
||||||
|
private SharedPreferences mPrefs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -27,15 +31,14 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
mPrefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||||
final String text = prefs.getString(Constants.TEXT, "");
|
final String text = mPrefs.getString(Constants.TEXT, "");
|
||||||
notesView.setText(text);
|
mNotesView.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
getMenuInflater().inflate(R.menu.menu, menu);
|
||||||
inflater.inflate(R.menu.menu, menu);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +58,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveText() {
|
private void saveText() {
|
||||||
final String text = notesView.getText().toString().trim();
|
final String text = mNotesView.getText().toString().trim();
|
||||||
prefs.edit().putString(Constants.TEXT, text).apply();
|
mPrefs.edit().putString(Constants.TEXT, text).apply();
|
||||||
|
|
||||||
Toast.makeText(this, getResources().getString(R.string.text_saved), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getResources().getString(R.string.text_saved), Toast.LENGTH_SHORT).show();
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
@ -65,7 +68,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void hideKeyboard() {
|
private void hideKeyboard() {
|
||||||
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(notesView.getWindowToken(), 0);
|
imm.hideSoftInputFromWindow(mNotesView.getWindowToken(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidget() {
|
private void updateWidget() {
|
@ -1,4 +1,4 @@
|
|||||||
package com.simplemobiletools.notes;
|
package com.simplemobiletools.notes.activities;
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -13,23 +13,27 @@ import android.widget.RemoteViews;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.simplemobiletools.notes.Constants;
|
||||||
|
import com.simplemobiletools.notes.MyWidgetProvider;
|
||||||
|
import com.simplemobiletools.notes.R;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import yuku.ambilwarna.AmbilWarnaDialog;
|
import yuku.ambilwarna.AmbilWarnaDialog;
|
||||||
|
|
||||||
public class MyWidgetConfigure extends AppCompatActivity {
|
public class WidgetConfigureActivity extends AppCompatActivity {
|
||||||
@BindView(R.id.config_bg_color) View bgColorPicker;
|
@BindView(R.id.config_bg_color) View mBgColorPicker;
|
||||||
@BindView(R.id.config_bg_seekbar) SeekBar bgSeekBar;
|
@BindView(R.id.config_bg_seekbar) SeekBar mBgSeekBar;
|
||||||
@BindView(R.id.config_text_color) View textColorPicker;
|
@BindView(R.id.config_text_color) View mTextColorPicker;
|
||||||
@BindView(R.id.notes_view) TextView notesView;
|
@BindView(R.id.notes_view) TextView mNotesView;
|
||||||
@BindView(R.id.config_save) Button saveBtn;
|
@BindView(R.id.config_save) Button mSaveBtn;
|
||||||
|
|
||||||
private int widgetId;
|
private float mBgAlpha;
|
||||||
private int bgColor;
|
private int mWidgetId;
|
||||||
private int bgColorWithoutTransparency;
|
private int mBgColor;
|
||||||
private float bgAlpha;
|
private int mBgColorWithoutTransparency;
|
||||||
private int textColor;
|
private int mTextColor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -42,28 +46,28 @@ public class MyWidgetConfigure extends AppCompatActivity {
|
|||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final Bundle extras = intent.getExtras();
|
final Bundle extras = intent.getExtras();
|
||||||
if (extras != null)
|
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();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initVariables() {
|
private void initVariables() {
|
||||||
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||||
bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, 1);
|
mBgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, 1);
|
||||||
if (bgColor == 1) {
|
if (mBgColor == 1) {
|
||||||
bgColor = Color.BLACK;
|
mBgColor = Color.BLACK;
|
||||||
bgAlpha = .2f;
|
mBgAlpha = .2f;
|
||||||
} else {
|
} 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));
|
mBgColorWithoutTransparency = Color.rgb(Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor));
|
||||||
bgSeekBar.setOnSeekBarChangeListener(bgSeekbarChangeListener);
|
mBgSeekBar.setOnSeekBarChangeListener(bgSeekbarChangeListener);
|
||||||
bgSeekBar.setProgress((int) (bgAlpha * 100));
|
mBgSeekBar.setProgress((int) (mBgAlpha * 100));
|
||||||
updateBackgroundColor();
|
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();
|
updateTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,53 +75,53 @@ public class MyWidgetConfigure extends AppCompatActivity {
|
|||||||
public void saveConfig() {
|
public void saveConfig() {
|
||||||
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
|
final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
|
||||||
final RemoteViews views = new RemoteViews(getPackageName(), R.layout.activity_main);
|
final RemoteViews views = new RemoteViews(getPackageName(), R.layout.activity_main);
|
||||||
views.setInt(R.id.notes_view, "setBackgroundColor", bgColor);
|
views.setInt(R.id.notes_view, "setBackgroundColor", mBgColor);
|
||||||
appWidgetManager.updateAppWidget(widgetId, views);
|
appWidgetManager.updateAppWidget(mWidgetId, views);
|
||||||
|
|
||||||
storeWidgetBackground();
|
storeWidgetBackground();
|
||||||
requestWidgetUpdate();
|
requestWidgetUpdate();
|
||||||
|
|
||||||
final Intent resultValue = new Intent();
|
final Intent resultValue = new Intent();
|
||||||
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
|
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId);
|
||||||
setResult(RESULT_OK, resultValue);
|
setResult(RESULT_OK, resultValue);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeWidgetBackground() {
|
private void storeWidgetBackground() {
|
||||||
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences prefs = getSharedPreferences(Constants.PREFS, Context.MODE_PRIVATE);
|
||||||
prefs.edit().putInt(Constants.WIDGET_BG_COLOR, bgColor).apply();
|
prefs.edit().putInt(Constants.WIDGET_BG_COLOR, mBgColor).apply();
|
||||||
prefs.edit().putInt(Constants.WIDGET_TEXT_COLOR, textColor).apply();
|
prefs.edit().putInt(Constants.WIDGET_TEXT_COLOR, mTextColor).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestWidgetUpdate() {
|
private void requestWidgetUpdate() {
|
||||||
final Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, this, MyWidgetProvider.class);
|
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);
|
sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBackgroundColor() {
|
private void updateBackgroundColor() {
|
||||||
bgColor = adjustAlpha(bgColorWithoutTransparency, bgAlpha);
|
mBgColor = adjustAlpha(mBgColorWithoutTransparency, mBgAlpha);
|
||||||
notesView.setBackgroundColor(bgColor);
|
mNotesView.setBackgroundColor(mBgColor);
|
||||||
bgColorPicker.setBackgroundColor(bgColor);
|
mBgColorPicker.setBackgroundColor(mBgColor);
|
||||||
saveBtn.setBackgroundColor(bgColor);
|
mSaveBtn.setBackgroundColor(mBgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTextColor() {
|
private void updateTextColor() {
|
||||||
textColorPicker.setBackgroundColor(textColor);
|
mTextColorPicker.setBackgroundColor(mTextColor);
|
||||||
saveBtn.setTextColor(textColor);
|
mSaveBtn.setTextColor(mTextColor);
|
||||||
notesView.setTextColor(textColor);
|
mNotesView.setTextColor(mTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.config_bg_color)
|
@OnClick(R.id.config_bg_color)
|
||||||
public void pickBackgroundColor() {
|
public void pickBackgroundColor() {
|
||||||
AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, bgColorWithoutTransparency, new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, mBgColorWithoutTransparency, new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(AmbilWarnaDialog dialog) {
|
public void onCancel(AmbilWarnaDialog dialog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOk(AmbilWarnaDialog dialog, int color) {
|
public void onOk(AmbilWarnaDialog dialog, int color) {
|
||||||
bgColorWithoutTransparency = color;
|
mBgColorWithoutTransparency = color;
|
||||||
updateBackgroundColor();
|
updateBackgroundColor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -127,14 +131,14 @@ public class MyWidgetConfigure extends AppCompatActivity {
|
|||||||
|
|
||||||
@OnClick(R.id.config_text_color)
|
@OnClick(R.id.config_text_color)
|
||||||
public void pickTextColor() {
|
public void pickTextColor() {
|
||||||
AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, textColor, new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, mTextColor, new AmbilWarnaDialog.OnAmbilWarnaListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(AmbilWarnaDialog dialog) {
|
public void onCancel(AmbilWarnaDialog dialog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOk(AmbilWarnaDialog dialog, int color) {
|
public void onOk(AmbilWarnaDialog dialog, int color) {
|
||||||
textColor = color;
|
mTextColor = color;
|
||||||
updateTextColor();
|
updateTextColor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -145,7 +149,7 @@ public class MyWidgetConfigure extends AppCompatActivity {
|
|||||||
private SeekBar.OnSeekBarChangeListener bgSeekbarChangeListener = new SeekBar.OnSeekBarChangeListener() {
|
private SeekBar.OnSeekBarChangeListener bgSeekbarChangeListener = new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
bgAlpha = (float) progress / (float) 100;
|
mBgAlpha = (float) progress / (float) 100;
|
||||||
updateBackgroundColor();
|
updateBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:configure="com.simplemobiletools.notes.MyWidgetConfigure"
|
android:configure="com.simplemobiletools.notes.activities.WidgetConfigureActivity"
|
||||||
android:initialLayout="@layout/widget"
|
android:initialLayout="@layout/widget"
|
||||||
android:minHeight="30dp"
|
android:minHeight="30dp"
|
||||||
android:minWidth="30dp"
|
android:minWidth="30dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user