Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99b22304 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Migrate more places to subsetting launcher"

parents 32876ff6 47854c29
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wfd.WifiDisplaySettings;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.instrumentation.SharedPreferencesLogger;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.drawer.DashboardCategory;
@@ -558,36 +557,16 @@ public class SettingsActivity extends SettingsDrawerActivity
    /**
     * Called by a preference panel fragment to finish itself.
     *
     * @param caller     The fragment that is asking to be finished.
     * @param resultCode Optional result code to send back to the original
     *                   launching fragment.
     * @param resultData Optional result data to send back to the original
     *                   launching fragment.
     */
    public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
    public void finishPreferencePanel(int resultCode, Intent resultData) {
        setResult(resultCode, resultData);
        finish();
    }

    /**
     * Start a new fragment.
     *
     * @param fragment The fragment to start
     * @param push     If true, the current fragment will be pushed onto the back stack.  If false,
     *                 the current fragment will be replaced.
     */
    public void startPreferenceFragment(Fragment fragment, boolean push) {
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.main_content, fragment);
        if (push) {
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            transaction.addToBackStack(BACK_STACK_PREFS);
        } else {
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        }
        transaction.commitAllowingStateLoss();
    }

    /**
     * Switch to a specific Fragment with taking care of validation, Title and BackStack
     */
+0 −65
Original line number Diff line number Diff line
@@ -388,71 +388,6 @@ public final class Utils extends com.android.settingslib.Utils {
                .getUsers().size() > 1;
    }

    /**
     * Start a new instance of the activity, showing only the given fragment.
     * When launched in this mode, the given preference fragment will be instantiated and fill the
     * entire activity.
     *
     * @param context The context.
     * @param fragmentName The name of the fragment to display.
     * @param args Optional arguments to supply to the fragment.
     * @param resultTo Option fragment that should receive the result of the activity launch.
     * @param resultRequestCode If resultTo is non-null, this is the request code in which
     *                          to report the result.
     * @param titleResId resource id for the String to display for the title of this set
     *                   of preferences.
     * @param title String to display for the title of this set of preferences.
     * @param metricsCategory The current metricsCategory for logging source when fragment starts
     */
    public static void startWithFragment(Context context, String fragmentName, Bundle args,
            Fragment resultTo, int resultRequestCode, int titleResId,
            CharSequence title, int metricsCategory) {
        startWithFragment(context, fragmentName, args, resultTo, resultRequestCode,
                null /* titleResPackageName */, titleResId, title, false /* not a shortcut */,
                metricsCategory);
    }

    /**
     * Start a new instance of the activity, showing only the given fragment.
     * When launched in this mode, the given preference fragment will be instantiated and fill the
     * entire activity.
     *
     * @param context The context.
     * @param fragmentName The name of the fragment to display.
     * @param args Optional arguments to supply to the fragment.
     * @param resultTo Option fragment that should receive the result of the activity launch.
     * @param resultRequestCode If resultTo is non-null, this is the request code in which
     *                          to report the result.
     * @param titleResId resource id for the String to display for the title of this set
     *                   of preferences.
     * @param title String to display for the title of this set of preferences.
     * @param metricsCategory The current metricsCategory for logging source when fragment starts
     */
    public static void startWithFragment(Context context, String fragmentName, Bundle args,
            Fragment resultTo, int resultRequestCode, int titleResId,
            CharSequence title, boolean isShortcut, int metricsCategory) {
        Intent intent = onBuildStartFragmentIntent(context, fragmentName, args,
                null /* titleResPackageName */, titleResId, title, isShortcut, metricsCategory);
        if (resultTo == null) {
            context.startActivity(intent);
        } else {
            resultTo.getActivity().startActivityForResult(intent, resultRequestCode);
        }
    }

    public static void startWithFragment(Context context, String fragmentName, Bundle args,
            Fragment resultTo, int resultRequestCode, String titleResPackageName, int titleResId,
            CharSequence title, boolean isShortcut, int metricsCategory) {
        Intent intent = onBuildStartFragmentIntent(context, fragmentName, args, titleResPackageName,
                titleResId, title, isShortcut, metricsCategory);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (resultTo == null) {
            context.startActivity(intent);
        } else {
            resultTo.startActivityForResult(intent, resultRequestCode);
        }
    }

    /**
     * Build an Intent to launch a new activity showing the selected fragment.
     * The implementation constructs an Intent that re-launches the current activity with the
+7 −5
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ import android.support.v7.preference.PreferenceScreen;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.accounts.AuthenticatorHelper;
import com.android.settingslib.core.AbstractPreferenceController;

@@ -43,7 +43,6 @@ public class AccountSyncPreferenceController extends AbstractPreferenceControlle

    private Account mAccount;
    private UserHandle mUserHandle;
    private AuthenticatorHelper mAuthenticatorHelper;
    private Preference mPreference;

    public AccountSyncPreferenceController(Context context) {
@@ -63,8 +62,12 @@ public class AccountSyncPreferenceController extends AbstractPreferenceControlle
        final Bundle args = new Bundle();
        args.putParcelable(AccountSyncSettings.ACCOUNT_KEY, mAccount);
        args.putParcelable(EXTRA_USER, mUserHandle);
        Utils.startWithFragment(mContext, AccountSyncSettings.class.getName(), args, null, 0,
                R.string.account_sync_title, null, MetricsProto.MetricsEvent.ACCOUNT);
        new SubSettingLauncher(mContext)
                .setDestination(AccountSyncSettings.class.getName())
                .setArguments(args)
                .setSourceMetricsCategory( MetricsProto.MetricsEvent.ACCOUNT)
                .setTitle( R.string.account_sync_title)
                .launch();

        return true;
    }
@@ -93,7 +96,6 @@ public class AccountSyncPreferenceController extends AbstractPreferenceControlle
    public void init(Account account, UserHandle userHandle) {
        mAccount = account;
        mUserHandle = userHandle;
        mAuthenticatorHelper = new AuthenticatorHelper(mContext, mUserHandle, this);
    }

    @VisibleForTesting
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
        Intent intent = new Intent();
        intent.putExtra(ManageApplications.APP_CHG, appChanged);
        SettingsActivity sa = (SettingsActivity)getActivity();
        sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
        sa.finishPreferencePanel(Activity.RESULT_OK, intent);
        mFinishing = true;
    }

+0 −54
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package com.android.settings.applications;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.Preference;

import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.applications.appinfo.DefaultAppShortcutPreferenceControllerBase;

/**
 * deprecated in favor of {@link DefaultAppShortcutPreferenceControllerBase}
 */
@Deprecated
public class ShortcutPreference extends Preference {

    private final Class mTarget;
    private final String mPrefKey;
    private final int mTitle;

    public ShortcutPreference(Context context, Class target, String prefKey, int prefTitle,
            int title) {
        super(context);
        mTarget = target;
        mPrefKey = prefKey;
        mTitle = title;
        setTitle(prefTitle);
        setKey(mPrefKey);
    }

    @Override
    public void performClick() {
        super.performClick();
        Bundle bundle = new Bundle();
        bundle.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, mPrefKey);
        Utils.startWithFragment(getContext(), mTarget.getName(), bundle, null, 0,
                mTitle, null, MetricsProto.MetricsEvent.VIEW_UNKNOWN);
    }
}
Loading