Skip to content

Commit

Permalink
Fixes #24 No browser update if setting changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalbra committed Dec 29, 2024
1 parent dc75dab commit 002e569
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/com/example/noreel/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import kotlin.concurrent.thread

open class MainActivity : ComponentActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
private var filePathCallback: ValueCallback<Array<Uri>>? = null
private var settingsChanged: Boolean = false

private lateinit var webView: WebView

Expand Down Expand Up @@ -94,6 +95,15 @@ open class MainActivity : ComponentActivity(), SharedPreferences.OnSharedPrefere
}
}

override fun onResume() {
super.onResume()
if (settingsChanged) {
settingsChanged = false
updateBrowser(webView)
Log.d("Settings", "Reload browser")
}
}

@RequiresApi(Build.VERSION_CODES.O)
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -118,6 +128,7 @@ open class MainActivity : ComponentActivity(), SharedPreferences.OnSharedPrefere
val preferences_button = findViewById<Button>(R.id.preferencesButton)

preferences_button.setOnClickListener {
settingsChanged = true
val settings_intent = Intent(this, SettingsActivity::class.java)
startActivity(settings_intent)
}
Expand Down

0 comments on commit 002e569

Please sign in to comment.