Commit b0e78262 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Download later: Change the title of the location dialog.

The location dialog title is changed to "Choose where to download" to
match the download later dialog's "Choose when to download".

The file size is kept, the text could be "Choose where to download 15Kb"
when the file size is available.

Also does layout polish to make the title and subtitle to match the
new download later dialog.

Bug: 1101010,1078454
Change-Id: I08c4965ca007afa74b5c23e019d615fbb8fcbc81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276347
Commit-Queue: Xing Liu <xingliu@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarHesen Zhang <hesen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784266}
parent c3d0b847
...@@ -205,6 +205,7 @@ android_resources("java_resources") { ...@@ -205,6 +205,7 @@ android_resources("java_resources") {
"java/res/values-night-v17/colors.xml", "java/res/values-night-v17/colors.xml",
"java/res/values-v17/attrs.xml", "java/res/values-v17/attrs.xml",
"java/res/values-v17/colors.xml", "java/res/values-v17/colors.xml",
"java/res/values-v17/dimens.xml",
"java/res/values-v17/ids.xml", "java/res/values-v17/ids.xml",
"java/res/values-v17/styles.xml", "java/res/values-v17/styles.xml",
"java/res/xml/download_preferences.xml", "java/res/xml/download_preferences.xml",
......
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="3dp" android:layout_marginBottom="@dimen/download_dialog_title_margin_bottom"
android:textAppearance="@style/TextAppearance.DownloadLaterTitle" android:textAppearance="@style/TextAppearance.DownloadDialogTitle"
android:text="@string/download_later_dialog_title" /> android:text="@string/download_later_dialog_title" />
<TextView <TextView
android:id="@+id/subtitle" android:id="@+id/subtitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="10dp" android:layout_marginBottom="@dimen/download_dialog_subtitle_margin_bottom"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary" android:textAppearance="@style/TextAppearance.TextMedium.Secondary"
android:text="@string/download_later_dialog_subtitle" /> android:text="@string/download_later_dialog_subtitle" />
......
...@@ -16,12 +16,18 @@ ...@@ -16,12 +16,18 @@
style="@style/AlertDialogContent"> style="@style/AlertDialogContent">
<TextView <TextView
android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/download_dialog_title_margin_bottom"
android:textAppearance="@style/TextAppearance.DownloadDialogTitle" />
<TextView
android:id="@+id/subtitle" android:id="@+id/subtitle"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary" android:layout_width="match_parent"
android:visibility="gone" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" /> android:layout_marginBottom="@dimen/download_dialog_subtitle_margin_bottom"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen name="download_dialog_title_margin_bottom">3dp</dimen>
<dimen name="download_dialog_subtitle_margin_bottom">10dp</dimen>
</resources>
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
<item name="android:tint">@color/modern_grey_800</item> <item name="android:tint">@color/modern_grey_800</item>
</style> </style>
<!-- Download Later Styles --> <!-- Download Dialogs Styles -->
<style name="TextAppearance.DownloadLaterTitle" parent="TextAppearance.AlertDialogTitleStyle"> <style name="TextAppearance.DownloadDialogTitle" parent="TextAppearance.AlertDialogTitleStyle">
<item name="android:textSize">20sp</item> <item name="android:textSize">20sp</item>
</style> </style>
</resources> </resources>
...@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.download.DownloadLocationDialogType; ...@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.download.DownloadLocationDialogType;
import org.chromium.chrome.browser.download.DownloadPromptStatus; import org.chromium.chrome.browser.download.DownloadPromptStatus;
import org.chromium.chrome.browser.download.R; import org.chromium.chrome.browser.download.R;
import org.chromium.chrome.browser.download.settings.DownloadDirectoryAdapter; import org.chromium.chrome.browser.download.settings.DownloadDirectoryAdapter;
import org.chromium.components.browser_ui.util.DownloadUtils;
import org.chromium.components.browser_ui.widget.text.AlertDialogEditText; import org.chromium.components.browser_ui.widget.text.AlertDialogEditText;
import java.io.File; import java.io.File;
...@@ -35,6 +36,7 @@ public class DownloadLocationCustomView ...@@ -35,6 +36,7 @@ public class DownloadLocationCustomView
extends ScrollView implements OnCheckedChangeListener, DownloadDirectoryAdapter.Delegate { extends ScrollView implements OnCheckedChangeListener, DownloadDirectoryAdapter.Delegate {
private DownloadDirectoryAdapter mDirectoryAdapter; private DownloadDirectoryAdapter mDirectoryAdapter;
private TextView mTitle;
private TextView mSubtitleView; private TextView mSubtitleView;
private AlertDialogEditText mFileName; private AlertDialogEditText mFileName;
private Spinner mFileLocation; private Spinner mFileLocation;
...@@ -50,13 +52,15 @@ public class DownloadLocationCustomView ...@@ -50,13 +52,15 @@ public class DownloadLocationCustomView
protected void onFinishInflate() { protected void onFinishInflate() {
super.onFinishInflate(); super.onFinishInflate();
mTitle = findViewById(R.id.title);
mSubtitleView = findViewById(R.id.subtitle); mSubtitleView = findViewById(R.id.subtitle);
mFileName = findViewById(R.id.file_name); mFileName = findViewById(R.id.file_name);
mFileLocation = findViewById(R.id.file_location); mFileLocation = findViewById(R.id.file_location);
mDontShowAgain = findViewById(R.id.show_again_checkbox); mDontShowAgain = findViewById(R.id.show_again_checkbox);
} }
void initialize(@DownloadLocationDialogType int dialogType, File suggestedPath) { void initialize(@DownloadLocationDialogType int dialogType, File suggestedPath, long totalBytes,
CharSequence title) {
mDialogType = dialogType; mDialogType = dialogType;
// Automatically check "don't show again" the first time the user is seeing the dialog. // Automatically check "don't show again" the first time the user is seeing the dialog.
...@@ -66,9 +70,18 @@ public class DownloadLocationCustomView ...@@ -66,9 +70,18 @@ public class DownloadLocationCustomView
mDontShowAgain.setOnCheckedChangeListener(this); mDontShowAgain.setOnCheckedChangeListener(this);
mFileName.setText(suggestedPath.getName()); mFileName.setText(suggestedPath.getName());
mSubtitleView.setVisibility( mTitle.setText(title);
dialogType == DownloadLocationDialogType.DEFAULT ? View.GONE : View.VISIBLE);
switch (dialogType) { switch (dialogType) {
case DownloadLocationDialogType.DEFAULT:
// Show a file size subtitle if file size is available.
if (totalBytes > 0) {
mSubtitleView.setText(
DownloadUtils.getStringForBytes(getContext(), totalBytes));
} else {
mSubtitleView.setVisibility(View.GONE);
}
break;
case DownloadLocationDialogType.LOCATION_FULL: case DownloadLocationDialogType.LOCATION_FULL:
mSubtitleView.setText(R.string.download_location_download_to_default_folder); mSubtitleView.setText(R.string.download_location_download_to_default_folder);
break; break;
......
...@@ -139,13 +139,13 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties. ...@@ -139,13 +139,13 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties.
// Actually show the dialog. // Actually show the dialog.
mCustomView = (DownloadLocationCustomView) LayoutInflater.from(mContext).inflate( mCustomView = (DownloadLocationCustomView) LayoutInflater.from(mContext).inflate(
R.layout.download_location_dialog, null); R.layout.download_location_dialog, null);
mCustomView.initialize(mDialogType, new File(mSuggestedPath)); mCustomView.initialize(
mDialogType, new File(mSuggestedPath), mTotalBytes, getTitle(mDialogType));
Resources resources = mContext.getResources(); Resources resources = mContext.getResources();
mDialogModel = mDialogModel =
new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS) new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS)
.with(ModalDialogProperties.CONTROLLER, this) .with(ModalDialogProperties.CONTROLLER, this)
.with(ModalDialogProperties.TITLE, getTitle(mTotalBytes, mDialogType))
.with(ModalDialogProperties.CUSTOM_VIEW, mCustomView) .with(ModalDialogProperties.CUSTOM_VIEW, mCustomView)
.with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, resources, .with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, resources,
R.string.duplicate_download_infobar_download_button) R.string.duplicate_download_infobar_download_button)
...@@ -156,7 +156,7 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties. ...@@ -156,7 +156,7 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties.
mModalDialogManager.showDialog(mDialogModel, ModalDialogManager.ModalDialogType.APP); mModalDialogManager.showDialog(mDialogModel, ModalDialogManager.ModalDialogType.APP);
} }
private String getTitle(long totalBytes, @DownloadLocationDialogType int dialogType) { private String getTitle(@DownloadLocationDialogType int dialogType) {
switch (dialogType) { switch (dialogType) {
case DownloadLocationDialogType.LOCATION_FULL: case DownloadLocationDialogType.LOCATION_FULL:
return mContext.getString(R.string.download_location_not_enough_space); return mContext.getString(R.string.download_location_not_enough_space);
...@@ -171,16 +171,7 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties. ...@@ -171,16 +171,7 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties.
return mContext.getString(R.string.download_location_rename_file); return mContext.getString(R.string.download_location_rename_file);
case DownloadLocationDialogType.DEFAULT: case DownloadLocationDialogType.DEFAULT:
String title = mContext.getString(R.string.download_location_dialog_title); return mContext.getString(R.string.download_location_dialog_title);
if (totalBytes > 0) {
StringBuilder stringBuilder = new StringBuilder(title);
stringBuilder.append(" ");
stringBuilder.append(
org.chromium.components.browser_ui.util.DownloadUtils.getStringForBytes(
mContext, totalBytes));
title = stringBuilder.toString();
}
return title;
} }
assert false; assert false;
return null; return null;
......
...@@ -1127,7 +1127,7 @@ Your Google account may have other forms of browsing history like searches and a ...@@ -1127,7 +1127,7 @@ Your Google account may have other forms of browsing history like searches and a
Ask where to save files Ask where to save files
</message> </message>
<message name="IDS_DOWNLOAD_LOCATION_DIALOG_TITLE" desc="Title for the dialog that asks where the user wants to save the download file before the download begins."> <message name="IDS_DOWNLOAD_LOCATION_DIALOG_TITLE" desc="Title for the dialog that asks where the user wants to save the download file before the download begins.">
Download file Choose where to download
</message> </message>
<message name="IDS_DOWNLOAD_LOCATION_DIALOG_CHECKBOX" desc="Label for the checkbox that allows the user to indicate if they do not want the download location selection dialog to appear every time they initiate a download."> <message name="IDS_DOWNLOAD_LOCATION_DIALOG_CHECKBOX" desc="Label for the checkbox that allows the user to indicate if they do not want the download location selection dialog to appear every time they initiate a download.">
Don‘t show again Don‘t show again
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment