Merge "Fix UI issue in LocationSettings"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2e2532077d
@@ -13,6 +13,8 @@
|
||||
*/
|
||||
package com.android.settings.core;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER_ID;
|
||||
|
||||
import static com.android.settings.dashboard.DashboardFragment.CATEGORY;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
@@ -20,6 +22,7 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
@@ -204,7 +207,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
* The status is used for the convenience methods: {@link #isAvailable()},
|
||||
* {@link #isSupported()}
|
||||
* </p>
|
||||
* The inherited class doesn't need to check work profile is existed or not if
|
||||
* The inherited class doesn't need to check work profile if
|
||||
* android:forWork="true" is set in preference xml.
|
||||
*/
|
||||
@AvailabilityStatus
|
||||
@@ -337,6 +340,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
if (!mIsForWork || mWorkProfileUser == null) {
|
||||
return super.handlePreferenceTreeClick(preference);
|
||||
}
|
||||
final Bundle extra = preference.getExtras();
|
||||
extra.putInt(EXTRA_USER_ID, mWorkProfileUser.getIdentifier());
|
||||
new SubSettingLauncher(preference.getContext())
|
||||
.setDestination(preference.getFragment())
|
||||
.setSourceMetricsCategory(preference.getExtras().getInt(CATEGORY,
|
||||
|
40
src/com/android/settings/core/WorkPreferenceController.java
Normal file
40
src/com/android/settings/core/WorkPreferenceController.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.core;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
|
||||
/**
|
||||
* Base class to be used directly in Xml with settings:forWork="true" attribute.
|
||||
* It is used specifically for work profile only preference
|
||||
*/
|
||||
public class WorkPreferenceController extends BasePreferenceController {
|
||||
|
||||
public WorkPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only available when work profile user is existed
|
||||
*/
|
||||
@CallSuper
|
||||
public int getAvailabilityStatus() {
|
||||
return getWorkProfileUser() != null ? AVAILABLE : DISABLED_FOR_USER;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user