diff options
-rw-r--r-- | AndroidManifest.xml | 5 | ||||
-rw-r--r-- | res/layout-land/audioplayer_activity.xml | 164 | ||||
-rw-r--r-- | res/layout-land/videoplayer_activity.xml (renamed from res/layout-land/mediaplayer_activity.xml) | 0 | ||||
-rw-r--r-- | res/layout/audioplayer_activity.xml (renamed from res/layout/mediaplayer_activity.xml) | 0 | ||||
-rw-r--r-- | res/layout/cover_fragment.xml | 1 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/AudioplayerActivity.java | 84 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/MediaplayerActivity.java | 12 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/VideoplayerActivity.java | 5 |
8 files changed, 253 insertions, 18 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7a79c26a3..e495e129a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -75,9 +75,7 @@ android:label="@string/downloads_label" /> <activity android:name=".activity.AudioplayerActivity" - android:configChanges="keyboardHidden|orientation" - android:launchMode="singleTask" - android:screenOrientation="portrait" > + android:launchMode="singleTask" > <intent-filter> <action android:name="android.intent.action.VIEW" /> @@ -362,6 +360,7 @@ </intent-filter> <intent-filter> <action android:name="android.intent.action.PACKAGE_REPLACED" /> + <data android:path="de.danoeh.antennapod" android:scheme="package" /> diff --git a/res/layout-land/audioplayer_activity.xml b/res/layout-land/audioplayer_activity.xml new file mode 100644 index 000000000..521dbc68a --- /dev/null +++ b/res/layout-land/audioplayer_activity.xml @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="horizontal" > + + <FrameLayout + android:id="@+id/contentView" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="0.5" > + </FrameLayout> + + <RelativeLayout + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="0.5" + android:background="?attr/non_transparent_background" + android:orientation="vertical" > + + <RelativeLayout + android:id="@+id/navBar" + android:layout_width="fill_parent" + android:layout_height="60dp" + android:layout_alignParentTop="true" > + + <ImageButton + android:id="@+id/butNavLeft" + android:layout_width="60dp" + android:layout_height="match_parent" + android:layout_alignParentLeft="true" + android:background="?attr/borderless_button" + android:padding="4dp" /> + + <ImageButton + android:id="@+id/butNavRight" + android:layout_width="60dp" + android:layout_height="match_parent" + android:layout_alignParentRight="true" + android:background="?attr/borderless_button" + android:padding="4dp" /> + + <TextView + android:id="@+id/txtvTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_marginLeft="8dp" + android:layout_marginRight="8dp" + android:layout_marginTop="8dp" + android:layout_toLeftOf="@id/butNavRight" + android:layout_toRightOf="@id/butNavLeft" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:maxLines="1" + android:textColor="?android:attr/textColorPrimary" + android:textSize="@dimen/text_size_medium" + android:textStyle="bold" /> + + <TextView + android:id="@+id/txtvFeed" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/txtvTitle" + android:layout_marginLeft="8dp" + android:layout_marginRight="8dp" + android:layout_toLeftOf="@id/butNavRight" + android:layout_toRightOf="@id/butNavLeft" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:maxLines="1" + android:textColor="?android:attr/textColorSecondary" + android:textSize="@dimen/text_size_small" /> + </RelativeLayout> + + <View + android:id="@+id/navBarDivider" + android:layout_width="match_parent" + android:layout_height="1dp" + android:layout_below="@id/navBar" + android:background="@color/bright_blue" /> + + <RelativeLayout + android:id="@+id/player_control" + android:layout_width="match_parent" + android:layout_height="80dp" + android:layout_alignParentBottom="true" + android:background="?attr/overlay_background" > + + <ImageButton + android:id="@+id/butPlay" + android:layout_width="80dp" + android:layout_height="match_parent" + android:layout_centerHorizontal="true" + android:layout_marginLeft="8dp" + android:layout_marginRight="8dp" + android:background="?attr/borderless_button" + android:src="?attr/av_pause" /> + + <ImageButton + android:id="@+id/butRev" + android:layout_width="80dp" + android:layout_height="match_parent" + android:layout_toLeftOf="@id/butPlay" + android:background="?attr/borderless_button" + android:src="?attr/av_rewind" /> + + <ImageButton + android:id="@+id/butFF" + android:layout_width="80dp" + android:layout_height="match_parent" + android:layout_toRightOf="@id/butPlay" + android:background="?attr/borderless_button" + android:src="?attr/av_fast_forward" /> + </RelativeLayout> + + <RelativeLayout + android:id="@+id/playtime_layout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_above="@id/player_control" + android:layout_alignParentLeft="true" + android:background="?attr/overlay_drawable" > + + <TextView + android:id="@+id/txtvPosition" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:layout_marginLeft="8dp" + android:layout_marginTop="16dp" + android:text="@string/position_default_label" + android:textColor="?android:attr/textColorSecondary" + android:textSize="@dimen/text_size_micro" /> + + <TextView + android:id="@+id/txtvLength" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true" + android:layout_centerVertical="true" + android:layout_marginRight="8dp" + android:layout_marginTop="16dp" + android:text="@string/position_default_label" + android:textColor="?android:attr/textColorSecondary" + android:textSize="@dimen/text_size_micro" /> + + <SeekBar + android:id="@+id/sbPosition" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_marginLeft="8dp" + android:layout_marginRight="8dp" + android:layout_marginTop="16dp" + android:layout_toLeftOf="@id/txtvLength" + android:layout_toRightOf="@id/txtvPosition" + android:max="500" /> + </RelativeLayout> + </RelativeLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/res/layout-land/mediaplayer_activity.xml b/res/layout-land/videoplayer_activity.xml index 675d9709d..675d9709d 100644 --- a/res/layout-land/mediaplayer_activity.xml +++ b/res/layout-land/videoplayer_activity.xml diff --git a/res/layout/mediaplayer_activity.xml b/res/layout/audioplayer_activity.xml index 73a0e0be6..73a0e0be6 100644 --- a/res/layout/mediaplayer_activity.xml +++ b/res/layout/audioplayer_activity.xml diff --git a/res/layout/cover_fragment.xml b/res/layout/cover_fragment.xml index f897d318c..9602f1ebc 100644 --- a/res/layout/cover_fragment.xml +++ b/res/layout/cover_fragment.xml @@ -11,6 +11,7 @@ android:layout_height="match_parent" android:layout_gravity="center" android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" android:adjustViewBounds="true" android:scaleType="centerInside" /> diff --git a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java index 2809d638f..6231e2a22 100644 --- a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -1,6 +1,7 @@ package de.danoeh.antennapod.activity; import android.content.Intent; +import android.content.res.Configuration; import android.content.res.TypedArray; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -47,6 +48,8 @@ public class AudioplayerActivity extends MediaplayerActivity { private Fragment currentlyShownFragment; private int currentlyShownPosition = -1; + /** Saved and restored on orientation change. */ + private int savedPosition = -1; private TextView txtvTitle; private TextView txtvFeed; @@ -54,6 +57,37 @@ public class AudioplayerActivity extends MediaplayerActivity { private ImageButton butNavRight; private void resetFragmentView() { + FragmentTransaction fT = getSupportFragmentManager().beginTransaction(); + + if (coverFragment != null) { + if (AppConfig.DEBUG) + Log.d(TAG, "Removing cover fragment"); + fT.remove(coverFragment); + } + if (descriptionFragment != null) { + if (AppConfig.DEBUG) + Log.d(TAG, "Removing description fragment"); + fT.remove(descriptionFragment); + } + if (chapterFragment != null) { + if (AppConfig.DEBUG) + Log.d(TAG, "Removing chapter fragment"); + fT.remove(chapterFragment); + } + if (currentlyShownFragment != null) { + if (AppConfig.DEBUG) + Log.d(TAG, "Removing currently shown fragment"); + fT.remove(currentlyShownFragment); + } + for (int i = 0; i < detachedFragments.length; i++) { + Fragment f = detachedFragments[i]; + if (f != null) { + if (AppConfig.DEBUG) + Log.d(TAG, "Removing detached fragment"); + fT.remove(f); + } + } + fT.commit(); currentlyShownFragment = null; coverFragment = null; descriptionFragment = null; @@ -65,7 +99,7 @@ public class AudioplayerActivity extends MediaplayerActivity { @Override protected void onStop() { super.onStop(); - resetFragmentView(); + if (AppConfig.DEBUG) Log.d(TAG, "onStop"); } @@ -78,6 +112,33 @@ public class AudioplayerActivity extends MediaplayerActivity { } @Override + public void onConfigurationChanged(Configuration newConfig) { + + super.onConfigurationChanged(newConfig); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + outState.putInt("selectedPosition", currentlyShownPosition); + resetFragmentView(); + super.onSaveInstanceState(outState); + } + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + if (AppConfig.DEBUG) + Log.d(TAG, "Restoring instance state"); + if (savedInstanceState != null) { + int p = savedInstanceState.getInt("selectedPosition", -1); + if (p != -1) { + savedPosition = p; + switchToFragment(savedPosition); + } + } + } + + @Override protected void onResume() { super.onResume(); if (getIntent().getAction() != null @@ -187,6 +248,7 @@ public class AudioplayerActivity extends MediaplayerActivity { ft.add(R.id.contentView, currentlyShownFragment); } ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + ft.disallowAddToBackStack(); ft.commit(); updateNavButtonDrawable(); } @@ -211,8 +273,8 @@ public class AudioplayerActivity extends MediaplayerActivity { @Override public void run() { - ImageLoader.getInstance().loadThumbnailBitmap( - media, butNavLeft); + ImageLoader.getInstance().loadThumbnailBitmap(media, + butNavLeft); } }); butNavRight.setImageDrawable(drawables.getDrawable(1)); @@ -223,8 +285,8 @@ public class AudioplayerActivity extends MediaplayerActivity { @Override public void run() { - ImageLoader.getInstance().loadThumbnailBitmap( - media, butNavLeft); + ImageLoader.getInstance().loadThumbnailBitmap(media, + butNavLeft); } }); butNavRight.setImageDrawable(drawables.getDrawable(0)); @@ -291,7 +353,12 @@ public class AudioplayerActivity extends MediaplayerActivity { } if (currentlyShownPosition == -1) { - switchToFragment(POS_COVER); + if (savedPosition != -1) { + switchToFragment(savedPosition); + savedPosition = -1; + } else { + switchToFragment(POS_COVER); + } } if (currentlyShownFragment instanceof AudioplayerContentFragment) { ((AudioplayerContentFragment) currentlyShownFragment) @@ -333,4 +400,9 @@ public class AudioplayerActivity extends MediaplayerActivity { public void onDataSetChanged(Playable media); } + @Override + protected int getContentViewResourceId() { + return R.layout.audioplayer_activity; + } + } diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index 6d27a82e0..16b03809a 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; -import android.content.res.Configuration; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Bundle; @@ -331,13 +330,6 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity controller.init(); } - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - // ignore orientation change - - } - /** * Called by 'handleStatus()' when the PlaybackService is in the * AWAITING_VIDEO_SURFACE state. @@ -399,7 +391,7 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity } protected void setupGUI() { - setContentView(R.layout.mediaplayer_activity); + setContentView(getContentViewResourceId()); sbPosition = (SeekBar) findViewById(R.id.sbPosition); txtvPosition = (TextView) findViewById(R.id.txtvPosition); txtvLength = (TextView) findViewById(R.id.txtvLength); @@ -421,6 +413,8 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity } + protected abstract int getContentViewResourceId(); + void handleError(int errorCode) { final AlertDialog.Builder errorDialog = new AlertDialog.Builder(this); errorDialog.setTitle(R.string.error_label); diff --git a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java index 2d9834a3e..b3567e417 100644 --- a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -287,4 +287,9 @@ public class VideoplayerActivity extends MediaplayerActivity implements videoOverlay.setVisibility(View.GONE); } + @Override + protected int getContentViewResourceId() { + return R.layout.videoplayer_activity; + } + } |