From ee1a83994c279d846ba36a42c6d3b86fcf4a4538 Mon Sep 17 00:00:00 2001 From: nebkat Date: Sat, 10 Nov 2012 10:36:07 +0000 Subject: Initial commit --- DeviceSettings/Android.mk | 15 ++ DeviceSettings/AndroidManifest.xml | 31 ++++ .../res/drawable/ic_launcher_cmdevicesettings.png | Bin 0 -> 8207 bytes DeviceSettings/res/layout/top.xml | 5 + DeviceSettings/res/values-de/arrays.xml | 56 +++++++ DeviceSettings/res/values-de/strings.xml | 34 +++++ DeviceSettings/res/values-es/arrays.xml | 48 ++++++ DeviceSettings/res/values-es/strings.xml | 28 ++++ DeviceSettings/res/values-hu/arrays.xml | 56 +++++++ DeviceSettings/res/values-hu/strings.xml | 34 +++++ DeviceSettings/res/values-pt-rBR/arrays.xml | 55 +++++++ DeviceSettings/res/values-pt-rBR/strings.xml | 28 ++++ DeviceSettings/res/values-ru/arrays.xml | 54 +++++++ DeviceSettings/res/values-ru/strings.xml | 34 +++++ DeviceSettings/res/values-zh-rCN/arrays.xml | 56 +++++++ DeviceSettings/res/values-zh-rCN/strings.xml | 33 ++++ DeviceSettings/res/values/arrays.xml | 109 ++++++++++++++ DeviceSettings/res/values/strings.xml | 34 +++++ DeviceSettings/res/xml/haptic_preferences.xml | 13 ++ DeviceSettings/res/xml/radio_preferences.xml | 12 ++ DeviceSettings/res/xml/screen_preferences.xml | 65 ++++++++ .../settings/device/DeviceSettings.java | 166 +++++++++++++++++++++ .../settings/device/HapticFragmentActivity.java | 66 ++++++++ .../src/com/cyanogenmod/settings/device/Hspa.java | 67 +++++++++ .../com/cyanogenmod/settings/device/LedFade.java | 59 ++++++++ .../settings/device/RadioFragmentActivity.java | 66 ++++++++ .../settings/device/ScreenFragmentActivity.java | 102 +++++++++++++ .../com/cyanogenmod/settings/device/Startup.java | 38 +++++ .../settings/device/TouchkeyTimeout.java | 59 ++++++++ .../src/com/cyanogenmod/settings/device/Utils.java | 143 ++++++++++++++++++ .../settings/device/VibratorIntensity.java | 59 ++++++++ .../com/cyanogenmod/settings/device/mDNIeMode.java | 59 ++++++++ .../cyanogenmod/settings/device/mDNIeNegative.java | 59 ++++++++ .../cyanogenmod/settings/device/mDNIeScenario.java | 59 ++++++++ 34 files changed, 1802 insertions(+) create mode 100644 DeviceSettings/Android.mk create mode 100644 DeviceSettings/AndroidManifest.xml create mode 100755 DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png create mode 100755 DeviceSettings/res/layout/top.xml create mode 100644 DeviceSettings/res/values-de/arrays.xml create mode 100644 DeviceSettings/res/values-de/strings.xml create mode 100644 DeviceSettings/res/values-es/arrays.xml create mode 100644 DeviceSettings/res/values-es/strings.xml create mode 100644 DeviceSettings/res/values-hu/arrays.xml create mode 100644 DeviceSettings/res/values-hu/strings.xml create mode 100755 DeviceSettings/res/values-pt-rBR/arrays.xml create mode 100755 DeviceSettings/res/values-pt-rBR/strings.xml create mode 100644 DeviceSettings/res/values-ru/arrays.xml create mode 100644 DeviceSettings/res/values-ru/strings.xml create mode 100644 DeviceSettings/res/values-zh-rCN/arrays.xml create mode 100644 DeviceSettings/res/values-zh-rCN/strings.xml create mode 100644 DeviceSettings/res/values/arrays.xml create mode 100644 DeviceSettings/res/values/strings.xml create mode 100644 DeviceSettings/res/xml/haptic_preferences.xml create mode 100644 DeviceSettings/res/xml/radio_preferences.xml create mode 100644 DeviceSettings/res/xml/screen_preferences.xml create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/LedFade.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/ScreenFragmentActivity.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeMode.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeNegative.java create mode 100644 DeviceSettings/src/com/cyanogenmod/settings/device/mDNIeScenario.java (limited to 'DeviceSettings') diff --git a/DeviceSettings/Android.mk b/DeviceSettings/Android.mk new file mode 100644 index 0000000..12c8de5 --- /dev/null +++ b/DeviceSettings/Android.mk @@ -0,0 +1,15 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13 + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := GalaxyS3Settings +LOCAL_CERTIFICATE := platform + +include $(BUILD_PACKAGE) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/DeviceSettings/AndroidManifest.xml b/DeviceSettings/AndroidManifest.xml new file mode 100644 index 0000000..d373ded --- /dev/null +++ b/DeviceSettings/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png new file mode 100755 index 0000000..66de9c3 Binary files /dev/null and b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png differ diff --git a/DeviceSettings/res/layout/top.xml b/DeviceSettings/res/layout/top.xml new file mode 100755 index 0000000..744b568 --- /dev/null +++ b/DeviceSettings/res/layout/top.xml @@ -0,0 +1,5 @@ + + diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml new file mode 100644 index 0000000..9edf346 --- /dev/null +++ b/DeviceSettings/res/values-de/arrays.xml @@ -0,0 +1,56 @@ + + + + 0% + 25% + 50% (Standard) + 75% + 100% + + + + Nur UMTS + Nur HSDPA + HSDPA + HSUPA + + + + CyanogenMod (Standard) + UI + Video + Video warm + Video kalt + Kamera + Navigation + Gallerie + VT + + + + Dynamisch (Standard) + Standard + Natürlich + Film + + + + Normal + Invertiert + + + + Blinken + Verblassen + + + + Niemals + 1 Sekunde + 2 Sekunden + 3 Sekunden (Standard) + 4 Sekunden + 5 Sekunden + 6 Sekunden + + + diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml new file mode 100644 index 0000000..50c66a6 --- /dev/null +++ b/DeviceSettings/res/values-de/strings.xml @@ -0,0 +1,34 @@ + + + Galaxy S III Einstellungen + + Haptik + Vibrator + Vibrator Intensität + Wähle Vibrator Intensität + + Mobilfunk + HSPA + Aktiviere HSDPA/HSUPA + + Display + Farben + Szenario + Wähle das mDNIe Szenario + Modus + Wähle den mDNIe Modus + Negativ Modus + Invertiere Farben + + Benachrichtigungslicht + Modus + Wähle zwischen sanftem Verblassen und Blinken + + Touchkeys + Beleuchtung + Aktiviere Beleuchtung + Deaktiviere Beleuchtung + Zeitabschaltung der Beleuchtung + Setze Zeit für automatische Abschaltung + + diff --git a/DeviceSettings/res/values-es/arrays.xml b/DeviceSettings/res/values-es/arrays.xml new file mode 100644 index 0000000..fd55bc4 --- /dev/null +++ b/DeviceSettings/res/values-es/arrays.xml @@ -0,0 +1,48 @@ + + + 0% + 25% + 50% (por defecto) + 75% + 100% + + + Solo UMTS + Solo HSDPA + HSDPA + HSUPA + + + CyanogenMod (por defecto) + UI + Vídeo + Vídeo cálido + Vídeo frío + Camara + Navegación + Galería + VT + + + Estándar (por defecto) + Dinámico + Natural + Película + + + Normal + Invertido + + + Parpadeo + Fundido + + + Nunca + 1 segundo + 2 segundos + 3 segundos (por defecto) + 4 segundos + 5 segundos + 6 segundos + + diff --git a/DeviceSettings/res/values-es/strings.xml b/DeviceSettings/res/values-es/strings.xml new file mode 100644 index 0000000..50674d3 --- /dev/null +++ b/DeviceSettings/res/values-es/strings.xml @@ -0,0 +1,28 @@ + + + "Ajustes Galaxy S III" + "Háptica" + "Vibración" + "Intensidad de vibración" + "Establecer la intensidad de vibración" + "Radio" + "HSPA" + "Habilitar HSDPA/HSUPA" + "Pantalla" + "Colores" + "Escenario" + "Establecer escenario mDNIe" + "Modo" + "Establecer modo mDNIe" + "Modo negativo" + "Habilitar/deshabilitar colores invertidos" + "Notificación LED" + "Fundido LED" + "Habilitar fundido suave en vez de parpadeo intenso" + "Teclas táctiles" + "Retroiluminación" + "Habilitar retroiluminación" + "Deshabilitar retroiluminación" + "Tiempo de espera de retroiluminación" + "Tiempo tras pulsar una tecla antes de apagar la retroiluminación" + diff --git a/DeviceSettings/res/values-hu/arrays.xml b/DeviceSettings/res/values-hu/arrays.xml new file mode 100644 index 0000000..824296d --- /dev/null +++ b/DeviceSettings/res/values-hu/arrays.xml @@ -0,0 +1,56 @@ + + + + 0% + 25% + 50% (Alapbeállítás) + 75% + 100% + + + + UMTS + HSDPA + HSDPA + HSUPA + + + + CyanogenMod (Alapbeállítás) + Felhasználói felület + Videó + Videó (Meleg árnyalat) + Videó (Hideg árnyalat) + Kamera + Navigáció + Galéria + VT + + + + Dinamikus (Alapbeállítás) + Hagyományos + Természetes + Film + + + + Normál + Fordított + + + + Villogás + Elhalványulás + + + + Soha + 1 másodperc + 2 másodperc + 3 másodperc (Alapbeállítás) + 4 másodperc + 5 másodperc + 6 másodperc + + + diff --git a/DeviceSettings/res/values-hu/strings.xml b/DeviceSettings/res/values-hu/strings.xml new file mode 100644 index 0000000..aecbf59 --- /dev/null +++ b/DeviceSettings/res/values-hu/strings.xml @@ -0,0 +1,34 @@ + + + Galaxy S III Beállítások + + Érintési visszajelzés + Rezgés + Rezgés erőssége + Rezgés erősségének beállítása + + GSM Rádió + HSPA + HSDPA/HSUPA engedélyezése + + Kijelző + Színek + Megjelenítés + mDNIe megjelenítési beállítások + Üzemmód + mDNIe üzemmódok + Negatív üzemmód + Fordított színek ki/be + + LED értesítés + LED halványítás + LED elhalványítása villogtatás helyett + + Érintőgombok + Háttérvilágítás + Háttérvilágítás engedélyezése + Háttérvilágítás tiltása + Háttérvilágítás időkorlátja + Háttérvilágítás késleltetése + + diff --git a/DeviceSettings/res/values-pt-rBR/arrays.xml b/DeviceSettings/res/values-pt-rBR/arrays.xml new file mode 100755 index 0000000..7ade7ea --- /dev/null +++ b/DeviceSettings/res/values-pt-rBR/arrays.xml @@ -0,0 +1,55 @@ + + + + 0% + 25% + 50% (Padrão) + 75% + 100% + + + + Somente UMTS + Somente HSDPA + HSDPA + HSUPA + + + + CyanogenMod (Padrão) + IU + Vídeo + Vídeo Quente + Vídeo Frio + Câmera + Navegação + Galeria + VT + + + + Padrão + Dinâmico + Natural + Filme + + + + Normal + Invertido + + + + Piscando + Desvanecimento + + + + Nunca + 1 segundo + 2 segundos + 3 segundos (Padrão) + 4 segundos + 5 segundos + 6 segundos + + diff --git a/DeviceSettings/res/values-pt-rBR/strings.xml b/DeviceSettings/res/values-pt-rBR/strings.xml new file mode 100755 index 0000000..668c59c --- /dev/null +++ b/DeviceSettings/res/values-pt-rBR/strings.xml @@ -0,0 +1,28 @@ + + + Config. Galaxy S III + Resposta Tátil + Vibração + Intensidade da Vibração + Define a intensidade da vibração + Rádio + Ativar HSDPA/HSUPA + Tela + Cores + Cenário + Define o Cenário mDNIe + Modo + Define o Modo mDNIe + Modo Negativo + Ativar/Desativar cores invertidas + Notificação com LED + Desvanecimento LED + Ativar desvanecimento suave do LED em vez de piscar. + Teclas sensíveis ao toque + Luz de fundo + Ativar luz de fundo + Desativar luz de fundo + Tempo limite da luz de fundo + Define o tempo limite para a luz de fundo + HSPA + \ No newline at end of file diff --git a/DeviceSettings/res/values-ru/arrays.xml b/DeviceSettings/res/values-ru/arrays.xml new file mode 100644 index 0000000..ed61b6e --- /dev/null +++ b/DeviceSettings/res/values-ru/arrays.xml @@ -0,0 +1,54 @@ + + + + 0% + 25% + 50% (По умолч.) + 75% + 100% + + + + Только UMTS + Только HSDPA + HSDPA + HSUPA + + + + CyanogenMod (По умолч.) + Видео + Видео (тёпл.) + Видео (хол.) + Камера + Навигация + Галерея + VT + + + + Динамический (По умолч.) + Стандартный + Натуральный + Кино + + + + Нормально + Инверсия + + + + Мигание + Затухание + + + + Никогда + 1 секунда + 2 секунды + 3 секунды (По умолч.) + 4 секунды + 5 секунд + 6 секунд + + diff --git a/DeviceSettings/res/values-ru/strings.xml b/DeviceSettings/res/values-ru/strings.xml new file mode 100644 index 0000000..d6d44b8 --- /dev/null +++ b/DeviceSettings/res/values-ru/strings.xml @@ -0,0 +1,34 @@ + + + Настройки Galaxy S III + + Отклик + Вибрация + Интенсивность вибрации + Установка интенсивности вибрации + + Модем + HSPA + Включить HSDPA/HSUPA + + Экран + Цвета + Сценарий + Установка сценария mDNIe + Режим + Установка режима mDNIe + Негатив + Вкл./выкл. инверсии цветов + + Индикатор событий + Режим + Плавное затухание или резкое мигание + + Сенсорные клавиши + Подсветка + Подсветка включена + Подсветка выключена + Тайм-аут подсветки + Установка тайм-аута подсветки + + diff --git a/DeviceSettings/res/values-zh-rCN/arrays.xml b/DeviceSettings/res/values-zh-rCN/arrays.xml new file mode 100644 index 0000000..3fe1780 --- /dev/null +++ b/DeviceSettings/res/values-zh-rCN/arrays.xml @@ -0,0 +1,56 @@ + + + + 0% + 25% + 50% (默认) + 75% + 100% + + + + 仅使用 UMTS + 仅使用 HSDPA + 使用 HSDPA + HSUPA + + + + CyanogenMod (默认) + 界面 + 影片 + 影片 (温) + 影片 (冷) + 相机 + 导航 + 图库 + VT + + + + 动态 (默认) + 标准 + 自然 + 电影 + + + + 正常 + 反色 + + + + 闪烁 + 淡出 + + + + 从不 + 1 秒 + 2 秒 + 3 秒 (默认) + 4 秒 + 5 秒 + 6 秒 + + + diff --git a/DeviceSettings/res/values-zh-rCN/strings.xml b/DeviceSettings/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000..17451bd --- /dev/null +++ b/DeviceSettings/res/values-zh-rCN/strings.xml @@ -0,0 +1,33 @@ + + + Galaxy S III 设置 + + 振动 + 振动器 + 振动器强度 + 设置振动器强度 + + 无线电 + HSPA + 启用 HSDPA/HSUPA + + 屏幕 + 颜色 + 场景 + 设置 mDNIe 场景 + 模式 + 设置 mDNIe 模式 + 负极模式 + 启用/禁用反色 + + LED 指示灯 + LED 淡出 + 启用后 LED 指示灯将会产生淡出效果而替代闪烁效果. + + 触摸键 + 背光灯 + 启用背光灯 + 禁用背光灯 + 背光灯超时 + 设置背光灯超时时间 + diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml new file mode 100644 index 0000000..d82ffbc --- /dev/null +++ b/DeviceSettings/res/values/arrays.xml @@ -0,0 +1,109 @@ + + + + 0% + 25% + 50% (Default) + 75% + 100% + + + + 0 + 25 + 50 + 75 + 100 + + + + UMTS Only + HSDPA Only + HSDPA + HSUPA + + + + 21 + 22 + 23 + + + + CyanogenMod (Default) + UI + Video + Video Warm + Video Cold + Camera + Navigation + Gallery + VT + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + + + + Dynamic (Default) + Standard + Natural + Movie + + + + 0 + 1 + 2 + 3 + + + + Normal + Inverted + + + + 0 + 1 + + + + Blinking + Fading + + + + 0 + 1 + + + + Never + 1 second + 2 seconds + 3 seconds (Default) + 4 seconds + 5 seconds + 6 seconds + + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + + + diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml new file mode 100644 index 0000000..e842ae4 --- /dev/null +++ b/DeviceSettings/res/values/strings.xml @@ -0,0 +1,34 @@ + + + Galaxy S III Settings + + Haptic + Vibrator + Vibrator Intensity + Set vibrator intensity + + Radio + HSPA + Enable HSDPA/HSUPA + + Screen + Colors + Scenario + Set the mDNIe Scenario + Mode + Set the mDNIe Mode + Negative Mode + Enable/Disable inverted colors + + Notification LED + LED Fading + Enable LED smooth fading instead of sharp blinking. + + Touchkeys + Backlight + Enable backlight + Disable backlight + Backlight timeout + Set timeout for the backlight + + diff --git a/DeviceSettings/res/xml/haptic_preferences.xml b/DeviceSettings/res/xml/haptic_preferences.xml new file mode 100644 index 0000000..31c0e21 --- /dev/null +++ b/DeviceSettings/res/xml/haptic_preferences.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/DeviceSettings/res/xml/radio_preferences.xml b/DeviceSettings/res/xml/radio_preferences.xml new file mode 100644 index 0000000..c173db7 --- /dev/null +++ b/DeviceSettings/res/xml/radio_preferences.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/DeviceSettings/res/xml/screen_preferences.xml b/DeviceSettings/res/xml/screen_preferences.xml new file mode 100644 index 0000000..aff39c0 --- /dev/null +++ b/DeviceSettings/res/xml/screen_preferences.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java new file mode 100644 index 0000000..152e361 --- /dev/null +++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2012 The CyanogenMod 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.cyanogenmod.settings.device; + +import android.app.ActionBar; +import android.app.ActionBar.Tab; +import android.app.Activity; +import android.app.Fragment; +import android.app.FragmentTransaction; +import android.content.Context; +import android.os.Bundle; +import android.support.v4.app.FragmentActivity; +import android.support.v13.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.MenuItem; + +import com.cyanogenmod.settings.device.R; + +import java.util.ArrayList; + +public class DeviceSettings extends FragmentActivity { + + public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device"; + public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE"; + public static final String KEY_HSPA = "hspa"; + public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity"; + public static final String KEY_MDNIE_SCENARIO = "mdnie_scenario"; + public static final String KEY_MDNIE_MODE = "mdnie_mode"; + public static final String KEY_MDNIE_NEGATIVE = "mdnie_negative"; + public static final String KEY_LED_FADE = "led_fade"; + public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light"; + public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout"; + + ViewPager mViewPager; + TabsAdapter mTabsAdapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mViewPager = new ViewPager(this); + mViewPager.setId(R.id.viewPager); + setContentView(mViewPager); + + final ActionBar bar = getActionBar(); + bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); + bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); + bar.setTitle(R.string.app_name); + bar.setDisplayHomeAsUpEnabled(true); + + mTabsAdapter = new TabsAdapter(this, mViewPager); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_radio_title), + RadioFragmentActivity.class, null); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_screen_title), + ScreenFragmentActivity.class, null); + mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title), + HapticFragmentActivity.class, null); + + + if (savedInstanceState != null) { + bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putInt("tab", getActionBar().getSelectedNavigationIndex()); + } + + public static class TabsAdapter extends FragmentPagerAdapter + implements ActionBar.TabListener, ViewPager.OnPageChangeListener { + private final Context mContext; + private final ActionBar mActionBar; + private final ViewPager mViewPager; + private final ArrayList mTabs = new ArrayList(); + + static final class TabInfo { + private final Class clss; + private final Bundle args; + + TabInfo(Class _class, Bundle _args) { + clss = _class; + args = _args; + } + } + + public TabsAdapter(Activity activity, ViewPager pager) { + super(activity.getFragmentManager()); + mContext = activity; + mActionBar = activity.getActionBar(); + mViewPager = pager; + mViewPager.setAdapter(this); + mViewPager.setOnPageChangeListener(this); + } + + public void addTab(ActionBar.Tab tab, Class clss, Bundle args) { + TabInfo info = new TabInfo(clss, args); + tab.setTag(info); + tab.setTabListener(this); + mTabs.add(info); + mActionBar.addTab(tab); + notifyDataSetChanged(); + } + + @Override + public int getCount() { + return mTabs.size(); + } + + @Override + public Fragment getItem(int position) { + TabInfo info = mTabs.get(position); + return Fragment.instantiate(mContext, info.clss.getName(), info.args); + } + + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + } + + public void onPageSelected(int position) { + mActionBar.setSelectedNavigationItem(position); + } + + public void onPageScrollStateChanged(int state) { + } + + public void onTabSelected(Tab tab, FragmentTransaction ft) { + Object tag = tab.getTag(); + for (int i=0; i