summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-10-17 19:10:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-10-17 19:10:29 +0000
commit47775667b84d6b6fdcec8f9ccbeff37053644cc0 (patch)
tree5f69860f0aae8253ff3b85c173906d7517a3320d /src
parent24ff765731b2fda6c8ea7ea3f2648849402f4e4d (diff)
parent1bde0d84b0dc189df3fcb8d0bceb5260805704ef (diff)
downloadpackages_apps_Settings-47775667b84d6b6fdcec8f9ccbeff37053644cc0.tar.gz
packages_apps_Settings-47775667b84d6b6fdcec8f9ccbeff37053644cc0.tar.bz2
packages_apps_Settings-47775667b84d6b6fdcec8f9ccbeff37053644cc0.zip
Merge "Add work-only-category controller"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/applications/DefaultAppSettings.java18
-rw-r--r--src/com/android/settings/applications/defaultapps/DefaultWorkBrowserPreferenceController.java3
-rw-r--r--src/com/android/settings/applications/defaultapps/DefaultWorkPhonePreferenceController.java3
-rw-r--r--src/com/android/settings/widget/WorkOnlyCategory.java (renamed from src/com/android/settings/WorkOnlyCategory.java)5
-rw-r--r--src/com/android/settings/widget/WorkOnlyCategoryPreferenceController.java57
5 files changed, 76 insertions, 10 deletions
diff --git a/src/com/android/settings/applications/DefaultAppSettings.java b/src/com/android/settings/applications/DefaultAppSettings.java
index bcbc91712a..1487da3092 100644
--- a/src/com/android/settings/applications/DefaultAppSettings.java
+++ b/src/com/android/settings/applications/DefaultAppSettings.java
@@ -26,11 +26,12 @@ import com.android.settings.applications.assist.DefaultAssistPreferenceControlle
import com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController;
import com.android.settings.applications.defaultapps.DefaultEmergencyPreferenceController;
import com.android.settings.applications.defaultapps.DefaultHomePreferenceController;
+import com.android.settings.applications.defaultapps.DefaultPaymentSettingsPreferenceController;
import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
import com.android.settings.applications.defaultapps.DefaultSmsPreferenceController;
import com.android.settings.applications.defaultapps.DefaultWorkBrowserPreferenceController;
+import com.android.settings.widget.WorkOnlyCategoryPreferenceController;
import com.android.settings.applications.defaultapps.DefaultWorkPhonePreferenceController;
-import com.android.settings.applications.defaultapps.DefaultPaymentSettingsPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -45,6 +46,7 @@ public class DefaultAppSettings extends DashboardFragment {
static final String TAG = "DefaultAppSettings";
+ private static final String KEY_DEFAULT_WORK_CATEGORY = "work_app_defaults";
private static final String KEY_ASSIST_VOICE_INPUT = "assist_and_voice_input";
@Override
@@ -69,12 +71,16 @@ public class DefaultAppSettings extends DashboardFragment {
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ final List<AbstractPreferenceController> workControllers = new ArrayList<>();
+ workControllers.add(new DefaultWorkPhonePreferenceController(context));
+ workControllers.add(new DefaultWorkBrowserPreferenceController(context));
+ controllers.addAll(workControllers);
+ controllers.add(new WorkOnlyCategoryPreferenceController(
+ context, KEY_DEFAULT_WORK_CATEGORY, workControllers));
controllers.add(new DefaultAssistPreferenceController(context, KEY_ASSIST_VOICE_INPUT,
false /* showSetting */));
controllers.add(new DefaultBrowserPreferenceController(context));
- controllers.add(new DefaultWorkBrowserPreferenceController(context));
controllers.add(new DefaultPhonePreferenceController(context));
- controllers.add(new DefaultWorkPhonePreferenceController(context));
controllers.add(new DefaultSmsPreferenceController(context));
controllers.add(new DefaultEmergencyPreferenceController(context));
controllers.add(new DefaultHomePreferenceController(context));
@@ -97,10 +103,8 @@ public class DefaultAppSettings extends DashboardFragment {
List<String> keys = super.getNonIndexableKeys(context);
keys.add(KEY_ASSIST_VOICE_INPUT);
// TODO (b/38230148) Remove these keys when we can differentiate work results
- keys.add((new DefaultWorkPhonePreferenceController(context))
- .getPreferenceKey());
- keys.add((new DefaultWorkBrowserPreferenceController(context))
- .getPreferenceKey());
+ keys.add(DefaultWorkPhonePreferenceController.KEY);
+ keys.add(DefaultWorkBrowserPreferenceController.KEY);
return keys;
}
diff --git a/src/com/android/settings/applications/defaultapps/DefaultWorkBrowserPreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultWorkBrowserPreferenceController.java
index 0792ff90a0..4dc984b8bc 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultWorkBrowserPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultWorkBrowserPreferenceController.java
@@ -23,6 +23,7 @@ import com.android.settings.Utils;
public class DefaultWorkBrowserPreferenceController extends DefaultBrowserPreferenceController {
+ public static final String KEY = "work_default_browser";
private final UserHandle mUserHandle;
public DefaultWorkBrowserPreferenceController(Context context) {
@@ -35,7 +36,7 @@ public class DefaultWorkBrowserPreferenceController extends DefaultBrowserPrefer
@Override
public String getPreferenceKey() {
- return "work_default_browser";
+ return KEY;
}
@Override
diff --git a/src/com/android/settings/applications/defaultapps/DefaultWorkPhonePreferenceController.java b/src/com/android/settings/applications/defaultapps/DefaultWorkPhonePreferenceController.java
index c6d04faed7..decff06759 100644
--- a/src/com/android/settings/applications/defaultapps/DefaultWorkPhonePreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/DefaultWorkPhonePreferenceController.java
@@ -23,6 +23,7 @@ import com.android.settings.Utils;
public class DefaultWorkPhonePreferenceController extends DefaultPhonePreferenceController {
+ public static final String KEY = "work_default_phone_app";
private final UserHandle mUserHandle;
public DefaultWorkPhonePreferenceController(Context context) {
@@ -43,6 +44,6 @@ public class DefaultWorkPhonePreferenceController extends DefaultPhonePreference
@Override
public String getPreferenceKey() {
- return "work_default_phone_app";
+ return KEY;
}
}
diff --git a/src/com/android/settings/WorkOnlyCategory.java b/src/com/android/settings/widget/WorkOnlyCategory.java
index ca4c82d7e9..53badb2221 100644
--- a/src/com/android/settings/WorkOnlyCategory.java
+++ b/src/com/android/settings/widget/WorkOnlyCategory.java
@@ -12,13 +12,16 @@
* permissions and limitations under the License.
*/
-package com.android.settings;
+package com.android.settings.widget;
import android.content.Context;
import android.os.UserManager;
import android.support.v7.preference.PreferenceCategory;
import android.util.AttributeSet;
+import com.android.settings.SelfAvailablePreference;
+import com.android.settings.Utils;
+
/**
* A PreferenceCategory that is only visible when the device has a work profile.
*/
diff --git a/src/com/android/settings/widget/WorkOnlyCategoryPreferenceController.java b/src/com/android/settings/widget/WorkOnlyCategoryPreferenceController.java
new file mode 100644
index 0000000000..a308b2f1b1
--- /dev/null
+++ b/src/com/android/settings/widget/WorkOnlyCategoryPreferenceController.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 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.widget;
+
+import android.content.Context;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import java.util.List;
+
+public class WorkOnlyCategoryPreferenceController extends AbstractPreferenceController
+ implements PreferenceControllerMixin {
+
+ private final String mKey;
+ private final List<AbstractPreferenceController> mChildren;
+
+ public WorkOnlyCategoryPreferenceController(Context context,
+ String key, List<AbstractPreferenceController> childrenControllers) {
+ super(context);
+ mKey = key;
+ mChildren = childrenControllers;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ if (mChildren == null || mChildren.isEmpty()) {
+ return true;
+ }
+ // Category is available if any child is available
+ for (AbstractPreferenceController controller : mChildren) {
+ if (controller.isAvailable()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return mKey;
+ }
+}