implement enabling Autosave from the dialog

This commit is contained in:
tibbi 2016-08-21 23:29:28 +02:00
parent 397fe8d47c
commit 903425e40a
6 changed files with 11 additions and 10 deletions

View File

@ -14,7 +14,6 @@ import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.simplemobiletools.notes.Config;
import com.simplemobiletools.notes.Constants;
import com.simplemobiletools.notes.MyWidgetProvider;
import com.simplemobiletools.notes.R;
@ -47,7 +46,7 @@ public class MainActivity extends SimpleActivity {
@Override
protected void onPause() {
super.onPause();
if (Config.newInstance(getApplicationContext()).getIsAutosaveEnabled()) {
if (mConfig.getIsAutosaveEnabled()) {
saveText(false);
}
}
@ -65,13 +64,13 @@ public class MainActivity extends SimpleActivity {
@Override
protected void onDestroy() {
super.onDestroy();
Config.newInstance(getApplicationContext()).setIsFirstRun(false);
mConfig.setIsFirstRun(false);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
if (Config.newInstance(getApplicationContext()).getIsAutosaveEnabled())
if (mConfig.getIsAutosaveEnabled())
menu.findItem(R.id.save).setVisible(false);
return true;
@ -106,7 +105,8 @@ public class MainActivity extends SimpleActivity {
alertDialog.setPositiveButton(R.string.enable_autosave, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mConfig.setIsAutosaveEnabled(true);
supportInvalidateOptionsMenu();
}
});
alertDialog.create().show();

View File

@ -11,6 +11,7 @@
android:layout_height="wrap_content"
android:background="@null"
android:gravity="top"
android:padding="@dimen/activity_margin"/>
android:padding="@dimen/activity_margin"
android:textSize="@dimen/normal_text_size"/>
</ScrollView>

View File

@ -10,7 +10,7 @@
<string name="enable_autosave">Enable autosave</string>
<string name="cancel">Cancel</string>
<string name="unsaved_changes">Unsaved changes</string>
<string name="autosave_prompt_msg">Changes made to the note have not be saved. Do you want to enable autosave?</string>
<string name="autosave_prompt_msg">Changes made to the note have not been saved. Do you want to enable autosave?</string>
<!-- Settings -->
<string name="settings">Impostazioni</string>

View File

@ -10,7 +10,7 @@
<string name="enable_autosave">Enable autosave</string>
<string name="cancel">Cancel</string>
<string name="unsaved_changes">Unsaved changes</string>
<string name="autosave_prompt_msg">Changes made to the note have not be saved. Do you want to enable autosave?</string>
<string name="autosave_prompt_msg">Changes made to the note have not been saved. Do you want to enable autosave?</string>
<!-- Settings -->
<string name="settings">設定</string>

View File

@ -10,7 +10,7 @@
<string name="enable_autosave">Enable autosave</string>
<string name="cancel">Cancel</string>
<string name="unsaved_changes">Unsaved changes</string>
<string name="autosave_prompt_msg">Changes made to the note have not be saved. Do you want to enable autosave?</string>
<string name="autosave_prompt_msg">Changes made to the note have not been saved. Do you want to enable autosave?</string>
<!-- Settings -->
<string name="settings">Inställningar</string>

View File

@ -10,7 +10,7 @@
<string name="enable_autosave">Enable autosave</string>
<string name="cancel">Cancel</string>
<string name="unsaved_changes">Unsaved changes</string>
<string name="autosave_prompt_msg">Changes made to the note have not be saved. Do you want to enable autosave?</string>
<string name="autosave_prompt_msg">Changes made to the note have not been saved. Do you want to enable autosave?</string>
<!-- Settings -->
<string name="settings">Settings</string>