Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Jan 5, 2021
2 parents 919b0a3 + 19dc726 commit 9c44a6a
Show file tree
Hide file tree
Showing 362 changed files with 3,945 additions and 1,065 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Network type:

## Build Variant

- [ ] App Store
- [ ] TestFlight
- [ ] Google Play
- [ ] FDroid

App version:
<!--Version Code here-->
Expand All @@ -35,4 +35,4 @@ App version:

### Expected behavior

<!--What is the expected behavior-->
<!--What is the expected behavior-->
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
set -x
assets=()
for asset in */*.apk; do
for asset in $(find -name *-release.apk); do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Twidere X is still in an early stage and will be periodically re-structuring/ref
```
Twidere X
Copyright (C) 2020 Tlaster <[email protected]>
Copyright (C) 2020-2021 Tlaster <[email protected]>
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
Expand Down
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ android {
}
}

lintOptions{
disable 'MissingTranslation'
}

flavorDimensions 'channel'
productFlavors {
if (enableGoogleVariant) {
Expand Down Expand Up @@ -165,6 +169,7 @@ dependencies {
implementation "com.google.dagger:hilt-android:$versions.hilt"
kapt "com.google.dagger:hilt-android-compiler:$versions.hilt"
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$versions.androidx_hilt"
implementation "androidx.hilt:hilt-work:$versions.androidx_hilt"
kapt "androidx.hilt:hilt-compiler:$versions.androidx_hilt"

compileOnly "com.squareup.inject:assisted-inject-annotations-dagger2:$versions.assisted_inject"
Expand All @@ -180,6 +185,8 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$versions.lifecycle"
implementation "androidx.lifecycle:lifecycle-common-java8:$versions.lifecycle"

implementation "androidx.work:work-runtime-ktx:2.5.0-beta02"

implementation "dev.chrisbanes.accompanist:accompanist-coil:0.4.0"

implementation "com.twitter.twittertext:twitter-text:3.1.0"
Expand All @@ -189,6 +196,8 @@ dependencies {

implementation "com.google.protobuf:protobuf-javalite:$versions.protobuf"

implementation 'com.google.android.exoplayer:exoplayer:2.12.2'

if (enableGoogleVariant) {
// START Non-FOSS component
googleImplementation platform('com.google.firebase:firebase-bom:26.1.0')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Twidere X
*
* Copyright (C) 2020 Tlaster <[email protected]>
* Copyright (C) 2020-2021 Tlaster <[email protected]>
*
* This file is part of Twidere X.
*
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
android:name=".TwidereApp"
Expand All @@ -21,10 +22,15 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TwidereX">
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
tools:node="remove" />
<activity
android:name=".TwidereXActivity"
android:label="@string/app_name"
android:theme="@style/Theme.TwidereX">
android:theme="@style/Theme.TwidereX"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/twidere/twiderex/Consts.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Twidere X
*
* Copyright (C) 2020 Tlaster <[email protected]>
* Copyright (C) 2020-2021 Tlaster <[email protected]>
*
* This file is part of Twidere X.
*
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/kotlin/com/twidere/twiderex/TwidereApp.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Twidere X
*
* Copyright (C) 2020 Tlaster <[email protected]>
* Copyright (C) 2020-2021 Tlaster <[email protected]>
*
* This file is part of Twidere X.
*
Expand All @@ -21,7 +21,18 @@
package com.twidere.twiderex

import android.app.Application
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject

@HiltAndroidApp
class TwidereApp : Application()
class TwidereApp : Application(), Configuration.Provider {
@Inject
lateinit var workerFactory: HiltWorkerFactory

override fun getWorkManagerConfiguration() =
Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}
57 changes: 54 additions & 3 deletions app/src/main/kotlin/com/twidere/twiderex/TwidereXActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Twidere X
*
* Copyright (C) 2020 Tlaster <[email protected]>
* Copyright (C) 2020-2021 Tlaster <[email protected]>
*
* This file is part of Twidere X.
*
Expand All @@ -20,6 +20,10 @@
*/
package com.twidere.twiderex

