Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated subscriptions list screen to Compose #163

Merged
merged 25 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
170b336
Migrated subscriptions list screen to Compose
ArnyminerZ Jul 20, 2023
cbb7181
Merge branch 'dev' into compose_iv
ArnyminerZ Jul 28, 2023
3299695
Removed old menu functions
ArnyminerZ Jul 28, 2023
6dd9c1c
Made methods private
ArnyminerZ Jul 28, 2023
c261db1
Migrated sync interval dialog to Compose
ArnyminerZ Jul 28, 2023
3747cb8
Removed trailing colon
ArnyminerZ Jul 28, 2023
4f39618
Added content description
ArnyminerZ Jul 28, 2023
f521266
Merge branch 'dev' into compose_iv
ArnyminerZ Jul 28, 2023
4cc9b0e
Migrated subscriptions list screen to Compose
ArnyminerZ Jul 20, 2023
22d0b1b
Removed old menu functions
ArnyminerZ Jul 28, 2023
fd5b052
Made methods private
ArnyminerZ Jul 28, 2023
62ca62f
Migrated sync interval dialog to Compose
ArnyminerZ Jul 28, 2023
33fb22c
Removed trailing colon
ArnyminerZ Jul 28, 2023
6144e6f
Added content description
ArnyminerZ Jul 28, 2023
c424815
Merge remote-tracking branch 'origin/compose_iv' into compose_iv
ArnyminerZ Jul 29, 2023
8e61c8b
Separate Settings from UI, provide LiveData
rfc2822 Aug 19, 2023
6396fa8
SyncIntervalDialog: use MaterialAlertDialogBuilder
rfc2822 Aug 19, 2023
d3ea479
[WIP] Add TODOs to replace Snackbar by UI elements; move logic to model
rfc2822 Aug 19, 2023
0efe874
Added `checkSyncSettings` to model
ArnyminerZ Aug 21, 2023
c3da4a4
Added more calls to `checkSyncSettings`
ArnyminerZ Aug 21, 2023
d89c3f4
Added permission explanation
ArnyminerZ Aug 21, 2023
8ad10d9
Added cards for permission requesting
ArnyminerZ Aug 21, 2023
5ccd4b6
Fixed typo
ArnyminerZ Aug 21, 2023
271d7fb
Minor changes
rfc2822 Aug 21, 2023
54f5602
Merge branch 'dev' into compose_iv
rfc2822 Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ dependencies {
implementation 'androidx.compose.material:material'
debugImplementation "androidx.compose.ui:ui-tooling"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.compose.runtime:runtime-livedata:1.4.3"
implementation 'com.google.accompanist:accompanist-themeadapter-material:0.30.1'
implementation 'io.github.vanpra.compose-material-dialogs:color:0.9.0'

Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

<activity
android:name=".ui.CalendarListActivity"
android:theme="@style/AppTheme.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/at/bitfire/icsdroid/AppAccount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import android.util.Log
object AppAccount {

private const val DEFAULT_SYNC_INTERVAL = 24*3600L // 1 day
private const val SYNC_INTERVAL_MANUALLY = -1L
const val SYNC_INTERVAL_MANUALLY = -1L

private const val PREF_ACCOUNT = "account"
private const val KEY_SYNC_INTERVAL = "syncInterval"
Expand Down
18 changes: 15 additions & 3 deletions app/src/main/java/at/bitfire/icsdroid/MyApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@ package at.bitfire.icsdroid

import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import at.bitfire.icsdroid.ui.Settings

class MyApp: Application() {

companion object {

fun setNightMode(forceDarkMode: Boolean) {
AppCompatDelegate.setDefaultNightMode(
if (forceDarkMode)
AppCompatDelegate.MODE_NIGHT_YES
else
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
)
}

}


override fun onCreate() {
super.onCreate()

// dark mode is not persisted over app restarts
if (Settings(this).forceDarkMode())
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
setNightMode(Settings(this).forceDarkMode())
}

}
50 changes: 50 additions & 0 deletions app/src/main/java/at/bitfire/icsdroid/Settings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/***************************************************************************************************
* Copyright © All Contributors. See LICENSE and AUTHORS in the root directory for details.
**************************************************************************************************/

package at.bitfire.icsdroid

import android.content.Context
import android.content.SharedPreferences
import androidx.lifecycle.LiveData

class Settings(context: Context) {

companion object {
private const val FORCE_DARK_MODE = "forceDarkMode"
}


private val prefs: SharedPreferences = context.getSharedPreferences("icsx5", 0)

fun forceDarkMode(): Boolean = prefs.getBoolean(FORCE_DARK_MODE, false)

fun forceDarkModeLive(): LiveData<Boolean> = object: LiveData<Boolean>() {
val listener = SharedPreferences.OnSharedPreferenceChangeListener { prefs, key ->
if (key == FORCE_DARK_MODE) {
val forceDarkMode = prefs.getBoolean(key, false)
postValue(forceDarkMode)
}
}

override fun onActive() {
prefs.registerOnSharedPreferenceChangeListener(listener)
listener.onSharedPreferenceChanged(prefs, FORCE_DARK_MODE)
}

override fun onInactive() {
prefs.unregisterOnSharedPreferenceChangeListener(listener)
}
}

fun forceDarkMode(force: Boolean) {
// save setting
prefs.edit()
.putBoolean(FORCE_DARK_MODE, force)
.apply()

// actually set dark mode
MyApp.setNightMode(force)
}

}
Loading
Loading