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

Commit 402385c6 authored by Manish Singh's avatar Manish Singh Committed by Android (Google) Code Review
Browse files

Merge "Remove CreatePrivateSpace entry from Private Space settings" into main

parents c01677b6 499eab13
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -1228,16 +1228,8 @@
    <string name="privatespace_hide_on_summary">On</string>
    <!-- System category for the Private Space page. [CHAR LIMIT=30] -->
    <string name="private_space_category_system">System</string>
    <!-- Title for the preference to create Private Space. [CHAR LIMIT=60] -->
    <string name="private_space_create_title">Create Private Space</string>
    <!-- Title for the preference to delete Private Space. [CHAR LIMIT=60] -->
    <string name="private_space_delete_title">Delete Private Space</string>
    <!-- Toast to show when the private space was created. [CHAR LIMIT=NONE] -->
    <string name="private_space_created">Private Space successfully created</string>
    <!-- Toast to show when the private space already exists. [CHAR LIMIT=NONE] -->
    <string name="private_space_already_exists">Private Space already exists</string>
    <!-- Toast to show when the private space could not be created. [CHAR LIMIT=NONE] -->
    <string name="private_space_create_failed">Private Space could not be created</string>
    <!-- Toast to show when the private space was deleted. [CHAR LIMIT=NONE] -->
    <string name="private_space_deleted">Private Space successfully deleted</string>
    <!-- Toast to show when the private space could not be deleted. [CHAR LIMIT=NONE] -->
+0 −6
Original line number Diff line number Diff line
@@ -43,12 +43,6 @@
    <PreferenceCategory
        android:title="@string/private_space_category_system">

        <Preference
            android:key="private_space_create"
            android:title="@string/private_space_create_title"
            settings:controller="com.android.settings.privatespace.CreatePrivateSpaceController"
            settings:searchable="false" />

        <Preference
            android:key="private_space_delete"
            android:title="@string/private_space_delete_title"
+0 −74
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.privatespace;

import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;

import androidx.preference.Preference;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

// TODO(b/293569406): Remove this when we have the setup flow in place to create PS
/**
 * Temp Controller to create the private space from the PS Settings page. This is to allow PM, UX,
 * and other folks to play around with PS before the PS setup flow is ready.
 */
public final class CreatePrivateSpaceController extends BasePreferenceController {

    public CreatePrivateSpaceController(Context context, String preferenceKey) {
        super(context, preferenceKey);
    }

    @Override
    public int getAvailabilityStatus() {
        return AVAILABLE;
    }

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
            return false;
        }

        if (PrivateSpaceMaintainer.getInstance(mContext).doesPrivateSpaceExist()) {
            showPrivateSpaceAlreadyExistsToast();
            return super.handlePreferenceTreeClick(preference);
        }

        if (PrivateSpaceMaintainer.getInstance(mContext).createPrivateSpace()) {
            showPrivateSpaceCreatedToast();
        } else {
            showPrivateSpaceCreationFailedToast();
        }
        return super.handlePreferenceTreeClick(preference);
    }

    private void showPrivateSpaceCreatedToast() {
        Toast.makeText(mContext, R.string.private_space_created, Toast.LENGTH_SHORT).show();
    }

    private void showPrivateSpaceCreationFailedToast() {
        Toast.makeText(mContext, R.string.private_space_create_failed, Toast.LENGTH_SHORT).show();
    }

    private void showPrivateSpaceAlreadyExistsToast() {
        Toast.makeText(mContext, R.string.private_space_already_exists, Toast.LENGTH_SHORT).show();
    }
}
+0 −31
Original line number Diff line number Diff line
@@ -17,25 +17,13 @@
package com.android.settings.privatespace;

import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Flags;

import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.safetycenter.SafetyCenterManagerWrapper;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;

import java.util.List;

/** Fragment representing the Private Space dashboard in Settings. */
@SearchIndexable
public class PrivateSpaceDashboardFragment extends DashboardFragment {
    private static final String TAG = "PrivateSpaceDashboardFragment";
    private static final String KEY_CREATE_PROFILE_PREFERENCE = "private_space_create";
    private static final String KEY_DELETE_PROFILE_PREFERENCE = "private_space_delete";
    private static final String KEY_ONE_LOCK_PREFERENCE = "private_space_use_one_lock";
    private static final String KEY_PS_HIDDEN_PREFERENCE = "private_space_hidden";

    @Override
    protected int getPreferenceScreenResId() {
@@ -51,23 +39,4 @@ public class PrivateSpaceDashboardFragment extends DashboardFragment {
    protected String getLogTag() {
        return TAG;
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider(R.xml.private_space_settings) {
                @Override
                protected boolean isPageSearchEnabled(Context context) {
                    return SafetyCenterManagerWrapper.get().isEnabled(context)
                            && Flags.allowPrivateProfile();
                }

                @Override
                public List<String> getNonIndexableKeys(Context context) {
                    List<String> keys = super.getNonIndexableKeys(context);
                    keys.add(KEY_CREATE_PROFILE_PREFERENCE);
                    keys.add(KEY_DELETE_PROFILE_PREFERENCE);
                    keys.add(KEY_ONE_LOCK_PREFERENCE);
                    keys.add(KEY_PS_HIDDEN_PREFERENCE);
                    return keys;
                }
            };
}