blob: 5368cb3801c28979473b0f8663e3f52fb0f4b872 [file] [log] [blame]
/*
* Copyright (C) 2015 BlissRoms Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.blissroms;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.provider.Settings;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceScreen;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.settings.DeviceInfoSettings;
import com.blissroms.blissify.PagerSlidingTabStrip;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.SettingsPreferenceFragment;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import java.util.ArrayList;
import java.util.List;
public class About extends SettingsPreferenceFragment {
ViewPager mViewPager;
String titleString[];
ViewGroup mContainer;
PagerSlidingTabStrip mTabs;
static Bundle mSavedState;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContainer = container;
final ActionBar actionBar = getActivity().getActionBar();
View view = inflater.inflate(R.layout.additional_settings, container, false);
mViewPager = (ViewPager) view.findViewById(R.id.pager);
mTabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
StatusBarAdapter StatusBarAdapter = new StatusBarAdapter(getFragmentManager());
mViewPager.setAdapter(StatusBarAdapter);
mTabs.setViewPager(mViewPager);
setHasOptionsMenu(true);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// After confirming PreferenceScreen is available, we call super.
super.onActivityCreated(savedInstanceState);
}
@Override
public void onSaveInstanceState(Bundle saveState) {
super.onSaveInstanceState(saveState);
}
@Override
public void onResume() {
super.onResume();
if (!Utils.isPhone(getActivity())) {
mContainer.setPadding(0, 0, 0, 0);
}
}
class StatusBarAdapter extends FragmentPagerAdapter {
String titles[] = getTitles();
private Fragment frags[] = new Fragment[titles.length];
public StatusBarAdapter(FragmentManager fm) {
super(fm);
frags[0] = new DeviceInfoSettings();
frags[1] = new AboutBliss();
}
@Override
public CharSequence getPageTitle(int position) {
return titles[position];
}
@Override
public Fragment getItem(int position) {
return frags[position];
}
@Override
public int getCount() {
return frags.length;
}
}
private String[] getTitles() {
String titleString[];
titleString = new String[]{
getString(R.string.about_settings),
getString(R.string.about_bliss_title)};
return titleString;
}
@Override
protected int getMetricsCategory() {
return MetricsEvent.ABOUT_BLISS;
}
}