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") {
"java/res/values-night-v17/colors.xml",
"java/res/values-v17/attrs.xml",
"java/res/values-v17/colors.xml",
"java/res/values-v17/dimens.xml",
"java/res/values-v17/ids.xml",
"java/res/values-v17/styles.xml",
"java/res/xml/download_preferences.xml",
......
......@@ -20,15 +20,15 @@
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:textAppearance="@style/TextAppearance.DownloadLaterTitle"
android:layout_marginBottom="@dimen/download_dialog_title_margin_bottom"
android:textAppearance="@style/TextAppearance.DownloadDialogTitle"
android:text="@string/download_later_dialog_title" />
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
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:text="@string/download_later_dialog_subtitle" />
......
......@@ -16,12 +16,18 @@
style="@style/AlertDialogContent">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
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:textAppearance="@style/TextAppearance.TextMedium.Secondary"
android:visibility="gone"
android:layout_marginBottom="16dp" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/download_dialog_subtitle_margin_bottom"
android:textAppearance="@style/TextAppearance.TextMedium.Secondary" />
<LinearLayout
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 @@
<item name="android:tint">@color/modern_grey_800</item>
</style>
<!-- Download Later Styles -->
<style name="TextAppearance.DownloadLaterTitle" parent="TextAppearance.AlertDialogTitleStyle">
<!-- Download Dialogs Styles -->
<style name="TextAppearance.DownloadDialogTitle" parent="TextAppearance.AlertDialogTitleStyle">
<item name="android:textSize">20sp</item>
</style>
</resources>
......@@ -24,6 +24,7 @@ import org.chromium.chrome.browser.download.DownloadLocationDialogType;
import org.chromium.chrome.browser.download.DownloadPromptStatus;
import org.chromium.chrome.browser.download.R;
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 java.io.File;
......@@ -35,6 +36,7 @@ public class DownloadLocationCustomView
extends ScrollView implements OnCheckedChangeListener, DownloadDirectoryAdapter.Delegate {
private DownloadDirectoryAdapter mDirectoryAdapter;
private TextView mTitle;
private TextView mSubtitleView;
private AlertDialogEditText mFileName;
private Spinner mFileLocation;
......@@ -50,13 +52,15 @@ public class DownloadLocationCustomView
protected void onFinishInflate() {
super.onFinishInflate();
mTitle = findViewById(R.id.title);
mSubtitleView = findViewById(R.id.subtitle);
mFileName = findViewById(R.id.file_name);
mFileLocation = findViewById(R.id.file_location);
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;
// Automatically check "don't show again" the first time the user is seeing the dialog.
......@@ -66,9 +70,18 @@ public class DownloadLocationCustomView
mDontShowAgain.setOnCheckedChangeListener(this);
mFileName.setText(suggestedPath.getName());
mSubtitleView.setVisibility(
dialogType == DownloadLocationDialogType.DEFAULT ? View.GONE : View.VISIBLE);
mTitle.setText(title);
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:
mSubtitleView.setText(R.string.download_location_download_to_default_folder);
break;
......
......@@ -139,13 +139,13 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties.
// Actually show the dialog.
mCustomView = (DownloadLocationCustomView) LayoutInflater.from(mContext).inflate(
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();
mDialogModel =
new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS)
.with(ModalDialogProperties.CONTROLLER, this)
.with(ModalDialogProperties.TITLE, getTitle(mTotalBytes, mDialogType))
.with(ModalDialogProperties.CUSTOM_VIEW, mCustomView)
.with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, resources,
R.string.duplicate_download_infobar_download_button)
......@@ -156,7 +156,7 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties.
mModalDialogManager.showDialog(mDialogModel, ModalDialogManager.ModalDialogType.APP);
}
private String getTitle(long totalBytes, @DownloadLocationDialogType int dialogType) {
private String getTitle(@DownloadLocationDialogType int dialogType) {
switch (dialogType) {
case DownloadLocationDialogType.LOCATION_FULL:
return mContext.getString(R.string.download_location_not_enough_space);
......@@ -171,16 +171,7 @@ public class DownloadLocationDialogCoordinator implements ModalDialogProperties.
return mContext.getString(R.string.download_location_rename_file);
case DownloadLocationDialogType.DEFAULT:
String title = 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;
return mContext.getString(R.string.download_location_dialog_title);
}
assert false;
return null;
......
......@@ -1127,7 +1127,7 @@ Your Google account may have other forms of browsing history like searches and a
Ask where to save files
</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.">
Download file
Choose where to download
</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.">
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