diff --git a/app/src/main/java/org/emulator/forty/eight/MainActivity.java b/app/src/main/java/org/emulator/forty/eight/MainActivity.java index eaeaf57..b1c5d49 100644 --- a/app/src/main/java/org/emulator/forty/eight/MainActivity.java +++ b/app/src/main/java/org/emulator/forty/eight/MainActivity.java @@ -327,12 +327,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On return super.onOptionsItemSelected(item); } - @SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); - if (id == R.id.nav_new) { OnFileNew(); } else if (id == R.id.nav_open) { @@ -390,7 +388,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On } - DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); + DrawerLayout drawer = findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; } @@ -546,19 +544,25 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ensureDocumentSaved(new Runnable() { @Override public void run() { - final String[] kmlScriptTitles = new String[kmlScripts.size()]; + final int lastIndex = kmlScripts.size(); + final String[] kmlScriptTitles = new String[lastIndex + 1]; for (int i = 0; i < kmlScripts.size(); i++) kmlScriptTitles[i] = kmlScripts.get(i).title; + kmlScriptTitles[lastIndex] = getResources().getString(R.string.load_custom_kml); new AlertDialog.Builder(MainActivity.this) - .setTitle("Pick a calculator") + .setTitle(getResources().getString(R.string.pick_calculator)) .setItems(kmlScriptTitles, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - String kmlScriptFilename = kmlScripts.get(which).filename; - NativeLib.onFileNew(kmlScriptFilename); - displayFilename(""); - showKMLLog(); - updateNavigationDrawerItems(); + if(which == lastIndex) { + + } else { + String kmlScriptFilename = kmlScripts.get(which).filename; + NativeLib.onFileNew(kmlScriptFilename); + displayFilename(""); + showKMLLog(); + updateNavigationDrawerItems(); + } } }).show(); } diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml index 73c67b6..52c5a6a 100644 --- a/app/src/main/res/menu/activity_main_drawer.xml +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -124,39 +124,39 @@ info *action + android:title="@string/nav_reset_calculator" /> + android:title="@string/nav_save_backup" /> + android:title="@string/nav_restore_backup" /> + android:title="@string/nav_delete_backup" /> - + + android:title="@string/nav_change_kml_script" /> - + + android:title="@string/nav_item_help" /> + android:title="@string/nav_about" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6300b13..b4ecc71 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,12 +16,12 @@ Emu48 for Android + Settings Open navigation drawer Close navigation drawer Emu48 for Android android.studio@android.com Navigation header - Settings New... Open... Save @@ -34,6 +34,17 @@ Recent Edit Paste Stack + Reset Calculator + Save Backup + Restore Backup + Delete Backup + View + Change KML Script... + Help + Help + About Emu48... + Custom KML script... + Pick a calculator