From 991b91dfdc14b5b634b626ef1d9785c5420d32a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 23 Oct 2013 01:13:39 +0200 Subject: [PATCH] Remove filter by root, replaced by ACCESS_SUPERUSER permission --- res/values/strings.xml | 6 +-- res/xml/preferences.xml | 3 -- src/org/fdroid/fdroid/AppFilter.java | 50 ------------------- src/org/fdroid/fdroid/AppListManager.java | 6 +-- src/org/fdroid/fdroid/DB.java | 44 ++++++---------- src/org/fdroid/fdroid/FDroidApp.java | 4 -- src/org/fdroid/fdroid/RepoXMLHandler.java | 2 - .../fdroid/fdroid/views/AppListAdapter.java | 2 +- 8 files changed, 22 insertions(+), 95 deletions(-) delete mode 100644 src/org/fdroid/fdroid/AppFilter.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 114038e35..872d12650 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -109,7 +109,7 @@ Expert Enable expert mode -Search applications + Search applications Database sync mode Set the value of SQLite\'s "synchronous" flag @@ -117,11 +117,9 @@ Application compatibility Incompatible apps Show apps written for newer Android versions or different hardware - Root - Show apps that require root privileges Ignore Touchscreen Always include apps that require touchscreen - + All What\'s New Recently Updated diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index f755058ef..b40c96113 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -28,9 +28,6 @@ - diff --git a/src/org/fdroid/fdroid/AppFilter.java b/src/org/fdroid/fdroid/AppFilter.java deleted file mode 100644 index c6be1d372..000000000 --- a/src/org/fdroid/fdroid/AppFilter.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010-12 Ciaran Gultnieks, ciaran@ciarang.com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.fdroid.fdroid; - -import android.content.Context; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; - -public class AppFilter { - - boolean pref_rooted; - - public AppFilter(Context ctx) { - - // Read preferences and cache them so we can do quick lookups. - SharedPreferences prefs = PreferenceManager - .getDefaultSharedPreferences(ctx); - pref_rooted = prefs.getBoolean("rooted", true); - } - - // Return true if the given app should be filtered based on user - // preferences, and false otherwise. - public boolean filter(DB.App app) { - boolean filtered = false; - if (app.requirements != null) { - for (String r : app.requirements) { - if (r.equals("root") && !pref_rooted) - filtered = true; - } - } - return filtered; - } - -} diff --git a/src/org/fdroid/fdroid/AppListManager.java b/src/org/fdroid/fdroid/AppListManager.java index 258f419b3..c2fb21203 100644 --- a/src/org/fdroid/fdroid/AppListManager.java +++ b/src/org/fdroid/fdroid/AppListManager.java @@ -197,9 +197,9 @@ public class AppListManager { boolean isInCategory = isInCategory(app, currentCategory, recentDate); // Add it to the list(s). Always to installed and updates, but - // only to available if it's not filtered. - if (!app.filtered && isInCategory - && (showIncompatible || app.compatible)) { + // only to available if it's compatible (or incompatible with + // showIncompatible at true) + if (isInCategory && (showIncompatible || app.compatible)) { availApps.add(app); } if (app.installedVersion != null) { diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 10c7ee81d..5482d6200 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -96,7 +96,7 @@ public class DB { + "curVersion text," + "curVercode integer," + "antiFeatures string," + "donateURL string," + "bitcoinAddr string," + "litecoinAddr string," - + "flattrID string," + "requirements string," + + "flattrID string," + "category string," + "added string," + "lastUpdated string," + "compatible int not null," + "ignoreAllUpdates int not null," @@ -119,7 +119,6 @@ public class DB { detail_litecoinAddr = null; detail_webURL = null; antiFeatures = null; - requirements = null; hasUpdates = false; toUpdate = false; updated = false; @@ -130,7 +129,6 @@ public class DB { compatible = false; ignoreAllUpdates = false; ignoreThisUpdate = 0; - filtered = false; iconUrl = null; } @@ -193,14 +191,6 @@ public class DB { // 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; - - // Whether the app is filtered or not based on AntiFeatures and root - // permission (set in the Settings page) - public boolean filtered; - // True if there are new versions (apks) available, regardless of // any filtering public boolean hasUpdates; @@ -440,7 +430,7 @@ public class DB { public String lastetag; // last etag we updated from, null forces update } - private final int DBVersion = 27; + private final int DBVersion = 28; private static void createAppApk(SQLiteDatabase db) { db.execSQL(CREATE_TABLE_APP); @@ -759,7 +749,7 @@ public class DB { long startTime = System.currentTimeMillis(); try { - String cols[] = new String[] { "antiFeatures", "requirements", + String cols[] = new String[] { "antiFeatures", "id", "name", "summary", "icon", "license", "category", "curVersion", "curVercode", "added", "lastUpdated", "compatible", "ignoreAllUpdates", "ignoreThisUpdate" }; @@ -769,25 +759,24 @@ public class DB { App app = new App(); app.antiFeatures = DB.CommaSeparatedList.make(c.getString(0)); - app.requirements = DB.CommaSeparatedList.make(c.getString(1)); - app.id = c.getString(2); - app.name = c.getString(3); - app.summary = c.getString(4); - app.icon = c.getString(5); - app.license = c.getString(6); - app.category = c.getString(7); - app.curVersion = c.getString(8); - app.curVercode = c.getInt(9); - String sAdded = c.getString(10); + app.id = c.getString(1); + app.name = c.getString(2); + app.summary = c.getString(3); + app.icon = c.getString(4); + app.license = c.getString(5); + app.category = c.getString(6); + app.curVersion = c.getString(7); + app.curVercode = c.getInt(8); + String sAdded = c.getString(9); app.added = (sAdded == null || sAdded.length() == 0) ? null : mDateFormat.parse(sAdded); - String sLastUpdated = c.getString(11); + String sLastUpdated = c.getString(10); app.lastUpdated = (sLastUpdated == null || sLastUpdated .length() == 0) ? null : mDateFormat .parse(sLastUpdated); - app.compatible = c.getInt(12) == 1; - app.ignoreAllUpdates = c.getInt(13) == 1; - app.ignoreThisUpdate = c.getInt(14); + app.compatible = c.getInt(11) == 1; + app.ignoreAllUpdates = c.getInt(12) == 1; + app.ignoreThisUpdate = c.getInt(13); app.hasUpdates = false; if (getinstalledinfo && systemApks.containsKey(app.id)) { @@ -1145,7 +1134,6 @@ public class DB { values.put("curVersion", upapp.curVersion); values.put("curVercode", upapp.curVercode); values.put("antiFeatures", CommaSeparatedList.str(upapp.antiFeatures)); - values.put("requirements", CommaSeparatedList.str(upapp.requirements)); values.put("compatible", upapp.compatible ? 1 : 0); // Values to keep if already present diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index a0eeade1e..2915a37aa 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -196,14 +196,10 @@ public class FDroidApp extends Application { } public void filterApps() { - AppFilter appFilter = new AppFilter(ctx); for (DB.App app : apps) { - app.filtered = appFilter.filter(app); - app.toUpdate = (app.hasUpdates && !app.ignoreAllUpdates && app.curApk.vercode > app.ignoreThisUpdate - && !app.filtered && (showIncompatible || app.compatible)); } } diff --git a/src/org/fdroid/fdroid/RepoXMLHandler.java b/src/org/fdroid/fdroid/RepoXMLHandler.java index f29c7d752..d5419050e 100644 --- a/src/org/fdroid/fdroid/RepoXMLHandler.java +++ b/src/org/fdroid/fdroid/RepoXMLHandler.java @@ -235,8 +235,6 @@ 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); } } } diff --git a/src/org/fdroid/fdroid/views/AppListAdapter.java b/src/org/fdroid/fdroid/views/AppListAdapter.java index 41044bd14..f335ce15b 100644 --- a/src/org/fdroid/fdroid/views/AppListAdapter.java +++ b/src/org/fdroid/fdroid/views/AppListAdapter.java @@ -111,7 +111,7 @@ abstract public class AppListAdapter extends BaseAdapter { // Disable it all if it isn't compatible... View[] views = { convertView, status, summary, license, name }; for (View view : views) { - view.setEnabled(app.compatible && !app.filtered); + view.setEnabled(app.compatible); } return convertView;