Skip to content

Commit

Permalink
Merge branch 'release/1.1.0-beta04'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Apr 26, 2021
2 parents 066028c + 1cc4ae6 commit fa44473
Show file tree
Hide file tree
Showing 33 changed files with 517 additions and 375 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,13 @@ dependencies {

implementation libs.work.runtime.ktx

implementation libs.startup

implementation libs.bundles.accompanist

implementation libs.zoomable
implementation libs.nestedScrollView
implementation libs.swiper

implementation libs.twittertext
implementation libs.jsoup
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
<meta-data
android:name="com.twidere.twiderex.notification.NotificationChannelInitializer"
android:value="androidx.startup" />
</provider>
<activity
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import androidx.work.WorkManager
import com.twidere.twiderex.model.ComposeData
import com.twidere.twiderex.model.MicroBlogKey
import com.twidere.twiderex.model.PlatformType
import com.twidere.twiderex.worker.MastodonComposeWorker
import com.twidere.twiderex.worker.TwitterComposeWorker
import com.twidere.twiderex.worker.compose.MastodonComposeWorker
import com.twidere.twiderex.worker.compose.TwitterComposeWorker
import com.twidere.twiderex.worker.draft.RemoveDraftWorker
import com.twidere.twiderex.worker.draft.SaveDraftWorker

Expand Down

This file was deleted.

5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/twidere/twiderex/di/AndroidModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.content.Context
import android.content.SharedPreferences
import android.location.LocationManager
import android.net.ConnectivityManager
import androidx.core.app.NotificationManagerCompat
import androidx.room.Room
import androidx.work.WorkManager
import com.twidere.twiderex.db.AppDatabase
Expand Down Expand Up @@ -78,4 +79,8 @@ object AndroidModule {
@Provides
fun provideContentResolver(@ApplicationContext context: Context): ContentResolver =
context.contentResolver

@Provides
fun provideNotificationManagerCompat(@ApplicationContext context: Context): NotificationManagerCompat =
NotificationManagerCompat.from(context)
}
6 changes: 6 additions & 0 deletions app/src/main/kotlin/com/twidere/twiderex/navigation/Route.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ object Route {
const val User = "deeplink/twitter/user/{screenName}"
const val Status = "deeplink/twitter/status/{statusId}"
}
fun Draft(id: String) = "$twidereXSchema://draft/compose/$id"
}

fun Status(statusKey: MicroBlogKey) = "status/$statusKey"
Expand All @@ -201,6 +202,8 @@ object DeepLinks {
const val User = "$twidereXSchema://user"
const val Search = "$twidereXSchema://search"
const val SignIn = "$twidereXSchema://signin"

const val Draft = "$twidereXSchema://draft/compose/{draftId}"
}

fun RouteBuilder.authorizedScene(
Expand Down Expand Up @@ -565,6 +568,9 @@ fun RouteBuilder.route(constraints: Constraints) {

scene(
"draft/compose/{draftId}",
deepLinks = listOf(
DeepLinks.Draft,
)
) { backStackEntry ->
backStackEntry.path<String>("draftId")?.let {
DraftComposeScene(draftId = it)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Twidere X
*
* Copyright (C) 2020-2021 Tlaster <[email protected]>
*
* This file is part of Twidere X.
*
* Twidere X is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Twidere X is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Twidere X. If not, see <http://www.gnu.org/licenses/>.
*/
package com.twidere.twiderex.notification

import android.content.Context
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationManagerCompat
import androidx.startup.Initializer

class NotificationChannelInitializerHolder

class NotificationChannelInitializer : Initializer<NotificationChannelInitializerHolder> {
override fun create(context: Context): NotificationChannelInitializerHolder {
val notificationManagerCompat = NotificationManagerCompat.from(context)
val addedChannels = mutableListOf<String>()
for (spec in NotificationChannelSpec.values()) {
if (spec.grouped) continue
val builder = NotificationChannelCompat.Builder(spec.id, spec.importance)
.setName(context.getString(spec.nameRes))

if (spec.descriptionRes != 0) {
builder.setDescription(context.getString(spec.descriptionRes))
}
builder.setShowBadge(spec.showBadge)
val channel = builder.build()
notificationManagerCompat.createNotificationChannel(channel)
addedChannels.add(channel.id)
}

notificationManagerCompat.notificationChannelsCompat.forEach {
if (it.id !in addedChannels && it.group == null) {
notificationManagerCompat.deleteNotificationChannel(it.id)
}
}
return NotificationChannelInitializerHolder()
}

override fun dependencies(): List<Class<out Initializer<*>>> {
return emptyList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Twidere X
*
* Copyright (C) 2020-2021 Tlaster <[email protected]>
*
* This file is part of Twidere X.
*
* Twidere X is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Twidere X is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Twidere X. If not, see <http://www.gnu.org/licenses/>.
*/
package com.twidere.twiderex.notification

import androidx.annotation.StringRes
import androidx.core.app.NotificationManagerCompat
import com.twidere.twiderex.R

enum class NotificationChannelSpec(
val id: String,
@StringRes val nameRes: Int,
@StringRes val descriptionRes: Int = 0,
val importance: Int,
val showBadge: Boolean = false,
val grouped: Boolean = false
) {
/**
* For notifications indicate that some lengthy operations are performing in the background.
* Such as sending attachment process.
*/
BackgroundProgresses(
"background_progresses",
R.string.common_notification_channel_background_progresses_name,
importance = NotificationManagerCompat.IMPORTANCE_HIGH
),
}
12 changes: 8 additions & 4 deletions app/src/main/kotlin/com/twidere/twiderex/scenes/MediaScene.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ import com.twidere.twiderex.R
import com.twidere.twiderex.component.foundation.InAppNotificationScaffold
import com.twidere.twiderex.component.foundation.LoadingProgress
import com.twidere.twiderex.component.foundation.NetworkImage
import com.twidere.twiderex.component.foundation.Swiper
import com.twidere.twiderex.component.foundation.SwiperState
import com.twidere.twiderex.component.foundation.VideoPlayer
import com.twidere.twiderex.component.foundation.rememberSwiperState
import com.twidere.twiderex.component.status.LikeButton
import com.twidere.twiderex.component.status.ReplyButton
import com.twidere.twiderex.component.status.RetweetButton
Expand All @@ -110,6 +107,9 @@ import com.twidere.twiderex.ui.LocalVideoPlayback
import com.twidere.twiderex.ui.LocalWindow
import com.twidere.twiderex.ui.TwidereDialog
import com.twidere.twiderex.viewmodel.MediaViewModel
import moe.tlaster.swiper.Swiper
import moe.tlaster.swiper.SwiperState
import moe.tlaster.swiper.rememberSwiperState
import moe.tlaster.zoomable.Zoomable
import moe.tlaster.zoomable.rememberZoomableState

Expand Down Expand Up @@ -142,7 +142,11 @@ fun StatusMediaScene(statusKey: MicroBlogKey, selectedIndex: Int) {
CompositionLocalProvider(
LocalVideoPlayback provides DisplayPreferences.AutoPlayback.Always
) {
StatusMediaScene(status = it, selectedIndex = selectedIndex, viewModel = viewModel)
StatusMediaScene(
status = it,
selectedIndex = selectedIndex.coerceIn(0, it.media.lastIndex),
viewModel = viewModel,
)
}
}
}
Expand Down
Loading

0 comments on commit fa44473

Please sign in to comment.