Home | History | Annotate | Download | only in backup
      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.backup;
     18 
     19 
     20 import android.content.Context;
     21 import android.content.Intent;
     22 import android.support.v7.preference.Preference;
     23 import android.support.v7.preference.PreferenceScreen;
     24 
     25 import com.android.settings.core.PreferenceController;
     26 
     27 public class BackupSettingsPreferenceController extends PreferenceController {
     28     private static final String BACKUP_SETTINGS = "backup_settings";
     29     private static final  String MANUFACTURER_SETTINGS = "manufacturer_backup";
     30     private Intent mBackupSettingsIntent;
     31     private String mBackupSettingsTitle;
     32     private String mBackupSettingsSummary;
     33     private Intent mManufacturerIntent;
     34     private String mManufacturerLabel;
     35 
     36     public BackupSettingsPreferenceController(Context context) {
     37         super(context);
     38         BackupSettingsHelper settingsHelper = new BackupSettingsHelper(context);
     39         mBackupSettingsIntent = settingsHelper.getIntentForBackupSettings();
     40         mBackupSettingsTitle = settingsHelper.getLabelForBackupSettings();
     41         mBackupSettingsSummary = settingsHelper.getSummaryForBackupSettings();
     42         mManufacturerIntent = settingsHelper.getIntentProvidedByManufacturer();
     43         mManufacturerLabel = settingsHelper.getLabelProvidedByManufacturer();
     44     }
     45 
     46     @Override
     47     public void displayPreference(PreferenceScreen screen) {
     48         Preference backupSettings = screen.findPreference(BACKUP_SETTINGS);
     49         Preference manufacturerSettings = screen.findPreference(MANUFACTURER_SETTINGS);
     50         backupSettings.setIntent(mBackupSettingsIntent);
     51         backupSettings.setTitle(mBackupSettingsTitle);
     52         backupSettings.setSummary(mBackupSettingsSummary);
     53         manufacturerSettings.setIntent(mManufacturerIntent);
     54         manufacturerSettings.setTitle(mManufacturerLabel);
     55     }
     56 
     57     /**
     58      * Returns true if preference is available (should be displayed)
     59      */
     60     @Override
     61     public boolean isAvailable() {
     62         return true;
     63     }
     64 
     65     /**
     66      * Returns the key for this preference.
     67      */
     68     @Override
     69     public String getPreferenceKey() {
     70         return null;
     71     }
     72 }
     73