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

[Unity][Android] Fix Settings link in sign-in and consent bump screens

This CL changes "Settings" link in the sign-in and consent bump screens
to point to SyncAndServicesPreferences instead of
AccountManagementFragment. It also links Chrome sync notification to
SyncAndServicesPreferences if UnifiedConsent feature is enabled.

Bug: 872812
Change-Id: Ie36788228cad14de9b82edfbd0e6bf1d1d9e295d
Reviewed-on: https://chromium-review.googlesource.com/1172973
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584401}
parent 94c87940
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.firstrun; package org.chromium.chrome.browser.firstrun;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils; import android.text.TextUtils;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
...@@ -13,8 +12,10 @@ import org.chromium.base.CommandLine; ...@@ -13,8 +12,10 @@ import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.SyncAndServicesPreferences;
import org.chromium.chrome.browser.signin.AccountManagementFragment; import org.chromium.chrome.browser.signin.AccountManagementFragment;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
import org.chromium.chrome.browser.signin.SigninManager.SignInCallback; import org.chromium.chrome.browser.signin.SigninManager.SignInCallback;
...@@ -105,9 +106,13 @@ public final class FirstRunSignInProcessor { ...@@ -105,9 +106,13 @@ public final class FirstRunSignInProcessor {
* Opens sign in settings as requested in the FRE sign-in dialog. * Opens sign in settings as requested in the FRE sign-in dialog.
*/ */
private static void openSignInSettings(Activity activity) { private static void openSignInSettings(Activity activity) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( final String fragmentName;
activity, AccountManagementFragment.class.getName()); if (ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)) {
activity.startActivity(intent); fragmentName = SyncAndServicesPreferences.class.getName();
} else {
fragmentName = AccountManagementFragment.class.getName();
}
PreferencesLauncher.launchSettingsPage(activity, fragmentName);
} }
/** /**
......
...@@ -12,6 +12,8 @@ import android.support.v4.app.FragmentTransaction; ...@@ -12,6 +12,8 @@ import android.support.v4.app.FragmentTransaction;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.SyncAndServicesPreferences;
/** /**
* This fragment implements the consent bump screen. This is a variation of the sign-in screen that * This fragment implements the consent bump screen. This is a variation of the sign-in screen that
...@@ -52,7 +54,12 @@ public class ConsentBumpFragment extends SigninFragmentBase { ...@@ -52,7 +54,12 @@ public class ConsentBumpFragment extends SigninFragmentBase {
protected void onSigninAccepted(String accountName, boolean isDefaultAccount, protected void onSigninAccepted(String accountName, boolean isDefaultAccount,
boolean settingsClicked, Runnable callback) { boolean settingsClicked, Runnable callback) {
// TODO(https://crbug.com/869426): Save the consent state. // TODO(https://crbug.com/869426): Save the consent state.
if (settingsClicked) {
PreferencesLauncher.launchSettingsPage(
getActivity(), SyncAndServicesPreferences.class.getName());
}
getActivity().finish(); getActivity().finish();
callback.run();
} }
@Override @Override
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.signin; package org.chromium.chrome.browser.signin;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
...@@ -14,6 +13,7 @@ import org.chromium.base.metrics.RecordUserAction; ...@@ -14,6 +13,7 @@ import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.SyncAndServicesPreferences;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -135,9 +135,8 @@ public class SigninFragment extends SigninFragmentBase { ...@@ -135,9 +135,8 @@ public class SigninFragment extends SigninFragmentBase {
@Override @Override
public void onSignInComplete() { public void onSignInComplete() {
if (settingsClicked) { if (settingsClicked) {
Intent intent = PreferencesLauncher.createIntentForSettingsPage( PreferencesLauncher.launchSettingsPage(
getActivity(), AccountManagementFragment.class.getName()); getActivity(), SyncAndServicesPreferences.class.getName());
startActivity(intent);
} }
recordSigninCompletedHistogramAccountInfo(); recordSigninCompletedHistogramAccountInfo();
......
...@@ -20,9 +20,7 @@ import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator; ...@@ -20,9 +20,7 @@ import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory; import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.invalidation.InvalidationController; import org.chromium.chrome.browser.invalidation.InvalidationController;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.AccountManagementFragment;
import org.chromium.chrome.browser.signin.SigninManager; import org.chromium.chrome.browser.signin.SigninManager;
import org.chromium.chrome.browser.sync.ui.PassphraseActivity;
import org.chromium.components.signin.ChromeSigninController; import org.chromium.components.signin.ChromeSigninController;
import org.chromium.components.sync.AndroidSyncSettings; import org.chromium.components.sync.AndroidSyncSettings;
import org.chromium.components.sync.ModelType; import org.chromium.components.sync.ModelType;
...@@ -86,8 +84,7 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen ...@@ -86,8 +84,7 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen
setSessionsId(); setSessionsId();
// Create the SyncNotificationController. // Create the SyncNotificationController.
mSyncNotificationController = new SyncNotificationController( mSyncNotificationController = new SyncNotificationController();
PassphraseActivity.class, AccountManagementFragment.class);
mProfileSyncService.addSyncStateChangedListener(mSyncNotificationController); mProfileSyncService.addSyncStateChangedListener(mSyncNotificationController);
updateSyncStateFromAndroid(); updateSyncStateFromAndroid();
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
package org.chromium.chrome.browser.sync; package org.chromium.chrome.browser.sync;
import android.app.Activity;
import android.app.Fragment;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
...@@ -17,6 +15,7 @@ import android.util.Log; ...@@ -17,6 +15,7 @@ import android.util.Log;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder; import org.chromium.chrome.browser.notifications.ChromeNotificationBuilder;
import org.chromium.chrome.browser.notifications.NotificationBuilderFactory; import org.chromium.chrome.browser.notifications.NotificationBuilderFactory;
import org.chromium.chrome.browser.notifications.NotificationConstants; import org.chromium.chrome.browser.notifications.NotificationConstants;
...@@ -25,7 +24,10 @@ import org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl; ...@@ -25,7 +24,10 @@ import org.chromium.chrome.browser.notifications.NotificationManagerProxyImpl;
import org.chromium.chrome.browser.notifications.NotificationUmaTracker; import org.chromium.chrome.browser.notifications.NotificationUmaTracker;
import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions; import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
import org.chromium.chrome.browser.preferences.PreferencesLauncher; import org.chromium.chrome.browser.preferences.PreferencesLauncher;
import org.chromium.chrome.browser.preferences.SyncAndServicesPreferences;
import org.chromium.chrome.browser.signin.AccountManagementFragment;
import org.chromium.chrome.browser.sync.GoogleServiceAuthError.State; import org.chromium.chrome.browser.sync.GoogleServiceAuthError.State;
import org.chromium.chrome.browser.sync.ui.PassphraseActivity;
import org.chromium.components.sync.AndroidSyncSettings; import org.chromium.components.sync.AndroidSyncSettings;
/** /**
...@@ -35,19 +37,14 @@ import org.chromium.components.sync.AndroidSyncSettings; ...@@ -35,19 +37,14 @@ import org.chromium.components.sync.AndroidSyncSettings;
public class SyncNotificationController implements ProfileSyncService.SyncStateChangedListener { public class SyncNotificationController implements ProfileSyncService.SyncStateChangedListener {
private static final String TAG = "SyncNotificationController"; private static final String TAG = "SyncNotificationController";
private final NotificationManagerProxy mNotificationManager; private final NotificationManagerProxy mNotificationManager;
private final Class<? extends Activity> mPassphraseRequestActivity;
private final Class<? extends Fragment> mAccountManagementFragment;
private final ProfileSyncService mProfileSyncService; private final ProfileSyncService mProfileSyncService;
public SyncNotificationController(Class<? extends Activity> passphraseRequestActivity, public SyncNotificationController() {
Class<? extends Fragment> accountManagementFragment) {
mNotificationManager = new NotificationManagerProxyImpl( mNotificationManager = new NotificationManagerProxyImpl(
(NotificationManager) ContextUtils.getApplicationContext().getSystemService( (NotificationManager) ContextUtils.getApplicationContext().getSystemService(
Context.NOTIFICATION_SERVICE)); Context.NOTIFICATION_SERVICE));
mProfileSyncService = ProfileSyncService.get(); mProfileSyncService = ProfileSyncService.get();
assert mProfileSyncService != null; assert mProfileSyncService != null;
mPassphraseRequestActivity = passphraseRequestActivity;
mAccountManagementFragment = accountManagementFragment;
} }
/** /**
...@@ -151,8 +148,14 @@ public class SyncNotificationController implements ProfileSyncService.SyncStateC ...@@ -151,8 +148,14 @@ public class SyncNotificationController implements ProfileSyncService.SyncStateC
* @return the intent for opening the settings * @return the intent for opening the settings
*/ */
private Intent createSettingsIntent() { private Intent createSettingsIntent() {
return PreferencesLauncher.createIntentForSettingsPage(ContextUtils.getApplicationContext(), final String fragmentName;
mAccountManagementFragment.getCanonicalName()); if (ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)) {
fragmentName = SyncAndServicesPreferences.class.getName();
} else {
fragmentName = AccountManagementFragment.class.getName();
}
return PreferencesLauncher.createIntentForSettingsPage(
ContextUtils.getApplicationContext(), fragmentName);
} }
/** /**
...@@ -165,8 +168,8 @@ public class SyncNotificationController implements ProfileSyncService.SyncStateC ...@@ -165,8 +168,8 @@ public class SyncNotificationController implements ProfileSyncService.SyncStateC
mProfileSyncService.setPassphrasePrompted(true); mProfileSyncService.setPassphrasePrompted(true);
Intent intent = new Intent(Intent.ACTION_MAIN); Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName( intent.setComponent(
ContextUtils.getApplicationContext(), mPassphraseRequestActivity)); new ComponentName(ContextUtils.getApplicationContext(), PassphraseActivity.class));
intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.addCategory(Intent.CATEGORY_LAUNCHER);
// This activity will become the start of a new task on this history stack. // This activity will become the start of a new task on this history stack.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
......
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