Alert before trying to downgrade

This commit is contained in:
Daniel Martí 2013-05-09 11:42:20 +02:00
parent 24c2b9731c
commit f5dc1ddc96
2 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,7 @@
<string name="searchres_noapps">No applications were found matching \'%s\'</string>
<string name="SignatureMismatch">The new version is signed with a different key to the old one. To install the new version, the old one must be uninstalled first. Please do this and try again. (Note that uninstalling will erase any internal data stored by the application)</string>
<string name="installIncompatible">Android says this package is not compatible with your device. Do you want to try and install it anyway?</string>
<string name="installDowngrade">You are trying to downgrade this application. Doing so might get it to malfunction and even lose your data. Do you want to try and downgrade it anyway?</string>
<string name="version">Version</string>
<string name="n_versions_available">%d versions available</string>
<string name="n_version_available">%d version available</string>

View File

@ -475,7 +475,26 @@ public class AppDetails extends ListActivity {
curapk = app.apks.get(position - l.getHeaderViewsCount());
if (app.installedVerCode == curapk.vercode)
removeApk(app.id);
else
else if (app.installedVerCode > curapk.vercode) {
AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this);
ask_alrt.setMessage(getString(R.string.installDowngrade));
ask_alrt.setPositiveButton(getString(R.string.yes),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
install();
}
});
ask_alrt.setNegativeButton(getString(R.string.no),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
return;
}
});
AlertDialog alert = ask_alrt.create();
alert.show();
} else
install();
}