Commit f2432a4c authored by Dominick Ng's avatar Dominick Ng Committed by Commit Bot

Rename members and variables in AddToHomescreenDialog.

This CL is a minor renaming CL with no functional changes.

This prepares for the introduction of a new use for the app layout:
app install banners for web and native apps.

BUG=811578

Change-Id: Iff4201d160cb93bb2881d24a2f24cadf7fcd94bc
Reviewed-on: https://chromium-review.googlesource.com/920125Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537913}
parent 271f2cfe
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="start" android:gravity="start"
style="@style/AlertDialogContent" > style="@style/AlertDialogContent" >
<!-- The icon that will be used on the home screen. -->
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="32dp" android:layout_width="32dp"
...@@ -13,11 +15,16 @@ ...@@ -13,11 +15,16 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:contentDescription="@null" android:contentDescription="@null"
android:visibility="gone" /> android:visibility="gone" />
<!-- A spinner used to indicate that data for the add to home screen
process is still being downloaded. -->
<ProgressBar <ProgressBar
android:id="@+id/spinny" android:id="@+id/spinny"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginTop="10dp" /> android:layout_marginTop="10dp" />
<!-- An editable text field for the name of the home screen icon. -->
<org.chromium.chrome.browser.widget.AlertDialogEditText <org.chromium.chrome.browser.widget.AlertDialogEditText
android:id="@+id/text" android:id="@+id/text"
android:inputType="text" android:inputType="text"
...@@ -28,8 +35,10 @@ ...@@ -28,8 +35,10 @@
android:paddingTop="0dp" android:paddingTop="0dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginStart="48dp" /> android:layout_marginStart="48dp" />
<!-- The layout used for apps. -->
<LinearLayout <LinearLayout
android:id="@+id/read_only_text" android:id="@+id/app_info"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -38,16 +47,22 @@ ...@@ -38,16 +47,22 @@
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:paddingTop="0dp" android:paddingTop="0dp"
android:visibility="gone" > android:visibility="gone" >
<!-- The name of the web app that will be used on the home screen. Not
editable as we preserve the developer's name choice for apps. -->
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/BlackTitle1" /> android:textAppearance="@style/BlackTitle1" />
<!-- The origin of the web app, displayed for security purposes. -->
<TextView <TextView
android:id="@+id/origin" android:id="@+id/origin"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="2dp" android:paddingBottom="2dp"
android:textAppearance="@style/BlackBody" /> android:textAppearance="@style/BlackBody" />
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
...@@ -32,7 +32,7 @@ import org.chromium.chrome.browser.banners.AppBannerManager; ...@@ -32,7 +32,7 @@ import org.chromium.chrome.browser.banners.AppBannerManager;
public class AddToHomescreenDialog { public class AddToHomescreenDialog {
/** /**
* The delegate for which this dialog is displayed. Used by the dialog to indicate when the user * The delegate for which this dialog is displayed. Used by the dialog to indicate when the user
* accedes to adding to home screen, and when the dialog is dismissedt gr. * accedes to adding to home screen, and when the dialog is dismissed.
*/ */
public static interface Delegate { public static interface Delegate {
/** /**
...@@ -51,11 +51,14 @@ public class AddToHomescreenDialog { ...@@ -51,11 +51,14 @@ public class AddToHomescreenDialog {
private ImageView mIconView; private ImageView mIconView;
/** /**
* The {@mShortcutTitleInput} and the {@mPwaLayout} are mutually exclusive, depending on * The {@mShortcutTitleInput} and the {@mAppLayout} are mutually exclusive, depending on whether
* whether the site is WebAPK compatible. * the home screen item is a bookmark shortcut or a web app.
*/ */
private EditText mShortcutTitleInput; private EditText mShortcutTitleInput;
private LinearLayout mPwaLayout; private LinearLayout mAppLayout;
private TextView mAppNameView;
private TextView mAppOriginView;
private Delegate mDelegate; private Delegate mDelegate;
...@@ -95,7 +98,10 @@ public class AddToHomescreenDialog { ...@@ -95,7 +98,10 @@ public class AddToHomescreenDialog {
mProgressBarView = view.findViewById(R.id.spinny); mProgressBarView = view.findViewById(R.id.spinny);
mIconView = (ImageView) view.findViewById(R.id.icon); mIconView = (ImageView) view.findViewById(R.id.icon);
mShortcutTitleInput = (EditText) view.findViewById(R.id.text); mShortcutTitleInput = (EditText) view.findViewById(R.id.text);
mPwaLayout = (LinearLayout) view.findViewById(R.id.read_only_text); mAppLayout = (LinearLayout) view.findViewById(R.id.app_info);
mAppNameView = (TextView) mAppLayout.findViewById(R.id.name);
mAppOriginView = (TextView) mAppLayout.findViewById(R.id.origin);
// The dialog's text field is disabled till the "user title" is fetched, // The dialog's text field is disabled till the "user title" is fetched,
mShortcutTitleInput.setVisibility(View.INVISIBLE); mShortcutTitleInput.setVisibility(View.INVISIBLE);
...@@ -161,21 +167,21 @@ public class AddToHomescreenDialog { ...@@ -161,21 +167,21 @@ public class AddToHomescreenDialog {
/** /**
* Called when the home screen icon title (and possibly information from the web manifest) is * Called when the home screen icon title (and possibly information from the web manifest) is
* available. * available. Used for web apps and bookmark shortcuts.
*/ */
public void onUserTitleAvailable(String title, String url, boolean isTitleEditable) { public void onUserTitleAvailable(String title, String url, boolean isWebapp) {
if (isTitleEditable) { // Users may edit the title of bookmark shortcuts, but we respect web app names and do not
mShortcutTitleInput.setText(title); // let users change them.
mShortcutTitleInput.setVisibility(View.VISIBLE); if (isWebapp) {
mShortcutTitleInput.setVisibility(View.GONE);
mAppNameView.setText(title);
mAppOriginView.setText(url);
mAppLayout.setVisibility(View.VISIBLE);
return; return;
} }
mShortcutTitleInput.setVisibility(View.GONE); mShortcutTitleInput.setText(title);
TextView nameView = (TextView) mPwaLayout.findViewById(R.id.name); mShortcutTitleInput.setVisibility(View.VISIBLE);
TextView originView = (TextView) mPwaLayout.findViewById(R.id.origin);
nameView.setText(title);
originView.setText(url);
mPwaLayout.setVisibility(View.VISIBLE);
} }
/** /**
...@@ -194,7 +200,7 @@ public class AddToHomescreenDialog { ...@@ -194,7 +200,7 @@ public class AddToHomescreenDialog {
void updateAddButtonEnabledState() { void updateAddButtonEnabledState() {
boolean enable = mHasIcon boolean enable = mHasIcon
&& (!TextUtils.isEmpty(mShortcutTitleInput.getText()) && (!TextUtils.isEmpty(mShortcutTitleInput.getText())
|| mPwaLayout.getVisibility() == View.VISIBLE); || mAppLayout.getVisibility() == View.VISIBLE);
mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enable); mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enable);
} }
} }
...@@ -80,8 +80,10 @@ public class AddToHomescreenManager implements AddToHomescreenDialog.Delegate { ...@@ -80,8 +80,10 @@ public class AddToHomescreenManager implements AddToHomescreenDialog.Delegate {
} }
@CalledByNative @CalledByNative
private void onUserTitleAvailable(String title, String url, boolean isTitleEditable) { private void onUserTitleAvailable(String title, String url, boolean isWebapp) {
mDialog.onUserTitleAvailable(title, url, isTitleEditable); // Users may edit the title of bookmark shortcuts, but we respect web app names and do not
// let users change them.
mDialog.onUserTitleAvailable(title, url, isWebapp);
} }
@CalledByNative @CalledByNative
......
...@@ -143,8 +143,7 @@ public class AddToHomescreenManagerTest { ...@@ -143,8 +143,7 @@ public class AddToHomescreenManagerTest {
public void showDialog() { public void showDialog() {
mDialog = new AddToHomescreenDialog(TestAddToHomescreenManager.this) { mDialog = new AddToHomescreenDialog(TestAddToHomescreenManager.this) {
@Override @Override
public void onUserTitleAvailable( public void onUserTitleAvailable(String title, String url, boolean isWebapp) {
String title, String url, boolean isTitleEditable) {
if (TextUtils.isEmpty(mTitle)) { if (TextUtils.isEmpty(mTitle)) {
mTitle = title; mTitle = title;
} }
......
...@@ -132,7 +132,7 @@ void AddToHomescreenManager::OnUserTitleAvailable( ...@@ -132,7 +132,7 @@ void AddToHomescreenManager::OnUserTitleAvailable(
url, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC)); url, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC));
Java_AddToHomescreenManager_onUserTitleAvailable( Java_AddToHomescreenManager_onUserTitleAvailable(
env, java_ref_, j_user_title, j_url, env, java_ref_, j_user_title, j_url,
!is_webapk_compatible_ /* isTitleEditable */); is_webapk_compatible_ /* isWebapp */);
} }
void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info, void AddToHomescreenManager::OnDataAvailable(const ShortcutInfo& info,
......
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