From dd93df9ef224d545ea91777d151539f9f2b2eb9e Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Tue, 8 Aug 2017 10:25:55 +1000 Subject: [PATCH] Show mismatching sig apks when incompatible versions enabled. This is in the spirit of the setting, where users can see which apks are available even though they are not installable. Adds a message explaining why it is incompatible (i.e. because the signature doesn't match the installed version). --- .../fdroid/views/AppDetailsRecyclerViewAdapter.java | 13 ++++++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java index 61ab2c8d6..5dea02a26 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java @@ -116,9 +116,10 @@ public class AppDetailsRecyclerViewAdapter versions = new ArrayList<>(); compatibleVersionsDifferentSig = new ArrayList<>(); final List apks = ApkProvider.Helper.findByPackageName(context, this.app.packageName); + boolean showIncompatibleVersions = Preferences.get().showIncompatibleVersions(); for (final Apk apk : apks) { - boolean allowByCompatability = apk.compatible || Preferences.get().showIncompatibleVersions(); - boolean allowBySig = this.app.installedSig == null || TextUtils.equals(this.app.installedSig, apk.sig); + boolean allowByCompatability = apk.compatible || showIncompatibleVersions; + boolean allowBySig = this.app.installedSig == null || showIncompatibleVersions || TextUtils.equals(this.app.installedSig, apk.sig); if (allowByCompatability) { compatibleVersionsDifferentSig.add(apk); if (allowBySig) { @@ -951,12 +952,18 @@ public class AppDetailsRecyclerViewAdapter nativecode.setVisibility(View.GONE); } + boolean mismatchedSig = app.installedSig != null && !TextUtils.equals(app.installedSig, apk.sig); + if (apk.incompatibleReasons != null) { incompatibleReasons.setText( context.getResources().getString( R.string.requires_features, TextUtils.join(", ", apk.incompatibleReasons))); incompatibleReasons.setVisibility(View.VISIBLE); + } else if (mismatchedSig) { + incompatibleReasons.setText( + context.getString(R.string.app_details__incompatible_mismatched_signature)); + incompatibleReasons.setVisibility(View.VISIBLE); } else { incompatibleReasons.setVisibility(View.GONE); } @@ -974,7 +981,7 @@ public class AppDetailsRecyclerViewAdapter nativecode, }; for (final View v : views) { - v.setEnabled(apk.compatible); + v.setEnabled(apk.compatible && !mismatchedSig); } itemView.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6136cb79d..ab5e19c1c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -54,6 +54,7 @@ Buy the developers of %1$s a coffee! %1$s is created by %2$s. Buy them a coffee! + Different signature to installed version To show incompatible versions here anyway, enable the \"%1$s\" setting. No versions with compatible signature No versions compatible with device