import android.net.ConnectivityManager
import android.net.Network
import android.net.NetworkCapabilities
import android.net.NetworkRequest
import android.os.Build
import android.os.Bundle
import android.view.WindowManager
Expand All @@ -31,25 +35,30 @@ import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.viewinterop.viewModel
import androidx.core.net.ConnectivityManagerCompat
import androidx.fragment.app.FragmentActivity
import androidx.hilt.lifecycle.HiltViewModelFactory
import androidx.lifecycle.MutableLiveData
import androidx.navigation.NavHostController
import androidx.navigation.compose.ComposeNavigator
import androidx.navigation.fragment.DialogFragmentNavigator
import com.twidere.twiderex.action.AmbientStatusActions
import com.twidere.twiderex.action.StatusActions
import com.twidere.twiderex.component.foundation.AmbientInAppNotification
import com.twidere.twiderex.di.assisted.AssistedViewModelFactoryHolder
import com.twidere.twiderex.di.assisted.ProvideAssistedFactory
import com.twidere.twiderex.extensions.ProvideNavigationViewModelFactoryMap
import com.twidere.twiderex.launcher.ActivityLauncher
import com.twidere.twiderex.launcher.AmbientLauncher
import com.twidere.twiderex.navigation.Router
import com.twidere.twiderex.notification.InAppNotification
import com.twidere.twiderex.preferences.PreferencesHolder
import com.twidere.twiderex.preferences.ProvidePreferences
import com.twidere.twiderex.providers.AmbientStatusActions
import com.twidere.twiderex.providers.StatusActions
import com.twidere.twiderex.ui.AmbientActiveAccount
import com.twidere.twiderex.ui.AmbientActiveAccountViewModel
import com.twidere.twiderex.ui.AmbientActivity
import com.twidere.twiderex.ui.AmbientApplication
import com.twidere.twiderex.ui.AmbientIsActiveNetworkMetered
import com.twidere.twiderex.ui.AmbientViewModelProviderFactory
import com.twidere.twiderex.ui.AmbientWindow
import com.twidere.twiderex.ui.AmbientWindowPadding
Expand All @@ -71,6 +80,21 @@ class TwidereXActivity : FragmentActivity() {
}

private lateinit var launcher: ActivityLauncher
private val isActiveNetworkMetered = MutableLiveData(false)
private val networkCallback by lazy {
object : ConnectivityManager.NetworkCallback() {
override fun onCapabilitiesChanged(
network: Network,
networkCapabilities: NetworkCapabilities
) {
isActiveNetworkMetered.postValue(
ConnectivityManagerCompat.isActiveNetworkMetered(
connectivityManager
)
)
}
}
}

@Inject
lateinit var statusActions: StatusActions
Expand All @@ -81,10 +105,21 @@ class TwidereXActivity : FragmentActivity() {
@Inject
lateinit var assistedViewModelFactoryHolder: AssistedViewModelFactoryHolder

@Inject
lateinit var inAppNotification: InAppNotification

@Inject
lateinit var connectivityManager: ConnectivityManager

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
launcher = ActivityLauncher(activityResultRegistry)
lifecycle.addObserver(launcher)
isActiveNetworkMetered.postValue(
ConnectivityManagerCompat.isActiveNetworkMetered(
connectivityManager
)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.setDecorFitsSystemWindows(false)
} else {
Expand All @@ -94,7 +129,9 @@ class TwidereXActivity : FragmentActivity() {
setContent {
val accountViewModel = viewModel<ActiveAccountViewModel>()
val account by accountViewModel.account.observeAsState()
val isActiveNetworkMetered by isActiveNetworkMetered.observeAsState(initial = false)
Providers(
AmbientInAppNotification provides inAppNotification,
AmbientLauncher provides launcher,
AmbientWindow provides window,
AmbientViewModelProviderFactory provides defaultViewModelProviderFactory,
Expand All @@ -103,6 +140,7 @@ class TwidereXActivity : FragmentActivity() {
AmbientStatusActions provides statusActions,
AmbientActivity provides this,
AmbientActiveAccountViewModel provides accountViewModel,
AmbientIsActiveNetworkMetered provides isActiveNetworkMetered
) {
ProvidePreferences(
preferencesHolder,
Expand All @@ -127,4 +165,17 @@ class TwidereXActivity : FragmentActivity() {
}
}
}

override fun onStart() {
super.onStart()
connectivityManager.registerNetworkCallback(
NetworkRequest.Builder().build(),
networkCallback,
)
}

override fun onPause() {
super.onPause()
connectivityManager.unregisterNetworkCallback(networkCallback)
}
}
43 changes: 43 additions & 0 deletions app/src/main/kotlin/com/twidere/twiderex/action/ComposeAction.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.action

import androidx.work.WorkManager
import com.twidere.twiderex.model.ComposeData
import com.twidere.twiderex.model.MicroBlogKey
import com.twidere.twiderex.worker.TwitterComposeWorker
import com.twidere.twiderex.worker.draft.RemoveDraftWorker
import com.twidere.twiderex.worker.draft.SaveDraftWorker

class ComposeAction(
private val workManager: WorkManager,
) {
fun commit(
accountKey: MicroBlogKey,
data: ComposeData,
) {
workManager
.beginWith(SaveDraftWorker.create(data = data))
.then(TwitterComposeWorker.create(accountKey = accountKey, data = data))
.then(RemoveDraftWorker.create(draftId = data.draftId))
.enqueue()
}
}
Loading

0 comments on commit 9c44a6a

Please sign in to comment.