mirror of
https://github.com/dgis/emu48android
synced 2024-12-26 09:58:49 +01:00
Ask to SaveAs just after creating a new calculator and improve the Save and SaveAs in certain situation.
This commit is contained in:
parent
ea970cbed3
commit
2d1af254a1
3 changed files with 21 additions and 9 deletions
|
@ -602,12 +602,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureDocumentSaved(Runnable continueCallback) {
|
||||
ensureDocumentSaved(continueCallback, false);
|
||||
}
|
||||
|
||||
private Runnable fileSaveAsCallback = null;
|
||||
private void ensureDocumentSaved(Runnable continueCallback) {
|
||||
ensureDocumentSaved(continueCallback, false, false);
|
||||
}
|
||||
private void ensureDocumentSaved(Runnable continueCallback, boolean forceRequest) {
|
||||
ensureDocumentSaved(continueCallback, forceRequest, false);
|
||||
}
|
||||
private void ensureDocumentSaved(Runnable continueCallback, boolean forceRequest, boolean simpleSave) {
|
||||
if(NativeLib.isDocumentAvailable()) {
|
||||
String currentFilename = NativeLib.getCurrentFilename();
|
||||
boolean hasFilename = (currentFilename != null && currentFilename.length() > 0);
|
||||
|
@ -629,7 +631,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
}
|
||||
};
|
||||
|
||||
if(!forceRequest && hasFilename && sharedPreferences.getBoolean("settings_autosave", true)) {
|
||||
if(simpleSave || (!forceRequest && hasFilename && sharedPreferences.getBoolean("settings_autosave", true))) {
|
||||
onClickListener.onClick(null, DialogInterface.BUTTON_POSITIVE);
|
||||
} else {
|
||||
new AlertDialog.Builder(this)
|
||||
|
@ -646,7 +648,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
// By default Port1 is set
|
||||
setPort1Settings(true, true);
|
||||
|
||||
ensureDocumentSaved(() -> showKMLPicker(false));
|
||||
ensureDocumentSaved(() -> showKMLPicker(false) );
|
||||
}
|
||||
|
||||
private void newFileFromKML(String kmlScriptFilename) {
|
||||
|
@ -655,11 +657,20 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
showCalculatorView(true);
|
||||
displayFilename("");
|
||||
showKMLLog();
|
||||
suggestToSaveNewFile();
|
||||
} else
|
||||
showKMLLogForce();
|
||||
updateNavigationDrawerItems();
|
||||
}
|
||||
|
||||
private void suggestToSaveNewFile() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(getString(R.string.message_save_new_file))
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> OnFileSaveAs())
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void OnFileOpen() {
|
||||
ensureDocumentSaved(() -> {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
|
@ -670,7 +681,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
});
|
||||
}
|
||||
private void OnFileSave() {
|
||||
ensureDocumentSaved(null);
|
||||
ensureDocumentSaved(null, false, true);
|
||||
}
|
||||
private void OnFileSaveAs() {
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
|
@ -1228,7 +1239,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
|
|||
}
|
||||
|
||||
private void showKMLLog() {
|
||||
if(sharedPreferences.getBoolean("settings_alwaysdisplog", true)) {
|
||||
if(sharedPreferences.getBoolean("settings_alwaysdisplog", false)) {
|
||||
showKMLLogForce();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<string name="message_open_security_retry_description">I hope now you could open again the state file.</string>
|
||||
<string name="message_state_saved">State saved</string>
|
||||
<string name="message_do_you_want_to_save">Do you want to save changes?\n(BACK to cancel)</string>
|
||||
<string name="message_save_new_file">Do you want to save this new state file?\n(To avoid losing the state of the machine)</string>
|
||||
<string name="message_yes">Yes</string>
|
||||
<string name="message_no">No</string>
|
||||
<string name="message_ok">Ok</string>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<SwitchPreference
|
||||
android:key="settings_alwaysdisplog"
|
||||
android:title="@string/settings_alwaysdisplog_title"
|
||||
android:defaultValue="true" />
|
||||
android:defaultValue="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/settings_category_ui_title">
|
||||
|
|
Loading…
Reference in a new issue