Commit b7f1ca2e authored by Hesen Zhang's avatar Hesen Zhang Committed by Commit Bot

[Download-Rename] Rename dialog UX review change.

- Remove the small icon in before edit text.
- Move down the error messege under edit text.
- Change the color to dark red when error dialog shows.
- Change extension dialog messages.

Bug: 1012450,952425
Change-Id: I9a8d47121025058bdca44c4b461d20305d6c1396
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865663
Commit-Queue: Hesen Zhang <hesen@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707113}
parent 65a3d424
......@@ -15,34 +15,20 @@
android:layout_height="wrap_content"
style="@style/AlertDialogContent">
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:visibility="gone"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<org.chromium.ui.widget.ChromeImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_drive_file_24dp"
app:tint="@color/default_icon_color"
style="@style/ListItemStartIcon" />
<org.chromium.chrome.browser.ui.widget.text.AlertDialogEditText
android:id="@+id/file_name"
android:layout_width="match_parent"
android:layout_height="48dp"
android:cursorVisible="true"
android:layout_marginStart="-4dp"
android:layout_marginEnd="-4dp"
android:singleLine="true" />
</LinearLayout>
<TextView
android:id="@+id/error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
</LinearLayout>
</org.chromium.chrome.browser.download.home.rename.RenameDialogCustomView>
......@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.download.home.rename;
import static android.content.Context.INPUT_METHOD_SERVICE;
import android.content.Context;
import android.graphics.PorterDuff;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
......@@ -16,6 +17,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.ScrollView;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.chrome.browser.ui.widget.text.AlertDialogEditText;
import org.chromium.chrome.download.R;
......@@ -25,7 +27,7 @@ import org.chromium.components.offline_items_collection.RenameResult;
* Content View of dialog in Download Home that allows users to rename a downloaded file.
*/
public class RenameDialogCustomView extends ScrollView {
private TextView mSubtitleView;
private TextView mErrorMessageView;
private AlertDialogEditText mFileName;
private Callback</*Empty*/ Boolean> mEmptyFileNameObserver;
......@@ -37,7 +39,7 @@ public class RenameDialogCustomView extends ScrollView {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mSubtitleView = findViewById(R.id.subtitle);
mErrorMessageView = findViewById(R.id.error_message);
mFileName = findViewById(R.id.file_name);
mFileName.addTextChangedListener(new TextWatcher() {
@Override
......@@ -68,24 +70,22 @@ public class RenameDialogCustomView extends ScrollView {
*/
public void updateToErrorView(String suggestedName, @RenameResult int renameResult) {
if (renameResult == RenameResult.SUCCESS) return;
if (!TextUtils.isEmpty(suggestedName)) {
mFileName.setText(suggestedName);
}
mFileName.clearFocus();
highlightEditText(suggestedName);
mSubtitleView.setVisibility(View.VISIBLE);
setEditText(suggestedName);
setEditTextStyle(true);
setErrorMessageVisibility(true);
switch (renameResult) {
case RenameResult.FAILURE_NAME_CONFLICT:
mSubtitleView.setText(R.string.rename_failure_name_conflict);
mErrorMessageView.setText(R.string.rename_failure_name_conflict);
break;
case RenameResult.FAILURE_NAME_TOO_LONG:
mSubtitleView.setText(R.string.rename_failure_name_too_long);
mErrorMessageView.setText(R.string.rename_failure_name_too_long);
break;
case RenameResult.FAILURE_NAME_INVALID:
mSubtitleView.setText(R.string.rename_failure_name_invalid);
mErrorMessageView.setText(R.string.rename_failure_name_invalid);
break;
case RenameResult.FAILURE_UNAVAILABLE:
mSubtitleView.setText(R.string.rename_failure_unavailable);
mErrorMessageView.setText(R.string.rename_failure_unavailable);
break;
default:
break;
......@@ -97,12 +97,9 @@ public class RenameDialogCustomView extends ScrollView {
* Initialize components in view: hide subtitle and reset value in the editTextBox.
*/
public void initializeView(String suggestedName) {
mSubtitleView.setVisibility(View.GONE);
if (!TextUtils.isEmpty(suggestedName)) {
mFileName.setText(suggestedName);
}
mFileName.clearFocus();
highlightEditText(suggestedName);
setEditText(suggestedName);
setEditTextStyle(false);
setErrorMessageVisibility(false);
}
/**
......@@ -147,4 +144,29 @@ public class RenameDialogCustomView extends ScrollView {
inputMethodManager.showSoftInput(mFileName, InputMethodManager.SHOW_FORCED);
}
}
private void setErrorMessageVisibility(boolean hasError) {
mErrorMessageView.setTextColor(
ApiCompatibilityUtils.getColor(getResources(), R.color.error_text_color));
mErrorMessageView.setVisibility(hasError ? View.VISIBLE : View.GONE);
}
private void setEditText(String suggestedName) {
if (!TextUtils.isEmpty(suggestedName)) {
mFileName.setText(suggestedName);
}
mFileName.clearFocus();
highlightEditText(suggestedName);
}
private void setEditTextStyle(boolean hasError) {
if (hasError) {
// Change the edit text box underline tint color.
mFileName.getBackground().setColorFilter(
ApiCompatibilityUtils.getColor(getResources(), R.color.default_red),
PorterDuff.Mode.SRC_IN);
} else {
mFileName.getBackground().clearColorFilter();
}
}
}
\ No newline at end of file
......@@ -1465,10 +1465,10 @@ Your Google account may have other forms of browsing history like searches and a
Rename unavailable
</message>
<message name="IDS_RENAME_EXTENSION_CONFIRMATION" desc="Subtitle for rename extension dialog in the case that user try to rename the file extension.">
Are you sure you want to change the file extension?
Change file extension?
</message>
<message name="IDS_RENAME_EXTENSION_MESSAGE" desc="Message to warn users the danger of changing file extension.">
Changing the file extension may result in unexpected behavior and be harmful to your device.
If you change the file extension, the file may open in a different application and potentially be a hazard to your device.
</message>
<!-- About Chrome preferences -->
......
7fac73dfe472bde49f7a300a818e3a1fe323ba92
\ No newline at end of file
7fac73dfe472bde49f7a300a818e3a1fe323ba92
\ No newline at end of file
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