1 /*
2  * Copyright (C) 2018 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.notification.zen;
18 
19 import android.app.AutomaticZenRule;
20 import android.content.Context;
21 import android.os.Bundle;
22 
23 import com.android.settings.core.PreferenceControllerMixin;
24 import com.android.settingslib.core.lifecycle.Lifecycle;
25 
26 abstract class AbstractZenCustomRulePreferenceController extends
27         AbstractZenModePreferenceController implements PreferenceControllerMixin {
28 
29     String mId;
30     AutomaticZenRule mRule;
31 
AbstractZenCustomRulePreferenceController(Context context, String key, Lifecycle lifecycle)32     AbstractZenCustomRulePreferenceController(Context context, String key,
33             Lifecycle lifecycle) {
34         super(context, key, lifecycle);
35     }
36 
37     @Override
isAvailable()38     public boolean isAvailable() {
39         return mRule != null;
40     }
41 
setIdAndRule(String id, AutomaticZenRule rule)42     public void setIdAndRule(String id, AutomaticZenRule rule) {
43         mId = id;
44         mRule = rule;
45     }
46 
onResume()47     public void onResume() {
48     }
49 
createBundle()50     Bundle createBundle() {
51         Bundle bundle = new Bundle();
52         bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);
53         return bundle;
54     }
55 }
56