Rename App.suggestedVercode to App.suggestedVersionCode

Updates #37.
This commit is contained in:
Daniel Martí 2016-04-19 12:03:05 +01:00
parent 4d8e410176
commit cde57efb98
6 changed files with 24 additions and 23 deletions

View File

@ -211,7 +211,7 @@ public class AppDetails extends AppCompatActivity {
holder.version.setText(getString(R.string.version) holder.version.setText(getString(R.string.version)
+ " " + apk.versionName + " " + apk.versionName
+ (apk.versionCode == app.suggestedVercode ? "" : "")); + (apk.versionCode == app.suggestedVersionCode ? "" : ""));
holder.status.setText(getInstalledStatus(apk)); holder.status.setText(getInstalledStatus(apk));
@ -661,7 +661,7 @@ public class AppDetails extends AppCompatActivity {
menu.add(Menu.NONE, IGNORETHIS, 2, R.string.menu_ignore_this) menu.add(Menu.NONE, IGNORETHIS, 2, R.string.menu_ignore_this)
.setIcon(R.drawable.ic_do_not_disturb_white) .setIcon(R.drawable.ic_do_not_disturb_white)
.setCheckable(true) .setCheckable(true)
.setChecked(app.ignoreThisUpdate >= app.suggestedVercode); .setChecked(app.ignoreThisUpdate >= app.suggestedVersionCode);
} }
// Ignore on devices without Bluetooth // Ignore on devices without Bluetooth
@ -766,8 +766,8 @@ public class AppDetails extends AppCompatActivity {
case INSTALL: case INSTALL:
// Note that this handles updating as well as installing. // Note that this handles updating as well as installing.
if (app.suggestedVercode > 0) { if (app.suggestedVersionCode > 0) {
final Apk apkToInstall = ApkProvider.Helper.find(this, app.packageName, app.suggestedVercode); final Apk apkToInstall = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode);
install(apkToInstall); install(apkToInstall);
} }
return true; return true;
@ -782,10 +782,10 @@ public class AppDetails extends AppCompatActivity {
return true; return true;
case IGNORETHIS: case IGNORETHIS:
if (app.ignoreThisUpdate >= app.suggestedVercode) { if (app.ignoreThisUpdate >= app.suggestedVersionCode) {
app.ignoreThisUpdate = 0; app.ignoreThisUpdate = 0;
} else { } else {
app.ignoreThisUpdate = app.suggestedVercode; app.ignoreThisUpdate = app.suggestedVersionCode;
} }
item.setChecked(app.ignoreThisUpdate > 0); item.setChecked(app.ignoreThisUpdate > 0);
return true; return true;
@ -1246,7 +1246,7 @@ public class AppDetails extends AppCompatActivity {
Apk curApk = null; Apk curApk = null;
for (int i = 0; i < appDetails.getApks().getCount(); i++) { for (int i = 0; i < appDetails.getApks().getCount(); i++) {
final Apk apk = appDetails.getApks().getItem(i); final Apk apk = appDetails.getApks().getItem(i);
if (apk.versionCode == app.suggestedVercode) { if (apk.versionCode == app.suggestedVersionCode) {
curApk = apk; curApk = apk;
break; break;
} }
@ -1498,7 +1498,7 @@ public class AppDetails extends AppCompatActivity {
if (appDetails.activeDownloadUrlString != null) { if (appDetails.activeDownloadUrlString != null) {
btMain.setText(R.string.downloading); btMain.setText(R.string.downloading);
btMain.setEnabled(false); btMain.setEnabled(false);
} else if (!app.isInstalled() && app.suggestedVercode > 0 && } else if (!app.isInstalled() && app.suggestedVersionCode > 0 &&
appDetails.adapter.getCount() > 0) { appDetails.adapter.getCount() > 0) {
// Check count > 0 due to incompatible apps resulting in an empty list. // Check count > 0 due to incompatible apps resulting in an empty list.
// If App isn't installed // If App isn't installed
@ -1550,8 +1550,8 @@ public class AppDetails extends AppCompatActivity {
public void onClick(View v) { public void onClick(View v) {
App app = appDetails.getApp(); App app = appDetails.getApp();
AppDetails activity = (AppDetails) getActivity(); AppDetails activity = (AppDetails) getActivity();
if (updateWanted && app.suggestedVercode > 0) { if (updateWanted && app.suggestedVersionCode > 0) {
Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVercode); Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVersionCode);
activity.install(apkToInstall); activity.install(apkToInstall);
return; return;
} }
@ -1563,11 +1563,11 @@ public class AppDetails extends AppCompatActivity {
} else { } else {
activity.removeApk(app.packageName); activity.removeApk(app.packageName);
} }
} else if (app.suggestedVercode > 0) { } else if (app.suggestedVersionCode > 0) {
// If not installed, install // If not installed, install
btMain.setEnabled(false); btMain.setEnabled(false);
btMain.setText(R.string.system_install_installing); btMain.setText(R.string.system_install_installing);
final Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVercode); final Apk apkToInstall = ApkProvider.Helper.find(activity, app.packageName, app.suggestedVersionCode);
activity.install(apkToInstall); activity.install(apkToInstall);
} }
} }

View File

@ -492,7 +492,7 @@ public class UpdateService extends IntentService implements ProgressListener {
cursor.moveToFirst(); cursor.moveToFirst();
for (int i = 0; i < cursor.getCount(); i++) { for (int i = 0; i < cursor.getCount(); i++) {
App app = new App(cursor); App app = new App(cursor);
Apk apk = ApkProvider.Helper.find(this, app.packageName, app.suggestedVercode, new String[]{ Apk apk = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode, new String[]{
ApkProvider.DataColumns.NAME, ApkProvider.DataColumns.NAME,
}); });
String urlString = Utils.getApkUrl(repoAddress, apk); String urlString = Utils.getApkUrl(repoAddress, apk);

View File

@ -65,11 +65,12 @@ public class App extends ValueObject implements Comparable<App> {
/** /**
* Unlike other public fields, this is only accessible via a getter, to * Unlike other public fields, this is only accessible via a getter, to
* emphasise that setting it wont do anything. In order to change this, * emphasise that setting it wont do anything. In order to change this,
* you need to change suggestedVercode to an apk which is in the apk table. * you need to change suggestedVersionCode to an apk which is in the
* apk table.
*/ */
private String suggestedVersion; private String suggestedVersion;
public int suggestedVercode; public int suggestedVersionCode;
public Date added; public Date added;
public Date lastUpdated; public Date lastUpdated;
@ -176,7 +177,7 @@ public class App extends ValueObject implements Comparable<App> {
suggestedVersion = cursor.getString(i); suggestedVersion = cursor.getString(i);
break; break;
case AppProvider.DataColumns.SUGGESTED_VERSION_CODE: case AppProvider.DataColumns.SUGGESTED_VERSION_CODE:
suggestedVercode = cursor.getInt(i); suggestedVersionCode = cursor.getInt(i);
break; break;
case AppProvider.DataColumns.UPSTREAM_VERSION_CODE: case AppProvider.DataColumns.UPSTREAM_VERSION_CODE:
upstreamVercode = cursor.getInt(i); upstreamVercode = cursor.getInt(i);
@ -402,7 +403,7 @@ public class App extends ValueObject implements Comparable<App> {
values.put(AppProvider.DataColumns.FLATTR_ID, flattrID); values.put(AppProvider.DataColumns.FLATTR_ID, flattrID);
values.put(AppProvider.DataColumns.ADDED, Utils.formatDate(added, "")); values.put(AppProvider.DataColumns.ADDED, Utils.formatDate(added, ""));
values.put(AppProvider.DataColumns.LAST_UPDATED, Utils.formatDate(lastUpdated, "")); values.put(AppProvider.DataColumns.LAST_UPDATED, Utils.formatDate(lastUpdated, ""));
values.put(AppProvider.DataColumns.SUGGESTED_VERSION_CODE, suggestedVercode); values.put(AppProvider.DataColumns.SUGGESTED_VERSION_CODE, suggestedVersionCode);
values.put(AppProvider.DataColumns.UPSTREAM_VERSION, upstreamVersion); values.put(AppProvider.DataColumns.UPSTREAM_VERSION, upstreamVersion);
values.put(AppProvider.DataColumns.UPSTREAM_VERSION_CODE, upstreamVercode); values.put(AppProvider.DataColumns.UPSTREAM_VERSION_CODE, upstreamVercode);
values.put(AppProvider.DataColumns.CATEGORIES, Utils.CommaSeparatedList.str(categories)); values.put(AppProvider.DataColumns.CATEGORIES, Utils.CommaSeparatedList.str(categories));
@ -424,8 +425,8 @@ public class App extends ValueObject implements Comparable<App> {
*/ */
public boolean hasUpdates() { public boolean hasUpdates() {
boolean updates = false; boolean updates = false;
if (suggestedVercode > 0) { if (suggestedVersionCode > 0) {
updates = installedVersionCode > 0 && installedVersionCode < suggestedVercode; updates = installedVersionCode > 0 && installedVersionCode < suggestedVersionCode;
} }
return updates; return updates;
} }
@ -434,7 +435,7 @@ public class App extends ValueObject implements Comparable<App> {
// to be notified about them // to be notified about them
public boolean canAndWantToUpdate() { public boolean canAndWantToUpdate() {
boolean canUpdate = hasUpdates(); boolean canUpdate = hasUpdates();
boolean wantsUpdate = !ignoreAllUpdates && ignoreThisUpdate < suggestedVercode; boolean wantsUpdate = !ignoreAllUpdates && ignoreThisUpdate < suggestedVersionCode;
return canUpdate && wantsUpdate && !isFiltered(); return canUpdate && wantsUpdate && !isFiltered();
} }

View File

@ -113,7 +113,7 @@ public abstract class AppListAdapter extends CursorAdapter {
private String getVersionInfo(App app) { private String getVersionInfo(App app) {
if (app.suggestedVercode <= 0) { if (app.suggestedVersionCode <= 0) {
return null; return null;
} }

View File

@ -336,7 +336,7 @@ public class SwapAppsView extends ListView implements
*/ */
private Apk getApkToInstall() { private Apk getApkToInstall() {
if (apkToInstall == null) { if (apkToInstall == null) {
apkToInstall = ApkProvider.Helper.find(getActivity(), app.packageName, app.suggestedVercode); apkToInstall = ApkProvider.Helper.find(getActivity(), app.packageName, app.suggestedVersionCode);
} }
return apkToInstall; return apkToInstall;
} }

View File

@ -782,7 +782,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
} }
public void install(@NonNull final App app) { public void install(@NonNull final App app) {
final Apk apk = ApkProvider.Helper.find(this, app.packageName, app.suggestedVercode); final Apk apk = ApkProvider.Helper.find(this, app.packageName, app.suggestedVersionCode);
String urlString = Utils.getApkUrl(apk.repoAddress, apk); String urlString = Utils.getApkUrl(apk.repoAddress, apk);
downloadCompleteReceiver = new BroadcastReceiver() { downloadCompleteReceiver = new BroadcastReceiver() {
@Override @Override