Home | History | Annotate | Download | only in name
      1 /*
      2  * Copyright (C) 2015 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.name;
     18 
     19 import android.os.Build;
     20 import android.os.Bundle;
     21 import android.support.annotation.NonNull;
     22 import android.support.v17.leanback.app.GuidedStepFragment;
     23 import android.support.v17.leanback.widget.GuidanceStylist;
     24 import android.support.v17.leanback.widget.GuidedAction;
     25 
     26 import com.android.tv.settings.R;
     27 
     28 import java.util.List;
     29 
     30 public class DeviceNameSetCustomFragment extends GuidedStepFragment {
     31 
     32     public static DeviceNameSetCustomFragment newInstance() {
     33         return new DeviceNameSetCustomFragment();
     34     }
     35 
     36     @NonNull
     37     @Override
     38     public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) {
     39         return new GuidanceStylist.Guidance(
     40                 getString(R.string.select_device_name_title, Build.MODEL),
     41                 getString(R.string.select_device_name_description, Build.MODEL),
     42                 null,
     43                 null);
     44     }
     45 
     46     @Override
     47     public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
     48         actions.add(new GuidedAction.Builder()
     49                 .title(DeviceManager.getDeviceName(getActivity()))
     50                 .editable(true)
     51                 .build());
     52     }
     53 
     54     @Override
     55     public long onGuidedActionEditedAndProceed(GuidedAction action) {
     56         DeviceManager.setDeviceName(getActivity(), action.getTitle().toString());
     57         getActivity().finish();
     58         return super.onGuidedActionEditedAndProceed(action);
     59     }
     60 }
     61