Skip to content

Commit

Permalink
Merge branch 'develop' into 1400-feature-refactor-details-screen-merg…
Browse files Browse the repository at this point in the history
…e-view-and-edit
  • Loading branch information
patrickunterwegs committed Nov 13, 2024
2 parents 73acc8f + 406d068 commit 93e7188
Show file tree
Hide file tree
Showing 40 changed files with 708 additions and 618 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v3
- uses: gradle/actions/setup-gradle@v4

- name: Enable KVM group perms
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v3
- uses: gradle/actions/setup-gradle@v4

- name: Prepare keystore
run: echo ${{ secrets.android_keystore_base64 }} | base64 -d >$GITHUB_WORKSPACE/keystore.jks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-baseline-profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

# Sets gradle up
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
uses: gradle/actions/setup-gradle@v4

# Grants execute permission to gradle (safety step)
- name: Grant Permissions to gradlew
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v3
- uses: gradle/actions/setup-gradle@v4

- name: Prepare keystore
run: echo ${{ secrets.android_keystore_base64 }} | base64 -d >$GITHUB_WORKSPACE/keystore.jks
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
run: cp app/build/outputs/apk/ose/release/app-ose-release.apk jtxBoard-${{ github.ref_name }}.apk

- name: Create Github release
uses: softprops/action-gh-release@v2.0.6
uses: softprops/action-gh-release@v2.0.9
with:
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }}
files: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
distribution: temurin
java-version: 17
- uses: gradle/actions/setup-gradle@v3
- uses: gradle/actions/setup-gradle@v4

- name: Prepare keystore
run: echo ${{ secrets.android_keystore_base64 }} | base64 -d >$GITHUB_WORKSPACE/keystore.jks
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
run: cp app/build/outputs/apk/ose/release/app-ose-release.apk jtxBoard-${{ github.ref_name }}.apk

- name: Create Github release
uses: softprops/action-gh-release@v2.0.6
uses: softprops/action-gh-release@v2.0.9
with:
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-rc') }}
files: |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
buildConfigField("long", "buildTime", "${System.currentTimeMillis()}L")
minSdk = 23
targetSdk = 34
versionCode = 209000010
versionName = "2.09.00-beta01" // keep -release as a suffix also for release, build flavor adds the suffix e.g. .gplay (e.g. 1.00.00-rc0.gplay)
versionCode = 209030005
versionName = "2.09.03-beta03" // keep -release as a suffix also for release, build flavor adds the suffix e.g. .gplay (e.g. 1.00.00-rc0.gplay)
buildConfigField("String", "versionCodename", "\"Pride is a protest \uD83C\uDF08\"")
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/at/techbee/jtx/database/properties/Alarm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,6 @@ data class Alarm(
if (isReadOnly && SettingsStateHolder(context).settingDisableAlarmsReadonly.value) // don't schedule alarm for read only if option was deactivated!
return

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
Log.i(
"scheduleNotification",
"Due to necessity of PendingIntent.FLAG_IMMUTABLE, the notification functionality can only be used from Build Versions > M (Api-Level 23)"
)
return
}

val notification = createNotification(
icalObjectId,
alarmId,
Expand All @@ -452,10 +444,20 @@ data class Alarm(

// the alarmManager finally takes care, that the pendingIntent is queued to start the notification Intent that on click would start the contentIntent
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && alarmManager.canScheduleExactAlarms()) || Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerTime!!, pendingIntent)
else
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime!!, pendingIntent)
try {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && alarmManager.canScheduleExactAlarms()) || Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerTime!!, pendingIntent)
else
alarmManager.set(AlarmManager.RTC_WAKEUP, triggerTime!!, pendingIntent)
} catch (e: IllegalStateException) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
alarmManager.cancelAll()
} else {
while(alarmManager.nextAlarmClock!=null) {
alarmManager.cancel(alarmManager.nextAlarmClock.showIntent)
}
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ data class ICal4ListRel(
this[context.getString(R.string.filter_no_category)] = mutableListOf(sortedEntry)
}
}
}
}.toSortedMap(
if(sortOrder == SortOrder.DESC)
compareByDescending { it.uppercase() }
else
compareBy { it.uppercase() }
)
GroupBy.RESOURCE -> mutableMapOf<String, MutableList<ICal4ListRel>>().apply {
sortedList.forEach { sortedEntry ->
if (sortedEntry.resources.isNotEmpty()) {
Expand All @@ -114,7 +119,12 @@ data class ICal4ListRel(
this[context.getString(R.string.filter_no_resource)] = mutableListOf(sortedEntry)
}
}
}
}.toSortedMap(
if(sortOrder == SortOrder.DESC)
compareByDescending { it.uppercase() }
else
compareBy { it.uppercase() }
)
//GroupBy.CATEGORY -> sortedList.groupBy { if(it.categories.isEmpty()) context.getString(R.string.filter_no_category) else it.categories.joinToString(separator = ", ") { category -> category.text } }.toSortedMap()
//GroupBy.RESOURCE -> sortedList.groupBy { if(it.resources.isEmpty()) context.getString(R.string.filter_no_resource) else it.resources.joinToString(separator = ", ") { resource -> resource.text?:"" } }.toSortedMap()
GroupBy.STATUS -> sortedList.groupBy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import androidx.preference.PreferenceManager
import at.techbee.jtx.R
import at.techbee.jtx.database.ICalCollection
import at.techbee.jtx.database.Module
import at.techbee.jtx.database.locals.StoredListSettingData
import at.techbee.jtx.database.views.CollectionsView
import at.techbee.jtx.ui.GlobalStateHolder
import at.techbee.jtx.ui.reusable.appbars.JtxNavigationDrawer
import at.techbee.jtx.ui.reusable.appbars.JtxTopAppBar
import at.techbee.jtx.ui.reusable.appbars.OverflowMenu
import at.techbee.jtx.ui.reusable.destinations.FilteredListDestination
import at.techbee.jtx.ui.reusable.dialogs.CollectionsAddOrEditDialog
import at.techbee.jtx.ui.reusable.dialogs.SelectModuleForTxtImportDialog
import at.techbee.jtx.ui.settings.DropdownSettingOption
import at.techbee.jtx.ui.settings.SettingsStateHolder
import at.techbee.jtx.ui.settings.SettingsStateHolder.Companion.PREFS_LAST_MODULE
import at.techbee.jtx.util.DateTimeUtils
import at.techbee.jtx.util.SyncUtil

