Add "Ignore Updates" to AppDetails (fixes: #99)
We can later separate updates by differing signatures, downgrades, ... But IMHO ignoring updates is important and a different issue.
This commit is contained in:
parent
abde150ce0
commit
c2159456e2
@ -116,6 +116,7 @@
|
|||||||
<string name="menu_share">Share</string>
|
<string name="menu_share">Share</string>
|
||||||
<string name="menu_install">Install</string>
|
<string name="menu_install">Install</string>
|
||||||
<string name="menu_uninstall">Uninstall</string>
|
<string name="menu_uninstall">Uninstall</string>
|
||||||
|
<string name="menu_ignore">Ignore Updates</string>
|
||||||
<string name="menu_website">Website</string>
|
<string name="menu_website">Website</string>
|
||||||
<string name="menu_issues">Issues</string>
|
<string name="menu_issues">Issues</string>
|
||||||
<string name="menu_source">Source Code</string>
|
<string name="menu_source">Source Code</string>
|
||||||
|
@ -158,15 +158,16 @@ public class AppDetails extends ListActivity {
|
|||||||
|
|
||||||
private static final int INSTALL = Menu.FIRST;
|
private static final int INSTALL = Menu.FIRST;
|
||||||
private static final int UNINSTALL = Menu.FIRST + 1;
|
private static final int UNINSTALL = Menu.FIRST + 1;
|
||||||
private static final int WEBSITE = Menu.FIRST + 2;
|
private static final int IGNORE = Menu.FIRST + 2;
|
||||||
private static final int ISSUES = Menu.FIRST + 3;
|
private static final int WEBSITE = Menu.FIRST + 3;
|
||||||
private static final int SOURCE = Menu.FIRST + 4;
|
private static final int ISSUES = Menu.FIRST + 4;
|
||||||
private static final int MARKET = Menu.FIRST + 5;
|
private static final int SOURCE = Menu.FIRST + 5;
|
||||||
private static final int BITCOIN = Menu.FIRST + 6;
|
private static final int MARKET = Menu.FIRST + 6;
|
||||||
private static final int FLATTR = Menu.FIRST + 7;
|
private static final int BITCOIN = Menu.FIRST + 7;
|
||||||
private static final int DONATE = Menu.FIRST + 8;
|
private static final int FLATTR = Menu.FIRST + 8;
|
||||||
private static final int LAUNCH = Menu.FIRST + 9;
|
private static final int DONATE = Menu.FIRST + 9;
|
||||||
private static final int SHARE = Menu.FIRST + 10;
|
private static final int LAUNCH = Menu.FIRST + 10;
|
||||||
|
private static final int SHARE = Menu.FIRST + 11;
|
||||||
|
|
||||||
private DB.App app;
|
private DB.App app;
|
||||||
private int app_currentvercode;
|
private int app_currentvercode;
|
||||||
@ -175,6 +176,7 @@ public class AppDetails extends ListActivity {
|
|||||||
private PackageManager mPm;
|
private PackageManager mPm;
|
||||||
private DownloadHandler downloadHandler;
|
private DownloadHandler downloadHandler;
|
||||||
private boolean stateRetained;
|
private boolean stateRetained;
|
||||||
|
private boolean ignoreToggled;
|
||||||
|
|
||||||
LinearLayout headerView;
|
LinearLayout headerView;
|
||||||
View infoView;
|
View infoView;
|
||||||
@ -244,6 +246,8 @@ public class AppDetails extends ListActivity {
|
|||||||
pref_permissions = prefs.getBoolean("showPermissions", false);
|
pref_permissions = prefs.getBoolean("showPermissions", false);
|
||||||
pref_incompatible = prefs.getBoolean("showIncompatible", false);
|
pref_incompatible = prefs.getBoolean("showIncompatible", false);
|
||||||
|
|
||||||
|
ignoreToggled = false;
|
||||||
|
|
||||||
startViews();
|
startViews();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -607,36 +611,42 @@ public class AppDetails extends ListActivity {
|
|||||||
MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItemCompat.setShowAsAction(menu.add(
|
MenuItemCompat.setShowAsAction(menu.add(
|
||||||
Menu.NONE, SHARE, 1, R.string.menu_share)
|
Menu.NONE, SHARE, 1, R.string.menu_share)
|
||||||
.setIcon(android.R.drawable.ic_menu_share),
|
.setIcon(android.R.drawable.ic_menu_share),
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM |
|
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM |
|
||||||
MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
|
|
||||||
|
menu.add(Menu.NONE, IGNORE, 2, R.string.menu_ignore)
|
||||||
|
.setIcon(android.R.drawable.ic_menu_add)
|
||||||
|
.setCheckable(true)
|
||||||
|
.setChecked(app.ignoreUpdates);
|
||||||
|
|
||||||
if (app.detail_webURL.length() > 0) {
|
if (app.detail_webURL.length() > 0) {
|
||||||
menu.add(Menu.NONE, WEBSITE, 2, R.string.menu_website).setIcon(
|
menu.add(Menu.NONE, WEBSITE, 3, R.string.menu_website).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
}
|
}
|
||||||
if (app.detail_trackerURL.length() > 0) {
|
if (app.detail_trackerURL.length() > 0) {
|
||||||
menu.add(Menu.NONE, ISSUES, 3, R.string.menu_issues).setIcon(
|
menu.add(Menu.NONE, ISSUES, 4, R.string.menu_issues).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
}
|
}
|
||||||
if (app.detail_sourceURL.length() > 0) {
|
if (app.detail_sourceURL.length() > 0) {
|
||||||
menu.add(Menu.NONE, SOURCE, 4, R.string.menu_source).setIcon(
|
menu.add(Menu.NONE, SOURCE, 5, R.string.menu_source).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
}
|
}
|
||||||
menu.add(Menu.NONE, MARKET, 5, R.string.menu_market).setIcon(
|
menu.add(Menu.NONE, MARKET, 6, R.string.menu_market).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
if (app.detail_bitcoinAddr != null) {
|
if (app.detail_bitcoinAddr != null) {
|
||||||
menu.add(Menu.NONE, BITCOIN, 6, R.string.menu_bitcoin).setIcon(
|
menu.add(Menu.NONE, BITCOIN, 7, R.string.menu_bitcoin).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
}
|
}
|
||||||
if (app.detail_flattrID != null) {
|
if (app.detail_flattrID != null) {
|
||||||
menu.add(Menu.NONE, FLATTR, 7, R.string.menu_flattr).setIcon(
|
menu.add(Menu.NONE, FLATTR, 8, R.string.menu_flattr).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
}
|
}
|
||||||
if (app.detail_donateURL != null) {
|
if (app.detail_donateURL != null) {
|
||||||
menu.add(Menu.NONE, DONATE, 8, R.string.menu_donate).setIcon(
|
menu.add(Menu.NONE, DONATE, 9, R.string.menu_donate).setIcon(
|
||||||
android.R.drawable.ic_menu_view);
|
android.R.drawable.ic_menu_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,6 +688,12 @@ public class AppDetails extends ListActivity {
|
|||||||
removeApk(app.id);
|
removeApk(app.id);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case IGNORE:
|
||||||
|
app.ignoreUpdates ^= true;
|
||||||
|
item.setChecked(app.ignoreUpdates);
|
||||||
|
ignoreToggled ^= true;
|
||||||
|
return true;
|
||||||
|
|
||||||
case WEBSITE:
|
case WEBSITE:
|
||||||
tryOpenUri(app.detail_webURL);
|
tryOpenUri(app.detail_webURL);
|
||||||
return true;
|
return true;
|
||||||
@ -950,4 +966,17 @@ public class AppDetails extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
if (ignoreToggled) {
|
||||||
|
try {
|
||||||
|
DB db = DB.getDB();
|
||||||
|
db.toggleIgnoreUpdates(app.id);
|
||||||
|
} finally {
|
||||||
|
DB.releaseDB();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,8 @@ public class AppListManager {
|
|||||||
}
|
}
|
||||||
if (app.installedVersion != null) {
|
if (app.installedVersion != null) {
|
||||||
installedApps.addItem(app);
|
installedApps.addItem(app);
|
||||||
if (app.hasUpdates && (showIncompatible || app.compatible))
|
if (!app.ignoreUpdates && app.hasUpdates &&
|
||||||
|
(showIncompatible || app.compatible))
|
||||||
canUpgradeApps.addItem(app);
|
canUpgradeApps.addItem(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class DB {
|
|||||||
+ "bitcoinAddr string," + "flattrID string,"
|
+ "bitcoinAddr string," + "flattrID string,"
|
||||||
+ "requirements string," + "category string," + "added string,"
|
+ "requirements string," + "category string," + "added string,"
|
||||||
+ "lastUpdated string," + "compatible int not null,"
|
+ "lastUpdated string," + "compatible int not null,"
|
||||||
+ "primary key(id));";
|
+ "ignoreUpdates int not null," + "primary key(id));";
|
||||||
|
|
||||||
public static class App implements Comparable<App> {
|
public static class App implements Comparable<App> {
|
||||||
|
|
||||||
@ -123,6 +123,7 @@ public class DB {
|
|||||||
apks = new ArrayList<Apk>();
|
apks = new ArrayList<Apk>();
|
||||||
detail_Populated = false;
|
detail_Populated = false;
|
||||||
compatible = false;
|
compatible = false;
|
||||||
|
ignoreUpdates = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// True when all the detail fields are populated, False otherwise.
|
// True when all the detail fields are populated, False otherwise.
|
||||||
@ -188,6 +189,10 @@ public class DB {
|
|||||||
// field for this - we make the decision on the fly in getApps().
|
// field for this - we make the decision on the fly in getApps().
|
||||||
public boolean hasUpdates;
|
public boolean hasUpdates;
|
||||||
|
|
||||||
|
// True if updates should not show up in the Updates tab for this
|
||||||
|
// application
|
||||||
|
public boolean ignoreUpdates;
|
||||||
|
|
||||||
// The name of the version that would be updated to.
|
// The name of the version that would be updated to.
|
||||||
public String updateVersion;
|
public String updateVersion;
|
||||||
|
|
||||||
@ -414,7 +419,7 @@ public class DB {
|
|||||||
public String lastetag; // last etag we updated from, null forces update
|
public String lastetag; // last etag we updated from, null forces update
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int DBVersion = 23;
|
private final int DBVersion = 24;
|
||||||
|
|
||||||
private static void createAppApk(SQLiteDatabase db) {
|
private static void createAppApk(SQLiteDatabase db) {
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL(CREATE_TABLE_APP);
|
||||||
@ -611,7 +616,7 @@ public class DB {
|
|||||||
List<App> apps = getAppsBasic(true);
|
List<App> apps = getAppsBasic(true);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (App app : apps) {
|
for (App app : apps) {
|
||||||
if (app.hasUpdates)
|
if (!app.ignoreUpdates && app.hasUpdates)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@ -753,7 +758,7 @@ public class DB {
|
|||||||
String cols[] = new String[] { "antiFeatures", "requirements",
|
String cols[] = new String[] { "antiFeatures", "requirements",
|
||||||
"id", "name", "summary", "icon", "license", "category",
|
"id", "name", "summary", "icon", "license", "category",
|
||||||
"curVersion", "curVercode", "added", "lastUpdated",
|
"curVersion", "curVercode", "added", "lastUpdated",
|
||||||
"compatible" };
|
"compatible", "ignoreUpdates" };
|
||||||
c = db.query(TABLE_APP, cols, null, null, null, null, null);
|
c = db.query(TABLE_APP, cols, null, null, null, null, null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
@ -777,6 +782,7 @@ public class DB {
|
|||||||
.length() == 0) ? null : mDateFormat
|
.length() == 0) ? null : mDateFormat
|
||||||
.parse(sLastUpdated);
|
.parse(sLastUpdated);
|
||||||
app.compatible = c.getInt(12) == 1;
|
app.compatible = c.getInt(12) == 1;
|
||||||
|
app.ignoreUpdates = c.getInt(13) == 1;
|
||||||
app.hasUpdates = false;
|
app.hasUpdates = false;
|
||||||
|
|
||||||
if (getinstalledinfo && systemApks.containsKey(app.id)) {
|
if (getinstalledinfo && systemApks.containsKey(app.id)) {
|
||||||
@ -1085,7 +1091,7 @@ public class DB {
|
|||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (App app : updateApps) {
|
for (App app : updateApps) {
|
||||||
if (app.hasUpdates)
|
if (!app.ignoreUpdates && app.hasUpdates)
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@ -1236,6 +1242,7 @@ public class DB {
|
|||||||
values.put("antiFeatures", CommaSeparatedList.str(upapp.antiFeatures));
|
values.put("antiFeatures", CommaSeparatedList.str(upapp.antiFeatures));
|
||||||
values.put("requirements", CommaSeparatedList.str(upapp.requirements));
|
values.put("requirements", CommaSeparatedList.str(upapp.requirements));
|
||||||
values.put("compatible", upapp.compatible ? 1 : 0);
|
values.put("compatible", upapp.compatible ? 1 : 0);
|
||||||
|
values.put("ignoreUpdates", upapp.ignoreUpdates ? 1 : 0);
|
||||||
if (oldapp != null) {
|
if (oldapp != null) {
|
||||||
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });
|
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });
|
||||||
} else {
|
} else {
|
||||||
@ -1341,6 +1348,12 @@ public class DB {
|
|||||||
new String[] { address });
|
new String[] { address });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void toggleIgnoreUpdates(String appid) {
|
||||||
|
db.execSQL("update " + TABLE_APP
|
||||||
|
+ " set ignoreUpdates=1-ignoreUpdates where id = ?",
|
||||||
|
new String[] { appid });
|
||||||
|
}
|
||||||
|
|
||||||
public void updateRepoByAddress(Repo repo) {
|
public void updateRepoByAddress(Repo repo) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("name", repo.name);
|
values.put("name", repo.name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user