diff options
author | Linus Lee <llee@cyngn.com> | 2015-04-17 18:52:24 -0700 |
---|---|---|
committer | Linus Lee <llee@cyngn.com> | 2015-05-22 19:58:52 +0000 |
commit | ffb652d58b7b5b9e9ef3a8c09f3ce88587437494 (patch) | |
tree | a36753c3109872698ca0a8400716d26ddc21c76c | |
parent | db74f2877c5499bfd322ee9eb2d0976ad4a2a004 (diff) | |
download | android_packages_apps_Eleven-ffb652d58b7b5b9e9ef3a8c09f3ce88587437494.tar.gz android_packages_apps_Eleven-ffb652d58b7b5b9e9ef3a8c09f3ce88587437494.tar.bz2 android_packages_apps_Eleven-ffb652d58b7b5b9e9ef3a8c09f3ce88587437494.zip |
Add Landscape support to Eleven
This adds most of the support. There is a bug around the album art
not loading on rotation - but this patch covers pretty much every
other case
Change-Id: If9033b0323beab8837493d289dcf77b76d1ea8c9
(cherry picked from commit 442768038f32eede422e0a3e7ec8235d564cd0b5)
-rw-r--r-- | AndroidManifest.xml | 7 | ||||
-rw-r--r-- | res/layout-land/activity_player_fragment.xml | 37 | ||||
-rw-r--r-- | res/layout/activity_player_fragment.xml | 239 | ||||
-rw-r--r-- | res/layout/main_album_flow.xml | 60 | ||||
-rw-r--r-- | res/layout/main_playback_controls.xml | 213 | ||||
-rw-r--r-- | src/com/cyanogenmod/eleven/ui/activities/HomeActivity.java | 63 | ||||
-rw-r--r-- | src/com/cyanogenmod/eleven/ui/activities/SlidingPanelActivity.java | 24 | ||||
-rw-r--r-- | src/com/cyanogenmod/eleven/ui/fragments/AudioPlayerFragment.java | 17 | ||||
-rw-r--r-- | src/com/cyanogenmod/eleven/ui/fragments/BaseFragment.java | 6 | ||||
-rw-r--r-- | src/com/cyanogenmod/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java | 13 |
10 files changed, 407 insertions, 272 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2506294..8faba5b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -72,7 +72,6 @@ android:windowSoftInputMode="adjustPan" android:launchMode="singleTop" android:exported="true" - android:screenOrientation="portrait" android:theme="@style/Eleven.Theme.ActionBar.Overlay"> <intent-filter> <action android:name="android.intent.action.MAIN" /> @@ -138,8 +137,7 @@ android:name="com.cyanogenmod.eleven.ui.activities.SearchActivity" android:windowSoftInputMode="adjustResize" android:exported="true" - android:theme="@style/Eleven.Theme" - android:screenOrientation="portrait"> + android:theme="@style/Eleven.Theme"> <intent-filter> <action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.MEDIA_SEARCH" /> @@ -154,8 +152,7 @@ <!-- Used to set options --> <activity android:name="com.cyanogenmod.eleven.ui.activities.SettingsActivity" - android:label="@string/menu_settings" - android:screenOrientation="portrait"/> + android:label="@string/menu_settings"/> <!-- 4x1 App Widget --> <receiver android:name="com.cyanogenmod.eleven.appwidgets.AppWidgetSmall" diff --git a/res/layout-land/activity_player_fragment.xml b/res/layout-land/activity_player_fragment.xml new file mode 100644 index 0000000..17d777e --- /dev/null +++ b/res/layout-land/activity_player_fragment.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2012 Andrew Neal + 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. +--> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <include + android:id="@+id/audio_player_header" + layout="@layout/audio_player_header_bar" /> + + <LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal"> + + <include layout="@layout/main_album_flow" /> + <include layout="@layout/main_playback_controls" /> + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/activity_player_fragment.xml b/res/layout/activity_player_fragment.xml index 2b2c4f6..3e47c08 100644 --- a/res/layout/activity_player_fragment.xml +++ b/res/layout/activity_player_fragment.xml @@ -25,242 +25,7 @@ android:id="@+id/audio_player_header" layout="@layout/audio_player_header_bar" /> - <com.cyanogenmod.eleven.widgets.SquareFrame - android:layout_width="match_parent" - android:layout_height="match_parent"> - <com.cyanogenmod.eleven.widgets.SquareViewPager - android:id="@+id/audio_player_album_art_viewpager" - android:layout_width="match_parent" - android:layout_height="match_parent" /> - <include layout="@layout/loading_empty_container" /> + <include layout="@layout/main_album_flow" /> - <View - android:id="@+id/equalizerGradient" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@drawable/equalizer_background" - android:layout_gravity="bottom"/> - - <com.cyanogenmod.eleven.widgets.EqualizerView - android:id="@+id/equalizerView" - android:gravity="bottom" - android:layout_gravity="bottom" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:clipToPadding="false" - android:visibility="visible" /> - - <TextView - android:id="@+id/audio_player_lyrics" - android:layout_gravity="center" - android:gravity="center" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:minHeight="66dp" - android:paddingLeft="15dp" - android:paddingRight="15dp" - android:paddingTop="6dp" - android:paddingBottom="6dp" - android:background="@color/lyrics_background_color" - android:textColor="@color/white" - android:textSize="@dimen/text_size_small" - android:alpha="0.0"/> - </com.cyanogenmod.eleven.widgets.SquareFrame> - - <RelativeLayout - android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:background="@android:color/transparent" > - <com.cyanogenmod.eleven.widgets.PlayPauseProgressButton - android:id="@+id/playPauseProgressButton" - android:layout_width="@dimen/audio_player_controls_main_button_width" - android:layout_height="@dimen/audio_player_controls_main_button_height" - android:layout_centerInParent="true" > - - <!-- TODO: Figure out why scaleType: centerInside isn't properly scaling up --> - <com.cyanogenmod.eleven.widgets.PlayPauseButton - android:id="@+id/action_button_play" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_gravity="center" - android:contentDescription="@string/accessibility_play" - android:focusable="true" - android:scaleType="centerCrop" - android:src="@drawable/btn_playback_play" /> - - <ProgressBar - android:id="@+id/progressBarBackground" - style="?android:attr/progressBarStyleHorizontal" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clickable="false" - android:indeterminate="false" - android:max="100" - android:progress="100" - android:progressDrawable="@drawable/now_playing_progress_background" /> - - <ProgressBar - android:id="@+id/circularProgressBar" - style="?android:attr/progressBarStyleHorizontal" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clickable="false" - android:indeterminate="false" - android:max="100" - android:progressDrawable="@drawable/now_playing_progress" /> - </com.cyanogenmod.eleven.widgets.PlayPauseProgressButton> - - <!-- TODO: Figure out why scaleType: centerInside isn't properly scaling up --> - <!-- ANSWER: two issues (a) centerInside doesn't scale up, only down, use - fitCenter instead. Also, ImageButtons come with built-in padding, but - that only makes a visible difference when you are scaling the image. - so you have to set the padding to zero in order to get the result you expect --> - <!-- This is the left side of the progress bar - it has the previous - and shuffle button and the current time text --> - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="fill_parent" - android:layout_toLeftOf="@id/playPauseProgressButton"> - - <TextView - android:id="@+id/audio_player_current_time" - android:layout_width="52dp" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:gravity="left|center_vertical" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:paddingLeft="@dimen/audio_player_time_text_padding" - android:textColor="@color/audio_player_text_color" - android:textSize="@dimen/audio_player_time_text_size" - android:textStyle="bold"/> - - <com.cyanogenmod.eleven.widgets.RepeatingImageButton - android:id="@+id/action_button_previous" - android:layout_width="@dimen/audio_player_controls_end_button_width" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_toLeftOf="@id/audio_player_current_time" - android:layout_centerVertical="true" - android:scaleType="fitCenter" - android:src="@drawable/btn_playback_previous" /> - - <!-- divider --> - <View - android:id="@+id/action_button_left_top_divider" - android:layout_height="@dimen/audio_player_divider_height" - android:layout_width="@dimen/audio_player_divider_length" - android:layout_marginRight="@dimen/audio_player_divider_horizontal_offset" - android:layout_alignParentRight="true" - android:layout_above="@id/audio_player_current_time" - android:background="@color/now_playing_divider" /> - - <!-- divider --> - <View - android:id="@+id/action_button_left_bottom_divider" - android:layout_height="@dimen/audio_player_divider_height" - android:layout_width="@dimen/audio_player_divider_length" - android:layout_marginRight="@dimen/audio_player_divider_horizontal_offset" - android:layout_alignParentRight="true" - android:layout_below="@id/audio_player_current_time" - android:background="@color/now_playing_divider" /> - - <com.cyanogenmod.eleven.widgets.BrowseButton - android:id="@+id/action_button_browse" - android:layout_width="@dimen/audio_player_controls_end_button_width" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_above="@id/action_button_left_top_divider" - android:layout_alignLeft="@id/action_button_previous" - android:layout_marginLeft="@dimen/audio_player_controls_end_button_half_width" - android:contentDescription="@string/accessibility_browse" - android:focusable="true" - android:scaleType="fitCenter" - android:src="@drawable/btn_playback_browse" /> - - <com.cyanogenmod.eleven.widgets.ShuffleButton - android:id="@+id/action_button_shuffle" - android:layout_width="@dimen/audio_player_controls_end_button_width" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_below="@id/action_button_left_bottom_divider" - android:layout_alignLeft="@id/action_button_previous" - android:layout_marginLeft="@dimen/audio_player_controls_end_button_half_width" - android:contentDescription="@string/accessibility_shuffle" - android:scaleType="fitCenter" - android:src="@drawable/btn_playback_shuffle_all" /> - </RelativeLayout> - - <!-- This is the right side of the progress bar - it has the next - and repeat button and the total time text --> - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="fill_parent" - android:layout_toRightOf="@id/playPauseProgressButton"> - - <TextView - android:id="@+id/audio_player_total_time" - android:layout_width="52dp" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - android:paddingRight="@dimen/audio_player_time_text_padding" - android:gravity="right|center_vertical" - android:textColor="@color/audio_player_text_color" - android:textSize="@dimen/audio_player_time_text_size" - android:textStyle="bold"/> - - <com.cyanogenmod.eleven.widgets.RepeatingImageButton - android:id="@+id/action_button_next" - android:layout_width="@dimen/audio_player_controls_end_button_width" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_toRightOf="@id/audio_player_total_time" - android:layout_centerVertical="true" - android:scaleType="fitCenter" - android:src="@drawable/btn_playback_next" /> - - <!-- divider --> - <View - android:id="@+id/action_button_right_top_divider" - android:layout_height="@dimen/audio_player_divider_height" - android:layout_width="@dimen/audio_player_divider_length" - android:layout_marginLeft="@dimen/audio_player_divider_horizontal_offset" - android:layout_alignParentLeft="true" - android:layout_above="@id/audio_player_total_time" - android:background="@color/now_playing_divider" /> - - <!-- divider --> - <View - android:id="@+id/action_button_right_bottom_divider" - android:layout_height="@dimen/audio_player_divider_height" - android:layout_width="@dimen/audio_player_divider_length" - android:layout_marginLeft="@dimen/audio_player_divider_horizontal_offset" - android:layout_alignParentLeft="true" - android:layout_below="@id/audio_player_total_time" - android:background="@color/now_playing_divider" /> - - <com.cyanogenmod.eleven.widgets.QueueButton - android:id="@+id/action_button_queue" - android:layout_width="@dimen/audio_player_controls_end_button_width" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_above="@id/action_button_right_top_divider" - android:layout_alignRight="@id/action_button_next" - android:layout_marginRight="@dimen/audio_player_controls_end_button_half_width" - android:contentDescription="@string/accessibility_queue" - android:focusable="true" - android:scaleType="fitCenter" - android:src="@drawable/btn_queue_icon" /> - - <com.cyanogenmod.eleven.widgets.RepeatButton - android:id="@+id/action_button_repeat" - android:layout_width="@dimen/audio_player_controls_end_button_width" - android:layout_height="@dimen/audio_player_controls_end_button_height" - android:layout_below="@id/action_button_right_bottom_divider" - android:layout_alignRight="@id/action_button_next" - android:layout_marginRight="@dimen/audio_player_controls_end_button_half_width" - android:contentDescription="@string/accessibility_repeat" - android:focusable="true" - android:scaleType="fitCenter" - android:src="@drawable/btn_playback_repeat_all" /> - - </RelativeLayout> - - </RelativeLayout> + <include layout="@layout/main_playback_controls" /> </LinearLayout> diff --git a/res/layout/main_album_flow.xml b/res/layout/main_album_flow.xml new file mode 100644 index 0000000..49b0afb --- /dev/null +++ b/res/layout/main_album_flow.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2012 Andrew Neal + 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. +--> +<com.cyanogenmod.eleven.widgets.SquareFrame + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + <com.cyanogenmod.eleven.widgets.SquareViewPager + android:id="@+id/audio_player_album_art_viewpager" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + <include layout="@layout/loading_empty_container" /> + + <View + android:id="@+id/equalizerGradient" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/equalizer_background" + android:layout_gravity="bottom"/> + + <com.cyanogenmod.eleven.widgets.EqualizerView + android:id="@+id/equalizerView" + android:gravity="bottom" + android:layout_gravity="bottom" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clipChildren="false" + android:clipToPadding="false" + android:visibility="visible" /> + + <TextView + android:id="@+id/audio_player_lyrics" + android:layout_gravity="center" + android:gravity="center" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:minHeight="66dp" + android:paddingLeft="15dp" + android:paddingRight="15dp" + android:paddingTop="6dp" + android:paddingBottom="6dp" + android:background="@color/lyrics_background_color" + android:textColor="@color/white" + android:textSize="@dimen/text_size_small" + android:alpha="0.0"/> +</com.cyanogenmod.eleven.widgets.SquareFrame>
\ No newline at end of file diff --git a/res/layout/main_playback_controls.xml b/res/layout/main_playback_controls.xml new file mode 100644 index 0000000..8c11211 --- /dev/null +++ b/res/layout/main_playback_controls.xml @@ -0,0 +1,213 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2012 Andrew Neal + 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. +--> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:background="@android:color/transparent" > + <com.cyanogenmod.eleven.widgets.PlayPauseProgressButton + android:id="@+id/playPauseProgressButton" + android:layout_width="@dimen/audio_player_controls_main_button_width" + android:layout_height="@dimen/audio_player_controls_main_button_height" + android:layout_centerInParent="true" > + + <!-- TODO: Figure out why scaleType: centerInside isn't properly scaling up --> + <com.cyanogenmod.eleven.widgets.PlayPauseButton + android:id="@+id/action_button_play" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:contentDescription="@string/accessibility_play" + android:focusable="true" + android:scaleType="centerCrop" + android:src="@drawable/btn_playback_play" /> + + <ProgressBar + android:id="@+id/progressBarBackground" + style="?android:attr/progressBarStyleHorizontal" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clickable="false" + android:indeterminate="false" + android:max="100" + android:progress="100" + android:progressDrawable="@drawable/now_playing_progress_background" /> + + <ProgressBar + android:id="@+id/circularProgressBar" + style="?android:attr/progressBarStyleHorizontal" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:clickable="false" + android:indeterminate="false" + android:max="100" + android:progressDrawable="@drawable/now_playing_progress" /> + </com.cyanogenmod.eleven.widgets.PlayPauseProgressButton> + + <!-- TODO: Figure out why scaleType: centerInside isn't properly scaling up --> + <!-- ANSWER: two issues (a) centerInside doesn't scale up, only down, use + fitCenter instead. Also, ImageButtons come with built-in padding, but + that only makes a visible difference when you are scaling the image. + so you have to set the padding to zero in order to get the result you expect --> + <!-- This is the left side of the progress bar - it has the previous + and shuffle button and the current time text --> + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="fill_parent" + android:layout_toLeftOf="@id/playPauseProgressButton"> + + <TextView + android:id="@+id/audio_player_current_time" + android:layout_width="52dp" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:gravity="left|center_vertical" + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:paddingLeft="@dimen/audio_player_time_text_padding" + android:textColor="@color/audio_player_text_color" + android:textSize="@dimen/audio_player_time_text_size" + android:textStyle="bold"/> + + <com.cyanogenmod.eleven.widgets.RepeatingImageButton + android:id="@+id/action_button_previous" + android:layout_width="@dimen/audio_player_controls_end_button_width" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_toLeftOf="@id/audio_player_current_time" + android:layout_centerVertical="true" + android:scaleType="fitCenter" + android:src="@drawable/btn_playback_previous" /> + + <!-- divider --> + <View + android:id="@+id/action_button_left_top_divider" + android:layout_height="@dimen/audio_player_divider_height" + android:layout_width="@dimen/audio_player_divider_length" + android:layout_marginRight="@dimen/audio_player_divider_horizontal_offset" + android:layout_alignParentRight="true" + android:layout_above="@id/audio_player_current_time" + android:background="@color/now_playing_divider" /> + + <!-- divider --> + <View + android:id="@+id/action_button_left_bottom_divider" + android:layout_height="@dimen/audio_player_divider_height" + android:layout_width="@dimen/audio_player_divider_length" + android:layout_marginRight="@dimen/audio_player_divider_horizontal_offset" + android:layout_alignParentRight="true" + android:layout_below="@id/audio_player_current_time" + android:background="@color/now_playing_divider" /> + + <com.cyanogenmod.eleven.widgets.BrowseButton + android:id="@+id/action_button_browse" + android:layout_width="@dimen/audio_player_controls_end_button_width" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_above="@id/action_button_left_top_divider" + android:layout_alignLeft="@id/action_button_previous" + android:layout_marginLeft="@dimen/audio_player_controls_end_button_half_width" + android:contentDescription="@string/accessibility_browse" + android:focusable="true" + android:scaleType="fitCenter" + android:src="@drawable/btn_playback_browse" /> + + <com.cyanogenmod.eleven.widgets.ShuffleButton + android:id="@+id/action_button_shuffle" + android:layout_width="@dimen/audio_player_controls_end_button_width" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_below="@id/action_button_left_bottom_divider" + android:layout_alignLeft="@id/action_button_previous" + android:layout_marginLeft="@dimen/audio_player_controls_end_button_half_width" + android:contentDescription="@string/accessibility_shuffle" + android:scaleType="fitCenter" + android:src="@drawable/btn_playback_shuffle_all" /> + </RelativeLayout> + + <!-- This is the right side of the progress bar - it has the next + and repeat button and the total time text --> + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="fill_parent" + android:layout_toRightOf="@id/playPauseProgressButton"> + + <TextView + android:id="@+id/audio_player_total_time" + android:layout_width="52dp" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:paddingRight="@dimen/audio_player_time_text_padding" + android:gravity="right|center_vertical" + android:textColor="@color/audio_player_text_color" + android:textSize="@dimen/audio_player_time_text_size" + android:textStyle="bold"/> + + <com.cyanogenmod.eleven.widgets.RepeatingImageButton + android:id="@+id/action_button_next" + android:layout_width="@dimen/audio_player_controls_end_button_width" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_toRightOf="@id/audio_player_total_time" + android:layout_centerVertical="true" + android:scaleType="fitCenter" + android:src="@drawable/btn_playback_next" /> + + <!-- divider --> + <View + android:id="@+id/action_button_right_top_divider" + android:layout_height="@dimen/audio_player_divider_height" + android:layout_width="@dimen/audio_player_divider_length" + android:layout_marginLeft="@dimen/audio_player_divider_horizontal_offset" + android:layout_alignParentLeft="true" + android:layout_above="@id/audio_player_total_time" + android:background="@color/now_playing_divider" /> + + <!-- divider --> + <View + android:id="@+id/action_button_right_bottom_divider" + android:layout_height="@dimen/audio_player_divider_height" + android:layout_width="@dimen/audio_player_divider_length" + android:layout_marginLeft="@dimen/audio_player_divider_horizontal_offset" + android:layout_alignParentLeft="true" + android:layout_below="@id/audio_player_total_time" + android:background="@color/now_playing_divider" /> + + <com.cyanogenmod.eleven.widgets.QueueButton + android:id="@+id/action_button_queue" + android:layout_width="@dimen/audio_player_controls_end_button_width" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_above="@id/action_button_right_top_divider" + android:layout_alignRight="@id/action_button_next" + android:layout_marginRight="@dimen/audio_player_controls_end_button_half_width" + android:contentDescription="@string/accessibility_queue" + android:focusable="true" + android:scaleType="fitCenter" + android:src="@drawable/btn_queue_icon" /> + + <com.cyanogenmod.eleven.widgets.RepeatButton + android:id="@+id/action_button_repeat" + android:layout_width="@dimen/audio_player_controls_end_button_width" + android:layout_height="@dimen/audio_player_controls_end_button_height" + android:layout_below="@id/action_button_right_bottom_divider" + android:layout_alignRight="@id/action_button_next" + android:layout_marginRight="@dimen/audio_player_controls_end_button_half_width" + android:contentDescription="@string/accessibility_repeat" + android:focusable="true" + android:scaleType="fitCenter" + android:src="@drawable/btn_playback_repeat_all" /> + + </RelativeLayout> + +</RelativeLayout> diff --git a/src/com/cyanogenmod/eleven/ui/activities/HomeActivity.java b/src/com/cyanogenmod/eleven/ui/activities/HomeActivity.java index f3a796a..ded1950 100644 --- a/src/com/cyanogenmod/eleven/ui/activities/HomeActivity.java +++ b/src/com/cyanogenmod/eleven/ui/activities/HomeActivity.java @@ -50,7 +50,8 @@ import com.cyanogenmod.eleven.utils.BitmapWithColors; import com.cyanogenmod.eleven.utils.MusicUtils; import com.cyanogenmod.eleven.utils.NavUtils; -public class HomeActivity extends SlidingPanelActivity { +public class HomeActivity extends SlidingPanelActivity implements + FragmentManager.OnBackStackChangedListener { private static final String TAG = "HomeActivity"; private static final String ACTION_PREFIX = HomeActivity.class.getName(); public static final String ACTION_VIEW_ARTIST_DETAILS = ACTION_PREFIX + ".view.ArtistDetails"; @@ -59,6 +60,8 @@ public class HomeActivity extends SlidingPanelActivity { public static final String ACTION_VIEW_SMART_PLAYLIST = ACTION_PREFIX + ".view.SmartPlaylist"; public static final String EXTRA_BROWSE_PAGE_IDX = "BrowsePageIndex"; + private static final String STATE_KEY_BASE_FRAGMENT = "BaseFragment"; + private static final int NEW_PHOTO = 1; public static final int EQUALIZER = 2; @@ -73,10 +76,10 @@ public class HomeActivity extends SlidingPanelActivity { */ protected boolean mTopLevelActivity = false; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + // if we've been launched by an intent, parse it Intent launchIntent = getIntent(); boolean intentHandled = false; @@ -85,42 +88,46 @@ public class HomeActivity extends SlidingPanelActivity { } // if the intent didn't cause us to load a fragment, load the music browse one - if (!mLoadedBaseFragment) { + if (savedInstanceState == null && !mLoadedBaseFragment) { final MusicBrowserPhoneFragment fragment = new MusicBrowserPhoneFragment(); if (launchIntent != null) { fragment.setDefaultPageIdx(launchIntent.getIntExtra(EXTRA_BROWSE_PAGE_IDX, MusicBrowserPhoneFragment.INVALID_PAGE_INDEX)); } getSupportFragmentManager().beginTransaction() - .replace(R.id.activity_base_content, fragment).commit(); + .replace(R.id.activity_base_content, fragment) + .commit(); mLoadedBaseFragment = true; mTopLevelActivity = true; } - getSupportFragmentManager().addOnBackStackChangedListener( - new FragmentManager.OnBackStackChangedListener() { - @Override - public void onBackStackChanged() { - Fragment topFragment = getTopFragment(); - if (topFragment != null) { - // the fragment that has come back to the top should now have its menu items - // added to the action bar -- so tell it to make it menu items visible - topFragment.setMenuVisibility(true); - ISetupActionBar setupActionBar = (ISetupActionBar) topFragment; - setupActionBar.setupActionBar(); - - getActionBar().setDisplayHomeAsUpEnabled( - !(topFragment instanceof MusicBrowserPhoneFragment)); - } - } - }); + getSupportFragmentManager().addOnBackStackChangedListener(this); + + // if we are resuming from a saved instance state + if (savedInstanceState != null) { + // track which fragments are loaded and if this is the top level activity + mTopLevelActivity = savedInstanceState.getBoolean(STATE_KEY_BASE_FRAGMENT); + mLoadedBaseFragment = mTopLevelActivity; + + // update the action bar based on the top most fragment + onBackStackChanged(); + + // figure which panel we are on and update the status bar + mBrowsePanelActive = (getCurrentPanel() == Panel.Browse); + updateStatusBarColor(); + } // if intent wasn't UI related, process it as a audio playback request if (!intentHandled) { handlePlaybackIntent(launchIntent); } + } + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(STATE_KEY_BASE_FRAGMENT, mTopLevelActivity); } public Fragment getTopFragment() { @@ -427,4 +434,18 @@ public class HomeActivity extends SlidingPanelActivity { return id; } + @Override + public void onBackStackChanged() { + Fragment topFragment = getTopFragment(); + if (topFragment != null) { + // the fragment that has come back to the top should now have its menu items + // added to the action bar -- so tell it to make it menu items visible + topFragment.setMenuVisibility(true); + ISetupActionBar setupActionBar = (ISetupActionBar) topFragment; + setupActionBar.setupActionBar(); + + getActionBar().setDisplayHomeAsUpEnabled( + !(topFragment instanceof MusicBrowserPhoneFragment)); + } + } } diff --git a/src/com/cyanogenmod/eleven/ui/activities/SlidingPanelActivity.java b/src/com/cyanogenmod/eleven/ui/activities/SlidingPanelActivity.java index 2a3665d..ace0947 100644 --- a/src/com/cyanogenmod/eleven/ui/activities/SlidingPanelActivity.java +++ b/src/com/cyanogenmod/eleven/ui/activities/SlidingPanelActivity.java @@ -52,6 +52,8 @@ public abstract class SlidingPanelActivity extends BaseActivity { public void onFinishSlide(SlidingPanelActivity.Panel visiblePanel); } + private static final String STATE_KEY_CURRENT_PANEL = "CurrentPanel"; + private SlidingUpPanelLayout mFirstPanel; private SlidingUpPanelLayout mSecondPanel; protected Panel mTargetNavigatePanel; @@ -106,6 +108,26 @@ public abstract class SlidingPanelActivity extends BaseActivity { // get the blur scrim image mBlurScrimImage = (BlurScrimImage)findViewById(R.id.blurScrimImage); + + if (savedInstanceState != null) { + int panelIndex = savedInstanceState.getInt(STATE_KEY_CURRENT_PANEL, + Panel.Browse.ordinal()); + Panel targetPanel = Panel.values()[panelIndex]; + + showPanel(targetPanel); + mTargetNavigatePanel = Panel.None; + + if (targetPanel == Panel.Queue) { + mFirstPanel.setSlidingEnabled(false); + } + } + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + + outState.putInt(STATE_KEY_CURRENT_PANEL, getCurrentPanel().ordinal()); } private void setupFirstPanel() { @@ -253,7 +275,7 @@ public abstract class SlidingPanelActivity extends BaseActivity { } } - protected Panel getCurrentPanel() { + public Panel getCurrentPanel() { if (mSecondPanel.isPanelExpanded()) { return Panel.Queue; } else if (mFirstPanel.isPanelExpanded()) { diff --git a/src/com/cyanogenmod/eleven/ui/fragments/AudioPlayerFragment.java b/src/com/cyanogenmod/eleven/ui/fragments/AudioPlayerFragment.java index 877cda4..2e102d4 100644 --- a/src/com/cyanogenmod/eleven/ui/fragments/AudioPlayerFragment.java +++ b/src/com/cyanogenmod/eleven/ui/fragments/AudioPlayerFragment.java @@ -180,6 +180,9 @@ public class AudioPlayerFragment extends Fragment implements ServiceConnection, // add a listener for the sliding ((SlidingPanelActivity)getActivity()).addSlidingPanelListener(this); + + // check equalizer view + checkEqualizerView(); } /** @@ -297,7 +300,11 @@ public class AudioPlayerFragment extends Fragment implements ServiceConnection, headerBar.setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { - outline.setRect(0, -bottomActionBarHeight, view.getWidth(), view.getHeight()); + // since we only want the top and bottom shadows, pad the horizontal width + // to hide the shadows. Can't seem to find a better way to do this + int padWidth = (int)(0.2f * view.getWidth()); + outline.setRect(-padWidth, -bottomActionBarHeight, view.getWidth() + padWidth, + view.getHeight()); } }); @@ -742,6 +749,14 @@ public class AudioPlayerFragment extends Fragment implements ServiceConnection, @Override public void onFinishSlide(SlidingPanelActivity.Panel visiblePanel) { + checkEqualizerView(visiblePanel); + } + + private void checkEqualizerView() { + checkEqualizerView(((HomeActivity)getActivity()).getCurrentPanel()); + } + + private void checkEqualizerView(SlidingPanelActivity.Panel visiblePanel) { if (visiblePanel == SlidingPanelActivity.Panel.MusicPlayer) { mEqualizerView.setPanelVisible(true); } diff --git a/src/com/cyanogenmod/eleven/ui/fragments/BaseFragment.java b/src/com/cyanogenmod/eleven/ui/fragments/BaseFragment.java index 7bbaf14..5a5885a 100644 --- a/src/com/cyanogenmod/eleven/ui/fragments/BaseFragment.java +++ b/src/com/cyanogenmod/eleven/ui/fragments/BaseFragment.java @@ -39,6 +39,12 @@ public abstract class BaseFragment extends Fragment implements MusicStateListene } @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setRetainInstance(true); + } + + @Override public void setupActionBar() { getContainingActivity().setupActionBar(getTitle()); getContainingActivity().setActionBarAlpha(255); diff --git a/src/com/cyanogenmod/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java b/src/com/cyanogenmod/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java index 1317c4b..376841e 100644 --- a/src/com/cyanogenmod/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java +++ b/src/com/cyanogenmod/eleven/ui/fragments/phone/MusicBrowserPhoneFragment.java @@ -95,13 +95,12 @@ public class MusicBrowserPhoneFragment extends BaseFragment { protected void onViewCreated() { super.onViewCreated(); - if (mPagerAdapter == null) { - // Initialize the adapter - mPagerAdapter = new PagerAdapter(getActivity(), getChildFragmentManager()); - final MusicFragments[] mFragments = MusicFragments.values(); - for (final MusicFragments mFragment : mFragments) { - mPagerAdapter.add(mFragment.getFragmentClass(), null); - } + // create the adapter - on rotation the view gets created again and we need to recreate + // the child fragments (fragments of fragments cannot be retained) + mPagerAdapter = new PagerAdapter(getActivity(), getChildFragmentManager()); + final MusicFragments[] mFragments = MusicFragments.values(); + for (final MusicFragments mFragment : mFragments) { + mPagerAdapter.add(mFragment.getFragmentClass(), null); } // Initialize the ViewPager |