blob: 10b6d12b15ac84e408b83d8327163c17b1653b4b [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;
starkdroid113e0c42017-01-18 20:23:38 +053037import com.blissroms.about.AboutBliss;
Jackeagle3f6b7df2017-03-13 21:52:52 -040038import com.android.settings.R;
39import com.android.settings.Utils;
40import com.android.settings.SettingsPreferenceFragment;
41
42import com.android.internal.logging.MetricsProto.MetricsEvent;
43
44import java.util.ArrayList;
45import java.util.List;
46
starkdroid113e0c42017-01-18 20:23:38 +053047public class BlissInfoSettings extends SettingsPreferenceFragment {
Jackeagle3f6b7df2017-03-13 21:52:52 -040048
49 ViewPager mViewPager;
50 String titleString[];
51 ViewGroup mContainer;
52 PagerSlidingTabStrip mTabs;
53
54 static Bundle mSavedState;
55
56 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
57 mContainer = container;
58 final ActionBar actionBar = getActivity().getActionBar();
59
starkdroid113e0c42017-01-18 20:23:38 +053060 View view = inflater.inflate(R.layout.blissify_ui, container, false);
Jackeagle3f6b7df2017-03-13 21:52:52 -040061 mViewPager = (ViewPager) view.findViewById(R.id.pager);
62 mTabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
63
64 StatusBarAdapter StatusBarAdapter = new StatusBarAdapter(getFragmentManager());
65 mViewPager.setAdapter(StatusBarAdapter);
66
67 mTabs.setViewPager(mViewPager);
68 setHasOptionsMenu(true);
69 return view;
70 }
71
72 @Override
73 public void onActivityCreated(Bundle savedInstanceState) {
74 // After confirming PreferenceScreen is available, we call super.
75 super.onActivityCreated(savedInstanceState);
76 }
77
78 @Override
79 public void onSaveInstanceState(Bundle saveState) {
80 super.onSaveInstanceState(saveState);
81 }
82
83 @Override
84 public void onResume() {
85 super.onResume();
86 if (!Utils.isPhone(getActivity())) {
87 mContainer.setPadding(0, 0, 0, 0);
88 }
89 }
90
91 class StatusBarAdapter extends FragmentPagerAdapter {
92 String titles[] = getTitles();
93 private Fragment frags[] = new Fragment[titles.length];
94
95 public StatusBarAdapter(FragmentManager fm) {
96 super(fm);
97 frags[0] = new DeviceInfoSettings();
98 frags[1] = new AboutBliss();
99 }
100
101 @Override
102 public CharSequence getPageTitle(int position) {
103 return titles[position];
104 }
105
106 @Override
107 public Fragment getItem(int position) {
108 return frags[position];
109 }
110
111 @Override
112 public int getCount() {
113 return frags.length;
114 }
115 }
116
117 private String[] getTitles() {
118 String titleString[];
119 titleString = new String[]{
starkdroid113e0c42017-01-18 20:23:38 +0530120 getString(R.string.about_phone_title),
Jackeagle3f6b7df2017-03-13 21:52:52 -0400121 getString(R.string.about_bliss_title)};
122 return titleString;
123 }
124
125 @Override
126 protected int getMetricsCategory() {
127 return MetricsEvent.ABOUT_BLISS;
128 }
129}