Expand Down Expand Up @@ -305,8 +309,25 @@ fun CollectionsScreen(
}
},
onCollectionClicked = { collection ->
if (globalStateHolder.icalString2Import.value?.isNotEmpty() == true && !collection.readonly)
if (globalStateHolder.icalString2Import.value?.isNotEmpty() == true && !collection.readonly) {
importCollection = collection
} else {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val lastUsedModule = try { Module.valueOf(prefs.getString(PREFS_LAST_MODULE, null)?: Module.JOURNAL.name) } catch (e: java.lang.IllegalArgumentException) { Module.JOURNAL }

navController.navigate(
FilteredListDestination.FilteredList.getRoute(
module = when {
lastUsedModule == Module.JOURNAL && collection.supportsVJOURNAL -> lastUsedModule
lastUsedModule == Module.NOTE && collection.supportsVJOURNAL -> lastUsedModule
lastUsedModule == Module.TODO && collection.supportsVTODO -> lastUsedModule
collection.supportsVTODO -> Module.TODO
else -> Module.JOURNAL
},
storedListSettingData = StoredListSettingData(searchCollection = listOf(collection.displayName?:""))
)
)
}
},
onDeleteAccount = { account -> collectionsViewModel.removeAccount(account) }
)
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/at/techbee/jtx/ui/detail/DetailViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
val mediaPlayer = MediaPlayer()

private var _isAuthenticated = false
private var immediateAlarmTriggeredOnce = false

companion object {
const val PREFS_DETAIL_JOURNALS = "prefsDetailJournals"
Expand All @@ -116,6 +117,7 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
fun load(icalObjectId: Long, isAuthenticated: Boolean) {
mainICalObjectId = icalObjectId
_isAuthenticated = isAuthenticated
immediateAlarmTriggeredOnce = false
viewModelScope.launch {
withContext(Dispatchers.Main) { changeState.value = DetailChangeState.LOADING }

Expand Down Expand Up @@ -210,6 +212,7 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
} ?: emptyList() else emptyList(),
searchAccount = if (sameAccount) collection.value?.accountName?.let { listOf(it) }
?: emptyList() else emptyList(),
flatView = true,
orderBy = OrderBy.LAST_MODIFIED,
sortOrder = SortOrder.DESC,
hideBiometricProtected = if (_isAuthenticated) emptyList() else ListSettings.getProtectedClassificationsFromSettings(
Expand Down Expand Up @@ -443,9 +446,16 @@ class DetailViewModel(application: Application) : AndroidViewModel(application)
databaseDao.setAlarmNotification(it.id, false)
}

if(triggerImmediateAlarm)
NotificationPublisher.triggerImmediateAlarm(it, _application)
val triggerInPastButNotDone =
mutableAlarms.any { alarm -> (alarm.triggerTime?:0L) <= System.currentTimeMillis() }
&& mutableAlarms.none { alarm -> (alarm.triggerTime?:0L) > System.currentTimeMillis() }
&& it.percent != 100
&& it.status != Status.COMPLETED.status

if(!immediateAlarmTriggeredOnce && (triggerImmediateAlarm || triggerInPastButNotDone)) {
NotificationPublisher.triggerImmediateAlarm(it, _application)
immediateAlarmTriggeredOnce = true
}
}
}

Expand Down
Loading

0 comments on commit 93e7188

Please sign in to comment.