summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml2
-rw-r--r--res/anim/component_selection_animate_in.xml7
-rw-r--r--res/anim/component_selection_animate_out.xml7
-rw-r--r--res/drawable-xxhdpi/bg_graygrid.pngbin0 -> 61916 bytes
-rw-r--r--res/drawable-xxhdpi/btn_customize.pngbin0 -> 427 bytes
-rw-r--r--res/drawable-xxhdpi/btn_theme_store.pngbin0 -> 2101 bytes
-rw-r--r--res/drawable-xxhdpi/btn_wallpaper.pngbin0 -> 4455 bytes
-rw-r--r--res/drawable/bg_grid.xml6
-rw-r--r--res/drawable/component_selection_selector.xml7
-rw-r--r--res/drawable/wallpaper_border.xml8
-rw-r--r--res/layout/bootani_component_selection_item.xml22
-rw-r--r--res/layout/component_divider.xml8
-rw-r--r--res/layout/component_selection_pager_item.xml8
-rw-r--r--res/layout/component_selector.xml40
-rw-r--r--res/layout/font_component_selection_item.xml31
-rw-r--r--res/layout/icon_component_selection_item.xml31
-rw-r--r--res/layout/navigation_bar_component_selection_item.xml45
-rw-r--r--res/layout/status_bar_component_selection_item.xml69
-rw-r--r--res/layout/v2_activity_main.xml128
-rw-r--r--res/layout/wallpaper_component_selection_item.xml32
-rw-r--r--res/values/attrs.xml4
-rw-r--r--res/values/colors.xml5
-rw-r--r--res/values/dimens.xml22
-rw-r--r--res/values/integers.xml5
-rw-r--r--res/values/strings.xml5
-rw-r--r--res/values/styles.xml24
-rw-r--r--src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java75
-rw-r--r--src/org/cyanogenmod/theme/chooserv2/ComponentSelector.java586
28 files changed, 1072 insertions, 105 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ab24b3b..92cd060 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -43,7 +43,7 @@
<activity android:name="org.cyanogenmod.theme.chooserv2.ChooserActivity"
android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+ android:theme="@style/ThemeChooserV2Theme"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
diff --git a/res/anim/component_selection_animate_in.xml b/res/anim/component_selection_animate_in.xml
new file mode 100644
index 0000000..81e8fd9
--- /dev/null
+++ b/res/anim/component_selection_animate_in.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/decelerate_interpolator"
+ android:fromYDelta="100%p"
+ android:toYDelta="0%p"
+ android:duration="300" />
diff --git a/res/anim/component_selection_animate_out.xml b/res/anim/component_selection_animate_out.xml
new file mode 100644
index 0000000..1b2443d
--- /dev/null
+++ b/res/anim/component_selection_animate_out.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<translate xmlns:android="http://schemas.android.com/apk/res/android"
+ android:interpolator="@android:anim/accelerate_interpolator"
+ android:fromYDelta="0%p"
+ android:toYDelta="100%p"
+ android:duration="300" />
diff --git a/res/drawable-xxhdpi/bg_graygrid.png b/res/drawable-xxhdpi/bg_graygrid.png
new file mode 100644
index 0000000..418d343
--- /dev/null
+++ b/res/drawable-xxhdpi/bg_graygrid.png
Binary files differ
diff --git a/res/drawable-xxhdpi/btn_customize.png b/res/drawable-xxhdpi/btn_customize.png
new file mode 100644
index 0000000..2d9cdd6
--- /dev/null
+++ b/res/drawable-xxhdpi/btn_customize.png
Binary files differ
diff --git a/res/drawable-xxhdpi/btn_theme_store.png b/res/drawable-xxhdpi/btn_theme_store.png
new file mode 100644
index 0000000..2cb16a6
--- /dev/null
+++ b/res/drawable-xxhdpi/btn_theme_store.png
Binary files differ
diff --git a/res/drawable-xxhdpi/btn_wallpaper.png b/res/drawable-xxhdpi/btn_wallpaper.png
new file mode 100644
index 0000000..c71acc9
--- /dev/null
+++ b/res/drawable-xxhdpi/btn_wallpaper.png
Binary files differ
diff --git a/res/drawable/bg_grid.xml b/res/drawable/bg_grid.xml
new file mode 100644
index 0000000..42a2a00
--- /dev/null
+++ b/res/drawable/bg_grid.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/bg_graygrid"
+ android:tileMode="repeat"
+ android:antialias="true" />
diff --git a/res/drawable/component_selection_selector.xml b/res/drawable/component_selection_selector.xml
new file mode 100644
index 0000000..a38e10a
--- /dev/null
+++ b/res/drawable/component_selection_selector.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true" android:drawable="@drawable/component_selection_pressed"/>
+ <item android:state_selected="true" android:drawable="@drawable/component_selection_pressed"/>
+ <item android:drawable="@android:color/transparent"/>
+</selector> \ No newline at end of file
diff --git a/res/drawable/wallpaper_border.xml b/res/drawable/wallpaper_border.xml
new file mode 100644
index 0000000..c330957
--- /dev/null
+++ b/res/drawable/wallpaper_border.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+
+ <stroke android:width="2dp" android:color="@android:color/white" />
+
+</shape> \ No newline at end of file
diff --git a/res/layout/bootani_component_selection_item.xml b/res/layout/bootani_component_selection_item.xml
new file mode 100644
index 0000000..6af9768
--- /dev/null
+++ b/res/layout/bootani_component_selection_item.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/component_selection_cell_height_boot_anim">
+
+ <ImageView
+ android:id="@+id/preview"
+ android:layout_width="@dimen/component_selection_bootani_content_width"
+ android:layout_height="@dimen/component_selection_bootani_content_height"
+ android:layout_marginTop="@dimen/component_margin_top"
+ android:layout_centerHorizontal="true"/>
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/preview"
+ android:layout_centerHorizontal="true"
+ style="@style/component_title"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/component_divider.xml b/res/layout/component_divider.xml
new file mode 100644
index 0000000..0e57821
--- /dev/null
+++ b/res/layout/component_divider.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<View xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="2dp"
+ android:layout_height="@dimen/component_divider_height"
+ android:layout_marginTop="32dp"
+ android:background="@color/component_divider_color"/>
diff --git a/res/layout/component_selection_pager_item.xml b/res/layout/component_selection_pager_item.xml
new file mode 100644
index 0000000..8a0129d
--- /dev/null
+++ b/res/layout/component_selection_pager_item.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/component_selector.xml b/res/layout/component_selector.xml
new file mode 100644
index 0000000..fadf2ee
--- /dev/null
+++ b/res/layout/component_selector.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<org.cyanogenmod.theme.chooserv2.ComponentSelector
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:themes="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/component_selector"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|left"
+ android:visibility="gone"
+ android:background="@color/component_selection_background">
+
+ <FrameLayout
+ android:id="@+id/selection_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <android.support.v4.view.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/component_selection_cell_height"
+ themes:itemsPerPage="4"
+ />
+
+ <com.viewpagerindicator.CirclePageIndicator
+ android:id="@+id/page_indicator"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ themes:fillColor="@android:color/white"/>
+
+ </FrameLayout>
+
+ <!-- This view will be set to gone if the device does not have a navigation bar -->
+ <Space
+ android:id="@+id/navbar_padding"
+ android:layout_width="match_parent"
+ android:layout_height="@*android:dimen/system_bar_height"/>
+</org.cyanogenmod.theme.chooserv2.ComponentSelector> \ No newline at end of file
diff --git a/res/layout/font_component_selection_item.xml b/res/layout/font_component_selection_item.xml
index b276f59..94515e9 100644
--- a/res/layout/font_component_selection_item.xml
+++ b/res/layout/font_component_selection_item.xml
@@ -1,11 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
-<org.cyanogenmod.theme.util.FittedTextView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/component_selection_item_width"
- android:layout_height="@dimen/component_selection_item_height"
- android:background="#000000"
- android:textColor="@android:color/white"
- android:text="@string/font_component_item_text">
-
-</org.cyanogenmod.theme.util.FittedTextView> \ No newline at end of file
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/component_selection_cell_height">
+
+ <org.cyanogenmod.theme.util.FittedTextView
+ android:id="@+id/text_preview"
+ android:layout_width="@dimen/component_selection_content_width"
+ android:layout_height="@dimen/component_selection_content_height"
+ android:textColor="@android:color/white"
+ android:text="@string/font_component_item_text"
+ android:layout_marginTop="@dimen/component_margin_top"
+ android:layout_centerHorizontal="true"/>
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/text_preview"
+ android:layout_centerHorizontal="true"
+ style="@style/component_title"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/icon_component_selection_item.xml b/res/layout/icon_component_selection_item.xml
index 8aeb61e..159d7ad 100644
--- a/res/layout/icon_component_selection_item.xml
+++ b/res/layout/icon_component_selection_item.xml
@@ -1,11 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
-<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/component_selection_item_width"
- android:layout_height="@dimen/component_selection_item_height"
- android:padding="@dimen/icon_component_margin"
- android:src="@drawable/ic_app_themes"
- android:scaleType="fitCenter"
- android:background="#000000">
-
-</ImageView> \ No newline at end of file
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/component_selection_cell_height">
+
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="@dimen/component_selection_content_width"
+ android:layout_height="@dimen/component_selection_content_height"
+ android:src="@drawable/ic_app_themes"
+ android:scaleType="fitCenter"
+ android:layout_marginTop="@dimen/component_margin_top"
+ android:layout_centerHorizontal="true"/>
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/icon"
+ android:layout_centerHorizontal="true"
+ style="@style/component_title"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/navigation_bar_component_selection_item.xml b/res/layout/navigation_bar_component_selection_item.xml
index 73b4548..207f4b9 100644
--- a/res/layout/navigation_bar_component_selection_item.xml
+++ b/res/layout/navigation_bar_component_selection_item.xml
@@ -1,27 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="@dimen/component_selection_item_width"
- android:layout_height="@dimen/component_selection_item_height"
- android:background="#000000">
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/component_selection_cell_height">
- <ImageView
- android:id="@+id/back"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
+ <LinearLayout
+ android:id="@+id/container"
+ android:orientation="vertical"
+ android:layout_width="@dimen/component_selection_content_width"
+ android:layout_height="@dimen/component_selection_content_height"
+ android:layout_marginTop="@dimen/component_margin_top"
+ android:background="#000000"
+ android:layout_centerHorizontal="true">
- <ImageView
- android:id="@+id/home"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
+ <ImageView
+ android:id="@+id/back"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"/>
+
+ </LinearLayout>
- <ImageView
- android:id="@+id/recent"
+ <TextView
+ android:id="@+id/title"
android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
+ android:layout_height="wrap_content"
+ android:layout_below="@id/container"
+ android:layout_centerHorizontal="true"
+ style="@style/component_title"/>
-</LinearLayout> \ No newline at end of file
+</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/status_bar_component_selection_item.xml b/res/layout/status_bar_component_selection_item.xml
index 4b859d0..f98fdac 100644
--- a/res/layout/status_bar_component_selection_item.xml
+++ b/res/layout/status_bar_component_selection_item.xml
@@ -1,28 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="@dimen/component_selection_item_width"
- android:layout_height="@dimen/component_selection_item_height"
- android:background="#000000">
-
- <ImageView
- android:id="@+id/slot1"
- style="@style/StatusBarComponentIcon"
- android:layout_gravity="top|left"/>
-
- <ImageView
- android:id="@+id/slot2"
- style="@style/StatusBarComponentIcon"
- android:layout_gravity="top|right"/>
- <ImageView
- android:id="@+id/slot3"
- style="@style/StatusBarComponentIcon"
- android:layout_gravity="bottom|left"/>
-
- <ImageView
- android:id="@+id/slot4"
- style="@style/StatusBarComponentIcon"
- android:layout_gravity="bottom|right"/>
-
-</FrameLayout> \ No newline at end of file
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/component_selection_cell_height"
+ android:background="@drawable/component_selection_selector">
+
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/container"
+ android:layout_width="@dimen/component_selection_content_width"
+ android:layout_height="@dimen/component_selection_content_height"
+ android:layout_marginTop="@dimen/component_margin_top"
+ android:background="#000000"
+ android:layout_centerHorizontal="true">
+
+ <ImageView
+ android:id="@+id/slot1"
+ style="@style/status_bar_component_icon"
+ android:layout_gravity="top|left"/>
+
+ <ImageView
+ android:id="@+id/slot2"
+ style="@style/status_bar_component_icon"
+ android:layout_gravity="top|right"/>
+ <ImageView
+ android:id="@+id/slot3"
+ style="@style/status_bar_component_icon"
+ android:layout_gravity="bottom|left"/>
+
+ <ImageView
+ android:id="@+id/slot4"
+ style="@style/status_bar_component_icon"
+ android:layout_gravity="bottom|right"/>
+
+ </FrameLayout>
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/container"
+ android:layout_centerHorizontal="true"
+ style="@style/component_title"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/v2_activity_main.xml b/res/layout/v2_activity_main.xml
index e2f88f0..47ba676 100644
--- a/res/layout/v2_activity_main.xml
+++ b/res/layout/v2_activity_main.xml
@@ -1,47 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:gravity="center_vertical"
- android:background="@drawable/bg_bluegrid">
-
- <TextView
- android:id="@+id/theme_name"
- android:layout_width="264dp"
- android:layout_height="wrap_content"
- android:layout_marginLeft="48dp"
- android:paddingBottom="24dp"
- android:textSize="24sp"
- />
- <org.cyanogenmod.theme.chooserv2.PagerContainer
- android:id="@+id/pager_container"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/bg_grid">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="300dp"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
android:layout_gravity="center_vertical">
- <android.support.v4.view.ThemeViewPager
- android:id="@+id/viewpager"
+ <TextView
+ android:id="@+id/theme_name"
android:layout_width="264dp"
- android:layout_height="match_parent"
- android:layout_gravity="center_horizontal"/>
- </org.cyanogenmod.theme.chooserv2.PagerContainer>
- <LinearLayout
- android:id="@+id/apply_edit_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="48dp"
- android:paddingRight="48dp">
- <Button android:id="@+id/apply"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="48dp"
+ android:paddingBottom="24dp"
+ android:textSize="24sp"
+ />
+ <org.cyanogenmod.theme.chooserv2.PagerContainer
+ android:id="@+id/pager_container"
+ android:layout_width="match_parent"
+ android:layout_height="300dp"
+ android:layout_gravity="center_vertical">
+ <android.support.v4.view.ThemeViewPager
+ android:id="@+id/viewpager"
+ android:layout_width="264dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal"/>
+ </org.cyanogenmod.theme.chooserv2.PagerContainer>
+ <LinearLayout
+ android:id="@+id/apply_edit_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="48dp"
+ android:paddingRight="48dp">
+ <Button android:id="@+id/apply"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:text="@string/apply"/>
- <Button android:id="@+id/edit"
+ <Button android:id="@+id/edit"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:text="@string/edit"/>
+ </LinearLayout>
+
+ <!-- selector_testing and it's children are for testing the component
+ selector and should be removed once this is no longer needed -->
+ <LinearLayout
+ android:id="@+id/selector_testing"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone">
+
+ <Button
+ android:id="@+id/show_status_bar"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/status_bar"/>
+
+ <Button
+ android:id="@+id/show_nav_bar"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/navigation_bar"/>
+
+ <Button
+ android:id="@+id/show_icons"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/icons"/>
+
+ <Button
+ android:id="@+id/show_fonts"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/fonts"/>
+
+ <Button
+ android:id="@+id/show_styles"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/style"/>
+
+ <Button
+ android:id="@+id/show_wallpaper"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/wallpapers"/>
+
+ <Button
+ android:id="@+id/show_bootani"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/boot_anims"/>
+
+ </LinearLayout>
</LinearLayout>
-</LinearLayout> \ No newline at end of file
+ <include layout="@layout/component_selector"/>
+</FrameLayout>
diff --git a/res/layout/wallpaper_component_selection_item.xml b/res/layout/wallpaper_component_selection_item.xml
new file mode 100644
index 0000000..015270f
--- /dev/null
+++ b/res/layout/wallpaper_component_selection_item.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/component_selection_cell_height">
+
+ <FrameLayout
+ android:id="@+id/wp_content"
+ android:layout_width="@dimen/component_selection_content_width"
+ android:layout_height="@dimen/component_selection_content_height"
+ android:layout_marginTop="@dimen/component_margin_top"
+ android:layout_centerHorizontal="true">
+ <ImageView
+ android:id="@+id/icon"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter"/>
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/wallpaper_border" />
+ </FrameLayout>
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/wp_content"
+ android:layout_centerHorizontal="true"
+ style="@style/component_title"/>
+
+</RelativeLayout> \ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 0c474be..a4f3878 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -37,4 +37,8 @@
<attr name="component" format="string" />
</declare-styleable>
+ <declare-styleable name="ComponentSelector">
+ <attr name="itemsPerPage" format="integer"/>
+ </declare-styleable>
+
</resources> \ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 897e145..522ba00 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -29,4 +29,9 @@
<color name="font_preview_color">#ffffff</color>
<color name="font_preview_shadow_color">#dd000000</color>
+
+ <color name="component_selection_background">#e6212121</color>
+ <color name="component_divider_color">#80cccccc</color>
+ <color name="background">#d6d6d8</color>
+ <drawable name="component_selection_pressed">#40000000</drawable>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 88de2c9..8642e78 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -23,11 +23,21 @@
<dimen name="navigation_button_width">80dp</dimen>
<dimen name="theme_preview_height">264dp</dimen>
- <!-- Arbitrary values for testing, will need red lines from UX for actual values -->
- <dimen name="component_selection_item_width">80dp</dimen>
- <dimen name="component_selection_item_height">@dimen/component_selection_item_width</dimen>
- <dimen name="status_bar_component_icon_width">32dp</dimen>
- <dimen name="status_bar_component_icon_height">32dp</dimen>
- <dimen name="status_bar_component_icon_margin">4dp</dimen>
+ <dimen name="component_selection_cell_width">80dp</dimen>
+ <dimen name="component_selection_cell_height">112dp</dimen>
+ <dimen name="component_selection_cell_height_boot_anim">203dp</dimen>
+ <dimen name="component_selection_content_width">48dp</dimen>
+ <dimen name="component_selection_content_height">@dimen/component_selection_content_width</dimen>
+ <dimen name="component_selection_bootani_content_width">80dp</dimen>
+ <dimen name="component_selection_bootani_content_height">142dp</dimen>
+ <dimen name="component_margin_top">24dp</dimen>
+ <dimen name="component_divider_height">32dp</dimen>
+ <dimen name="component_divider_height_bootani">48dp</dimen>
+ <dimen name="component_divider_margin_top">32dp</dimen>
+ <dimen name="component_divider_margin_top_bootani">72dp</dimen>
+
+ <dimen name="status_bar_component_icon_width">20dp</dimen>
+ <dimen name="status_bar_component_icon_height">20dp</dimen>
+ <dimen name="status_bar_component_icon_margin">2dp</dimen>
<dimen name="icon_component_margin">4dp</dimen>
</resources>
diff --git a/res/values/integers.xml b/res/values/integers.xml
new file mode 100644
index 0000000..209e43b
--- /dev/null
+++ b/res/values/integers.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <integer name="default_items_per_page">4</integer>
+ <integer name="bootani_items_per_page">3</integer>
+</resources> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 22c94da..34af42e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -77,4 +77,9 @@
<string name="font_component_item_text">Aa</string>
+ <!-- Bottom bar items -->
+ <string name="btn_wallpaper_text">Wallpaper</string>
+ <string name="btn_customize_text">Customize</string>
+ <string name="btn_theme_store_text">Theme Store</string>
+
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e51dbc4..eca0581 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -32,6 +32,10 @@
<item name="android:logo">@drawable/ic_app_themes_bw</item>
</style>
+ <style name="ThemeChooserV2Theme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
+ <item name="android:windowTranslucentNavigation">true</item>
+ </style>
+
<!-- ActionBar title text -->
<style name="ThemeChooserActionBarTitleText">
<item name="android:textColor">#FFFFFF</item>
@@ -114,11 +118,29 @@
<item name="android:textStyle">normal</item>
</style>
- <style name="StatusBarComponentIcon">
+ <style name="status_bar_component_icon">
<item name="android:layout_width">@dimen/status_bar_component_icon_width</item>
<item name="android:layout_height">@dimen/status_bar_component_icon_height</item>
<item name="android:layout_margin">@dimen/status_bar_component_icon_margin</item>
<item name="android:scaleType">fitCenter</item>
</style>
+ <style name="bottom_bar_item_text_style">
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:textColor">@android:color/white</item>
+ <item name="android:gravity">center_horizontal</item>
+ <item name="android:fontFamily">sans-serif-condensed</item>
+ </style>
+
+ <style name="component_title">
+ <item name="android:textColor">@android:color/white</item>
+ <item name="android:gravity">center_horizontal</item>
+ <item name="android:paddingStart">2dp</item>
+ <item name="android:paddingEnd">2dp</item>
+ <item name="android:paddingTop">8dp</item>
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textSize">12sp</item>
+ </style>
+
</resources>
diff --git a/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java b/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java
index 10ae97b..c0d7186 100644
--- a/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java
+++ b/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java
@@ -52,6 +52,14 @@ public class ChooserActivity extends FragmentActivity
private ThemesAdapter mAdapter;
private ThemeManager mService;
private boolean mExpanded = false;
+ private Button mStatusBar;
+ private Button mNavBar;
+ private Button mIcons;
+ private Button mFonts;
+ private Button mStyles;
+ private Button mWallpaper;
+ private Button mBootani;
+ private ComponentSelector mSelector;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -105,6 +113,26 @@ public class ChooserActivity extends FragmentActivity
}
});
+ mSelector = (ComponentSelector) findViewById(R.id.component_selector);
+
+ if (ComponentSelector.DEBUG_SELECTOR) {
+ findViewById(R.id.selector_testing).setVisibility(View.VISIBLE);
+ mStatusBar = (Button) findViewById(R.id.show_status_bar);
+ mNavBar = (Button) findViewById(R.id.show_nav_bar);
+ mIcons = (Button) findViewById(R.id.show_icons);
+ mFonts = (Button) findViewById(R.id.show_fonts);
+ mStyles = (Button) findViewById(R.id.show_styles);
+ mWallpaper = (Button) findViewById(R.id.show_wallpaper);
+ mBootani = (Button) findViewById(R.id.show_bootani);
+ mStatusBar.setOnClickListener(mButtonClickListener);
+ mNavBar.setOnClickListener(mButtonClickListener);
+ mIcons.setOnClickListener(mButtonClickListener);
+ mFonts.setOnClickListener(mButtonClickListener);
+ mStyles.setOnClickListener(mButtonClickListener);
+ mWallpaper.setOnClickListener(mButtonClickListener);
+ mBootani.setOnClickListener(mButtonClickListener);
+ }
+
mService = (ThemeManager) getSystemService(Context.THEME_SERVICE);
getSupportLoaderManager().initLoader(0, null, this);
}
@@ -117,7 +145,9 @@ public class ChooserActivity extends FragmentActivity
@Override
public void onBackPressed() {
- if (mExpanded) {
+ if (mSelector.getVisibility() == View.VISIBLE) {
+ mSelector.hide();
+ } else if (mExpanded) {
mExpanded = false;
mContainer.collapse();
ThemeFragment f = (ThemeFragment) getSupportFragmentManager()
@@ -146,6 +176,49 @@ public class ChooserActivity extends FragmentActivity
mThemeName.setText(name);
}
+ private View.OnClickListener mButtonClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (v == mStatusBar) {
+ mSelector.setNumItemsPerPage(4);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_STATUS_BAR);
+ } else if (v == mNavBar) {
+ mSelector.setNumItemsPerPage(4);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_NAVIGATION_BAR);
+ } else if (v == mIcons) {
+ mSelector.setNumItemsPerPage(4);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_ICONS);
+ } else if (v == mFonts) {
+ mSelector.setNumItemsPerPage(4);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_FONTS);
+ } else if (v == mStyles) {
+ mSelector.setNumItemsPerPage(4);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_OVERLAYS);
+ } else if (v == mWallpaper) {
+ mSelector.setNumItemsPerPage(4);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_LAUNCHER);
+ } else if (v == mBootani) {
+ mSelector.setNumItemsPerPage(3);
+ mSelector.setHeight(getResources().getDimensionPixelSize(
+ R.dimen.component_selection_cell_height_boot_anim));
+ mSelector.setComponentType(ThemesColumns.MODIFIES_BOOT_ANIM);
+ }
+ if (mSelector.getVisibility() == View.GONE) mSelector.show();
+ }
+ };
+
private View.OnClickListener mPagerClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/src/org/cyanogenmod/theme/chooserv2/ComponentSelector.java b/src/org/cyanogenmod/theme/chooserv2/ComponentSelector.java
new file mode 100644
index 0000000..727a6f6
--- /dev/null
+++ b/src/org/cyanogenmod/theme/chooserv2/ComponentSelector.java
@@ -0,0 +1,586 @@
+/*
+ * Copyright (C) 2014 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 org.cyanogenmod.theme.chooserv2;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Typeface;
+import android.graphics.drawable.BitmapDrawable;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.provider.ThemesContract;
+import android.provider.ThemesContract.PreviewColumns;
+import android.provider.ThemesContract.ThemesColumns;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.Animation.AnimationListener;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+import com.viewpagerindicator.PageIndicator;
+import org.cyanogenmod.theme.chooser.R;
+import org.cyanogenmod.theme.util.ThemedTypefaceHelper;
+
+import java.util.HashMap;
+
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_BOOT_ANIM;
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LAUNCHER;
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_OVERLAYS;
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_STATUS_BAR;
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NAVIGATION_BAR;
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_ICONS;
+import static android.provider.ThemesContract.ThemesColumns.MODIFIES_FONTS;
+
+public class ComponentSelector extends LinearLayout
+ implements LoaderManager.LoaderCallbacks<Cursor> {
+ private static final String TAG = ComponentSelector.class.getSimpleName();
+
+ public static final boolean DEBUG_SELECTOR = true;
+
+ private static final int LOADER_ID_STATUS_BAR = 100;
+ private static final int LOADER_ID_NAVIGATION_BAR = 101;
+ private static final int LOADER_ID_FONT = 102;
+ private static final int LOADER_ID_ICON = 103;
+ private static final int LOADER_ID_STYLE = 104;
+ private static final int LOADER_ID_WALLPAPER = 105;
+ private static final int LOADER_ID_BOOTANIMATIONS = 106;
+
+ private Context mContext;
+ private LayoutInflater mInflater;
+ private ViewPager mPager;
+
+ private String mComponentType;
+ private CursorPagerAdapter mAdapter;
+ private int mBatteryStyle;
+ private int mItemsPerPage;
+
+ // animations for bringing selector in and out of view
+ private Animation mAnimateIn;
+ private Animation mAnimateOut;
+
+ private OnItemClickedListener mListener;
+
+ public ComponentSelector(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ComponentSelector);
+ mItemsPerPage = a.getInt(R.styleable.ComponentSelector_itemsPerPage,
+ context.getResources().getInteger(R.integer.default_items_per_page));
+ a.recycle();
+
+ mContext = context;
+ mInflater = LayoutInflater.from(context);
+ mBatteryStyle = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.STATUS_BAR_BATTERY, 0);
+
+ mAnimateIn = AnimationUtils.loadAnimation(mContext,
+ R.anim.component_selection_animate_in);
+ mAnimateOut = AnimationUtils.loadAnimation(mContext,
+ R.anim.component_selection_animate_out);
+ mAnimateOut.setAnimationListener(new AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+ }
+ });
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mPager = (ViewPager) findViewById(R.id.pager);
+ mAdapter = new CursorPagerAdapter<View>(null, mItemsPerPage);
+ mPager.setAdapter(mAdapter);
+ PageIndicator indicator = (PageIndicator) findViewById(R.id.page_indicator);
+ indicator.setViewPager(mPager);
+
+ // set navbar_padding to GONE if no on screen navigation bar is available
+ if (!hasNavigationBar()) findViewById(R.id.navbar_padding).setVisibility(View.GONE);
+ }
+
+ public void setComponentType(String component) {
+ mComponentType = component;
+ mAdapter = new CursorPagerAdapter<View>(null, mItemsPerPage);
+ mPager.setAdapter(mAdapter);
+ ((FragmentActivity) mContext).getSupportLoaderManager().initLoader(
+ getLoaderIdFromComponent(component), null, this);
+ }
+
+ public void setNumItemsPerPage(int itemsPerPage) {
+ mItemsPerPage = itemsPerPage;
+ }
+
+ public void setHeight(int height) {
+ ViewGroup.LayoutParams params = mPager.getLayoutParams();
+ params.height = height;
+ mPager.setLayoutParams(params);
+ requestLayout();
+ }
+
+ public void show() {
+ setVisibility(View.VISIBLE);
+ startAnimation(mAnimateIn);
+ }
+
+ public void hide() {
+ startAnimation(mAnimateOut);
+ }
+
+ private boolean hasNavigationBar() {
+ return !ViewConfiguration.get(mContext).hasPermanentMenuKey();
+ }
+
+ private int getLoaderIdFromComponent(String component) {
+ if (MODIFIES_STATUS_BAR.equals(component)) {
+ return LOADER_ID_STATUS_BAR;
+ }
+ if (MODIFIES_NAVIGATION_BAR.equals(component)) {
+ return LOADER_ID_NAVIGATION_BAR;
+ }
+ if (MODIFIES_FONTS.equals(component)) {
+ return LOADER_ID_FONT;
+ }
+ if (MODIFIES_ICONS.equals(component)) {
+ return LOADER_ID_ICON;
+ }
+ if (MODIFIES_OVERLAYS.equals(component)) {
+ return LOADER_ID_STYLE;
+ }
+ if (MODIFIES_LAUNCHER.equals(component)) {
+ return LOADER_ID_WALLPAPER;
+ }
+ if (MODIFIES_BOOT_ANIM.equals(component)) {
+ return LOADER_ID_BOOTANIMATIONS;
+ }
+ return -1;
+ }
+
+ private String getBatteryIndex(int type) {
+ switch(type) {
+ case 2:
+ return PreviewColumns.STATUSBAR_BATTERY_CIRCLE;
+ case 5:
+ return PreviewColumns.STATUSBAR_BATTERY_LANDSCAPE;
+ default:
+ return PreviewColumns.STATUSBAR_BATTERY_PORTRAIT;
+ }
+ }
+
+ private Bitmap loadBitmapBlob(Cursor cursor, int columnIdx) {
+ byte[] blob = cursor.getBlob(columnIdx);
+ if (blob == null) return null;
+ return BitmapFactory.decodeByteArray(blob, 0, blob.length);
+ }
+
+ @Override
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ String selection;
+ String[] selectionArgs = { "1" };
+ String[] projection = { ThemesColumns.TITLE, ThemesColumns.PKG_NAME };
+ switch(id) {
+ case LOADER_ID_STATUS_BAR:
+ selection = MODIFIES_STATUS_BAR + "=?";
+ projection = new String[] {
+ PreviewColumns.STATUSBAR_WIFI_ICON,
+ PreviewColumns.STATUSBAR_SIGNAL_ICON,
+ PreviewColumns.STATUSBAR_BLUETOOTH_ICON,
+ PreviewColumns.STATUSBAR_BACKGROUND,
+ PreviewColumns.STATUSBAR_BATTERY_CIRCLE,
+ PreviewColumns.STATUSBAR_BATTERY_LANDSCAPE,
+ PreviewColumns.STATUSBAR_BATTERY_PORTRAIT,
+ ThemesColumns.TITLE,
+ ThemesColumns.PKG_NAME
+ };
+ break;
+ case LOADER_ID_NAVIGATION_BAR:
+ selection = MODIFIES_NAVIGATION_BAR + "=?";
+ projection = new String[] {
+ PreviewColumns.NAVBAR_BACK_BUTTON,
+ PreviewColumns.STATUSBAR_BACKGROUND,
+ ThemesColumns.TITLE,
+ ThemesColumns.PKG_NAME,
+ };
+ break;
+ case LOADER_ID_FONT:
+ selection = MODIFIES_FONTS + "=?";
+ break;
+ case LOADER_ID_ICON:
+ selection = MODIFIES_ICONS + "=?";
+ projection = new String[] {
+ PreviewColumns.ICON_PREVIEW_1,
+ ThemesColumns.TITLE,
+ ThemesColumns.PKG_NAME
+ };
+ break;
+ case LOADER_ID_STYLE:
+ selection = MODIFIES_OVERLAYS + "=?";
+ projection = new String[] {
+ PreviewColumns.STYLE_PREVIEW,
+ ThemesColumns.TITLE,
+ ThemesColumns.PKG_NAME
+ };
+ break;
+ case LOADER_ID_WALLPAPER:
+ selection = MODIFIES_LAUNCHER + "=?";
+ projection = new String[] {
+ PreviewColumns.WALLPAPER_THUMBNAIL,
+ ThemesColumns.TITLE,
+ ThemesColumns.PKG_NAME
+ };
+ break;
+ case LOADER_ID_BOOTANIMATIONS:
+ selection = MODIFIES_BOOT_ANIM + "=?";
+ projection = new String[] {
+ PreviewColumns.BOOTANIMATION_THUMBNAIL,
+ ThemesColumns.TITLE,
+ ThemesColumns.PKG_NAME
+ };
+ break;
+ default:
+ return null;
+ }
+ // sort in ascending order but make sure the "default" theme is always first
+ String sortOrder = "(" + ThemesContract.ThemesColumns.IS_DEFAULT_THEME + "=1) DESC, "
+ + ThemesContract.ThemesColumns.TITLE + " ASC";
+ return new CursorLoader(mContext, PreviewColumns.CONTENT_URI,
+ projection, selection, selectionArgs, sortOrder);
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ mAdapter.swapCursor(data);
+ mAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {
+ mAdapter.swapCursor(null);
+ mAdapter.notifyDataSetChanged();
+ }
+
+ public void setOnItemClickedListener(OnItemClickedListener listener) {
+ mListener = listener;
+ }
+
+ public class CursorPagerAdapter<T extends View> extends PagerAdapter {
+ LinearLayout.LayoutParams mItemParams =
+ new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
+ private Cursor mCursor;
+ private int mItemsPerPage;
+ HashMap<String, ThemedTypefaceHelper> mTypefaceHelpers =
+ new HashMap<String, ThemedTypefaceHelper>();
+
+ public CursorPagerAdapter(Cursor cursor, int itemsPerPage) {
+ super();
+ mCursor = cursor;
+ mItemsPerPage = itemsPerPage;
+ }
+
+ @Override
+ public Object instantiateItem(ViewGroup container, int position) {
+ ViewGroup v = (ViewGroup) mInflater.inflate(R.layout.component_selection_pager_item,
+ container, false);
+ if (v instanceof LinearLayout) {
+ ((LinearLayout) v).setWeightSum(mItemsPerPage);
+ }
+ if (MODIFIES_STATUS_BAR.equals(mComponentType)) {
+ newStatusBarView(mCursor, v, position);
+ }
+ if (MODIFIES_NAVIGATION_BAR.equals(mComponentType)) {
+ newNavBarView(mCursor, v, position);
+ }
+ if (MODIFIES_FONTS.equals(mComponentType)) {
+ newFontView(mCursor, v, position);
+ }
+ if (MODIFIES_ICONS.equals(mComponentType)) {
+ newIconView(mCursor, v, position);
+ }
+ if (MODIFIES_OVERLAYS.equals(mComponentType)) {
+ newStyleView(mCursor, v, position);
+ }
+ if (MODIFIES_LAUNCHER.equals(mComponentType)) {
+ newWallpapersView(mCursor, v, position);
+ }
+ if (MODIFIES_BOOT_ANIM.equals(mComponentType)) {
+ newBootanimationView(mCursor, v, position);
+ }
+ container.addView(v);
+ return v;
+ }
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object) {
+ if (object instanceof View) {
+ container.removeView((View) object);
+ }
+ }
+
+ @Override
+ public int getCount() {
+ return mCursor == null ? 0 : (int) Math.ceil((float)mCursor.getCount() / mItemsPerPage);
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object object) {
+ return view == object;
+ }
+
+ public void swapCursor(Cursor c) {
+ if (mCursor == c)
+ return;
+
+ mCursor = c;
+ notifyDataSetChanged();
+ }
+
+ public Cursor getCursor() {
+ return mCursor;
+ }
+
+ private OnClickListener mItemClickListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String pkgName = (String) v.getTag();
+ if (DEBUG_SELECTOR) Toast.makeText(mContext, pkgName, Toast.LENGTH_SHORT).show();
+ if (mListener != null) {
+ mListener.onItemClicked(pkgName);
+ }
+ }
+ };
+
+ private void newStatusBarView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.status_bar_component_selection_item,
+ parent, false);
+ int wifiIndex = cursor.getColumnIndex(PreviewColumns.STATUSBAR_WIFI_ICON);
+ int signalIndex = cursor.getColumnIndex(PreviewColumns.STATUSBAR_SIGNAL_ICON);
+ int bluetoothIndex = cursor.getColumnIndex(PreviewColumns.STATUSBAR_BLUETOOTH_ICON);
+ int batteryIndex = cursor.getColumnIndex(getBatteryIndex(mBatteryStyle));
+ int backgroundIndex = cursor.getColumnIndex(PreviewColumns.STATUSBAR_BACKGROUND);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ ((ImageView) v.findViewById(R.id.slot1)).setImageBitmap(
+ loadBitmapBlob(cursor, wifiIndex));
+ ((ImageView) v.findViewById(R.id.slot2)).setImageBitmap(
+ loadBitmapBlob(cursor, signalIndex));
+ ((ImageView) v.findViewById(R.id.slot3)).setImageBitmap(
+ loadBitmapBlob(cursor, bluetoothIndex));
+ ((ImageView) v.findViewById(R.id.slot4)).setImageBitmap(
+ loadBitmapBlob(cursor, batteryIndex));
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.findViewById(R.id.container).setBackground(
+ new BitmapDrawable(loadBitmapBlob(cursor, backgroundIndex)));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void newNavBarView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.navigation_bar_component_selection_item, parent,
+ false);
+ int backIndex = cursor.getColumnIndex(PreviewColumns.NAVBAR_BACK_BUTTON);
+ int backgroundIndex = cursor.getColumnIndex(PreviewColumns.STATUSBAR_BACKGROUND);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ ((ImageView) v.findViewById(R.id.back)).setImageBitmap(
+ loadBitmapBlob(cursor, backIndex));
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.findViewById(R.id.container).setBackground(
+ new BitmapDrawable(loadBitmapBlob(cursor, backgroundIndex)));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void newFontView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.font_component_selection_item, parent,
+ false);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ TextView preview = (TextView) v.findViewById(R.id.text_preview);
+ String pkgName = cursor.getString(pkgNameIndex);
+
+ ThemedTypefaceHelper helper;
+ if (!mTypefaceHelpers.containsKey(pkgName)) {
+ helper = new ThemedTypefaceHelper();
+ helper.load(mContext, pkgName);
+ mTypefaceHelpers.put(pkgName, helper);
+ } else {
+ helper = mTypefaceHelpers.get(pkgName);
+ }
+ Typeface typefaceNormal = helper.getTypeface(Typeface.NORMAL);
+ preview.setTypeface(typefaceNormal);
+
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void newIconView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.icon_component_selection_item, parent,
+ false);
+ int iconIndex = cursor.getColumnIndex(PreviewColumns.ICON_PREVIEW_1);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ ((ImageView) v.findViewById(R.id.icon)).setImageBitmap(
+ loadBitmapBlob(cursor, iconIndex));
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void newStyleView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.icon_component_selection_item, parent,
+ false);
+ int styleIndex = cursor.getColumnIndex(PreviewColumns.STYLE_PREVIEW);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ ((ImageView) v.findViewById(R.id.icon)).setImageBitmap(
+ loadBitmapBlob(cursor, styleIndex));
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void newWallpapersView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.wallpaper_component_selection_item, parent,
+ false);
+ int wallpaperIndex = cursor.getColumnIndex(PreviewColumns.WALLPAPER_THUMBNAIL);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ ((ImageView) v.findViewById(R.id.icon)).setImageBitmap(
+ loadBitmapBlob(cursor, wallpaperIndex));
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void newBootanimationView(Cursor cursor, ViewGroup parent, int position) {
+ for (int i = 0; i < mItemsPerPage; i++) {
+ int index = position * mItemsPerPage + i;
+ if (cursor.getCount() <= index) continue;
+ cursor.moveToPosition(index);
+ View v = mInflater.inflate(R.layout.bootani_component_selection_item, parent,
+ false);
+ int wallpaperIndex = cursor.getColumnIndex(PreviewColumns.BOOTANIMATION_THUMBNAIL);
+ int titleIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.TITLE);
+ int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME);
+
+ ((ImageView) v.findViewById(R.id.preview)).setImageBitmap(
+ loadBitmapBlob(cursor,wallpaperIndex));
+ ((TextView) v.findViewById(R.id.title)).setText(cursor.getString(titleIndex));
+ v.setTag(cursor.getString(pkgNameIndex));
+ v.setOnClickListener(mItemClickListener);
+ parent.addView(v, mItemParams);
+ addDividerIfNeeded(parent, i, index, cursor);
+ }
+ }
+
+ private void addDivider(ViewGroup parent) {
+ final Resources res = getResources();
+ View v = mInflater.inflate(R.layout.component_divider, parent, false);
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) v.getLayoutParams();
+ // Boot animations require a taller divider so adjust accordingly
+ if (ThemesColumns.MODIFIES_BOOT_ANIM.equals(mComponentType)) {
+ params.topMargin = res.getDimensionPixelSize(
+ R.dimen.component_divider_margin_top_bootani);
+ params.height = res.getDimensionPixelSize(R.dimen.component_divider_height_bootani);
+ }
+ v.setLayoutParams(params);
+ parent.addView(v);
+ }
+
+ private void addDividerIfNeeded(ViewGroup parent, int position, int cursorIndex,
+ Cursor cursor) {
+ if (position < mItemsPerPage - 1 && cursorIndex < cursor.getCount() - 1) {
+ addDivider(parent);
+ }
+ }
+ }
+
+ public interface OnItemClickedListener {
+ public void onItemClicked(String pkgName);
+ }
+} \ No newline at end of file