Skip to content

Commit

Permalink
Merge pull request #1185 from tenJirka/OrientationChengeFix
Browse files Browse the repository at this point in the history
Android: Added onSaveInstanceState
  • Loading branch information
pulsejet authored May 17, 2024
2 parents 2fea0c5 + 33f9d8b commit c107a52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.Memories.NoActionBar"
android:configChanges="orientation|screenSize">
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|density|screenSize|smallestScreenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
14 changes: 9 additions & 5 deletions android/app/src/main/java/gallery/memories/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(binding.root)

// Set fullscreen mode if in landscape
val orientation = resources.configuration.orientation
setFullscreen(orientation == Configuration.ORIENTATION_LANDSCAPE)

// Restore last known look
restoreTheme()

Expand All @@ -99,9 +103,9 @@ class MainActivity : AppCompatActivity() {

override fun onDestroy() {
super.onDestroy()
binding.webview.removeAllViews();
binding.webview.removeAllViews()
binding.coordinator.removeAllViews()
binding.webview.destroy();
binding.webview.destroy()
nativex.destroy()
}

Expand Down Expand Up @@ -132,7 +136,7 @@ class MainActivity : AppCompatActivity() {
}

override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.action == KeyEvent.ACTION_DOWN) {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
if (binding.webview.canGoBack()) {
Expand Down Expand Up @@ -268,7 +272,7 @@ class MainActivity : AppCompatActivity() {
if (BuildConfig.DEBUG) {
Toast.makeText(this, "Debugging enabled", Toast.LENGTH_SHORT).show()
binding.webview.clearCache(true)
WebView.setWebContentsDebuggingEnabled(true);
WebView.setWebContentsDebuggingEnabled(true)
}

// Welcome page or actual app
Expand All @@ -288,7 +292,7 @@ class MainActivity : AppCompatActivity() {
if (host != null) return true

// Load welcome page
binding.webview.loadUrl("file:///android_asset/welcome.html");
binding.webview.loadUrl("file:///android_asset/welcome.html")
return false
}

Expand Down

0 comments on commit c107a52

Please sign in to comment.