Commit ad1c576f authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Implement bottom button bar in SyncAndServicesPreferences

This CL implements bottom bar with "Cancel" and "Confirm" buttons in
SyncAndServicesPreferences. This bottom bar is only shown when the user
opens SyncAndServicesPreferences screen from the sign-in screen.

Bug: 914056
Change-Id: I3f5f2002ab7bcd566f3305fd2344a79069bb82fb
Reviewed-on: https://chromium-review.googlesource.com/c/1435276Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630098}
parent 465e778e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<!-- TODO(https://crbug.com/929743): Use standard layout and specify only bottom button here. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 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. -->
<merge
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/bottom_bar_shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/action_bar_shadow_height"
android:layout_marginTop="@dimen/action_bar_shadow_margin_negative"
android:background="@drawable/modern_toolbar_shadow"
android:scaleY="-1"
android:importantForAccessibility="no"/>
<LinearLayout
android:id="@+id/bottom_bar_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/cancel_button"
style="@style/TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="invisible"/>
<org.chromium.ui.widget.ButtonCompat
android:id="@+id/confirm_button"
style="@style/FilledButton.Flat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/confirm"/>
</LinearLayout>
</merge>
...@@ -524,6 +524,8 @@ ...@@ -524,6 +524,8 @@
<!-- Miscellaneous dimensions --> <!-- Miscellaneous dimensions -->
<dimen name="action_bar_shadow_height">10dp</dimen> <dimen name="action_bar_shadow_height">10dp</dimen>
<!-- Used as a margin to force the shadow view to overlap other views. -->
<dimen name="action_bar_shadow_margin_negative">-10dp</dimen>
<dimen name="clear_text_button_end_padding">10dp</dimen> <dimen name="clear_text_button_end_padding">10dp</dimen>
<dimen name="sync_promo_view_padding">16dp</dimen> <dimen name="sync_promo_view_padding">16dp</dimen>
<dimen name="open_new_tab_animation_y_translation">-20dp</dimen> <dimen name="open_new_tab_animation_y_translation">-20dp</dimen>
......
...@@ -21,9 +21,12 @@ import android.provider.Settings; ...@@ -21,9 +21,12 @@ import android.provider.Settings;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import org.chromium.base.BuildInfo; import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -51,6 +54,7 @@ import org.chromium.components.signin.ChromeSigninController; ...@@ -51,6 +54,7 @@ import org.chromium.components.signin.ChromeSigninController;
import org.chromium.components.sync.AndroidSyncSettings; import org.chromium.components.sync.AndroidSyncSettings;
import org.chromium.components.sync.ProtocolErrorClientAction; import org.chromium.components.sync.ProtocolErrorClientAction;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
import org.chromium.ui.widget.ButtonCompat;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -246,16 +250,42 @@ public class SyncAndServicesPreferences extends PreferenceFragment ...@@ -246,16 +250,42 @@ public class SyncAndServicesPreferences extends PreferenceFragment
return false; return false;
} }
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
ViewGroup result = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
if (mIsFromSigninScreen) {
inflater.inflate(R.layout.sync_and_services_bottom_bar, result, true);
ButtonCompat cancelButton = result.findViewById(R.id.cancel_button);
cancelButton.setOnClickListener(view -> cancelSync());
ButtonCompat confirmButton = result.findViewById(R.id.confirm_button);
confirmButton.setOnClickListener(view -> confirmSettings());
}
return result;
}
private void confirmSettings() {
// Settings will be applied when mSyncSetupInProgressHandle is released in onDestroy.
getActivity().finish();
}
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
mProfileSyncService.addSyncStateChangedListener(this); mProfileSyncService.addSyncStateChangedListener(this);
mSigninPreference.registerForUpdates(); mSigninPreference.registerForUpdates();
if (!ChromeSigninController.get().isSignedIn()) { if (!mIsFromSigninScreen || ChromeSigninController.get().isSignedIn()) {
// Don't show CancelSyncDialog. return;
mIsFromSigninScreen = false;
} }
// Don't show CancelSyncDialog and hide bottom bar.
mIsFromSigninScreen = false;
View bottomBarShadow = getView().findViewById(R.id.bottom_bar_shadow);
bottomBarShadow.setVisibility(View.GONE);
View bottomBarButtonContainer = getView().findViewById(R.id.bottom_bar_button_container);
bottomBarButtonContainer.setVisibility(View.GONE);
} }
@Override @Override
......
...@@ -251,6 +251,9 @@ CHAR-LIMIT guidelines: ...@@ -251,6 +251,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_BACK" desc="Label for a back button to return to a previous UI state or screen. Used in multiple contexts. [CHAR-LIMIT=20]"> <message name="IDS_BACK" desc="Label for a back button to return to a previous UI state or screen. Used in multiple contexts. [CHAR-LIMIT=20]">
Back Back
</message> </message>
<message name="IDS_CONFIRM" desc="Label for a confirm button. Used in multiple contexts. [CHAR-LIMIT=20]">
Confirm
</message>
<!-- Main Preferences --> <!-- Main Preferences -->
<message name="IDS_PREFERENCES" desc="Title for Chrome's Settings."> <message name="IDS_PREFERENCES" desc="Title for Chrome's Settings.">
......
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