mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
feat(ui): support portrait launcher layouts (#1606)
This commit is contained in:
1 parent
db56cff880
commit
78f95c5a0c
18 files changed
+427
-73
No files matched your search
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
import com.droiddeck.launcher.core.AppUiPrefs
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -17,6 +18,7 @@ class OrientationTest {
|
||||
|
||||
@Before fun clearOrientation() {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
context.getSharedPreferences("app-ui", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
}
|
||||
|
||||
@Test fun landscapeChoicesPersistGloballyAndCanRestoreAutomaticRotation() {
|
||||
@@ -41,4 +43,25 @@ class OrientationTest {
|
||||
}
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE, SessionPrefs.orientation(context))
|
||||
}
|
||||
|
||||
@Test fun launcherFollowsDeviceRotationAndPortraitDoesNotChangeSessions() {
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, AppUiPrefs.orientation(context))
|
||||
for ((value, _) in AppUiPrefs.orientationOptions) {
|
||||
AppUiPrefs.setOrientation(context, value)
|
||||
assertEquals(value, AppUiPrefs.orientation(context))
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, SessionPrefs.orientation(context))
|
||||
}
|
||||
AppUiPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
|
||||
SessionPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, AppUiPrefs.orientation(context))
|
||||
}
|
||||
|
||||
@Test fun invalidLauncherOrientationFallsBackAndInvalidChoicePreservesPreference() {
|
||||
context.getSharedPreferences("app-ui", Context.MODE_PRIVATE).edit().putInt("orientation", 999).commit()
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, AppUiPrefs.orientation(context))
|
||||
AppUiPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
|
||||
assertThrows(IllegalArgumentException::class.java) { AppUiPrefs.setOrientation(context, 999) }
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, AppUiPrefs.orientation(context))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user