From d3432fb3d8459338da14cb989a274d4f5ae74497 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Tue, 20 Nov 2018 12:23:50 -0800 Subject: [PATCH] Show release notes on first launch/upgrade - Include a menu item to re-show the release notes - Upgrade migration sets new Color TV video mode --- Android/.idea/misc.xml | 2 +- Android/AndroidManifest.xml | 2 +- .../org/deadc0de/apple2ix/Apple2Activity.java | 89 +++++++++++++++++-- .../deadc0de/apple2ix/Apple2Preferences.java | 8 ++ .../deadc0de/apple2ix/Apple2SettingsMenu.java | 16 ++++ .../app/src/main/res/values-de/strings.xml | 4 +- .../app/src/main/res/values-es/strings.xml | 4 +- .../app/src/main/res/values-fr/strings.xml | 4 +- Android/app/src/main/res/values/strings.xml | 4 +- Android/assets/release_notes.txt | 18 ++++ 10 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 Android/assets/release_notes.txt diff --git a/Android/.idea/misc.xml b/Android/.idea/misc.xml index 199f8698..ac595445 100644 --- a/Android/.idea/misc.xml +++ b/Android/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/Android/AndroidManifest.xml b/Android/AndroidManifest.xml index 9b975be3..71d92705 120000 --- a/Android/AndroidManifest.xml +++ b/Android/AndroidManifest.xml @@ -1 +1 @@ -app/build/intermediates/manifests/full/debug/AndroidManifest.xml \ No newline at end of file +app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml \ No newline at end of file diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java index 0728db3b..45d45044 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java @@ -14,9 +14,12 @@ package org.deadc0de.apple2ix; import android.Manifest; import android.app.Activity; import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.pm.PackageManager; +import android.content.res.AssetManager; import android.os.Build; import android.os.Bundle; +import android.os.Handler; import android.os.StrictMode; import android.util.Log; import android.view.KeyEvent; @@ -25,6 +28,11 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.Toast; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.InterruptedIOException; +import java.io.Reader; import java.util.ArrayList; import java.util.Collections; import java.util.concurrent.atomic.AtomicBoolean; @@ -152,16 +160,14 @@ public class Apple2Activity extends Activity implements Apple2DiskChooserActivit boolean extperm = true; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // On Marshmallow+ specifically ask for permission to read/write storage - String readPermission = Manifest.permission.READ_EXTERNAL_STORAGE; - String writePermission = Manifest.permission.WRITE_EXTERNAL_STORAGE; - int hasReadPermission = checkSelfPermission(readPermission); - int hasWritePermission = checkSelfPermission(writePermission); + int hasReadPermission = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE); + int hasWritePermission = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE); ArrayList permissions = new ArrayList(); if (hasReadPermission != PackageManager.PERMISSION_GRANTED) { - permissions.add(readPermission); + permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE); } if (hasWritePermission != PackageManager.PERMISSION_GRANTED) { - permissions.add(writePermission); + permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); } if (!permissions.isEmpty()) { extperm = false; @@ -179,9 +185,20 @@ public class Apple2Activity extends Activity implements Apple2DiskChooserActivit Apple2Utils.exposeAPKAssets(Apple2Activity.this); if (externalStoragePermission) { Apple2Utils.exposeAPKAssetsToExternal(Apple2Activity.this); + Log.d(TAG, "Finished first time copying #1..."); + + if (!(boolean)Apple2Preferences.getJSONPref(Apple2Preferences.PREF_DOMAIN_INTERFACE, Apple2Preferences.PREF_RELEASE_NOTES, false)) { + Runnable myRunnable = new Runnable() { + @Override + public void run() { + showReleaseNotes(); + } + }; + new Handler(Apple2Activity.this.getMainLooper()).post(myRunnable); + } } + mSplashScreen.setDismissable(true); - Log.d(TAG, "Finished first time copying..."); } }).start(); } @@ -215,10 +232,15 @@ public class Apple2Activity extends Activity implements Apple2DiskChooserActivit // perform migration(s) and assets exposure now Apple2Utils.migrateToExternalStorage(Apple2Activity.this); Apple2Utils.exposeAPKAssetsToExternal(Apple2Activity.this); + Log.d(TAG, "Finished first time copying #2..."); } // else ... we keep nagging on app startup ... } else { super.onRequestPermissionsResult(requestCode, permissions, grantResults); } + + if (!(boolean)Apple2Preferences.getJSONPref(Apple2Preferences.PREF_DOMAIN_INTERFACE, Apple2Preferences.PREF_RELEASE_NOTES, false)) { + showReleaseNotes(); + } } @Override @@ -363,6 +385,59 @@ public class Apple2Activity extends Activity implements Apple2DiskChooserActivit } } + public void showReleaseNotes() { + + Apple2Preferences.setJSONPref(Apple2Preferences.PREF_DOMAIN_INTERFACE, Apple2Preferences.PREF_RELEASE_NOTES, true); + Apple2Preferences.save(this); + + String releaseNotes = ""; + final int maxAttempts = 5; + int attempts = 0; + do { + InputStream is = null; + try { + AssetManager assetManager = getAssets(); + is = assetManager.open("release_notes.txt"); + + final int bufferSize = 4096; + final char[] buffer = new char[bufferSize]; + final StringBuilder out = new StringBuilder(); + Reader in = new InputStreamReader(is, "UTF-8"); + while (true) { + int siz = in.read(buffer, 0, buffer.length); + if (siz < 0) { + break; + } + out.append(buffer, 0, siz); + } + releaseNotes = out.toString(); + break; + } catch (InterruptedIOException e) { + /* EINTR, EAGAIN */ + } catch (IOException e) { + Log.e(TAG, "OOPS could not load release_notes.txt!", e); + } finally { + if (is != null) { + try { + is.close(); + } catch (IOException e) { + // NOOP + } + } + } + ++attempts; + } while (attempts < maxAttempts); + + AlertDialog.Builder builder = new AlertDialog.Builder(Apple2Activity.this).setIcon(R.drawable.ic_launcher).setCancelable(false).setTitle(R.string.release_notes).setMessage(releaseNotes).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + AlertDialog dialog = builder.create(); + registerAndShowDialog(dialog); + } + public Apple2MainMenu getMainMenu() { return mMainMenu; } diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java index f117caad..ec740510 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java @@ -48,6 +48,7 @@ public class Apple2Preferences { public final static String PREF_DEVICE_HEIGHT = "deviceHeight"; public final static String PREF_DEVICE_WIDTH = "deviceWidth"; public final static String PREF_EMULATOR_VERSION = "emulatorVersion"; + public final static String PREF_RELEASE_NOTES = "shownReleaseNotes"; // JSON preferences private static JSONObject sSettings = null; @@ -174,6 +175,13 @@ public class Apple2Preferences { Log.v(TAG, "Triggering migration to Apple2ix version : " + BuildConfig.VERSION_NAME); setJSONPref(PREF_DOMAIN_INTERFACE, PREF_EMULATOR_VERSION, BuildConfig.VERSION_CODE); + setJSONPref(PREF_DOMAIN_INTERFACE, PREF_RELEASE_NOTES, false); + + if (versionCode < 22) { + // force upgrade to defaults here ... + setJSONPref(Apple2VideoSettingsMenu.SETTINGS.SHOW_HALF_SCANLINES, Apple2VideoSettingsMenu.SETTINGS.SHOW_HALF_SCANLINES.getPrefDefault()); + setJSONPref(Apple2VideoSettingsMenu.SETTINGS.COLOR_MODE_CONFIGURE, Apple2VideoSettingsMenu.SETTINGS.COLOR_MODE_CONFIGURE.getPrefDefault()); + } Apple2Utils.migrateToExternalStorage(activity); if (BuildConfig.VERSION_CODE >= 17) { diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2SettingsMenu.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2SettingsMenu.java index f35359b9..81ff8fa6 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2SettingsMenu.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2SettingsMenu.java @@ -283,6 +283,22 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu { return convertView; } }, + RELEASE_NOTES { + @Override + public final String getTitle(Apple2Activity activity) { + return activity.getResources().getString(R.string.release_notes); + } + + @Override + public final String getSummary(Apple2Activity activity) { + return activity.getResources().getString(R.string.release_notes_summary); + } + + @Override + public void handleSelection(Apple2Activity activity, final Apple2AbstractMenu settingsMenu, boolean isChecked) { + activity.showReleaseNotes(); + } + }, ABOUT { @Override public final String getTitle(Apple2Activity activity) { diff --git a/Android/app/src/main/res/values-de/strings.xml b/Android/app/src/main/res/values-de/strings.xml index 08449ca5..27c592d9 100644 --- a/Android/app/src/main/res/values-de/strings.xml +++ b/Android/app/src/main/res/values-de/strings.xml @@ -132,7 +132,7 @@ Mockingboard deaktiviert Mockingboard konnte nicht aktiviert werden Aktiviere Mockingboard - Revision C in Slot 4/5 (evtl. wird ein Restart benötigt) + Revision C in Slot 4/5 (evtl. wird ein Restart benötigt) (may consume extra battery) Mockingboard Lautstärke Einstellen der Mockingboard Lautstärke Nein @@ -199,5 +199,7 @@ Disk fast loading (EXPERIMENTAL) Quickly load disk images (may negatively affect device battery life) Renders pixel vertical divisions + Release notes + View notes for this release diff --git a/Android/app/src/main/res/values-es/strings.xml b/Android/app/src/main/res/values-es/strings.xml index d3fbac5a..4d7260d4 100644 --- a/Android/app/src/main/res/values-es/strings.xml +++ b/Android/app/src/main/res/values-es/strings.xml @@ -130,7 +130,7 @@ Mockingboard desactivado Mockingboard no pudo ser habilitado Activar Mockingboard - Revisión C en la ranura 4/5 puede requerir reinicio + Revisión C en Slot 4/5 (puede requerir reinicio) (may consume extra battery) Volumen de Mockingboard Adjustar el volumen del Mockingboard No @@ -199,5 +199,7 @@ Disk fast loading (EXPERIMENTAL) Quickly load disk images (may negatively affect device battery life) Renders pixel vertical divisions + Release notes + View notes for this release diff --git a/Android/app/src/main/res/values-fr/strings.xml b/Android/app/src/main/res/values-fr/strings.xml index fa1fb792..0d614863 100644 --- a/Android/app/src/main/res/values-fr/strings.xml +++ b/Android/app/src/main/res/values-fr/strings.xml @@ -130,7 +130,7 @@ Mockingboard désactivé Le Mockingboard ne peut être activé Activer le Mockingboard - Révision C dans Slot 4/5 (redémarrage possible) + Révision C dans Slot 4/5 (redémarrage possible) (may consume extra battery) Volume du Mockingboard Placer le volume du Mockingboard Non @@ -199,5 +199,7 @@ Disk fast loading (EXPERIMENTAL) Quickly load disk images (may negatively affect device battery life) Renders pixel vertical divisions + Release notes + View notes for this release diff --git a/Android/app/src/main/res/values/strings.xml b/Android/app/src/main/res/values/strings.xml index b4958828..d1ef644a 100644 --- a/Android/app/src/main/res/values/strings.xml +++ b/Android/app/src/main/res/values/strings.xml @@ -138,7 +138,7 @@ Mockingboard disabled Mockingboard could not be enabled Enable Mockingboard - Revision C in Slot 4/5 (may require restart) + Revision C in Slot 4/5 (may require restart) (may consume extra battery) Mockingboard volume Set the Mockingboard volume Landscape @@ -199,5 +199,7 @@ Disk fast loading (EXPERIMENTAL) Quickly load disk images (may negatively affect device battery life) Renders pixel vertical divisions + Release notes + View notes for this release diff --git a/Android/assets/release_notes.txt b/Android/assets/release_notes.txt new file mode 100644 index 00000000..621cec35 --- /dev/null +++ b/Android/assets/release_notes.txt @@ -0,0 +1,18 @@ +Apple2ix (a2ix) 2.0.0-Android Release Notes + +TL;DR : new video mode settings! + +CHANGES: + +- Implemented a more conformant video scanner. This improves emulation fidelity for programs that implement custom video modes (e.g., custom split screen between text & graphics). + +- New NTSC video display modes including "Color monitor", "Monochrome TV", and "Color TV" modes. Also support "Green screen" monochrome video. Thanks to the AppleWin project and Bill Simms for these modes. + +- New preference to enable/disable half-scanline video effects. + +- EXPERIMENTAL: New preference to enable/disable fast disk image loading. This may cause audio glitches or other instability. Use at your own risk! + +MORE INFO: + +- https://deadc0de.org/apple2ix/android +