Describe the status of an update, rather than showing the app summary.
This commit is contained in:
parent
c275fae9b7
commit
0826533d40
@ -22,6 +22,9 @@ import java.util.List;
|
|||||||
* {@link AppUpdateStatusManager.Status#ReadyToInstall}. This is an {@link IntentService} so as to
|
* {@link AppUpdateStatusManager.Status#ReadyToInstall}. This is an {@link IntentService} so as to
|
||||||
* run on a background thread, as it hits the disk a bit to figure out the hash of each downloaded
|
* run on a background thread, as it hits the disk a bit to figure out the hash of each downloaded
|
||||||
* file.
|
* file.
|
||||||
|
*
|
||||||
|
* TODO: Deal with more than just the suggested version. It should also work for people downloading earlier versions (but still newer than their current)
|
||||||
|
* TODO: Identify new apps which have not been installed before, but which have been downloading. Currently only works for updates.
|
||||||
*/
|
*/
|
||||||
public class AppUpdateStatusService extends IntentService {
|
public class AppUpdateStatusService extends IntentService {
|
||||||
|
|
||||||
|
@ -126,6 +126,10 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
cancelButton = (ImageButton) itemView.findViewById(R.id.cancel_button);
|
cancelButton = (ImageButton) itemView.findViewById(R.id.cancel_button);
|
||||||
actionButton = (Button) itemView.findViewById(R.id.action_button);
|
actionButton = (Button) itemView.findViewById(R.id.action_button);
|
||||||
|
|
||||||
|
if (actionButton != null) {
|
||||||
|
actionButton.setOnClickListener(onInstallClicked);
|
||||||
|
}
|
||||||
|
|
||||||
if (cancelButton != null) {
|
if (cancelButton != null) {
|
||||||
cancelButton.setOnClickListener(onCancelDownload);
|
cancelButton.setOnClickListener(onCancelDownload);
|
||||||
}
|
}
|
||||||
@ -137,7 +141,6 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
public void bindModel(@NonNull App app) {
|
public void bindModel(@NonNull App app) {
|
||||||
currentApp = app;
|
currentApp = app;
|
||||||
name.setText(Utils.formatAppNameAndSummary(app.name, app.summary));
|
|
||||||
|
|
||||||
ImageLoader.getInstance().displayImage(app.iconUrl, icon, displayImageOptions);
|
ImageLoader.getInstance().displayImage(app.iconUrl, icon, displayImageOptions);
|
||||||
|
|
||||||
@ -151,6 +154,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
broadcastManager.registerReceiver(onDownloadProgress, DownloaderService.getIntentFilter(currentAppDownloadUrl));
|
broadcastManager.registerReceiver(onDownloadProgress, DownloaderService.getIntentFilter(currentAppDownloadUrl));
|
||||||
broadcastManager.registerReceiver(onInstallAction, Installer.getInstallIntentFilter(Uri.parse(currentAppDownloadUrl)));
|
broadcastManager.registerReceiver(onInstallAction, Installer.getInstallIntentFilter(Uri.parse(currentAppDownloadUrl)));
|
||||||
|
|
||||||
|
configureAppName(app);
|
||||||
configureStatusText(app);
|
configureStatusText(app);
|
||||||
configureInstalledVersion(app);
|
configureInstalledVersion(app);
|
||||||
configureIgnoredStatus(app);
|
configureIgnoredStatus(app);
|
||||||
@ -163,8 +167,6 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
* * Is compatible with the users device
|
* * Is compatible with the users device
|
||||||
* * Is installed
|
* * Is installed
|
||||||
* * Can be updated
|
* * Can be updated
|
||||||
*
|
|
||||||
* TODO: This button also needs to be repurposed to support the "Downloaded but not installed" state.
|
|
||||||
*/
|
*/
|
||||||
private void configureStatusText(@NonNull App app) {
|
private void configureStatusText(@NonNull App app) {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
@ -226,6 +228,10 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queries the {@link AppUpdateStatusManager} to find out if there are any apks corresponding to
|
||||||
|
* `app` which are ready to install.
|
||||||
|
*/
|
||||||
private boolean isReadyToInstall(@NonNull App app) {
|
private boolean isReadyToInstall(@NonNull App app) {
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus appStatus : AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName)) {
|
for (AppUpdateStatusManager.AppUpdateStatus appStatus : AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName)) {
|
||||||
if (appStatus.status == AppUpdateStatusManager.Status.ReadyToInstall) {
|
if (appStatus.status == AppUpdateStatusManager.Status.ReadyToInstall) {
|
||||||
@ -235,6 +241,38 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queries the {@link AppUpdateStatusManager} to find out if there are any apks corresponding to
|
||||||
|
* `app` which are in the process of being downloaded.
|
||||||
|
*/
|
||||||
|
private boolean isDownloading(@NonNull App app) {
|
||||||
|
for (AppUpdateStatusManager.AppUpdateStatus appStatus : AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName)) {
|
||||||
|
if (appStatus.status == AppUpdateStatusManager.Status.Downloading) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The app name {@link TextView} is used for a few reasons:
|
||||||
|
* * Display name + summary of the app (most common).
|
||||||
|
* * If downloading, mention that it is downloading instead of showing the summary.
|
||||||
|
* * If downloaded and ready to install, mention that it is ready to update/install.
|
||||||
|
*/
|
||||||
|
private void configureAppName(@NonNull App app) {
|
||||||
|
if (isReadyToInstall(app)) {
|
||||||
|
if (app.isInstalled()) {
|
||||||
|
name.setText(activity.getString(R.string.app_list__name__downloaded_and_ready_to_update, app.name));
|
||||||
|
} else {
|
||||||
|
name.setText(activity.getString(R.string.app_list__name__downloaded_and_ready_to_install, app.name));
|
||||||
|
}
|
||||||
|
} else if (isDownloading(app)) {
|
||||||
|
name.setText(activity.getString(R.string.app_list__name__downloading_in_progress, app.name));
|
||||||
|
} else {
|
||||||
|
name.setText(Utils.formatAppNameAndSummary(app.name, app.summary));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The action button will either tell the user to "Update" or "Install" the app. Both actually do
|
* The action button will either tell the user to "Update" or "Install" the app. Both actually do
|
||||||
@ -246,15 +284,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean readyToInstall = false;
|
if (!isReadyToInstall(app)) {
|
||||||
for (AppUpdateStatusManager.AppUpdateStatus status : AppUpdateStatusManager.getInstance(activity).getByPackageName(app.packageName)) {
|
|
||||||
if (status.status == AppUpdateStatusManager.Status.ReadyToInstall) {
|
|
||||||
readyToInstall = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!readyToInstall) {
|
|
||||||
actionButton.setVisibility(View.GONE);
|
actionButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
actionButton.setVisibility(View.VISIBLE);
|
actionButton.setVisibility(View.VISIBLE);
|
||||||
@ -271,8 +301,6 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
* * Is compatible with the users device.
|
* * Is compatible with the users device.
|
||||||
* * Has not been filtered due to anti-features/root/etc.
|
* * Has not been filtered due to anti-features/root/etc.
|
||||||
* * Is either not installed or installed but can be updated.
|
* * Is either not installed or installed but can be updated.
|
||||||
*
|
|
||||||
* TODO: This button also needs to be repurposed to support the "Downloaded but not installed" state.
|
|
||||||
*/
|
*/
|
||||||
private void configureInstallButton(@NonNull App app) {
|
private void configureInstallButton(@NonNull App app) {
|
||||||
if (installButton == null) {
|
if (installButton == null) {
|
||||||
@ -382,6 +410,8 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureAppName(currentApp);
|
||||||
|
|
||||||
if (Downloader.ACTION_STARTED.equals(intent.getAction())) {
|
if (Downloader.ACTION_STARTED.equals(intent.getAction())) {
|
||||||
onDownloadStarted();
|
onDownloadStarted();
|
||||||
} else if (Downloader.ACTION_PROGRESS.equals(intent.getAction())) {
|
} else if (Downloader.ACTION_PROGRESS.equals(intent.getAction())) {
|
||||||
@ -401,6 +431,8 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configureAppName(currentApp);
|
||||||
|
|
||||||
Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
|
Apk apk = intent.getParcelableExtra(Installer.EXTRA_APK);
|
||||||
if (!TextUtils.equals(apk.packageName, currentApp.packageName)) {
|
if (!TextUtils.equals(apk.packageName, currentApp.packageName)) {
|
||||||
return;
|
return;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
tools:text="F-Droid Application manager with a long name that will wrap and then ellipsize"
|
||||||
android:textSize="18sp"
|
android:textSize="16sp"
|
||||||
android:textColor="#424242"
|
android:textColor="#424242"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
@ -70,6 +70,10 @@
|
|||||||
<string name="added_on">Added on %s</string>
|
<string name="added_on">Added on %s</string>
|
||||||
<string name="app__install_downloaded_update">Update</string>
|
<string name="app__install_downloaded_update">Update</string>
|
||||||
|
|
||||||
|
<string name="app_list__name__downloaded_and_ready_to_update">Update %1$s</string>
|
||||||
|
<string name="app_list__name__downloaded_and_ready_to_install">Install %1$s</string>
|
||||||
|
<string name="app_list__name__downloading_in_progress">Downloading %1$s</string>
|
||||||
|
|
||||||
<string name="installed_apps__activity_title">Installed Apps</string>
|
<string name="installed_apps__activity_title">Installed Apps</string>
|
||||||
<string name="installed_app__updates_ignored">Updates ignored</string>
|
<string name="installed_app__updates_ignored">Updates ignored</string>
|
||||||
<string name="installed_app__updates_ignored_for_suggested_version">Updates ignored for Version %1$s</string>
|
<string name="installed_app__updates_ignored_for_suggested_version">Updates ignored for Version %1$s</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user