That should deal with the antifeatures filtering, but it needs testing
This commit is contained in:
parent
ae6e9d57ff
commit
45a32f45ba
@ -26,11 +26,13 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class DB {
|
public class DB {
|
||||||
@ -250,9 +252,11 @@ public class DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PackageManager mPm;
|
private PackageManager mPm;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
public DB(Context ctx) {
|
public DB(Context ctx) {
|
||||||
|
|
||||||
|
mContext = ctx;
|
||||||
DBHelper h = new DBHelper(ctx);
|
DBHelper h = new DBHelper(ctx);
|
||||||
db = h.getWritableDatabase();
|
db = h.getWritableDatabase();
|
||||||
mPm = ctx.getPackageManager();
|
mPm = ctx.getPackageManager();
|
||||||
@ -286,12 +290,21 @@ public class DB {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of apps matching the given criteria.
|
// Return a list of apps matching the given criteria. Filtering is also
|
||||||
|
// done based on the user's current anti-features preferences.
|
||||||
// 'appid' - specific app id to retrieve, or null
|
// 'appid' - specific app id to retrieve, or null
|
||||||
// 'filter' - search text to filter on, or null
|
// 'filter' - search text to filter on, or null
|
||||||
// 'update' - update installed version information from device, rather than
|
// 'update' - update installed version information from device, rather than
|
||||||
// simply using values cached in the database. Slower.
|
// simply using values cached in the database. Slower.
|
||||||
public Vector<App> getApps(String appid, String filter, boolean update) {
|
public Vector<App> getApps(String appid, String filter, boolean update) {
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(mContext);
|
||||||
|
boolean pref_antiAds = prefs.getBoolean("antiAds", false);
|
||||||
|
boolean pref_antiTracking = prefs.getBoolean("antiTracking", false);
|
||||||
|
boolean pref_antiNonFreeAdd = prefs.getBoolean("antiNonFreeAdd", false);
|
||||||
|
boolean pref_antiNonFreeNet = prefs.getBoolean("antiNonFreeNet", false);
|
||||||
|
|
||||||
Vector<App> result = new Vector<App>();
|
Vector<App> result = new Vector<App>();
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
Cursor c2 = null;
|
Cursor c2 = null;
|
||||||
@ -311,14 +324,34 @@ public class DB {
|
|||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
|
|
||||||
App app = new App();
|
App app = new App();
|
||||||
|
app.antiFeatures = c
|
||||||
|
.getString(c.getColumnIndex("antiFeatures"));
|
||||||
|
boolean include=true;
|
||||||
|
if(app.antiFeatures!=null && app.antiFeatures.length()>0) {
|
||||||
|
String[] afs=app.antiFeatures.split(",");
|
||||||
|
for(String af : afs) {
|
||||||
|
if (af.equals("Ads") && !pref_antiAds)
|
||||||
|
include=false;
|
||||||
|
else if(af.equals("Tracking") && !pref_antiTracking)
|
||||||
|
include=false;
|
||||||
|
else if(af.equals("NonFreeNet") && !pref_antiNonFreeNet)
|
||||||
|
include=false;
|
||||||
|
else if(af.equals("NonFreeAdd") && !pref_antiNonFreeAdd)
|
||||||
|
include=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (include) {
|
||||||
app.id = c.getString(c.getColumnIndex("id"));
|
app.id = c.getString(c.getColumnIndex("id"));
|
||||||
app.name = c.getString(c.getColumnIndex("name"));
|
app.name = c.getString(c.getColumnIndex("name"));
|
||||||
app.summary = c.getString(c.getColumnIndex("summary"));
|
app.summary = c.getString(c.getColumnIndex("summary"));
|
||||||
app.icon = c.getString(c.getColumnIndex("icon"));
|
app.icon = c.getString(c.getColumnIndex("icon"));
|
||||||
app.description = c.getString(c.getColumnIndex("description"));
|
app.description = c.getString(c
|
||||||
|
.getColumnIndex("description"));
|
||||||
app.license = c.getString(c.getColumnIndex("license"));
|
app.license = c.getString(c.getColumnIndex("license"));
|
||||||
app.webURL = c.getString(c.getColumnIndex("webURL"));
|
app.webURL = c.getString(c.getColumnIndex("webURL"));
|
||||||
app.trackerURL = c.getString(c.getColumnIndex("trackerURL"));
|
app.trackerURL = c
|
||||||
|
.getString(c.getColumnIndex("trackerURL"));
|
||||||
app.sourceURL = c.getString(c.getColumnIndex("sourceURL"));
|
app.sourceURL = c.getString(c.getColumnIndex("sourceURL"));
|
||||||
app.installedVersion = c.getString(c
|
app.installedVersion = c.getString(c
|
||||||
.getColumnIndex("installedVersion"));
|
.getColumnIndex("installedVersion"));
|
||||||
@ -326,9 +359,8 @@ public class DB {
|
|||||||
.getColumnIndex("installedVerCode"));
|
.getColumnIndex("installedVerCode"));
|
||||||
app.marketVersion = c.getString(c
|
app.marketVersion = c.getString(c
|
||||||
.getColumnIndex("marketVersion"));
|
.getColumnIndex("marketVersion"));
|
||||||
app.marketVercode = c.getInt(c.getColumnIndex("marketVercode"));
|
app.marketVercode = c.getInt(c
|
||||||
app.antiFeatures = c
|
.getColumnIndex("marketVercode"));
|
||||||
.getString(c.getColumnIndex("antiFeatures"));
|
|
||||||
app.hasUpdates = false;
|
app.hasUpdates = false;
|
||||||
|
|
||||||
c2 = db.rawQuery("select * from " + TABLE_APK
|
c2 = db.rawQuery("select * from " + TABLE_APK
|
||||||
@ -338,21 +370,25 @@ public class DB {
|
|||||||
while (!c2.isAfterLast()) {
|
while (!c2.isAfterLast()) {
|
||||||
Apk apk = new Apk();
|
Apk apk = new Apk();
|
||||||
apk.id = app.id;
|
apk.id = app.id;
|
||||||
apk.version = c2.getString(c2.getColumnIndex("version"));
|
apk.version = c2
|
||||||
|
.getString(c2.getColumnIndex("version"));
|
||||||
apk.vercode = c2.getInt(c2.getColumnIndex("vercode"));
|
apk.vercode = c2.getInt(c2.getColumnIndex("vercode"));
|
||||||
apk.server = c2.getString(c2.getColumnIndex("server"));
|
apk.server = c2.getString(c2.getColumnIndex("server"));
|
||||||
apk.hash = c2.getString(c2.getColumnIndex("hash"));
|
apk.hash = c2.getString(c2.getColumnIndex("hash"));
|
||||||
apk.sig = c2.getString(c2.getColumnIndex("sig"));
|
apk.sig = c2.getString(c2.getColumnIndex("sig"));
|
||||||
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
||||||
apk.apkName = c2.getString(c2.getColumnIndex("apkName"));
|
apk.apkName = c2
|
||||||
apk.apkSource = c2
|
.getString(c2.getColumnIndex("apkName"));
|
||||||
.getString(c2.getColumnIndex("apkSource"));
|
apk.apkSource = c2.getString(c2
|
||||||
|
.getColumnIndex("apkSource"));
|
||||||
app.apks.add(apk);
|
app.apks.add(apk);
|
||||||
c2.moveToNext();
|
c2.moveToNext();
|
||||||
}
|
}
|
||||||
c2.close();
|
c2.close();
|
||||||
|
|
||||||
result.add(app);
|
result.add(app);
|
||||||
|
}
|
||||||
|
|
||||||
c.moveToNext();
|
c.moveToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user