Optionally filter apps that require root

This commit is contained in:
Henrik Tunedal 2011-03-08 17:14:50 +01:00
parent 7ae24e2917
commit cea9278ef2
4 changed files with 28 additions and 2 deletions

View File

@ -133,4 +133,6 @@
<string name="appcompatibility">Application compatibility</string>
<string name="showincompat">Incompatible apps</string>
<string name="showincompat_long">Show apps written for newer Android versions or different hardware</string>
<string name="rooted">Root</string>
<string name="rooted_long">Show apps that require root privileges</string>
</resources>

View File

@ -37,6 +37,9 @@
<CheckBoxPreference android:title="@string/showincompat"
android:defaultValue="false" android:summary="@string/showincompat_long"
android:key="showIncompatible" />
<CheckBoxPreference android:title="@string/rooted"
android:defaultValue="true" android:summary="@string/rooted_long"
android:key="rooted" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/maintenance">
<Preference android:title="@string/reset" android:summary="@string/clear_all_cached_data"

View File

@ -75,6 +75,7 @@ public class DB {
donateURL = null;
webURL = "";
antiFeatures = null;
requirements = null;
hasUpdates = false;
updated = false;
apks = new Vector<Apk>();
@ -95,10 +96,14 @@ public class DB {
public String marketVersion;
public int marketVercode;
// Array of anti-features (as defined in the metadata
// List of anti-features (as defined in the metadata
// documentation) or null if there aren't any.
public CommaSeparatedList antiFeatures;
// List of special requirements (such as root privileges) or
// null if there aren't any.
public CommaSeparatedList requirements;
// True if there are new versions (apks) that the user hasn't
// explicitly ignored. (We're currently not using the database
// field for this - we make the decision on the fly in getApps().
@ -301,7 +306,10 @@ public class DB {
// Version 10...
{ "alter table " + TABLE_APK + " add minSdkVersion integer",
"alter table " + TABLE_APK + " add permissions string",
"alter table " + TABLE_APK + " add features string" }};
"alter table " + TABLE_APK + " add features string" },
// Version 11...
{ "alter table " + TABLE_APP + " add requirements string" }};
private class DBHelper extends SQLiteOpenHelper {
@ -409,6 +417,7 @@ public class DB {
boolean pref_antiNonFreeAdd = prefs.getBoolean("antiNonFreeAdd", false);
boolean pref_antiNonFreeNet = prefs.getBoolean("antiNonFreeNet", false);
boolean pref_showIncompat = prefs.getBoolean("showIncompatible", false);
boolean pref_rooted = prefs.getBoolean("rooted", true);
Vector<App> result = new Vector<App>();
Cursor c = null;
@ -446,6 +455,15 @@ public class DB {
include = false;
}
}
app.requirements = DB.CommaSeparatedList.make(c
.getString(c.getColumnIndex("requirements")));
if (app.requirements != null) {
for (String r : app.requirements) {
if (r.equals("root") && !pref_rooted) {
include = false;
}
}
}
if (include) {
app.id = c.getString(c.getColumnIndex("id"));
@ -752,6 +770,7 @@ public class DB {
values.put("marketVersion", upapp.marketVersion);
values.put("marketVercode", upapp.marketVercode);
values.put("antiFeatures", CommaSeparatedList.str(upapp.antiFeatures));
values.put("requirements", CommaSeparatedList.str(upapp.requirements));
values.put("hasUpdates", upapp.hasUpdates ? 1 : 0);
if (oldapp != null) {
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });

View File

@ -162,6 +162,8 @@ public class RepoXMLHandler extends DefaultHandler {
}
} else if (curel.equals("antifeatures")) {
curapp.antiFeatures = DB.CommaSeparatedList.make(str);
} else if (curel.equals("requirements")) {
curapp.requirements = DB.CommaSeparatedList.make(str);
}
}