use just 1 orientation button at toggling orientation
This commit is contained in:
parent
50dd2766c8
commit
528dc06a10
3 changed files with 12 additions and 15 deletions
|
@ -124,7 +124,8 @@
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.VideoPlayerActivity"
|
android:name=".activities.VideoPlayerActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"/>
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
|
android:parentActivityName=".activities.MediaActivity"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.PanoramaPhotoActivity"
|
android:name=".activities.PanoramaPhotoActivity"
|
||||||
|
|
|
@ -25,10 +25,8 @@ import kotlinx.android.synthetic.main.activity_video_player.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class VideoPlayerActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
open class VideoPlayerActivity : SimpleActivity(), ViewPagerFragment.FragmentListener {
|
||||||
|
|
||||||
private var mMedium: Medium? = null
|
private var mMedium: Medium? = null
|
||||||
private var mIsFullScreen = false
|
private var mIsFullScreen = false
|
||||||
private var mCurrentOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
|
||||||
private var mFragment: ViewPagerFragment? = null
|
private var mFragment: ViewPagerFragment? = null
|
||||||
private var mUri: Uri? = null
|
private var mUri: Uri? = null
|
||||||
|
|
||||||
|
@ -100,15 +98,18 @@ open class VideoPlayerActivity : SimpleActivity(), ViewPagerFragment.FragmentLis
|
||||||
}
|
}
|
||||||
|
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.menu_force_portrait -> forceOrientation(true)
|
R.id.menu_change_orientation -> changeOrientation()
|
||||||
R.id.menu_force_landscape -> forceOrientation(false)
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun forceOrientation(portrait: Boolean) {
|
private fun changeOrientation() {
|
||||||
|
requestedOrientation = if (resources.configuration.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
|
} else {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fragmentClicked() {
|
override fun fragmentClicked() {
|
||||||
|
|
|
@ -2,14 +2,9 @@
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_force_portrait"
|
android:id="@+id/menu_change_orientation"
|
||||||
android:icon="@drawable/ic_orientation_portrait"
|
android:icon="@drawable/ic_orientation_auto"
|
||||||
android:title="@string/force_portrait"
|
android:title="@string/change_orientation"
|
||||||
app:showAsAction="ifRoom"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_force_landscape"
|
|
||||||
android:icon="@drawable/ic_orientation_landscape"
|
|
||||||
android:title="@string/force_landscape"
|
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_share"
|
android:id="@+id/menu_share"
|
||||||
|
|
Loading…
Reference in a new issue