diff options
36 files changed, 91 insertions, 1341 deletions
diff --git a/res/layout-land/activity_player_base.xml b/res/layout-land/activity_player_base.xml index bc46cfa..a2ef12f 100644 --- a/res/layout-land/activity_player_base.xml +++ b/res/layout-land/activity_player_base.xml @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -<com.cyngn.eleven.widgets.theme.ThemeableFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > @@ -93,7 +92,7 @@ android:paddingLeft="@dimen/audio_player_header_padding_left" android:paddingRight="@dimen/audio_player_header_padding_right" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_track_name" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -101,18 +100,16 @@ android:gravity="bottom" android:singleLine="true" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="audio_player_line_one" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_artist_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:gravity="top" android:singleLine="true" - android:textSize="@dimen/text_size_medium" - app:themeResource="audio_player_line_two" /> + android:textSize="@dimen/text_size_medium" /> </LinearLayout> <FrameLayout @@ -137,7 +134,7 @@ </FrameLayout> </LinearLayout> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_current_time" android:layout_width="@dimen/audio_player_time_width" android:layout_height="wrap_content" @@ -145,10 +142,9 @@ android:layout_alignTop="@android:id/progress" android:layout_toRightOf="@+id/audio_player_large_album_frame" android:gravity="center" - android:textSize="@dimen/text_size_micro" - app:themeResource="audio_player_current_time" /> + android:textSize="@dimen/text_size_micro" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_total_time" android:layout_width="@dimen/audio_player_time_width" android:layout_height="wrap_content" @@ -156,10 +152,9 @@ android:layout_alignParentRight="true" android:layout_alignTop="@android:id/progress" android:gravity="center" - android:textSize="@dimen/text_size_micro" - app:themeResource="audio_player_total_time" /> + android:textSize="@dimen/text_size_micro" /> - <com.cyngn.eleven.widgets.theme.ThemeableSeekBar + <SeekBar android:id="@android:id/progress" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -186,4 +181,4 @@ <include layout="@layout/colorstrip" /> -</com.cyngn.eleven.widgets.theme.ThemeableFrameLayout>
\ No newline at end of file +</FrameLayout>
\ No newline at end of file diff --git a/res/layout/activity_base.xml b/res/layout/activity_base.xml index 76476a9..a0529b0 100644 --- a/res/layout/activity_base.xml +++ b/res/layout/activity_base.xml @@ -19,7 +19,7 @@ android:layout_height="match_parent" android:orientation="vertical" > - <com.cyngn.eleven.widgets.theme.ThemeableFrameLayout + <FrameLayout android:id="@+id/activity_base_content" android:layout_width="match_parent" android:layout_height="0dip" diff --git a/res/layout/activity_player_base.xml b/res/layout/activity_player_base.xml index 67c931f..66e2e53 100644 --- a/res/layout/activity_player_base.xml +++ b/res/layout/activity_player_base.xml @@ -14,8 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -<com.cyngn.eleven.widgets.theme.ThemeableFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > @@ -47,24 +46,22 @@ android:paddingLeft="@dimen/audio_player_header_padding_left" android:paddingRight="@dimen/audio_player_header_padding_right" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_track_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:singleLine="true" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="audio_player_line_one" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_artist_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:singleLine="true" - android:textSize="@dimen/text_size_medium" - app:themeResource="audio_player_line_two" /> + android:textSize="@dimen/text_size_medium" /> </LinearLayout> <FrameLayout @@ -154,7 +151,7 @@ </FrameLayout> </RelativeLayout> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_current_time" android:layout_width="@dimen/audio_player_time_width" android:layout_height="wrap_content" @@ -162,10 +159,9 @@ android:layout_alignParentLeft="true" android:layout_alignTop="@android:id/progress" android:gravity="center" - android:textSize="@dimen/text_size_micro" - app:themeResource="audio_player_current_time" /> + android:textSize="@dimen/text_size_micro" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/audio_player_total_time" android:layout_width="@dimen/audio_player_time_width" android:layout_height="wrap_content" @@ -173,10 +169,9 @@ android:layout_alignParentRight="true" android:layout_alignTop="@android:id/progress" android:gravity="center" - android:textSize="@dimen/text_size_micro" - app:themeResource="audio_player_total_time" /> + android:textSize="@dimen/text_size_micro" /> - <com.cyngn.eleven.widgets.theme.ThemeableSeekBar + <SeekBar android:id="@android:id/progress" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -203,4 +198,4 @@ <include layout="@layout/colorstrip" /> -</com.cyngn.eleven.widgets.theme.ThemeableFrameLayout>
\ No newline at end of file +</FrameLayout>
\ No newline at end of file diff --git a/res/layout/activity_profile_base.xml b/res/layout/activity_profile_base.xml index 3a31efa..ca66dd3 100644 --- a/res/layout/activity_profile_base.xml +++ b/res/layout/activity_profile_base.xml @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -<com.cyngn.eleven.widgets.theme.ThemeableFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > @@ -51,4 +51,4 @@ <include layout="@layout/bottom_action_bar" /> </LinearLayout> -</com.cyngn.eleven.widgets.theme.ThemeableFrameLayout>
\ No newline at end of file +</FrameLayout>
\ No newline at end of file diff --git a/res/layout/bottom_action_bar.xml b/res/layout/bottom_action_bar.xml index a55295b..ee38db3 100644 --- a/res/layout/bottom_action_bar.xml +++ b/res/layout/bottom_action_bar.xml @@ -50,16 +50,14 @@ android:layout_weight="1" android:paddingLeft="@dimen/bottom_action_bar_info_padding_left" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/bottom_action_bar_line_one" - style="@style/BottomActionBarLineOne" - app:themeResource="bab_line_one" /> + style="@style/BottomActionBarLineOne" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/bottom_action_bar_line_two" style="@style/BottomActionBarLineTwo" - android:layout_below="@+id/bottom_action_bar_line_one" - app:themeResource="bab_line_two" /> + android:layout_below="@+id/bottom_action_bar_line_one" /> </RelativeLayout> <HorizontalScrollView diff --git a/res/layout/colorstrip.xml b/res/layout/colorstrip.xml index d92fe17..2ab074a 100644 --- a/res/layout/colorstrip.xml +++ b/res/layout/colorstrip.xml @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> -<com.cyngn.eleven.widgets.theme.Colorstrip xmlns:android="http://schemas.android.com/apk/res/android" +<View xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/colorstrip" + android:background="@color/holo_blue_light" android:layout_width="match_parent" android:layout_height="@dimen/colorstrip_height"/>
\ No newline at end of file diff --git a/res/layout/fragment_music_browser_phone.xml b/res/layout/fragment_music_browser_phone.xml index 9eb5a75..bf6529a 100644 --- a/res/layout/fragment_music_browser_phone.xml +++ b/res/layout/fragment_music_browser_phone.xml @@ -23,7 +23,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - <com.cyngn.eleven.widgets.theme.ThemeableTitlePageIndicator + <com.viewpagerindicator.TitlePageIndicator android:id="@+id/fragment_home_phone_pager_titles" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/res/layout/grid_items_normal.xml b/res/layout/grid_items_normal.xml index 96df42a..69c447d 100644 --- a/res/layout/grid_items_normal.xml +++ b/res/layout/grid_items_normal.xml @@ -15,7 +15,6 @@ limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" > @@ -30,7 +29,7 @@ android:gravity="center_vertical" android:paddingLeft="@dimen/grid_item_padding_left" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_one" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -38,18 +37,16 @@ android:maxLines="2" android:textColor="@color/white" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="@null" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_two" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/line_one" android:singleLine="true" android:textColor="@color/transparent_white" - android:textSize="@dimen/text_size_small" - app:themeResource="@null" /> + android:textSize="@dimen/text_size_small" /> </RelativeLayout> </RelativeLayout>
\ No newline at end of file diff --git a/res/layout/list_item_detailed.xml b/res/layout/list_item_detailed.xml index 68b8c25..f8be1d4 100644 --- a/res/layout/list_item_detailed.xml +++ b/res/layout/list_item_detailed.xml @@ -15,7 +15,6 @@ limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" > @@ -42,7 +41,7 @@ android:background="@color/list_item_background" android:padding="@dimen/list_preferred_item_padding" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_one" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -50,10 +49,9 @@ android:maxLines="2" android:textColor="@color/white" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="@null" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_two" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -61,18 +59,16 @@ android:layout_marginTop="@dimen/list_item_line_two_margin_top" android:maxLines="2" android:textColor="@color/transparent_white" - android:textSize="@dimen/text_size_small" - app:themeResource="@null" /> + android:textSize="@dimen/text_size_small" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_three" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:singleLine="true" android:textColor="@color/transparent_white" - android:textSize="@dimen/text_size_small" - app:themeResource="@null" /> + android:textSize="@dimen/text_size_small" /> </RelativeLayout> </RelativeLayout>
\ No newline at end of file diff --git a/res/layout/list_item_detailed_no_background.xml b/res/layout/list_item_detailed_no_background.xml index 2eda428..f8be1d4 100644 --- a/res/layout/list_item_detailed_no_background.xml +++ b/res/layout/list_item_detailed_no_background.xml @@ -15,7 +15,6 @@ limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" > @@ -42,7 +41,7 @@ android:background="@color/list_item_background" android:padding="@dimen/list_preferred_item_padding" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_one" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -50,10 +49,9 @@ android:maxLines="2" android:textColor="@color/white" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="line_one" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_two" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -61,18 +59,16 @@ android:layout_marginTop="@dimen/list_item_line_two_margin_top" android:maxLines="2" android:textColor="@color/transparent_white" - android:textSize="@dimen/text_size_small" - app:themeResource="line_two" /> + android:textSize="@dimen/text_size_small" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_three" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:singleLine="true" android:textColor="@color/transparent_white" - android:textSize="@dimen/text_size_small" - app:themeResource="line_three" /> + android:textSize="@dimen/text_size_small" /> </RelativeLayout> </RelativeLayout>
\ No newline at end of file diff --git a/res/layout/list_item_normal.xml b/res/layout/list_item_normal.xml index af8d7b6..52e5610 100644 --- a/res/layout/list_item_normal.xml +++ b/res/layout/list_item_normal.xml @@ -16,7 +16,6 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" @@ -40,25 +39,23 @@ android:paddingLeft="@dimen/list_preferred_item_padding" android:paddingRight="@dimen/list_preferred_item_padding" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_one" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:singleLine="true" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="line_one" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_two" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/line_one" android:layout_marginTop="@dimen/list_item_line_two_margin_top" android:singleLine="true" - android:textSize="@dimen/text_size_small" - app:themeResource="line_two" /> + android:textSize="@dimen/text_size_small" /> </RelativeLayout> </RelativeLayout>
\ No newline at end of file diff --git a/res/layout/list_item_simple.xml b/res/layout/list_item_simple.xml index ad630df..029ad54 100644 --- a/res/layout/list_item_simple.xml +++ b/res/layout/list_item_simple.xml @@ -15,7 +15,6 @@ limitations under the License. --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res/com.cyngn.eleven" android:layout_width="match_parent" android:layout_height="@dimen/item_normal_height" android:gravity="center_vertical" @@ -23,7 +22,7 @@ android:paddingLeft="@dimen/list_preferred_item_padding" android:paddingRight="@dimen/list_preferred_item_padding" > - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_one" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -32,10 +31,9 @@ android:layout_toLeftOf="@+id/line_one_right" android:singleLine="true" android:textSize="@dimen/text_size_medium" - android:textStyle="bold" - app:themeResource="line_one" /> + android:textStyle="bold" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_one_right" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -43,26 +41,23 @@ android:layout_alignParentRight="true" android:paddingRight="@dimen/list_preferred_item_padding" android:singleLine="true" - android:textSize="@dimen/text_size_medium" - app:themeResource="line_one" /> + android:textSize="@dimen/text_size_medium" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_two" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/line_one" android:layout_marginTop="@dimen/list_item_line_two_margin_top" android:singleLine="true" - android:textSize="@dimen/text_size_small" - app:themeResource="line_two" /> + android:textSize="@dimen/text_size_small" /> - <com.cyngn.eleven.widgets.theme.ThemeableTextView + <TextView android:id="@+id/line_three" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:singleLine="true" - android:textSize="@dimen/text_size_small" - app:themeResource="line_three" /> + android:textSize="@dimen/text_size_small" /> </RelativeLayout>
\ No newline at end of file diff --git a/res/layout/profile_tab.xml b/res/layout/profile_tab.xml index 4d69d20..6529bae 100644 --- a/res/layout/profile_tab.xml +++ b/res/layout/profile_tab.xml @@ -58,7 +58,7 @@ android:layout_alignParentLeft="true" android:background="@color/transparent_black" /> - <com.cyngn.eleven.widgets.theme.Colorstrip + <View android:id="@+id/profile_tab_colorstrip" android:layout_width="match_parent" android:layout_height="@dimen/profile_indicator_height" diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 1d6a7fb..2c06448 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -14,11 +14,4 @@ limitations under the License. --> <resources> - - <declare-styleable name="ThemeableTextView"> - - <!-- Used to set the themeable resource name for the text view --> - <attr name="themeResource" format="string" /> - </declare-styleable> - </resources> diff --git a/res/xml/settings.xml b/res/xml/settings.xml index eca1e39..387ed08 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -24,10 +24,6 @@ android:key="color_scheme" android:summary="@string/settings_color_scheme_summary" android:title="@string/settings_color_scheme_title" /> - <!-- Theme chooser --> - <Preference - android:key="theme_chooser" - android:title="@string/settings_theme_chooser_title" /> </PreferenceCategory> <!-- Data catetory --> <PreferenceCategory android:title="@string/settings_data_category" > diff --git a/src/com/cyngn/eleven/cache/ImageWorker.java b/src/com/cyngn/eleven/cache/ImageWorker.java index 11ff242..68553f4 100644 --- a/src/com/cyngn/eleven/cache/ImageWorker.java +++ b/src/com/cyngn/eleven/cache/ImageWorker.java @@ -24,7 +24,6 @@ import android.widget.ImageView; import com.cyngn.eleven.R; import com.cyngn.eleven.utils.ApolloUtils; -import com.cyngn.eleven.utils.ThemeUtils; import java.lang.ref.WeakReference; import java.util.concurrent.RejectedExecutionException; @@ -81,8 +80,7 @@ public abstract class ImageWorker { mContext = context.getApplicationContext(); mResources = mContext.getResources(); // Create the default artwork - final ThemeUtils theme = new ThemeUtils(context); - mDefault = ((BitmapDrawable) theme.getDrawable("default_artwork")).getBitmap(); + mDefault = ((BitmapDrawable) mResources.getDrawable(R.drawable.default_artwork)).getBitmap(); // Create the transparent layer for the transition drawable mCurrentDrawable = new ColorDrawable(mResources.getColor(R.color.transparent)); // A transparent image (layer 0) and the new result (layer 1) diff --git a/src/com/cyngn/eleven/ui/activities/AudioPlayerActivity.java b/src/com/cyngn/eleven/ui/activities/AudioPlayerActivity.java index c3b142d..d28627c 100644 --- a/src/com/cyngn/eleven/ui/activities/AudioPlayerActivity.java +++ b/src/com/cyngn/eleven/ui/activities/AudioPlayerActivity.java @@ -61,7 +61,6 @@ import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; import com.cyngn.eleven.utils.MusicUtils.ServiceToken; import com.cyngn.eleven.utils.NavUtils; -import com.cyngn.eleven.utils.ThemeUtils; import com.cyngn.eleven.widgets.PlayPauseButton; import com.cyngn.eleven.widgets.RepeatButton; import com.cyngn.eleven.widgets.RepeatingImageButton; @@ -143,9 +142,6 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn // Image cache private ImageFetcher mImageFetcher; - // Theme resources - private ThemeUtils mResources; - private long mPosOverride = -1; private long mStartSeekPos = 0; @@ -165,11 +161,6 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Initialze the theme resources - mResources = new ThemeUtils(this); - // Set the overflow style - mResources.setOverflowStyle(this); - // Fade it in overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); @@ -190,7 +181,7 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn // Theme the action bar final ActionBar actionBar = getActionBar(); - mResources.themeActionBar(actionBar, getString(R.string.app_name)); + actionBar.setTitle(getString(R.string.app_name)); actionBar.setDisplayHomeAsUpEnabled(true); // Set the layout @@ -291,7 +282,7 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn final MenuItem effects = menu.findItem(R.id.menu_audio_player_equalizer); effects.setVisible(false); } - mResources.setFavoriteIcon(menu); +// mResources.setFavoriteIcon(menu); return true; } @@ -303,7 +294,7 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn // Search view getMenuInflater().inflate(R.menu.search, menu); // Theme the search icon - mResources.setSearchIcon(menu); +// mResources.setSearchIcon(menu); final SearchView searchView = (SearchView)menu.findItem(R.id.menu_search).getActionView(); // Add voice search @@ -483,7 +474,7 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn mPageContainer = (FrameLayout)findViewById(R.id.audio_player_pager_container); // Theme the pager container background mPageContainer - .setBackgroundDrawable(mResources.getDrawable("audio_player_pager_container")); + .setBackgroundDrawable(getResources().getDrawable(R.drawable.audio_player_pager_container)); // Now playing header mAudioPlayerHeader = (LinearLayout)findViewById(R.id.audio_player_header); @@ -530,7 +521,7 @@ public class AudioPlayerActivity extends FragmentActivity implements ServiceConn // Used to show and hide the queue fragment mQueueSwitch = (ImageView)findViewById(R.id.audio_player_switch_queue); // Theme the queue switch icon - mQueueSwitch.setImageDrawable(mResources.getDrawable("btn_switch_queue")); + mQueueSwitch.setImageDrawable(getResources().getDrawable(R.drawable.btn_switch_queue)); // Progress mProgress = (SeekBar)findViewById(android.R.id.progress); diff --git a/src/com/cyngn/eleven/ui/activities/BaseActivity.java b/src/com/cyngn/eleven/ui/activities/BaseActivity.java index d9c4dab..996f790 100644 --- a/src/com/cyngn/eleven/ui/activities/BaseActivity.java +++ b/src/com/cyngn/eleven/ui/activities/BaseActivity.java @@ -28,7 +28,6 @@ import android.support.v4.app.FragmentActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.Window; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.SearchView; @@ -44,7 +43,6 @@ import com.cyngn.eleven.utils.Lists; import com.cyngn.eleven.utils.MusicUtils; import com.cyngn.eleven.utils.MusicUtils.ServiceToken; import com.cyngn.eleven.utils.NavUtils; -import com.cyngn.eleven.utils.ThemeUtils; import com.cyngn.eleven.widgets.PlayPauseButton; import com.cyngn.eleven.widgets.RepeatButton; import com.cyngn.eleven.widgets.ShuffleButton; @@ -113,23 +111,12 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo private boolean mIsBackPressed = false; /** - * Theme resources - */ - protected ThemeUtils mResources; - - /** * {@inheritDoc} */ @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Initialze the theme resources - mResources = new ThemeUtils(this); - - // Set the overflow style - mResources.setOverflowStyle(this); - // Fade it in overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); @@ -142,8 +129,7 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo // Initialize the broadcast receiver mPlaybackStatus = new PlaybackStatus(this); - // Theme the action bar - mResources.themeActionBar(getActionBar(), getString(R.string.app_name)); + getActionBar().setTitle(getString(R.string.app_name)); // Set the layout setContentView(setContentView()); @@ -183,8 +169,6 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo getMenuInflater().inflate(R.menu.search, menu); // Settings getMenuInflater().inflate(R.menu.activity_base, menu); - // Theme the search icon - mResources.setSearchIcon(menu); final SearchView searchView = (SearchView)menu.findItem(R.id.menu_search).getActionView(); // Add voice search diff --git a/src/com/cyngn/eleven/ui/activities/ProfileActivity.java b/src/com/cyngn/eleven/ui/activities/ProfileActivity.java index c224729..d4a256d 100644 --- a/src/com/cyngn/eleven/ui/activities/ProfileActivity.java +++ b/src/com/cyngn/eleven/ui/activities/ProfileActivity.java @@ -163,7 +163,7 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene mPagerAdapter.add(ArtistAlbumFragment.class, mArguments); // Action bar title - mResources.setTitle(mArtistName); + getActionBar().setTitle(mArtistName); } else // Set up the album profile @@ -175,9 +175,9 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene mPagerAdapter.add(AlbumSongFragment.class, mArguments); // Action bar title = album name - mResources.setTitle(mProfileName); + getActionBar().setTitle(mProfileName); // Action bar subtitle = year released - mResources.setSubtitle(mArguments.getString(Config.ALBUM_YEAR)); + getActionBar().setSubtitle(mArguments.getString(Config.ALBUM_YEAR)); } else // Set up the favorites profile if (isFavorites()) { @@ -188,7 +188,7 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene mPagerAdapter.add(FavoriteFragment.class, null); // Action bar title = Favorites - mResources.setTitle(mProfileName); + getActionBar().setTitle(mProfileName); } else // Set up the last added profile if (isLastAdded()) { @@ -199,7 +199,7 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene mPagerAdapter.add(LastAddedFragment.class, null); // Action bar title = Last added - mResources.setTitle(mProfileName); + getActionBar().setTitle(mProfileName); } else // Set up the user playlist profile if (isPlaylist()) { @@ -210,7 +210,7 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene mPagerAdapter.add(PlaylistSongFragment.class, mArguments); // Action bar title = playlist name - mResources.setTitle(mProfileName); + getActionBar().setTitle(mProfileName); } else // Set up the genre profile if (isGenre()) { @@ -221,7 +221,7 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene mPagerAdapter.add(GenreSongFragment.class, mArguments); // Action bar title = playlist name - mResources.setTitle(mProfileName); + getActionBar().setTitle(mProfileName); } // Initialize the ViewPager @@ -258,8 +258,6 @@ public class ProfileActivity extends BaseActivity implements OnPageChangeListene */ @Override public boolean onPrepareOptionsMenu(final Menu menu) { - // Theme the add to home screen icon - mResources.setAddToHomeScreenIcon(menu); // Set the shuffle all title to "play all" if a playlist. final MenuItem shuffle = menu.findItem(R.id.menu_shuffle); String title = null; diff --git a/src/com/cyngn/eleven/ui/activities/SearchActivity.java b/src/com/cyngn/eleven/ui/activities/SearchActivity.java index 2d775cb..1868e5a 100644 --- a/src/com/cyngn/eleven/ui/activities/SearchActivity.java +++ b/src/com/cyngn/eleven/ui/activities/SearchActivity.java @@ -36,7 +36,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.Window; import android.view.inputmethod.InputMethodManager; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; @@ -60,7 +59,6 @@ import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; import com.cyngn.eleven.utils.MusicUtils.ServiceToken; import com.cyngn.eleven.utils.NavUtils; -import com.cyngn.eleven.utils.ThemeUtils; import java.util.Locale; @@ -100,11 +98,6 @@ public class SearchActivity extends Activity implements LoaderCallbacks<Cursor>, private SearchView mSearchView; /** - * Theme resources - */ - private ThemeUtils mResources; - - /** * {@inheritDoc} */ @SuppressWarnings("deprecation") @@ -112,11 +105,6 @@ public class SearchActivity extends Activity implements LoaderCallbacks<Cursor>, protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Initialze the theme resources - mResources = new ThemeUtils(this); - // Set the overflow style - mResources.setOverflowStyle(this); - // Fade it in overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); @@ -128,7 +116,7 @@ public class SearchActivity extends Activity implements LoaderCallbacks<Cursor>, // Theme the action bar final ActionBar actionBar = getActionBar(); - mResources.themeActionBar(actionBar, getString(R.string.app_name)); + actionBar.setTitle(getString(R.string.app_name)); actionBar.setDisplayHomeAsUpEnabled(true); // Set the layout @@ -143,7 +131,7 @@ public class SearchActivity extends Activity implements LoaderCallbacks<Cursor>, mFilterString = !TextUtils.isEmpty(query) ? query : null; // Action bar subtitle - mResources.setSubtitle("\"" + mFilterString + "\""); + getActionBar().setSubtitle("\"" + mFilterString + "\""); // Initialize the adapter mAdapter = new SearchAdapter(this); @@ -188,8 +176,6 @@ public class SearchActivity extends Activity implements LoaderCallbacks<Cursor>, public boolean onCreateOptionsMenu(final Menu menu) { // Search view getMenuInflater().inflate(R.menu.search, menu); - // Theme the search icon - mResources.setSearchIcon(menu); // Filter the list the user is looking it via SearchView mSearchView = (SearchView)menu.findItem(R.id.menu_search).getActionView(); @@ -324,7 +310,7 @@ public class SearchActivity extends Activity implements LoaderCallbacks<Cursor>, mSearchView.clearFocus(); } // Action bar subtitle - mResources.setSubtitle("\"" + mFilterString + "\""); + getActionBar().setSubtitle("\"" + mFilterString + "\""); return true; } diff --git a/src/com/cyngn/eleven/ui/activities/SettingsActivity.java b/src/com/cyngn/eleven/ui/activities/SettingsActivity.java index 3ddda90..53005db 100644 --- a/src/com/cyngn/eleven/ui/activities/SettingsActivity.java +++ b/src/com/cyngn/eleven/ui/activities/SettingsActivity.java @@ -28,7 +28,6 @@ import android.view.MenuItem; import com.cyngn.eleven.MusicPlaybackService; import com.cyngn.eleven.R; import com.cyngn.eleven.cache.ImageCache; -import com.cyngn.eleven.ui.fragments.ThemeFragment; import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; import com.cyngn.eleven.utils.PreferenceUtils; @@ -125,8 +124,6 @@ public class SettingsActivity extends PreferenceActivity { private void initInterface() { // Color scheme picker updateColorScheme(); - // Open the theme chooser - openThemeChooser(); } /** @@ -144,22 +141,6 @@ public class SettingsActivity extends PreferenceActivity { } /** - * Opens the {@link ThemeFragment}. - */ - private void openThemeChooser() { - final Preference themeChooser = findPreference("theme_chooser"); - themeChooser.setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(final Preference preference) { - final Intent themeChooserIntent = new Intent(SettingsActivity.this, - ThemesActivity.class); - startActivity(themeChooserIntent); - return true; - } - }); - } - - /** * Removes all of the cache entries. */ private void deleteCache() { diff --git a/src/com/cyngn/eleven/ui/activities/ThemesActivity.java b/src/com/cyngn/eleven/ui/activities/ThemesActivity.java deleted file mode 100644 index 712f1fb..0000000 --- a/src/com/cyngn/eleven/ui/activities/ThemesActivity.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.ui.activities; - -import android.app.ActionBar; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - -import com.cyngn.eleven.R; -import com.cyngn.eleven.ui.fragments.ThemeFragment; - -/** - * A class the displays the {@link ThemeFragment}. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemesActivity extends BaseActivity { - - /** - * {@inheritDoc} - */ - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Set up the action bar - final ActionBar actionBar = getActionBar(); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setTitle(getString(R.string.settings_theme_chooser_title)); - - // Transact the theme fragment - if (savedInstanceState == null) { - getSupportFragmentManager().beginTransaction() - .replace(R.id.activity_base_content, new ThemeFragment()).commit(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onPrepareOptionsMenu(final Menu menu) { - mResources.setShopIcon(menu); - return super.onPrepareOptionsMenu(menu); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onCreateOptionsMenu(final Menu menu) { - getMenuInflater().inflate(R.menu.theme_shop, menu); - return super.onCreateOptionsMenu(menu); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onOptionsItemSelected(final MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - finish(); - return true; - case R.id.menu_shop: - mResources.shopFor(this); - return true; - default: - break; - } - return super.onOptionsItemSelected(item); - } - - /** - * {@inheritDoc} - */ - @Override - public int setContentView() { - return R.layout.activity_base; - } -} diff --git a/src/com/cyngn/eleven/ui/fragments/ThemeFragment.java b/src/com/cyngn/eleven/ui/fragments/ThemeFragment.java deleted file mode 100644 index a4ad28a..0000000 --- a/src/com/cyngn/eleven/ui/fragments/ThemeFragment.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.ui.fragments; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.pm.ResolveInfo; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.ContextMenu; -import android.view.ContextMenu.ContextMenuInfo; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.AdapterContextMenuInfo; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ArrayAdapter; -import android.widget.GridView; - -import com.cyngn.eleven.R; -import com.cyngn.eleven.recycler.RecycleHolder; -import com.cyngn.eleven.ui.MusicHolder; -import com.cyngn.eleven.utils.ThemeUtils; -import com.devspark.appmsg.AppMsg; - -import java.util.List; - -/** - * Used to show all of the available themes on a user's device. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemeFragment extends Fragment implements OnItemClickListener { - - private static final int OPEN_IN_PLAY_STORE = 0; - - private GridView mGridView; - - private PackageManager mPackageManager; - - private List<ResolveInfo> mThemes; - - private String[] mEntries; - - private String[] mValues; - - private Drawable[] mThemePreview; - - private Resources mThemeResources; - - private String mThemePackageName; - - private String mThemeName; - - private ThemesAdapter mAdapter; - - private ThemeUtils mTheme; - - /** - * Empty constructor as per the {@link Fragment} documentation - */ - public ThemeFragment() { - } - - /** - * {@inheritDoc} - */ - @Override - public View onCreateView(final LayoutInflater inflater, final ViewGroup container, - final Bundle savedInstanceState) { - // The View for the fragment's UI - final ViewGroup rootView = (ViewGroup)inflater.inflate(R.layout.grid_base, null); - // Initialize the grid - mGridView = (GridView)rootView.findViewById(R.id.grid_base); - // Release any reference to the recycled Views - mGridView.setRecyclerListener(new RecycleHolder()); - // Set the new theme - mGridView.setOnItemClickListener(this); - // Listen for ContextMenus to be created - mGridView.setOnCreateContextMenuListener(this); - if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { - // Limit the columns to one in portrait mode - mGridView.setNumColumns(1); - } else { - // And two for landscape - mGridView.setNumColumns(2); - } - return rootView; - } - - /** - * {@inheritDoc} - */ - @Override - public void onActivityCreated(final Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - // keep apollo theme support - final Intent apolloThemeIntent = new Intent("com.andrew.apollo.THEMES"); - apolloThemeIntent.addCategory("android.intent.category.DEFAULT"); - - mPackageManager = getActivity().getPackageManager(); - mThemes = mPackageManager.queryIntentActivities(apolloThemeIntent, 0); - mEntries = new String[mThemes.size() + 1]; - mValues = new String[mThemes.size() + 1]; - mThemePreview = new Drawable[mThemes.size() + 1]; - - // Default items - mEntries[0] = getString(R.string.app_name); - // mValues[0] = ThemeUtils.ELEVEN_PACKAGE; - mThemePreview[0] = getResources().getDrawable(R.drawable.theme_preview); - - for (int i = 0; i < mThemes.size(); i++) { - mThemePackageName = mThemes.get(i).activityInfo.packageName.toString(); - mThemeName = mThemes.get(i).loadLabel(mPackageManager).toString(); - mEntries[i + 1] = mThemeName; - mValues[i + 1] = mThemePackageName; - - // Theme resources - try { - mThemeResources = mPackageManager.getResourcesForApplication(mThemePackageName - .toString()); - } catch (final NameNotFoundException ignored) { - } - - // Theme preview - final int previewId = mThemeResources.getIdentifier("theme_preview", "drawable", //$NON-NLS-2$ - mThemePackageName.toString()); - if (previewId != 0) { - mThemePreview[i + 1] = mThemeResources.getDrawable(previewId); - } - } - - // Initialize the Adapter - mAdapter = new ThemesAdapter(getActivity(), R.layout.fragment_themes_base); - // Bind the data - mGridView.setAdapter(mAdapter); - - // Get the theme utils - mTheme = new ThemeUtils(getActivity()); - } - - /** - * {@inheritDoc} - */ - @Override - public void onCreateContextMenu(final ContextMenu menu, final View v, - final ContextMenuInfo menuInfo) { - final AdapterContextMenuInfo info = (AdapterContextMenuInfo)menuInfo; - if (info.position > 0) { - // Open to the theme's Play Store page - menu.add(Menu.NONE, OPEN_IN_PLAY_STORE, Menu.NONE, - getString(R.string.context_menu_open_in_play_store)); - } - super.onCreateContextMenu(menu, v, menuInfo); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onContextItemSelected(final android.view.MenuItem item) { - final AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo(); - switch (item.getItemId()) { - case OPEN_IN_PLAY_STORE: - ThemeUtils.openAppPage(getActivity(), mValues[info.position]); - return true; - default: - break; - } - return super.onContextItemSelected(item); - } - - /** - * {@inheritDoc} - */ - @Override - public void onItemClick(final AdapterView<?> parent, final View view, final int position, - final long id) { - mTheme.setThemePackageName(mValues[position]); - AppMsg.makeText(getActivity(), - getString(R.string.theme_set, mEntries[position]), AppMsg.STYLE_CONFIRM) - .show(); - } - - /** - * Populates the {@link GridView} with the available themes - */ - private class ThemesAdapter extends ArrayAdapter<ResolveInfo> { - - /** - * Number of views (ImageView and TextView) - */ - private static final int VIEW_TYPE_COUNT = 2; - - /** - * The resource ID of the layout to inflate - */ - private final int mLayoutID; - - /** - * Used to cache the theme info - */ - private DataHolder[] mData; - - /** - * Constructor of <code>ThemesAdapter</code> - * - * @param context The {@link Context} to use. - * @param layoutID The resource ID of the view to inflate. - */ - public ThemesAdapter(final Context context, final int layoutID) { - super(context, 0); - // Get the layout ID - mLayoutID = layoutID; - // Build the cache - buildCache(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getCount() { - return mEntries.length; - } - - /** - * {@inheritDoc} - */ - @Override - public View getView(final int position, View convertView, final ViewGroup parent) { - - /* Recycle ViewHolder's items */ - MusicHolder holder; - if (convertView == null) { - convertView = LayoutInflater.from(getContext()).inflate(mLayoutID, parent, false); - holder = new MusicHolder(convertView); - convertView.setTag(holder); - } else { - holder = (MusicHolder)convertView.getTag(); - } - - // Retrieve the data holder - final DataHolder dataHolder = mData[position]; - - // Set the theme preview - holder.mImage.get().setImageDrawable(dataHolder.mPreview); - // Set the theme name - holder.mLineOne.get().setText(dataHolder.mName); - return convertView; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasStableIds() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public int getViewTypeCount() { - return VIEW_TYPE_COUNT; - } - - /** - * Method used to cache the data used to populate the list or grid. The - * idea is to cache everything before - * {@code #getView(int, View, ViewGroup)} is called. - */ - private void buildCache() { - mData = new DataHolder[getCount()]; - for (int i = 0; i < getCount(); i++) { - // Build the data holder - mData[i] = new DataHolder(); - // Theme names (line one) - mData[i].mName = mEntries[i]; - // Theme preview - mData[i].mPreview = mThemePreview[i]; - } - } - - } - - /** - * @param view The {@link View} used to initialize content - */ - public final static class DataHolder { - - public String mName; - - public Drawable mPreview; - - /** - * Constructor of <code>DataHolder</code> - */ - public DataHolder() { - super(); - } - } -} diff --git a/src/com/cyngn/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java b/src/com/cyngn/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java index 087b462..3dbf280 100644 --- a/src/com/cyngn/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java +++ b/src/com/cyngn/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java @@ -31,7 +31,6 @@ import com.cyngn.eleven.utils.MusicUtils; import com.cyngn.eleven.utils.NavUtils; import com.cyngn.eleven.utils.PreferenceUtils; import com.cyngn.eleven.utils.SortOrder; -import com.cyngn.eleven.utils.ThemeUtils; import com.viewpagerindicator.TitlePageIndicator; import com.viewpagerindicator.TitlePageIndicator.OnCenterItemClickListener; @@ -60,11 +59,6 @@ public class MusicBrowserPhoneFragment extends Fragment implements */ private PagerAdapter mPagerAdapter; - /** - * Theme resources - */ - private ThemeUtils mResources; - private PreferenceUtils mPreferences; /** @@ -125,8 +119,6 @@ public class MusicBrowserPhoneFragment extends Fragment implements @Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - // Initialze the theme resources - mResources = new ThemeUtils(getActivity()); // Enable the options menu setHasOptionsMenu(true); } @@ -147,7 +139,6 @@ public class MusicBrowserPhoneFragment extends Fragment implements @Override public void onPrepareOptionsMenu(final Menu menu) { super.onPrepareOptionsMenu(menu); - mResources.setFavoriteIcon(menu); } /** diff --git a/src/com/cyngn/eleven/utils/ThemeUtils.java b/src/com/cyngn/eleven/utils/ThemeUtils.java deleted file mode 100644 index ab19fa3..0000000 --- a/src/com/cyngn/eleven/utils/ThemeUtils.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.utils; - -import android.app.ActionBar; -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.net.Uri; -import android.os.AsyncTask; -import android.preference.PreferenceManager; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.TextView; - -import com.cyngn.eleven.R; - -/** - * In order to implement the theme chooser for Apollo, this class returns a - * {@link Resources} object that can be used like normal. In other words, when - * {@code getDrawable()} or {@code getColor()} is called, the object returned is - * from the current theme package name and because all of the theme resource - * identifiers are the same as all of Apollo's resources a little less code is - * used to implement the theme chooser. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemeUtils { - - /** - * Used to searc the "Apps" section of the Play Store for "Apollo Themes". - */ - private static final String SEARCH_URI = "https://market.android.com/search?q=%s&c=apps&featured=APP_STORE_SEARCH"; - - /** - * Used to search the Play Store for a specific theme. - */ - private static final String APP_URI = "market://details?id="; - - /** - * Default package name. - */ - public static final String ELEVEN_PACKAGE = "com.cyngn.eleven"; - - /** - * Current theme package name. - */ - public static final String PACKAGE_NAME = "theme_package_name"; - - /** - * Used to get and set the theme package name. - */ - private final SharedPreferences mPreferences; - - /** - * The theme package name. - */ - private final String mThemePackage; - - /** - * The keyword to use when search for different themes. - */ - private static String sApolloSearch; - - /** - * This is the current theme color as set by the color picker. - */ - private final int mCurrentThemeColor; - - /** - * Package manager - */ - private final PackageManager mPackageManager; - - /** - * Custom action bar layout - */ - private final View mActionBarLayout; - - /** - * The theme resources. - */ - private Resources mResources; - - /** - * Constructor for <code>ThemeUtils</code> - * - * @param context The {@link Context} to use. - */ - public ThemeUtils(final Context context) { - // Get the search query - sApolloSearch = context.getString(R.string.apollo_themes_shop_key); - // Get the preferences - mPreferences = PreferenceManager.getDefaultSharedPreferences(context); - // Get the theme package name - mThemePackage = getThemePackageName(); - // Initialze the package manager - mPackageManager = context.getPackageManager(); - try { - // Find the theme resources - mResources = mPackageManager.getResourcesForApplication(mThemePackage); - } catch (final Exception e) { - // If the user isn't using a theme, then the resources should be - // Eleven's. - setThemePackageName(ELEVEN_PACKAGE); - } - // Get the current theme color - mCurrentThemeColor = PreferenceUtils.getInstance(context).getDefaultThemeColor(context); - // Inflate the custom layout - mActionBarLayout = LayoutInflater.from(context).inflate(R.layout.action_bar, null); - } - - /** - * Set the new theme package name. - * - * @param packageName The package name of the theme to be set. - */ - public void setThemePackageName(final String packageName) { - ApolloUtils.execute(false, new AsyncTask<Void, Void, Void>() { - @Override - protected Void doInBackground(final Void... unused) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putString(PACKAGE_NAME, packageName); - editor.apply(); - return null; - } - }, (Void[])null); - } - - /** - * Return the current theme package name. - * - * @return The default theme package name. - */ - public final String getThemePackageName() { - return mPreferences.getString(PACKAGE_NAME, ELEVEN_PACKAGE); - } - - /** - * Used to return a color from the theme resources. - * - * @param resourceName The name of the color to return. i.e. - * "action_bar_color". - * @return A new color from the theme resources. - */ - public int getColor(final String resourceName) { - final int resourceId = mResources.getIdentifier(resourceName, "color", mThemePackage); - try { - return mResources.getColor(resourceId); - } catch (final Resources.NotFoundException e) { - // If the theme designer wants to allow the user to theme a - // particular object via the color picker, they just remove the - // resource item from the themeconfig.xml file. - } - return mCurrentThemeColor; - } - - /** - * Used to return a drawable from the theme resources. - * - * @param resourceName The name of the drawable to return. i.e. - * "pager_background". - * @return A new color from the theme resources. - */ - public Drawable getDrawable(final String resourceName) { - final int resourceId = mResources.getIdentifier(resourceName, "drawable", mThemePackage); - try { - return mResources.getDrawable(resourceId); - } catch (final Resources.NotFoundException e) { - //$FALL-THROUGH$ - } - return null; - } - - /** - * Used to tell if the action bar's backgrond color is dark or light and - * depending on which the proper overflow icon is set from a style. - * - * @return True if the action bar color is dark, false if light. - */ - public boolean isActionBarDark() { - return ApolloUtils.isColorDark(getColor("action_bar")); - } - - /** - * Sets the corret overflow icon in the action bar depending on whether or - * not the current action bar color is dark or light. - * - * @param app The {@link Activity} used to set the theme. - */ - public void setOverflowStyle(final Activity app) { - if (isActionBarDark()) { - app.setTheme(R.style.Apollo_Theme_Dark); - } else { - app.setTheme(R.style.Apollo_Theme_Light); - } - } - - /** - * This is used to set the color of a {@link MenuItem}. For instance, when - * the current song is a favorite, the favorite icon will use the current - * theme color. - * - * @param menuItem The {@link MenuItem} to set. - * @param resourceColorName The color theme resource key. - * @param resourceDrawableName The drawable theme resource key. - */ - public void setMenuItemColor(final MenuItem menuItem, final String resourceColorName, - final String resourceDrawableName) { - - final Drawable maskDrawable = getDrawable(resourceDrawableName); - if (!(maskDrawable instanceof BitmapDrawable)) { - return; - } - - final Bitmap maskBitmap = ((BitmapDrawable)maskDrawable).getBitmap(); - final int width = maskBitmap.getWidth(); - final int height = maskBitmap.getHeight(); - - final Bitmap outBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - final Canvas canvas = new Canvas(outBitmap); - canvas.drawBitmap(maskBitmap, 0, 0, null); - - final Paint maskedPaint = new Paint(); - maskedPaint.setColor(getColor(resourceColorName)); - maskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); - - canvas.drawRect(0, 0, width, height, maskedPaint); - - final BitmapDrawable outDrawable = new BitmapDrawable(mResources, outBitmap); - menuItem.setIcon(outDrawable); - } - - /** - * Sets the {@link MenuItem} icon for the favorites action. - * - * @param context The {@link Context} to use. - * @param favorite The favorites action. - */ - public void setFavoriteIcon(final Menu favorite) { - final MenuItem favoriteAction = favorite.findItem(R.id.menu_favorite); - final String favoriteIconId = "ic_action_favorite"; - if (MusicUtils.isFavorite()) { - setMenuItemColor(favoriteAction, "favorite_selected", favoriteIconId); - } else { - setMenuItemColor(favoriteAction, "favorite_normal", favoriteIconId); - } - } - - /** - * Sets the {@link MenuItem} icon for the search action. - * - * @param context The {@link Context} to use. - * @param search The Menu used to find the "menu_search" action. - */ - public void setSearchIcon(final Menu search) { - final MenuItem searchAction = search.findItem(R.id.menu_search); - final String searchIconId = "ic_action_search"; - setMenuItemColor(searchAction, "search_action", searchIconId); - } - - /** - * Sets the {@link MenuItem} icon for the shop action. - * - * @param context The {@link Context} to use. - * @param search The Menu used to find the "menu_shop" action. - */ - public void setShopIcon(final Menu search) { - final MenuItem shopAction = search.findItem(R.id.menu_shop); - final String shopIconId = "ic_action_shop"; - setMenuItemColor(shopAction, "shop_action", shopIconId); - } - - /** - * Sets the {@link MenuItem} icon for the add to Home screen action. - * - * @param context The {@link Context} to use. - * @param search The Menu used to find the "add_to_homescreen" item. - */ - public void setAddToHomeScreenIcon(final Menu search) { - final MenuItem pinnAction = search.findItem(R.id.menu_add_to_homescreen); - final String pinnIconId = "ic_action_pinn_to_home"; - setMenuItemColor(pinnAction, "pinn_to_action", pinnIconId); - } - - /** - * Builds a custom layout and applies it to the action bar, then themes the - * background, title, and subtitle. - * - * @param actionBar The {@link ActionBar} to use. - * @param resources The {@link ThemeUtils} used to theme the background, - * title, and subtitle. - * @param title The title for the action bar - * @param subtitle The subtitle for the action bar. - */ - public void themeActionBar(final ActionBar actionBar, final String title) { - // Set the custom layout - actionBar.setCustomView(mActionBarLayout); - actionBar.setDisplayShowCustomEnabled(true); - actionBar.setDisplayShowTitleEnabled(false); - - // Theme the action bar background - actionBar.setBackgroundDrawable(getDrawable("action_bar")); - - // Theme the title - setTitle(title); - } - - /** - * Themes the action bar subtitle - * - * @param subtitle The subtitle to use - */ - public void setTitle(final String title) { - if (!TextUtils.isEmpty(title)) { - // Get the title text view - final TextView actionBarTitle = (TextView)mActionBarLayout - .findViewById(R.id.action_bar_title); - // Theme the title - actionBarTitle.setTextColor(getColor("action_bar_title")); - // Set the title - actionBarTitle.setText(title); - } - } - - /** - * Themes the action bar subtitle - * - * @param subtitle The subtitle to use - */ - public void setSubtitle(final String subtitle) { - if (!TextUtils.isEmpty(subtitle)) { - final TextView actionBarSubtitle = (TextView)mActionBarLayout - .findViewById(R.id.action_bar_subtitle); - actionBarSubtitle.setVisibility(View.VISIBLE); - // Theme the subtitle - actionBarSubtitle.setTextColor(getColor("action_bar_subtitle")); - // Set the subtitle - actionBarSubtitle.setText(subtitle); - } - } - - /** - * Used to search the Play Store for "Apollo Themes". - * - * @param context The {@link Context} to use. - */ - public void shopFor(final Context context) { - final Intent shopIntent = new Intent(Intent.ACTION_VIEW); - shopIntent.setData(Uri.parse(String.format(SEARCH_URI, Uri.encode(sApolloSearch)))); - shopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - shopIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); - context.startActivity(shopIntent); - } - - /** - * Used to search the Play Store for a specific app. - * - * @param context The {@link Context} to use. - * @param themeName The theme name to search for. - */ - public static void openAppPage(final Context context, final String themeName) { - final Intent shopIntent = new Intent(Intent.ACTION_VIEW); - shopIntent.setData(Uri.parse(APP_URI + themeName)); - shopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - shopIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); - context.startActivity(shopIntent); - } -} diff --git a/src/com/cyngn/eleven/widgets/PlayPauseButton.java b/src/com/cyngn/eleven/widgets/PlayPauseButton.java index d1f77fa..157d96e 100644 --- a/src/com/cyngn/eleven/widgets/PlayPauseButton.java +++ b/src/com/cyngn/eleven/widgets/PlayPauseButton.java @@ -22,7 +22,6 @@ import android.widget.ImageButton; import com.cyngn.eleven.R; import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; -import com.cyngn.eleven.utils.ThemeUtils; import com.cyngn.eleven.widgets.theme.HoloSelector; /** @@ -43,19 +42,12 @@ public class PlayPauseButton extends ImageButton implements OnClickListener, OnL private static final String PAUSE = "btn_playback_pause"; /** - * The resources to use. - */ - private final ThemeUtils mResources; - - /** * @param context The {@link Context} to use * @param attrs The attributes of the XML tag that is inflating the view. */ @SuppressWarnings("deprecation") public PlayPauseButton(final Context context, final AttributeSet attrs) { super(context, attrs); - // Initialze the theme resources - mResources = new ThemeUtils(context); // Theme the selector setBackgroundDrawable(new HoloSelector(context)); // Control playback (play/pause) @@ -92,10 +84,10 @@ public class PlayPauseButton extends ImageButton implements OnClickListener, OnL public void updateState() { if (MusicUtils.isPlaying()) { setContentDescription(getResources().getString(R.string.accessibility_pause)); - setImageDrawable(mResources.getDrawable(PAUSE)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_pause)); } else { setContentDescription(getResources().getString(R.string.accessibility_play)); - setImageDrawable(mResources.getDrawable(PLAY)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_play)); } } diff --git a/src/com/cyngn/eleven/widgets/RepeatButton.java b/src/com/cyngn/eleven/widgets/RepeatButton.java index cecd769..cafa2ad 100644 --- a/src/com/cyngn/eleven/widgets/RepeatButton.java +++ b/src/com/cyngn/eleven/widgets/RepeatButton.java @@ -23,7 +23,6 @@ import com.cyngn.eleven.MusicPlaybackService; import com.cyngn.eleven.R; import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; -import com.cyngn.eleven.utils.ThemeUtils; import com.cyngn.eleven.widgets.theme.HoloSelector; /** @@ -49,19 +48,12 @@ public class RepeatButton extends ImageButton implements OnClickListener, OnLong private static final String REPEAT_NONE = "btn_playback_repeat"; /** - * The resources to use. - */ - private final ThemeUtils mResources; - - /** * @param context The {@link Context} to use * @param attrs The attributes of the XML tag that is inflating the view. */ @SuppressWarnings("deprecation") public RepeatButton(final Context context, final AttributeSet attrs) { super(context, attrs); - // Initialze the theme resources - mResources = new ThemeUtils(context); // Set the selector setBackgroundDrawable(new HoloSelector(context)); // Control playback (cycle repeat modes) @@ -99,15 +91,15 @@ public class RepeatButton extends ImageButton implements OnClickListener, OnLong switch (MusicUtils.getRepeatMode()) { case MusicPlaybackService.REPEAT_ALL: setContentDescription(getResources().getString(R.string.accessibility_repeat_all)); - setImageDrawable(mResources.getDrawable(REPEAT_ALL)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_repeat_all)); break; case MusicPlaybackService.REPEAT_CURRENT: setContentDescription(getResources().getString(R.string.accessibility_repeat_one)); - setImageDrawable(mResources.getDrawable(REPEAT_CURRENT)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_repeat_one)); break; case MusicPlaybackService.REPEAT_NONE: setContentDescription(getResources().getString(R.string.accessibility_repeat)); - setImageDrawable(mResources.getDrawable(REPEAT_NONE)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_repeat)); break; default: break; diff --git a/src/com/cyngn/eleven/widgets/RepeatingImageButton.java b/src/com/cyngn/eleven/widgets/RepeatingImageButton.java index e633648..6aaabcd 100644 --- a/src/com/cyngn/eleven/widgets/RepeatingImageButton.java +++ b/src/com/cyngn/eleven/widgets/RepeatingImageButton.java @@ -23,7 +23,6 @@ import android.widget.ImageButton; import com.cyngn.eleven.R; import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; -import com.cyngn.eleven.utils.ThemeUtils; import com.cyngn.eleven.widgets.theme.HoloSelector; /** @@ -45,11 +44,6 @@ public class RepeatingImageButton extends ImageButton implements OnClickListener private static final long sInterval = 400; - /** - * The resources to use. - */ - private final ThemeUtils mResources; - private long mStartTime; private int mRepeatCount; @@ -63,8 +57,6 @@ public class RepeatingImageButton extends ImageButton implements OnClickListener @SuppressWarnings("deprecation") public RepeatingImageButton(final Context context, final AttributeSet attrs) { super(context, attrs); - // Initialze the theme resources - mResources = new ThemeUtils(context); // Theme the selector setBackgroundDrawable(new HoloSelector(context)); setFocusable(true); @@ -193,10 +185,10 @@ public class RepeatingImageButton extends ImageButton implements OnClickListener public void updateState() { switch (getId()) { case R.id.action_button_next: - setImageDrawable(mResources.getDrawable(NEXT)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_next)); break; case R.id.action_button_previous: - setImageDrawable(mResources.getDrawable(PREVIOUS)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_previous)); break; default: break; diff --git a/src/com/cyngn/eleven/widgets/ShuffleButton.java b/src/com/cyngn/eleven/widgets/ShuffleButton.java index 808656b..0b44d53 100644 --- a/src/com/cyngn/eleven/widgets/ShuffleButton.java +++ b/src/com/cyngn/eleven/widgets/ShuffleButton.java @@ -23,7 +23,6 @@ import com.cyngn.eleven.MusicPlaybackService; import com.cyngn.eleven.R; import com.cyngn.eleven.utils.ApolloUtils; import com.cyngn.eleven.utils.MusicUtils; -import com.cyngn.eleven.utils.ThemeUtils; import com.cyngn.eleven.widgets.theme.HoloSelector; /** @@ -42,19 +41,12 @@ public class ShuffleButton extends ImageButton implements OnClickListener, OnLon private static final String SHUFFLE_ALL = "btn_playback_shuffle_all"; /** - * The resources to use. - */ - private final ThemeUtils mResources; - - /** * @param context The {@link Context} to use * @param attrs The attributes of the XML tag that is inflating the view. */ @SuppressWarnings("deprecation") public ShuffleButton(final Context context, final AttributeSet attrs) { super(context, attrs); - // Initialze the theme resources - mResources = new ThemeUtils(context); // Theme the selector setBackgroundDrawable(new HoloSelector(context)); // Control playback (cycle shuffle) @@ -92,15 +84,15 @@ public class ShuffleButton extends ImageButton implements OnClickListener, OnLon switch (MusicUtils.getShuffleMode()) { case MusicPlaybackService.SHUFFLE_NORMAL: setContentDescription(getResources().getString(R.string.accessibility_shuffle_all)); - setImageDrawable(mResources.getDrawable(SHUFFLE_ALL)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_shuffle_all)); break; case MusicPlaybackService.SHUFFLE_AUTO: setContentDescription(getResources().getString(R.string.accessibility_shuffle_all)); - setImageDrawable(mResources.getDrawable(SHUFFLE_ALL)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_shuffle_all)); break; case MusicPlaybackService.SHUFFLE_NONE: setContentDescription(getResources().getString(R.string.accessibility_shuffle)); - setImageDrawable(mResources.getDrawable(SHUFFLE)); + setImageDrawable(getResources().getDrawable(R.drawable.btn_playback_shuffle)); break; default: break; diff --git a/src/com/cyngn/eleven/widgets/theme/BottomActionBar.java b/src/com/cyngn/eleven/widgets/theme/BottomActionBar.java index 2b9cbf1..96606ae 100644 --- a/src/com/cyngn/eleven/widgets/theme/BottomActionBar.java +++ b/src/com/cyngn/eleven/widgets/theme/BottomActionBar.java @@ -18,7 +18,6 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; import com.cyngn.eleven.R; -import com.cyngn.eleven.utils.ThemeUtils; /** * @author Andrew Neal (andrewdneal@gmail.com) @@ -38,10 +37,7 @@ public class BottomActionBar extends RelativeLayout { */ public BottomActionBar(final Context context, final AttributeSet attrs) { super(context, attrs); - // Initialze the theme resources - final ThemeUtils resources = new ThemeUtils(context); - // Theme the bottom action bar - setBackgroundDrawable(resources.getDrawable(BOTTOM_ACTION_BAR)); + setBackgroundDrawable(getResources().getDrawable(R.drawable.bottom_action_bar)); } /** diff --git a/src/com/cyngn/eleven/widgets/theme/Colorstrip.java b/src/com/cyngn/eleven/widgets/theme/Colorstrip.java deleted file mode 100644 index b613bec..0000000 --- a/src/com/cyngn/eleven/widgets/theme/Colorstrip.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.widgets.theme; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.View; - -import com.cyngn.eleven.utils.ThemeUtils; - -/** - * Used as a thin strip placed just above the bottom action bar or just below - * the top action bar. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class Colorstrip extends View { - - /** - * Resource name used to theme the colorstrip - */ - private static final String COLORSTRIP = "colorstrip"; - - /** - * @param context The {@link Context} to use - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public Colorstrip(final Context context, final AttributeSet attrs) { - super(context, attrs); - // Initialze the theme resources - final ThemeUtils resources = new ThemeUtils(context); - // Theme the colorstrip - setBackgroundColor(resources.getColor(COLORSTRIP)); - } -} diff --git a/src/com/cyngn/eleven/widgets/theme/HoloSelector.java b/src/com/cyngn/eleven/widgets/theme/HoloSelector.java index 9f76ee7..51326e1 100644 --- a/src/com/cyngn/eleven/widgets/theme/HoloSelector.java +++ b/src/com/cyngn/eleven/widgets/theme/HoloSelector.java @@ -17,8 +17,7 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.StateListDrawable; -import com.cyngn.eleven.utils.ApolloUtils; -import com.cyngn.eleven.utils.ThemeUtils; +import com.cyngn.eleven.R; import java.lang.ref.WeakReference; @@ -51,8 +50,7 @@ public class HoloSelector extends StateListDrawable { */ @SuppressLint("NewApi") public HoloSelector(final Context context) { - final ThemeUtils resources = new ThemeUtils(context); - final int themeColor = resources.getColor(RESOURCE_NAME); + final int themeColor = context.getResources().getColor(R.color.holo_blue_light); // Focused addState(new int[] { FOCUSED diff --git a/src/com/cyngn/eleven/widgets/theme/ThemeableFrameLayout.java b/src/com/cyngn/eleven/widgets/theme/ThemeableFrameLayout.java deleted file mode 100644 index e747989..0000000 --- a/src/com/cyngn/eleven/widgets/theme/ThemeableFrameLayout.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.widgets.theme; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.FrameLayout; - -import com.cyngn.eleven.utils.ThemeUtils; - -/** - * This is a custom {@link FrameLayout} that is used as the main conent when - * transacting fragments that is made themeable by allowing developers to change - * the background. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemeableFrameLayout extends FrameLayout { - - /** - * Used to set the background - */ - public static final String BACKGROUND = "pager_background"; - - /** - * @param context The {@link Context} to use - * @param attrs The attributes of the XML tag that is inflating the view. - */ - @SuppressWarnings("deprecation") - public ThemeableFrameLayout(final Context context, final AttributeSet attrs) { - super(context, attrs); - // Initialze the theme resources - final ThemeUtils resources = new ThemeUtils(context); - // Theme the layout - setBackgroundDrawable(resources.getDrawable(BACKGROUND)); - } - -} diff --git a/src/com/cyngn/eleven/widgets/theme/ThemeableSeekBar.java b/src/com/cyngn/eleven/widgets/theme/ThemeableSeekBar.java deleted file mode 100644 index 1251d4e..0000000 --- a/src/com/cyngn/eleven/widgets/theme/ThemeableSeekBar.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.widgets.theme; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.SeekBar; - -import com.cyngn.eleven.utils.ThemeUtils; - -/** - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemeableSeekBar extends SeekBar { - - /** - * Used to set the progess bar - */ - public static final String PROGESS = "audio_player_seekbar"; - - /** - * @param context The {@link Context} to use - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public ThemeableSeekBar(final Context context, final AttributeSet attrs) { - super(context, attrs); - // Initialze the theme resources - final ThemeUtils resources = new ThemeUtils(context); - // Theme the seek bar - setProgressDrawable(resources.getDrawable(PROGESS)); - } - -} diff --git a/src/com/cyngn/eleven/widgets/theme/ThemeableTextView.java b/src/com/cyngn/eleven/widgets/theme/ThemeableTextView.java deleted file mode 100644 index 9cde3da..0000000 --- a/src/com/cyngn/eleven/widgets/theme/ThemeableTextView.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.widgets.theme; - -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Typeface; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.widget.TextView; - -import com.cyngn.eleven.R; -import com.cyngn.eleven.utils.ThemeUtils; - -import java.util.WeakHashMap; - -/** - * A custom {@link TextView} that is made themeable for developers. It allows a - * custom font and color to be set, otherwise functions like normal. Because - * different text views may required different colors to be set, the resource - * name each can be set in the XML via the attribute {@value themeResource}. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemeableTextView extends TextView { - - /** - * @param context The {@link Context} to use - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public ThemeableTextView(final Context context, final AttributeSet attrs) { - super(context, attrs); - // Initialze the theme resources - final ThemeUtils resources = new ThemeUtils(context); - // Retrieve styles attributes - final TypedArray typedArray = context.obtainStyledAttributes(attrs, - R.styleable.ThemeableTextView, 0, 0); - // Get the theme resource name - final String resourceName = typedArray - .getString(R.styleable.ThemeableTextView_themeResource); - // Theme the text color - if (!TextUtils.isEmpty(resourceName)) { - setTextColor(resources.getColor(resourceName)); - } - // Recyle the attrs - typedArray.recycle(); - } - - /** - * A small class that holds a weak cache for any typefaces applied to the - * text. - */ - public static final class TypefaceCache { - - private static final WeakHashMap<String, Typeface> MAP = new WeakHashMap<String, Typeface>(); - - private static TypefaceCache sInstance; - - /** - * Constructor for <code>TypefaceCache</code> - */ - public TypefaceCache() { - } - - /** - * @return A singleton of {@linkTypefaceCache}. - */ - public static final TypefaceCache getInstance() { - if (sInstance == null) { - sInstance = new TypefaceCache(); - } - return sInstance; - } - - /** - * @param file The name of the type face asset. - * @param context The {@link Context} to use. - * @return A new type face. - */ - public Typeface getTypeface(final String file, final Context context) { - Typeface result = MAP.get(file); - if (result == null) { - result = Typeface.createFromAsset(context.getAssets(), file); - MAP.put(file, result); - } - return result; - } - } -} diff --git a/src/com/cyngn/eleven/widgets/theme/ThemeableTitlePageIndicator.java b/src/com/cyngn/eleven/widgets/theme/ThemeableTitlePageIndicator.java deleted file mode 100644 index 2455c34..0000000 --- a/src/com/cyngn/eleven/widgets/theme/ThemeableTitlePageIndicator.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2012 Andrew Neal 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.cyngn.eleven.widgets.theme; - -import android.content.Context; -import android.util.AttributeSet; - -import com.cyngn.eleven.utils.ThemeUtils; -import com.viewpagerindicator.TitlePageIndicator; - -/** - * This is a custom {@link TitlePageIndicator} that is made themeable by - * allowing developers to choose the background and the selected and unselected - * text colors. - * - * @author Andrew Neal (andrewdneal@gmail.com) - */ -public class ThemeableTitlePageIndicator extends TitlePageIndicator { - - /** - * Resource name used to theme the background - */ - private static final String BACKGROUND = "tpi_background"; - - /** - * Resource name used to theme the selected text color - */ - private static final String SELECTED_TEXT = "tpi_selected_text_color"; - - /** - * Resource name used to theme the unselected text color - */ - private static final String TEXT = "tpi_unselected_text_color"; - - /** - * Resource name used to theme the footer color - */ - private static final String FOOTER = "tpi_footer_color"; - - /** - * @param context The {@link Context} to use - * @param attrs The attributes of the XML tag that is inflating the view. - */ - @SuppressWarnings("deprecation") - public ThemeableTitlePageIndicator(final Context context, final AttributeSet attrs) { - super(context, attrs); - // Initialze the theme resources - final ThemeUtils resources = new ThemeUtils(context); - // Theme the background - setBackgroundDrawable(resources.getDrawable(BACKGROUND)); - // Theme the selected text color - setSelectedColor(resources.getColor(SELECTED_TEXT)); - // Theme the unselected text color - setTextColor(resources.getColor(TEXT)); - // Theme the footer - setFooterColor(resources.getColor(FOOTER)); - } -} |