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 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="start"
style="@style/AlertDialogContent" >
<!-- The icon that will be used on the home screen. -->
<ImageView
android:id="@+id/icon"
android:layout_width="32dp"
......@@ -13,11 +15,16 @@
android:layout_marginTop="10dp"
android:contentDescription="@null"
android:visibility="gone" />
<!-- A spinner used to indicate that data for the add to home screen
process is still being downloaded. -->
<ProgressBar
android:id="@+id/spinny"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginTop="10dp" />
<!-- An editable text field for the name of the home screen icon. -->
<org.chromium.chrome.browser.widget.AlertDialogEditText
android:id="@+id/text"
android:inputType="text"
......@@ -28,8 +35,10 @@
android:paddingTop="0dp"
android:layout_marginTop="10dp"
android:layout_marginStart="48dp" />
<!-- The layout used for apps. -->
<LinearLayout
android:id="@+id/read_only_text"
android:id="@+id/app_info"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -38,16 +47,22 @@
android:layout_marginBottom="5dp"
android:paddingTop="0dp"
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
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/BlackTitle1" />
<!-- The origin of the web app, displayed for security purposes. -->
<TextView
android:id="@+id/origin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:textAppearance="@style/BlackBody" />
</LinearLayout>
</FrameLayout>
......@@ -32,7 +32,7 @@ import org.chromium.chrome.browser.banners.AppBannerManager;
public class AddToHomescreenDialog {
/**
* 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 {
/**
......@@ -51,11 +51,14 @@ public class AddToHomescreenDialog {
private ImageView mIconView;
/**
* The {@mShortcutTitleInput} and the {@mPwaLayout} are mutually exclusive, depending on
* whether the site is WebAPK compatible.
* The {@mShortcutTitleInput} and the {@mAppLayout} are mutually exclusive, depending on whether
* the home screen item is a bookmark shortcut or a web app.
*/
private EditText mShortcutTitleInput;
private LinearLayout mPwaLayout;
private LinearLayout mAppLayout;
private TextView mAppNameView;
private TextView mAppOriginView;
private Delegate mDelegate;
......@@ -95,7 +98,10 @@ public class AddToHomescreenDialog {
mProgressBarView = view.findViewById(R.id.spinny);
mIconView = (ImageView) view.findViewById(R.id.icon);
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,
mShortcutTitleInput.setVisibility(View.INVISIBLE);
......@@ -161,21 +167,21 @@ public class AddToHomescreenDialog {
/**
* 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) {
if (isTitleEditable) {
mShortcutTitleInput.setText(title);
mShortcutTitleInput.setVisibility(View.VISIBLE);
public void onUserTitleAvailable(String title, String url, boolean isWebapp) {
// Users may edit the title of bookmark shortcuts, but we respect web app names and do not
// let users change them.
if (isWebapp) {
mShortcutTitleInput.setVisibility(View.GONE);
mAppNameView.setText(title);
mAppOriginView.setText(url);
mAppLayout.setVisibility(View.VISIBLE);
return;
}
mShortcutTitleInput.setVisibility(View.GONE);
TextView nameView = (TextView) mPwaLayout.findViewById(R.id.name);
TextView originView = (TextView) mPwaLayout.findViewById(R.id.origin);
nameView.setText(title);
originView.setText(url);
mPwaLayout.setVisibility(View.VISIBLE);
mShortcutTitleInput.setText(title);
mShortcutTitleInput.setVisibility(View.VISIBLE);
}
/**
......@@ -194,7 +200,7 @@ public class AddToHomescreenDialog {
void updateAddButtonEnabledState() {
boolean enable = mHasIcon
&& (!TextUtils.isEmpty(mShortcutTitleInput.getText())
|| mPwaLayout.getVisibility() == View.VISIBLE);
|| mAppLayout.getVisibility() == View.VISIBLE);
mDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enable);
}
}
......@@ -80,8 +80,10 @@ public class AddToHomescreenManager implements AddToHomescreenDialog.Delegate {
}
@CalledByNative
private void onUserTitleAvailable(String title, String url, boolean isTitleEditable) {
mDialog.onUserTitleAvailable(title, url, isTitleEditable);
private void onUserTitleAvailable(String title, String url, boolean isWebapp) {
// 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
......
......@@ -143,8 +143,7 @@ public class AddToHomescreenManagerTest {
public void showDialog() {
mDialog = new AddToHomescreenDialog(TestAddToHomescreenManager.this) {
@Override
public void onUserTitleAvailable(
String title, String url, boolean isTitleEditable) {
public void onUserTitleAvailable(String title, String url, boolean isWebapp) {
if (TextUtils.isEmpty(mTitle)) {
mTitle = title;
}
......
......@@ -132,7 +132,7 @@ void AddToHomescreenManager::OnUserTitleAvailable(
url, url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC));
Java_AddToHomescreenManager_onUserTitleAvailable(
env, java_ref_, j_user_title, j_url,
!is_webapk_compatible_ /* isTitleEditable */);
is_webapk_compatible_ /* isWebapp */);
}
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