Add App.toUpdate as the filter result of App.hasUpdates (fixes #372)
This commit is contained in:
		
							parent
							
								
									458f163f7e
								
							
						
					
					
						commit
						78ba64c2ec
					
				| @ -583,7 +583,7 @@ public class AppDetails extends ListActivity { | ||||
|         if (app == null) | ||||
|             return true; | ||||
|         DB.Apk curver = app.getCurrentVersion(); | ||||
|         if (app.hasUpdates == true) { | ||||
|         if (app.toUpdate) { | ||||
|             MenuItemCompat.setShowAsAction(menu.add( | ||||
|                         Menu.NONE, INSTALL, 0, R.string.menu_update) | ||||
|                         .setIcon(R.drawable.ic_menu_refresh), | ||||
|  | ||||
| @ -203,8 +203,7 @@ public class AppListManager { | ||||
|             } | ||||
|             if (app.installedVersion != null) { | ||||
|                 installedApps.addItem(app); | ||||
|                 if (!app.ignoreUpdates && app.hasUpdates && !app.filtered | ||||
|                         && (showIncompatible || app.compatible)) | ||||
|                 if (app.toUpdate) | ||||
|                     canUpgradeApps.addItem(app); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -116,6 +116,7 @@ public class DB { | ||||
|             antiFeatures = null; | ||||
|             requirements = null; | ||||
|             hasUpdates = false; | ||||
|             toUpdate = false; | ||||
|             updated = false; | ||||
|             added = null; | ||||
|             lastUpdated = null; | ||||
| @ -189,11 +190,14 @@ public class DB { | ||||
|         // permission (set in the Settings page) | ||||
|         public boolean filtered; | ||||
| 
 | ||||
|         // 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(). | ||||
|         // True if there are new versions (apks) available, regardless of | ||||
|         // any filtering | ||||
|         public boolean hasUpdates; | ||||
| 
 | ||||
|         // True if there are new versions (apks) available and the user wants | ||||
|         // to be notified about them | ||||
|         public boolean toUpdate; | ||||
| 
 | ||||
|         // True if updates should not show up in the Updates tab for this | ||||
|         // application | ||||
|         public boolean ignoreUpdates; | ||||
|  | ||||
| @ -54,6 +54,7 @@ public class FDroidApp extends Application { | ||||
|         // because the install intent says it's finished when it hasn't. | ||||
|         SharedPreferences prefs = PreferenceManager | ||||
|                 .getDefaultSharedPreferences(getBaseContext()); | ||||
|         showIncompatible = prefs.getBoolean("showIncompatible", false); | ||||
|         if (!prefs.getBoolean("cacheDownloaded", false)) { | ||||
| 
 | ||||
|             File local_path = DB.getDataPath(this); | ||||
| @ -100,6 +101,8 @@ public class FDroidApp extends Application { | ||||
|     // Global list of all known applications. | ||||
|     private List<DB.App> apps; | ||||
| 
 | ||||
|     private boolean showIncompatible; | ||||
| 
 | ||||
|     // Set when something has changed (database or installed apps) so we know | ||||
|     // we should invalidate the apps. | ||||
|     private volatile boolean appsAllInvalid = false; | ||||
| @ -154,7 +157,7 @@ public class FDroidApp extends Application { | ||||
|                     for (DB.Repo repo : repos) { | ||||
|                         DB.Apk bestApk = app.apks.get(0); | ||||
|                         if (repo.id == bestApk.repo) { | ||||
| 							app.iconUrl = repo.address + "/icons/" + app.icon; | ||||
|                             app.iconUrl = repo.address + "/icons/" + app.icon; | ||||
|                             break; | ||||
|                         } | ||||
|                     } | ||||
| @ -174,7 +177,7 @@ public class FDroidApp extends Application { | ||||
|                     for (DB.Repo repo : repos) { | ||||
|                         DB.Apk bestApk = app.apks.get(0); | ||||
|                         if (repo.id == bestApk.repo) { | ||||
| 							app.iconUrl = repo.address + "/icons/" + app.icon; | ||||
|                             app.iconUrl = repo.address + "/icons/" + app.icon; | ||||
|                             break; | ||||
|                         } | ||||
|                     } | ||||
| @ -195,6 +198,12 @@ public class FDroidApp extends Application { | ||||
|         AppFilter appFilter = new AppFilter(ctx); | ||||
|         for (DB.App app : apps) { | ||||
|             app.filtered = appFilter.filter(app); | ||||
| 
 | ||||
|             app.toUpdate = ( | ||||
|                     !app.ignoreUpdates | ||||
|                     && app.hasUpdates | ||||
|                     && !app.filtered | ||||
|                     && (showIncompatible || app.compatible)); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -87,11 +87,11 @@ public class ManageRepo extends ListActivity { | ||||
|         long lastUpdate = prefs.getLong("lastUpdateCheck", 0); | ||||
|         String s_lastUpdateCheck = ""; | ||||
|         if (lastUpdate == 0) { | ||||
|         	s_lastUpdateCheck = getString(R.string.never); | ||||
|             s_lastUpdateCheck = getString(R.string.never); | ||||
|         } else { | ||||
|         	Date d = new Date(lastUpdate); | ||||
|         	s_lastUpdateCheck = DateFormat.getDateFormat(this).format(d) +  | ||||
|         			" " + DateFormat.getTimeFormat(this).format(d); | ||||
|             Date d = new Date(lastUpdate); | ||||
|             s_lastUpdateCheck = DateFormat.getDateFormat(this).format(d) +  | ||||
|                     " " + DateFormat.getTimeFormat(this).format(d); | ||||
|         } | ||||
|         tv_lastCheck.setText(getString(R.string.last_update_check,s_lastUpdateCheck)); | ||||
| 
 | ||||
|  | ||||
| @ -75,7 +75,7 @@ public class RepoXMLHandler extends DefaultHandler { | ||||
|     public static final int PROGRESS_TYPE_DOWNLOAD     = 1; | ||||
|     public static final int PROGRESS_TYPE_PROCESS_XML  = 2; | ||||
| 
 | ||||
| 	public static final String PROGRESS_DATA_REPO = "repo"; | ||||
|     public static final String PROGRESS_DATA_REPO = "repo"; | ||||
| 
 | ||||
|     // The date format used in the repo XML file. | ||||
|     private SimpleDateFormat mXMLDateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| @ -242,11 +242,11 @@ public class RepoXMLHandler extends DefaultHandler { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	private static Bundle createProgressData(String repoAddress) { | ||||
| 		Bundle data = new Bundle(); | ||||
| 		data.putString(PROGRESS_DATA_REPO, repoAddress); | ||||
| 		return data; | ||||
| 	} | ||||
|     private static Bundle createProgressData(String repoAddress) { | ||||
|         Bundle data = new Bundle(); | ||||
|         data.putString(PROGRESS_DATA_REPO, repoAddress); | ||||
|         return data; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void startElement(String uri, String localName, String qName, | ||||
|  | ||||
| @ -104,7 +104,7 @@ public class UpdateService extends IntentService implements ProgressListener { | ||||
|     public int getNumUpdates(List<DB.App> apps) { | ||||
|         int count = 0; | ||||
|         for (DB.App app : apps) { | ||||
|             if (!app.ignoreUpdates && app.hasUpdates) | ||||
|             if (!app.toUpdate) | ||||
|                 count++; | ||||
|         } | ||||
|         return count; | ||||
|  | ||||
| @ -94,7 +94,7 @@ abstract public class AppListAdapter extends BaseAdapter { | ||||
|             iconInstalled.setImageResource(R.drawable.ic_cab_done_holo_dark); | ||||
|             iconUpdates.setImageResource(R.drawable.ic_menu_refresh); | ||||
| 
 | ||||
|             if (app.hasUpdates && showStatusUpdate()) { | ||||
|             if (app.toUpdate && showStatusUpdate()) { | ||||
|                 iconUpdates.setVisibility(View.VISIBLE); | ||||
|             } else { | ||||
|                 iconUpdates.setVisibility(View.GONE); | ||||
| @ -152,7 +152,7 @@ abstract public class AppListAdapter extends BaseAdapter { | ||||
|         StringBuilder version = new StringBuilder(); | ||||
|         if (app.installedVersion != null) { | ||||
|             version.append(app.installedVersion); | ||||
|             if (app.hasUpdates) { | ||||
|             if (app.toUpdate) { | ||||
|                 version.append(" -> "); | ||||
|                 version.append(app.updateVersion); | ||||
|             } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Martí
						Daniel Martí