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).
This commit is contained in:
Peter Serwylo 2017-08-08 10:25:55 +10:00
parent ef717437a9
commit dd93df9ef2
2 changed files with 11 additions and 3 deletions

View File

@ -116,9 +116,10 @@ public class AppDetailsRecyclerViewAdapter
versions = new ArrayList<>();
compatibleVersionsDifferentSig = new ArrayList<>();
final List<Apk> 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

View File

@ -54,6 +54,7 @@
<string name="app_details_donate_prompt_unknown_author">Buy the developers of %1$s a coffee!</string>
<string name="app_details_donate_prompt">%1$s is created by %2$s. Buy them a coffee!</string>
<string name="app_details__incompatible_mismatched_signature">Different signature to installed version</string>
<string name="app_details__no_versions__show_incompat_versions">To show incompatible versions here anyway, enable the \"%1$s\" setting.</string>
<string name="app_details__no_versions__no_compatible_signatures">No versions with compatible signature</string>
<string name="app_details__no_versions__none_compatible_with_device">No versions compatible with device</string>