blob: 5368cb3801c28979473b0f8663e3f52fb0f4b872 [file] [log] [blame]
Jackeagle3f6b7df2017-03-13 21:52:52 -04001/*
2* Copyright (C) 2015 BlissRoms 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
17package com.blissroms;
18
19import android.app.ActionBar;
20import android.app.Activity;
21import android.app.Fragment;
22import android.app.FragmentManager;
23import android.os.Bundle;
24import android.provider.Settings;
25import android.preference.Preference;
26import android.preference.PreferenceCategory;
27import android.preference.PreferenceManager;
28import android.preference.Preference.OnPreferenceChangeListener;
29import android.preference.PreferenceScreen;
30import android.support.v13.app.FragmentPagerAdapter;
31import android.support.v4.view.ViewPager;
32import android.view.LayoutInflater;
33import android.view.View;
34import android.view.ViewGroup;
35import com.android.settings.DeviceInfoSettings;
36import com.blissroms.blissify.PagerSlidingTabStrip;
37import com.android.settings.R;
38import com.android.settings.Utils;
39import com.android.settings.SettingsPreferenceFragment;
40
41import com.android.internal.logging.MetricsProto.MetricsEvent;
42
43import java.util.ArrayList;
44import java.util.List;
45
46public class About extends SettingsPreferenceFragment {
47
48 ViewPager mViewPager;
49 String titleString[];
50 ViewGroup mContainer;
51 PagerSlidingTabStrip mTabs;
52
53 static Bundle mSavedState;
54
55 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
56 mContainer = container;
57 final ActionBar actionBar = getActivity().getActionBar();
58
59 View view = inflater.inflate(R.layout.additional_settings, container, false);
60 mViewPager = (ViewPager) view.findViewById(R.id.pager);
61 mTabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
62
63 StatusBarAdapter StatusBarAdapter = new StatusBarAdapter(getFragmentManager());
64 mViewPager.setAdapter(StatusBarAdapter);
65
66 mTabs.setViewPager(mViewPager);
67 setHasOptionsMenu(true);
68 return view;
69 }
70
71 @Override
72 public void onActivityCreated(Bundle savedInstanceState) {
73 // After confirming PreferenceScreen is available, we call super.
74 super.onActivityCreated(savedInstanceState);
75 }
76
77 @Override
78 public void onSaveInstanceState(Bundle saveState) {
79 super.onSaveInstanceState(saveState);
80 }
81
82 @Override
83 public void onResume() {
84 super.onResume();
85 if (!Utils.isPhone(getActivity())) {
86 mContainer.setPadding(0, 0, 0, 0);
87 }
88 }
89
90 class StatusBarAdapter extends FragmentPagerAdapter {
91 String titles[] = getTitles();
92 private Fragment frags[] = new Fragment[titles.length];
93
94 public StatusBarAdapter(FragmentManager fm) {
95 super(fm);
96 frags[0] = new DeviceInfoSettings();
97 frags[1] = new AboutBliss();
98 }
99
100 @Override
101 public CharSequence getPageTitle(int position) {
102 return titles[position];
103 }
104
105 @Override
106 public Fragment getItem(int position) {
107 return frags[position];
108 }
109
110 @Override
111 public int getCount() {
112 return frags.length;
113 }
114 }
115
116 private String[] getTitles() {
117 String titleString[];
118 titleString = new String[]{
119 getString(R.string.about_settings),
120 getString(R.string.about_bliss_title)};
121 return titleString;
122 }
123
124 @Override
125 protected int getMetricsCategory() {
126 return MetricsEvent.ABOUT_BLISS;
127 }
128}