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