• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.development;
18 
19 import android.content.Context;
20 import android.support.annotation.Nullable;
21 import android.support.v7.preference.Preference;
22 
23 import com.android.settings.core.PreferenceControllerMixin;
24 import com.android.settingslib.core.lifecycle.Lifecycle;
25 import com.android.settingslib.development.AbstractLogpersistPreferenceController;
26 
27 public class LogPersistPreferenceController extends AbstractLogpersistPreferenceController
28         implements PreferenceControllerMixin {
29 
30     private final DevelopmentSettingsDashboardFragment mFragment;
31 
LogPersistPreferenceController(Context context, DevelopmentSettingsDashboardFragment fragment, Lifecycle lifecycle)32     public LogPersistPreferenceController(Context context,
33             DevelopmentSettingsDashboardFragment fragment, Lifecycle lifecycle) {
34         super(context, lifecycle);
35 
36         mFragment = fragment;
37     }
38 
39     @Override
showConfirmationDialog(@ullable Preference preference)40     public void showConfirmationDialog(@Nullable Preference preference) {
41         DisableLogPersistWarningDialog.show(mFragment);
42     }
43 
44     @Override
dismissConfirmationDialog()45     public void dismissConfirmationDialog() {
46         // intentional no-op
47     }
48 
49     @Override
isConfirmationDialogShowing()50     public boolean isConfirmationDialogShowing() {
51         return false;
52     }
53 
54     @Override
updateState(Preference preference)55     public void updateState(Preference preference) {
56         updateLogpersistValues();
57     }
58 
59     @Override
onDeveloperOptionsSwitchDisabled()60     protected void onDeveloperOptionsSwitchDisabled() {
61         super.onDeveloperOptionsSwitchDisabled();
62         writeLogpersistOption(null /* new value */, true);
63     }
64 
onDisableLogPersistDialogConfirmed()65     public void onDisableLogPersistDialogConfirmed() {
66         setLogpersistOff(true);
67         updateLogpersistValues();
68     }
69 
onDisableLogPersistDialogRejected()70     public void onDisableLogPersistDialogRejected() {
71         updateLogpersistValues();
72     }
73 }
74