From 26df1d2f1dc5fd4edab0cf7693b38eecad68e026 Mon Sep 17 00:00:00 2001 From: Andy Carra Date: Tue, 15 Oct 2024 13:50:13 -0700 Subject: [PATCH 1/2] [FIX] Window disassociation (#714) * initial nullchecks and tests * getting gradle 8 working * whyyyy * addressing feedback --------- Co-authored-by: Andy Carra --- .github/workflows/android.yml | 4 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- wiglewifiwardriving/build.gradle | 4 +- .../wigleandroid/ErrorReportActivity.java | 7 ++-- .../net/wigle/wigleandroid/MainActivity.java | 5 ++- .../net/wigle/wigleandroid/TokenAccess.java | 34 ++++++++-------- .../background/BackgroundGuiHandler.java | 8 +++- .../wigleandroid/db/MxcDatabaseHelper.java | 4 +- .../ui/NetworkBubbleDrawable.java | 4 +- .../wigleandroid/ui/NetworkIconGenerator.java | 10 ++--- .../ui/WiGLEConfirmationDialog.java | 39 ++++++++++++------- .../src/main/res/values/strings.xml | 1 + 13 files changed, 73 insertions(+), 51 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index f2cd07f6a..2464d78d7 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -13,10 +13,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: set up JDK 11 + - name: set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' cache: gradle - name: Update API KEY from Secrets diff --git a/build.gradle b/build.gradle index b67da5450..4cc0fb3ad 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.1.1' } } plugins { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8faa4335a..b109adb18 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/wiglewifiwardriving/build.gradle b/wiglewifiwardriving/build.gradle index c8479a0ee..658fc7bb7 100644 --- a/wiglewifiwardriving/build.gradle +++ b/wiglewifiwardriving/build.gradle @@ -15,6 +15,9 @@ android { vectorDrawables.useSupportLibrary = true multiDexEnabled true } + buildFeatures { + buildConfig = true + } buildTypes { release { @@ -27,7 +30,6 @@ android { excludes += ['META-INF/ASL2.0', 'META-INF/LICENSE', 'META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/LICENSE.txt', 'META-INF/MANIFEST.MF'] } } - } configurations { diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ErrorReportActivity.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ErrorReportActivity.java index 0990b978e..ae652da22 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ErrorReportActivity.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ErrorReportActivity.java @@ -88,9 +88,10 @@ public void run() { @Override public void onClick( final DialogInterface dialog, final int which ) { try { - dialog.dismiss(); - } - catch ( Exception ex ) { + if (null != dialog) { + dialog.dismiss(); + } + } catch ( Exception ex ) { // guess it wasn't there anyways Logging.info( "exception dismissing alert dialog: " + ex ); } diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/MainActivity.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/MainActivity.java index 3654c6538..f2c16ef37 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/MainActivity.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/MainActivity.java @@ -2426,7 +2426,10 @@ public void checkStorage() { iseDlgBuilder.setMessage(external?R.string.no_external_space_message:R.string.no_internal_space_message) .setTitle(external?R.string.no_external_space_title:R.string.no_internal_space_title) .setCancelable(true) - .setPositiveButton(R.string.ok, (dialog, which) -> dialog.dismiss()); + .setPositiveButton(R.string.ok, (dialog, which) -> { + if (null != dialog) { + dialog.dismiss(); + }}); final Dialog dialog = iseDlgBuilder.create(); if (!isFinishing()) { dialog.show(); diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/TokenAccess.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/TokenAccess.java index 543ad46b6..a32cb353b 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/TokenAccess.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/TokenAccess.java @@ -183,27 +183,27 @@ public static String getApiToken(SharedPreferences prefs) { try { final KeyStore keyStore = getKeyStore(); - KeyStore.PrivateKeyEntry privateKeyEntry; - + KeyStore.PrivateKeyEntry privateKeyEntry = null; // prefer v2 key -> v1 key -> v0 key, nada as applicable int versionThreshold = android.os.Build.VERSION_CODES.M; - if (keyStore.containsAlias(KEYSTORE_WIGLE_CREDS_KEY_V2)) { - //DEBUG: MainActivity.info("Using v2: " + KEYSTORE_WIGLE_CREDS_KEY_V2); - return getApiTokenVersion2(prefs); - } else if (keyStore.containsAlias(KEYSTORE_WIGLE_CREDS_KEY_V1)) { - privateKeyEntry = (KeyStore.PrivateKeyEntry) - keyStore.getEntry(KEYSTORE_WIGLE_CREDS_KEY_V1, null); - } else if (keyStore.containsAlias(KEYSTORE_WIGLE_CREDS_KEY_V0)) { - privateKeyEntry = (KeyStore.PrivateKeyEntry) - keyStore.getEntry(KEYSTORE_WIGLE_CREDS_KEY_V0, null); - versionThreshold = Build.VERSION_CODES.JELLY_BEAN_MR2; - } else { - Logging.warn("[TOKEN] Compatible build, but no key set: " + - android.os.Build.VERSION.SDK_INT + " - returning plaintext."); - return prefs.getString(PreferenceKeys.PREF_TOKEN, ""); + if (null != keyStore) { + if (keyStore.containsAlias(KEYSTORE_WIGLE_CREDS_KEY_V2)) { + //DEBUG: MainActivity.info("Using v2: " + KEYSTORE_WIGLE_CREDS_KEY_V2); + return getApiTokenVersion2(prefs); + } else if (keyStore.containsAlias(KEYSTORE_WIGLE_CREDS_KEY_V1)) { + privateKeyEntry = (KeyStore.PrivateKeyEntry) + keyStore.getEntry(KEYSTORE_WIGLE_CREDS_KEY_V1, null); + } else if (keyStore.containsAlias(KEYSTORE_WIGLE_CREDS_KEY_V0)) { + privateKeyEntry = (KeyStore.PrivateKeyEntry) + keyStore.getEntry(KEYSTORE_WIGLE_CREDS_KEY_V0, null); + versionThreshold = Build.VERSION_CODES.JELLY_BEAN_MR2; + } else { + Logging.warn("[TOKEN] Compatible build, but no key set: " + + android.os.Build.VERSION.SDK_INT + " - returning plaintext."); + return prefs.getString(PreferenceKeys.PREF_TOKEN, ""); + } } - if (null != privateKeyEntry) { String encodedCypherText = prefs.getString(PreferenceKeys.PREF_TOKEN, ""); if (!encodedCypherText.isEmpty()) { diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/background/BackgroundGuiHandler.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/background/BackgroundGuiHandler.java index f72a0fb37..ea02fdbaa 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/background/BackgroundGuiHandler.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/background/BackgroundGuiHandler.java @@ -128,7 +128,9 @@ public void handleMessage( final Message msg ) { if (dialog != null) { try { //DEBUG: Logging.info("fragment from dialog: " + dialog); - dialog.dismiss(); + if (null != dialog && dialog.isVisible()) { + dialog.dismiss(); + } } catch ( Exception ex ) { // you can't dismiss what isn't there Logging.error( "exception dismissing fm dialog: " + ex ); @@ -326,7 +328,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog ad = builder.create(); ad.setButton( DialogInterface.BUTTON_POSITIVE, "OK", (dialog, which) -> { try { - dialog.dismiss(); + if (null != dialog) { + dialog.dismiss(); + } } catch ( Exception ex ) { // guess it wasn't there anyways Logging.info( "exception dismissing alert dialog: " + ex ); diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/db/MxcDatabaseHelper.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/db/MxcDatabaseHelper.java index 0a1206c8a..0c0199417 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/db/MxcDatabaseHelper.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/db/MxcDatabaseHelper.java @@ -92,7 +92,9 @@ public void implantMxcDatabase(final Context context, final Boolean isFinishing) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); + if (null != dialog) { + dialog.dismiss(); + } } }); diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkBubbleDrawable.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkBubbleDrawable.java index 40ae0212e..b31f3191c 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkBubbleDrawable.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkBubbleDrawable.java @@ -26,8 +26,8 @@ public class NetworkBubbleDrawable extends Drawable { @SuppressLint("UseCompatLoadingForDrawables") //ALIBI: lifted from the original public NetworkBubbleDrawable(Resources res) { - this.mMask = res.getDrawable(R.drawable.amu_bubble_mask); - this.mShadow = res.getDrawable(R.drawable.amu_bubble_shadow); + this.mMask = res.getDrawable(com.google.maps.android.R.drawable.amu_bubble_mask); + this.mShadow = res.getDrawable(com.google.maps.android.R.drawable.amu_bubble_shadow); } public void setColor(int color) { this.mColor = color; diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkIconGenerator.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkIconGenerator.java index 8244e9e91..13472afcf 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkIconGenerator.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/NetworkIconGenerator.java @@ -59,9 +59,9 @@ public class NetworkIconGenerator { public NetworkIconGenerator(Context context) { mContext = context; mBackground = new NetworkBubbleDrawable(this.mContext.getResources()); - mContainer = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.amu_text_bubble, null); + mContainer = (ViewGroup) LayoutInflater.from(mContext).inflate(com.google.maps.android.R.layout.amu_text_bubble, null); mRotationLayout = (RotationLayout) mContainer.getChildAt(0); - mContentView = mTextView = (TextView) mRotationLayout.findViewById(R.id.amu_text); + mContentView = mTextView = (TextView) mRotationLayout.findViewById(com.google.maps.android.R.id.amu_text); setStyle(STYLE_DEFAULT); } @@ -123,7 +123,7 @@ public void setContentView(View contentView) { mRotationLayout.removeAllViews(); mRotationLayout.addView(contentView); mContentView = contentView; - final View view = mRotationLayout.findViewById(R.id.amu_text); + final View view = mRotationLayout.findViewById(com.google.maps.android.R.id.amu_text); mTextView = view instanceof TextView ? (TextView) view : null; } @@ -210,14 +210,14 @@ private static int getTextStyle(int style) { case 1: case 2: default: - return R.style.amu_Bubble_TextAppearance_Dark; //style.amu_Bubble_TextAppearance_Dark; + return com.google.maps.android.R.style.amu_Bubble_TextAppearance_Dark; //style.amu_Bubble_TextAppearance_Dark; case 3: case 4: case 5: case 6: case 7: case 8: - return R.style.amu_Bubble_TextAppearance_Light;//style.amu_Bubble_TextAppearance_Light; + return com.google.maps.android.R.style.amu_Bubble_TextAppearance_Light;//style.amu_Bubble_TextAppearance_Light; } } diff --git a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/WiGLEConfirmationDialog.java b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/WiGLEConfirmationDialog.java index b985819ad..fc4dbcf7d 100644 --- a/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/WiGLEConfirmationDialog.java +++ b/wiglewifiwardriving/src/main/java/net/wigle/wigleandroid/ui/WiGLEConfirmationDialog.java @@ -70,13 +70,17 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { final Activity activity = getActivity(); final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setCancelable(true); - builder.setTitle("Confirmation"); //TODO: literal string - final String checkboxLabel = getArguments().getString("checkboxLabel"); - if (null != checkboxLabel) { - View checkBoxView = View.inflate(activity, R.layout.checkbox, null); - CheckBox checkBox = checkBoxView.findViewById(R.id.checkbox); - checkBox.setText(checkboxLabel); - builder.setView(checkBoxView); + final String confirmString = getString(R.string.dialog_confirm); + builder.setTitle(confirmString); + Bundle arguments = getArguments(); + if (null != arguments) { + final String checkboxLabel = arguments.getString("checkboxLabel"); + if (null != checkboxLabel) { + View checkBoxView = View.inflate(activity, R.layout.checkbox, null); + CheckBox checkBox = checkBoxView.findViewById(R.id.checkbox); + checkBox.setText(checkboxLabel); + builder.setView(checkBoxView); + } } final String persistPrefKey = getArguments().getString("persistPref"); final String persistPrefAgreeValue = getArguments().getString("persistPrefAgreeValue"); @@ -90,17 +94,20 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog ad = builder.create(); // ok - ad.setButton(DialogInterface.BUTTON_POSITIVE, activity.getString(R.string.ok), (dialog, which) -> { + final String okString = (null != activity) ? activity.getString(R.string.ok) : "OK"; + ad.setButton(DialogInterface.BUTTON_POSITIVE, okString, (dialog, which) -> { try { if (null != persistPrefKey) { CheckBox checkBox = ((AlertDialog) dialog).findViewById(R.id.checkbox); - if (checkBox.isChecked()) { + if (checkBox.isChecked() && prefs != null) { final SharedPreferences.Editor editor = prefs.edit(); editor.putString(persistPrefKey, persistPrefAgreeValue); editor.apply(); } } - dialog.dismiss(); + if (null != dialog) { + dialog.dismiss(); + } final Activity activity1 = getActivity(); if (activity1 == null) { Logging.info("activity is null in dialog. tabPos: " + tabPos + " dialogId: " + dialogId); @@ -113,7 +120,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { final Fragment fragment = fragmentManager.findFragmentByTag(MainActivity.FRAGMENT_TAG_PREFIX + tabPos); if (fragment == null) { Logging.error("null fragment for: " + String.format("0x%08X", tabPos) + " (" + maybeName + ")"); - //TODO: might behoove us to show an error here + //ALIBI: how would we show an error here with a null fragment? } else { ((DialogListener) fragment).handleDialog(dialogId); } @@ -128,7 +135,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { }); // cancel - ad.setButton(DialogInterface.BUTTON_NEGATIVE, activity.getString(R.string.cancel), (dialog, which) -> { + final String cancelString = (null != activity) ? activity.getString(R.string.cancel) : "Cancel"; + ad.setButton(DialogInterface.BUTTON_NEGATIVE, cancelString, (dialog, which) -> { try { if (null != persistPrefKey) { CheckBox checkBox = ((AlertDialog) dialog).findViewById(R.id.checkbox); @@ -138,7 +146,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { editor.apply(); } } - dialog.dismiss(); + if (null != dialog) { + dialog.dismiss(); + } } catch (Exception ex) { // guess it wasn't there anyways Logging.info("exception dismissing fragment alert dialog: ", ex); @@ -146,6 +156,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { }); return ad; } + public static void createConfirmation(final FragmentActivity activity, final String message, final int tabPos, final int dialogId) { try { @@ -181,6 +192,4 @@ public static void createCheckboxConfirmation(final FragmentActivity activity, f Logging.error(errorMessage, ex); } } - - } diff --git a/wiglewifiwardriving/src/main/res/values/strings.xml b/wiglewifiwardriving/src/main/res/values/strings.xml index 99c3eb631..cdce08a8d 100644 --- a/wiglewifiwardriving/src/main/res/values/strings.xml +++ b/wiglewifiwardriving/src/main/res/values/strings.xml @@ -453,4 +453,5 @@ Search area: (%1$d queued tasks) A job of this type is already running or waiting to run. + Confirm \ No newline at end of file From 18e3db6772279deaebc46c5dc3047a5f973f2604 Mon Sep 17 00:00:00 2001 From: bobzilla Date: Wed, 23 Oct 2024 20:03:37 -0400 Subject: [PATCH 2/2] fix dutch typo --- wiglewifiwardriving/src/main/res/values-da/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiglewifiwardriving/src/main/res/values-da/strings.xml b/wiglewifiwardriving/src/main/res/values-da/strings.xml index 8e93db174..ea41ebf0f 100644 --- a/wiglewifiwardriving/src/main/res/values-da/strings.xml +++ b/wiglewifiwardriving/src/main/res/values-da/strings.xml @@ -26,7 +26,7 @@ Sæt max kør til: Start CSV Eksport Eksport aktuelle forløb til CSV-fil - CSV Eksport til DB + CSV Eksport fra DB Eksportere hele DB til CSV fil Start KML Eksport Eksport aktuelle forløb til KML-fil