Added "Successfully Installed" status text to updates tab.
Also: * Extracted common styles into `@Style/AppListItemStatusText`. * Fixed left margin on older devices (where `layout_marginStart` doesn't exist).
This commit is contained in:
parent
d0cf621314
commit
ef230f749c
@ -66,7 +66,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
private final TextView status;
|
||||
|
||||
@Nullable
|
||||
private final TextView downloadReady;
|
||||
private final TextView appInstallStatus;
|
||||
|
||||
@Nullable
|
||||
private final TextView installedVersion;
|
||||
@ -125,7 +125,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
name = (TextView) itemView.findViewById(R.id.app_name);
|
||||
status = (TextView) itemView.findViewById(R.id.status);
|
||||
downloadReady = (TextView) itemView.findViewById(R.id.download_ready);
|
||||
appInstallStatus = (TextView) itemView.findViewById(R.id.app_install_status);
|
||||
installedVersion = (TextView) itemView.findViewById(R.id.installed_version);
|
||||
ignoredStatus = (TextView) itemView.findViewById(R.id.ignored_status);
|
||||
progressBar = (ProgressBar) itemView.findViewById(R.id.progress_bar);
|
||||
@ -207,8 +207,13 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
|
||||
name.setText(viewState.getMainText());
|
||||
|
||||
if (downloadReady != null) {
|
||||
downloadReady.setVisibility(viewState.shouldShowActionButton() ? View.VISIBLE : View.GONE);
|
||||
if (appInstallStatus != null) {
|
||||
if (viewState.shouldShowAppInstallStatusText()) {
|
||||
appInstallStatus.setVisibility(View.VISIBLE);
|
||||
appInstallStatus.setText(viewState.getAppInstallStatusText());
|
||||
} else {
|
||||
appInstallStatus.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (actionButton != null) {
|
||||
@ -290,7 +295,9 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
CharSequence mainText = activity.getString(
|
||||
R.string.app_list__name__successfully_installed, app.name);
|
||||
|
||||
AppListItemState state = new AppListItemState(activity, app).setMainText(mainText);
|
||||
AppListItemState state = new AppListItemState(activity, app)
|
||||
.setMainText(mainText)
|
||||
.setAppInstallStatusText(activity.getString(R.string.notification_content_single_installed));
|
||||
|
||||
if (activity.getPackageManager().getLaunchIntentForPackage(app.packageName) != null) {
|
||||
state.showActionButton(activity.getString(R.string.menu_launch));
|
||||
@ -317,7 +324,7 @@ public class AppListItemController extends RecyclerView.ViewHolder {
|
||||
return new AppListItemState(activity, app)
|
||||
.setMainText(app.name)
|
||||
.showActionButton(activity.getString(actionButtonLabel))
|
||||
.setShowDownloadReady();
|
||||
.setAppInstallStatusText(activity.getString(R.string.app_list_download_ready));
|
||||
}
|
||||
|
||||
private AppListItemState getViewStateDefault(@NonNull App app) {
|
||||
|
@ -15,7 +15,7 @@ public class AppListItemState {
|
||||
private final Context context;
|
||||
private final App app;
|
||||
private CharSequence mainText = null;
|
||||
private boolean showDownloadReady = false;
|
||||
private CharSequence appInstallStatusText = null;
|
||||
private CharSequence actionButtonText = null;
|
||||
private int progressCurrent = -1;
|
||||
private int progressMax = -1;
|
||||
@ -30,13 +30,13 @@ public class AppListItemState {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppListItemState setShowDownloadReady() {
|
||||
this.showDownloadReady = true;
|
||||
public AppListItemState showActionButton(@NonNull CharSequence label) {
|
||||
actionButtonText = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppListItemState showActionButton(@NonNull CharSequence label) {
|
||||
actionButtonText = label;
|
||||
public AppListItemState setAppInstallStatusText(@NonNull CharSequence text) {
|
||||
appInstallStatusText = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -60,10 +60,6 @@ public class AppListItemState {
|
||||
return installable && shouldAllow && !shouldShowActionButton() && !showProgress();
|
||||
}
|
||||
|
||||
public boolean shouldShowDownloadReady() {
|
||||
return showDownloadReady;
|
||||
}
|
||||
|
||||
public boolean shouldShowActionButton() {
|
||||
return actionButtonText != null;
|
||||
}
|
||||
@ -88,6 +84,14 @@ public class AppListItemState {
|
||||
return progressMax;
|
||||
}
|
||||
|
||||
public boolean shouldShowAppInstallStatusText() {
|
||||
return appInstallStatusText != null;
|
||||
}
|
||||
|
||||
public CharSequence getAppInstallStatusText() {
|
||||
return appInstallStatusText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text/visibility of the {@link R.id#status} {@link TextView} based on whether the app:
|
||||
* * Is compatible with the users device
|
||||
|
@ -46,12 +46,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="Installed"
|
||||
android:textStyle="italic"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#424242"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-light"
|
||||
style="@style/AppListItemStatusText"
|
||||
app:layout_constraintTop_toBottomOf="@+id/app_name"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
android:layout_marginStart="8dp"
|
||||
|
@ -36,20 +36,18 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintVertical_bias="0.333" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/download_ready"
|
||||
android:id="@+id/app_install_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_list_download_ready"
|
||||
android:textSize="14sp"
|
||||
android:textColor="?attr/lightGrayTextColor"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-light"
|
||||
tools:text="@string/app_list_download_ready"
|
||||
style="@style/AppListItemStatusText"
|
||||
app:layout_constraintTop_toBottomOf="@+id/app_name"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon"
|
||||
android:layout_marginStart="8dp"
|
||||
|
@ -6,4 +6,7 @@
|
||||
</style>
|
||||
<style name="BodyText" parent="BodyTextV16" />
|
||||
|
||||
<style name="AppListItemStatusText" parent="AppListItemStatusTextBase">
|
||||
<item name="android:fontFamily">sans-serif-light</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
@ -121,6 +121,17 @@
|
||||
<item name="android:textColor">?attr/lightGrayTextColor</item>
|
||||
</style>
|
||||
|
||||
<!-- Used for supplementary information to show below an app name in app lists, such as
|
||||
whether it is incompatible, what version is installed, etc -->
|
||||
<style name="AppListItemStatusTextBase">
|
||||
<item name="android:textStyle">italic</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:textColor">?attr/lightGrayTextColor</item>
|
||||
<item name="android:maxLines">1</item>
|
||||
<item name="android:ellipsize">end</item>
|
||||
</style>
|
||||
<style name="AppListItemStatusText" parent="AppListItemStatusTextBase" />
|
||||
|
||||
<style name="SwapTheme.Wizard" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorButtonNormal">@color/swap_bright_blue</item>
|
||||
<item name="actionButtonStyle">@style/SwapTheme.Wizard.ActionButton</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user