Always keep incompatible apps in the DB
Show them under the following circumstances: 1) If showIncompatible is true, show all incompatible apps/apks always 2) Installed tab, Searches and direct links will always show incompatible apps, but NOT apks TODO: onResume should repopulate all lists. And it seems to, lists are reloaded. But the updates don't take effect and so restart is required for a change in showIncompatible to take effect.
This commit is contained in:
		
							parent
							
								
									19583c2b75
								
							
						
					
					
						commit
						4109bb270d
					
				@ -243,6 +243,7 @@ public class AppDetails extends ListActivity {
 | 
			
		||||
 | 
			
		||||
    private boolean pref_expert;
 | 
			
		||||
    private boolean pref_permissions;
 | 
			
		||||
    private boolean pref_incompatible;
 | 
			
		||||
    private boolean resetRequired;
 | 
			
		||||
 | 
			
		||||
    // The signature of the installed version.
 | 
			
		||||
@ -263,6 +264,7 @@ public class AppDetails extends ListActivity {
 | 
			
		||||
                .getDefaultSharedPreferences(getBaseContext());
 | 
			
		||||
        pref_expert = prefs.getBoolean("expert", false);
 | 
			
		||||
        pref_permissions = prefs.getBoolean("showPermissions", false);
 | 
			
		||||
        pref_incompatible = prefs.getBoolean("showIncompatible", false);
 | 
			
		||||
        updateViews();
 | 
			
		||||
 | 
			
		||||
        MenuManager.create(this).invalidateOptionsMenu();
 | 
			
		||||
@ -375,7 +377,8 @@ public class AppDetails extends ListActivity {
 | 
			
		||||
        // Populate the list...
 | 
			
		||||
        ApkListAdapter la = (ApkListAdapter) getListAdapter();
 | 
			
		||||
        for (DB.Apk apk : app.apks)
 | 
			
		||||
            la.addItem(apk);
 | 
			
		||||
            if (pref_incompatible || apk.compatible)
 | 
			
		||||
                la.addItem(apk);
 | 
			
		||||
        la.notifyDataSetChanged();
 | 
			
		||||
 | 
			
		||||
        // Insert the 'infoView' (which contains the summary, various odds and
 | 
			
		||||
 | 
			
		||||
@ -178,6 +178,9 @@ public class AppListManager {
 | 
			
		||||
    private boolean updateApps() {
 | 
			
		||||
 | 
			
		||||
        allApps = ((FDroidApp)fdroidActivity.getApplication()).getApps();
 | 
			
		||||
        SharedPreferences prefs = PreferenceManager
 | 
			
		||||
                .getDefaultSharedPreferences(fdroidActivity.getBaseContext());
 | 
			
		||||
        boolean showIncompatible = prefs.getBoolean("showIncompatible", false);
 | 
			
		||||
 | 
			
		||||
        if (allApps.isEmpty()) {
 | 
			
		||||
            // If its the first time we've run the app, this should update
 | 
			
		||||
@ -197,11 +200,14 @@ public class AppListManager {
 | 
			
		||||
 | 
			
		||||
            // Add it to the list(s). Always to installed and updates, but
 | 
			
		||||
            // only to available if it's not filtered.
 | 
			
		||||
            if (!isFiltered && isInCategory)
 | 
			
		||||
                availApps.add(app);
 | 
			
		||||
            if (!isFiltered && isInCategory) {
 | 
			
		||||
                if (showIncompatible || app.compatible) {
 | 
			
		||||
                    availApps.add(app);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (app.installedVersion != null) {
 | 
			
		||||
                installedApps.addItem(app);
 | 
			
		||||
                if (app.hasUpdates)
 | 
			
		||||
                if (app.hasUpdates && (showIncompatible || app.compatible))
 | 
			
		||||
                    canUpgradeApps.addItem(app);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1153,27 +1153,15 @@ public class DB {
 | 
			
		||||
        if (compatChecker == null)
 | 
			
		||||
            compatChecker = Apk.CompatibilityChecker.getChecker(mContext);
 | 
			
		||||
 | 
			
		||||
        SharedPreferences prefs = PreferenceManager
 | 
			
		||||
                .getDefaultSharedPreferences(mContext);
 | 
			
		||||
        boolean prefCompat = prefs.getBoolean("showIncompatible", false);
 | 
			
		||||
 | 
			
		||||
        // See if it's compatible (by which we mean if it has at least one
 | 
			
		||||
        // compatible apk - if it's not, leave it out)
 | 
			
		||||
        // Also keep a list of which were compatible, because they're the
 | 
			
		||||
        // only ones we'll add, unless the showIncompatible preference is set.
 | 
			
		||||
        List<Apk> compatibleapks = new ArrayList<Apk>();
 | 
			
		||||
        // compatible apk)
 | 
			
		||||
        upapp.compatible = false;
 | 
			
		||||
        for (Apk apk : upapp.apks) {
 | 
			
		||||
            if (compatChecker.isCompatible(apk)) {
 | 
			
		||||
                apk.compatible = true;
 | 
			
		||||
                compatibleapks.add(apk);
 | 
			
		||||
                upapp.compatible = true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (compatibleapks.size() > 0)
 | 
			
		||||
            upapp.compatible = true;
 | 
			
		||||
        if (prefCompat)
 | 
			
		||||
            compatibleapks = upapp.apks;
 | 
			
		||||
        if (compatibleapks.size() == 0)
 | 
			
		||||
            return false;
 | 
			
		||||
 | 
			
		||||
        boolean found = false;
 | 
			
		||||
        for (App app : updateApps) {
 | 
			
		||||
@ -1181,7 +1169,7 @@ public class DB {
 | 
			
		||||
                updateApp(app, upapp);
 | 
			
		||||
                app.updated = true;
 | 
			
		||||
                found = true;
 | 
			
		||||
                for (Apk upapk : compatibleapks) {
 | 
			
		||||
                for (Apk upapk : upapp.apks) {
 | 
			
		||||
                    boolean afound = false;
 | 
			
		||||
                    for (Apk apk : app.apks) {
 | 
			
		||||
                        if (apk.vercode == upapk.vercode) {
 | 
			
		||||
@ -1206,7 +1194,7 @@ public class DB {
 | 
			
		||||
        if (!found) {
 | 
			
		||||
            // It's a brand new application...
 | 
			
		||||
            updateApp(null, upapp);
 | 
			
		||||
            for (Apk upapk : compatibleapks) {
 | 
			
		||||
            for (Apk upapk : upapp.apks) {
 | 
			
		||||
                updateApkIfDifferent(null, upapk);
 | 
			
		||||
                upapk.updated = true;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -255,8 +255,6 @@ public class FDroid extends FragmentActivity {
 | 
			
		||||
                finish();
 | 
			
		||||
                overridePendingTransition(0, 0);
 | 
			
		||||
                startActivity(intent);
 | 
			
		||||
            } else {
 | 
			
		||||
                repopulateViews();
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -35,7 +35,6 @@ public class PreferencesActivity extends PreferenceActivity implements
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private boolean ignoreTouchscreenChanged = false;
 | 
			
		||||
    private boolean showIncompatibleChanged = false;
 | 
			
		||||
    private boolean lightThemeChanged = false;
 | 
			
		||||
 | 
			
		||||
    Intent ret;
 | 
			
		||||
@ -51,7 +50,7 @@ public class PreferencesActivity extends PreferenceActivity implements
 | 
			
		||||
        ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true);
 | 
			
		||||
        addPreferencesFromResource(R.xml.preferences);
 | 
			
		||||
        for (String prefkey : new String[] { "ignoreTouchscreen",
 | 
			
		||||
                "showIncompatible", "lightTheme" }) {
 | 
			
		||||
                "lightTheme" }) {
 | 
			
		||||
            Preference pref = findPreference(prefkey);
 | 
			
		||||
            pref.setOnPreferenceClickListener(this);
 | 
			
		||||
        }
 | 
			
		||||
@ -63,14 +62,12 @@ public class PreferencesActivity extends PreferenceActivity implements
 | 
			
		||||
        String key = preference.getKey();
 | 
			
		||||
        if (key.equals("ignoreTouchscreen"))
 | 
			
		||||
            ignoreTouchscreenChanged ^= true;
 | 
			
		||||
        else if (key.equals("showIncompatible"))
 | 
			
		||||
            showIncompatibleChanged ^= true;
 | 
			
		||||
        else
 | 
			
		||||
            lightThemeChanged ^= true;
 | 
			
		||||
 | 
			
		||||
        if (lightThemeChanged)
 | 
			
		||||
            ret.putExtra("restart", true);
 | 
			
		||||
        else if (ignoreTouchscreenChanged || showIncompatibleChanged)
 | 
			
		||||
        else if (ignoreTouchscreenChanged)
 | 
			
		||||
            ret.putExtra("update", true);
 | 
			
		||||
 | 
			
		||||
        setResult(RESULT_OK, ret);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user