Home | History | Annotate | Download | only in privacy
      1 /*
      2  * Copyright (C) 2014 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.tv.settings.device.privacy;
     18 
     19 import com.android.tv.settings.ActionBehavior;
     20 import com.android.tv.settings.ActionKey;
     21 import com.android.tv.settings.R;
     22 import com.android.tv.settings.dialog.old.Action;
     23 
     24 import android.content.res.Resources;
     25 
     26 enum ActionType {
     27     BACKUP_DATA(R.string.privacy_backup_data),
     28     BACKUP_ACCOUNT(R.string.privacy_backup_account),
     29     AUTOMATIC_RESTORE(R.string.privacy_automatic_restore),
     30     FACTORY_RESET(R.string.device_reset),
     31     FACTORY_RESET_CONFIRM(R.string.confirm_factory_reset_device);
     32 
     33 
     34     private final int mTitleResource;
     35 
     36     private ActionType(int titleResource) {
     37         mTitleResource = titleResource;
     38     }
     39 
     40     String getTitle(Resources resources) {
     41         return resources.getString(mTitleResource);
     42     }
     43 
     44     Action toAction(Resources resources) {
     45         return toAction(resources, null);
     46     }
     47 
     48     Action toAction(Resources resources, String description) {
     49         return new Action.Builder()
     50                 .key(getKey(this, ActionBehavior.INIT))
     51                 .title(getTitle(resources))
     52                 .description(description)
     53                 .build();
     54     }
     55 
     56     private String getKey(ActionType t, ActionBehavior b) {
     57         return new ActionKey<ActionType, ActionBehavior>(t, b).getKey();
     58     }
     59 }
     60