Merge "Add toggle to hide private space entry point in All Apps" into main

This commit is contained in:
Joseph Vincent
2023-10-25 21:17:01 +00:00
committed by Android (Google) Code Review
12 changed files with 392 additions and 15 deletions

View File

@@ -16,30 +16,41 @@
package com.android.settings.privatespace;
import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.core.TogglePreferenceController;
/** Represents the preference controller for (un)hiding the Private Space */
public final class HidePrivateSpaceController extends TogglePreferenceController {
public HidePrivateSpaceController(Context context, String preferenceKey) {
super(context, preferenceKey);
/**
* A class that is used to show details page for the setting to hide private space entry point
* in All Apps.
*/
public class HidePrivateSpaceController extends TogglePreferenceController {
private static final int DISABLED_VALUE = 0;
private static final int ENABLED_VALUE = 1;
public HidePrivateSpaceController(Context context, String key) {
super(context, key);
}
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public boolean isChecked() {
// TODO(b/293569406) Need to check this from a persistent store, maybe like SettingsProvider
return false;
return Settings.Secure.getInt(mContext.getContentResolver(),
HIDE_PRIVATESPACE_ENTRY_POINT, DISABLED_VALUE) != DISABLED_VALUE;
}
@Override
public boolean setChecked(boolean isChecked) {
// TODO(b/293569406) Need to save this to a persistent store, maybe like SettingsProvider
Settings.Secure.putInt(mContext.getContentResolver(), HIDE_PRIVATESPACE_ENTRY_POINT,
isChecked ? ENABLED_VALUE : DISABLED_VALUE);
return true;
}

View File

@@ -0,0 +1,41 @@
/*
* 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.app.settings.SettingsEnums;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
public class HidePrivateSpaceSettings extends DashboardFragment{
private static final String TAG = "HidePrivateSpaceSettings";
@Override
public int getMetricsCategory() {
return SettingsEnums.PRIVATE_SPACE_SETTINGS;
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.privatespace_hide_locked;
}
@Override
protected String getLogTag() {
return TAG;
}
}

View File

@@ -0,0 +1,57 @@
/*
* 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 static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
import android.content.Context;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
/**
* Represents the preference controller for (un)hiding Private Space entry point in All Apps and
* shows On/Off summary depending upon the settings provider value.
*/
public final class HidePrivateSpaceSummaryController extends BasePreferenceController {
public HidePrivateSpaceSummaryController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public int getSliceHighlightMenuRes() {
return 0;
}
@Override
public CharSequence getSummary() {
return isHidden() ? mContext.getString(R.string.privatespace_hide_on_summary)
: mContext.getString(R.string.privatespace_hide_off_summary);
}
private boolean isHidden() {
return Settings.Secure.getInt(mContext.getContentResolver(),
HIDE_PRIVATESPACE_ENTRY_POINT, 0) == 1;
}
}