Skip to content

Commit

Permalink
EOF-19
Browse files Browse the repository at this point in the history
EOF-19
  • Loading branch information
umerov1999 committed Jul 10, 2023
1 parent 4a57eb9 commit 2879ea1
Show file tree
Hide file tree
Showing 315 changed files with 6,114 additions and 5,148 deletions.
10 changes: 8 additions & 2 deletions app_fenrir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlin_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines")
compileOnly("org.jetbrains.kotlin:kotlin-annotations-jvm:$kotlin_version")
implementation("com.google.guava:guava:$guavaVersion")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:$desugarLibraryVersion")
implementation("androidx.core:core-ktx:$coreVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-common:$lifecycleVersion")
implementation("androidx.annotation:annotation:$annotationVersion")
//implementation("androidx.recyclerview:recyclerview:$recyclerviewVersion")
Expand Down Expand Up @@ -153,9 +155,7 @@ dependencies {
implementation("androidx.activity:activity-ktx:$activityVersion")
implementation("androidx.fragment:fragment-ktx:$fragmentVersion")
implementation("androidx.work:work-runtime-ktx:$workVersion")
implementation("com.google.guava:guava:$guavaVersion")
implementation("androidx.drawerlayout:drawerlayout:$drawerlayoutVersion")
implementation("androidx.loader:loader:$loaderVersion")
implementation("androidx.collection:collection-ktx:$collectionVersion")
implementation("androidx.savedstate:savedstate-ktx:$savedStateVersion")
implementation("androidx.cardview:cardview:$cardviewVersion")
Expand All @@ -166,5 +166,11 @@ dependencies {
//implementation("androidx.camera:camera-camera2:$cameraVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serializer")
implementation("com.google.errorprone:error_prone_annotations:${errorproneVersion}")

modules {
module("com.google.guava:listenablefuture") {
replacedBy("com.google.guava:guava", "listenablefuture is part of guava")
}
}
}
apply plugin: "com.google.gms.google-services"
1 change: 1 addition & 0 deletions app_fenrir/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ interface IAudioPlayerService {
int getAudioSessionId();
int getBufferPercent();
long getBufferPosition();
void doNotDestroyWhenActivityRecreated();
}

1 change: 0 additions & 1 deletion app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class App : Application() {
Utils.isCompressIncomingTraffic = Settings.get().other().isCompress_incoming_traffic
Utils.isCompressOutgoingTraffic = Settings.get().other().isCompress_outgoing_traffic
Utils.currentParser = Settings.get().other().currentParser
MusicPlaybackController.registerBroadcast(this)
PicassoInstance.init(this, Includes.proxySettings)
if (Settings.get().other().isKeepLongpoll) {
KeepLongpollService.start(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ abstract class BaseMvpActivity<P : AbsPresenter<V>, V : IMvpView> : AbsMvpActivi

companion object {
const val EXTRA_HIDE_TOOLBAR = "extra_hide_toolbar"
protected fun safelySetChecked(button: CompoundButton?, checked: Boolean) {
fun safelySetChecked(button: CompoundButton?, checked: Boolean) {
button?.isChecked = checked
}

protected fun safelySetText(target: TextView?, text: String?) {
fun safelySetText(target: TextView?, text: String?) {
target?.text = text
}

protected fun safelySetText(target: TextView?, @StringRes text: Int) {
fun safelySetText(target: TextView?, @StringRes text: Int) {
target?.setText(text)
}

protected fun safelySetVisibleOrGone(target: View?, visible: Boolean) {
fun safelySetVisibleOrGone(target: View?, visible: Boolean) {
target?.visibility = if (visible) View.VISIBLE else View.GONE
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package dev.ragnarok.fenrir.activity

import android.content.ComponentName
import android.content.Intent
import android.content.ServiceConnection
import android.graphics.Color
import android.os.Bundle
import android.os.IBinder
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
Expand All @@ -23,19 +26,57 @@ import dev.ragnarok.fenrir.fragment.messages.chat.ChatFragment.Companion.newInst
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.getParcelableExtraCompat
import dev.ragnarok.fenrir.listener.AppStyleable
import dev.ragnarok.fenrir.media.music.MusicPlaybackController
import dev.ragnarok.fenrir.media.music.MusicPlaybackService
import dev.ragnarok.fenrir.model.Document
import dev.ragnarok.fenrir.model.Peer
import dev.ragnarok.fenrir.place.Place
import dev.ragnarok.fenrir.place.PlaceProvider
import dev.ragnarok.fenrir.settings.CurrentTheme
import dev.ragnarok.fenrir.util.Logger
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.ViewUtils

class ChatActivity : NoMainActivity(), PlaceProvider, AppStyleable {
class ChatActivity : NoMainActivity(), PlaceProvider, AppStyleable, ServiceConnection {
//resolveToolbarNavigationIcon();
private val mOnBackStackChangedListener =
FragmentManager.OnBackStackChangedListener { keyboardHide() }

private var mAudioPlayServiceToken: MusicPlaybackController.ServiceToken? = null

private fun bindToAudioPlayService() {
if (mAudioPlayServiceToken == null) {
mAudioPlayServiceToken = MusicPlaybackController.bindToServiceWithoutStart(this, this)
}
}

private fun unbindFromAudioPlayService() {
if (mAudioPlayServiceToken != null) {
if (isChangingConfigurations) {
MusicPlaybackController.doNotDestroyWhenActivityRecreated()
}
MusicPlaybackController.unbindFromService(mAudioPlayServiceToken)
mAudioPlayServiceToken = null
}
}

private val TAG = "ChatActivity_LOG"

override fun onServiceConnected(name: ComponentName, service: IBinder) {
if (name.className == MusicPlaybackService::class.java.name) {
Logger.d(TAG, "Connected to MusicPlaybackService")
}
}

override fun onServiceDisconnected(name: ComponentName) {
if (mAudioPlayServiceToken == null) return
if (name.className == MusicPlaybackService::class.java.name) {
Logger.d(TAG, "Disconnected from MusicPlaybackService")
mAudioPlayServiceToken = null
bindToAudioPlayService()
}
}

public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
attach(
Expand All @@ -46,6 +87,8 @@ class ChatActivity : NoMainActivity(), PlaceProvider, AppStyleable {
handleIntent(intent)
supportFragmentManager.addOnBackStackChangedListener(mOnBackStackChangedListener)
}

bindToAudioPlayService()
}

private fun handleIntent(intent: Intent?) {
Expand Down Expand Up @@ -158,6 +201,8 @@ class ChatActivity : NoMainActivity(), PlaceProvider, AppStyleable {
public override fun onDestroy() {
supportFragmentManager.removeOnBackStackChangedListener(mOnBackStackChangedListener)
ViewUtils.keyboardHide(this)

unbindFromAudioPlayService()
super.onDestroy()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package dev.ragnarok.fenrir.activity

import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.graphics.Color
import android.os.Bundle
import android.os.IBinder
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
Expand All @@ -26,20 +29,58 @@ import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.getParcelableExtraCompat
import dev.ragnarok.fenrir.listener.AppStyleable
import dev.ragnarok.fenrir.longpoll.NotificationHelper
import dev.ragnarok.fenrir.media.music.MusicPlaybackController
import dev.ragnarok.fenrir.media.music.MusicPlaybackService
import dev.ragnarok.fenrir.model.Document
import dev.ragnarok.fenrir.model.Peer
import dev.ragnarok.fenrir.place.Place
import dev.ragnarok.fenrir.place.PlaceFactory
import dev.ragnarok.fenrir.place.PlaceProvider
import dev.ragnarok.fenrir.settings.CurrentTheme
import dev.ragnarok.fenrir.util.Logger
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.ViewUtils

class ChatActivityBubbles : NoMainActivity(), PlaceProvider, AppStyleable {
class ChatActivityBubbles : NoMainActivity(), PlaceProvider, AppStyleable, ServiceConnection {
//resolveToolbarNavigationIcon();
private val mOnBackStackChangedListener =
FragmentManager.OnBackStackChangedListener { keyboardHide() }

private var mAudioPlayServiceToken: MusicPlaybackController.ServiceToken? = null

private fun bindToAudioPlayService() {
if (mAudioPlayServiceToken == null) {
mAudioPlayServiceToken = MusicPlaybackController.bindToServiceWithoutStart(this, this)
}
}

private fun unbindFromAudioPlayService() {
if (mAudioPlayServiceToken != null) {
if (isChangingConfigurations) {
MusicPlaybackController.doNotDestroyWhenActivityRecreated()
}
MusicPlaybackController.unbindFromService(mAudioPlayServiceToken)
mAudioPlayServiceToken = null
}
}

private val TAG = "ChatActivityBubbles_LOG"

override fun onServiceConnected(name: ComponentName, service: IBinder) {
if (name.className == MusicPlaybackService::class.java.name) {
Logger.d(TAG, "Connected to MusicPlaybackService")
}
}

override fun onServiceDisconnected(name: ComponentName) {
if (mAudioPlayServiceToken == null) return
if (name.className == MusicPlaybackService::class.java.name) {
Logger.d(TAG, "Disconnected from MusicPlaybackService")
mAudioPlayServiceToken = null
bindToAudioPlayService()
}
}

public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
attach(this, SlidrConfig.Builder().listener(object : SlidrListener {
Expand All @@ -56,6 +97,8 @@ class ChatActivityBubbles : NoMainActivity(), PlaceProvider, AppStyleable {
handleIntent(intent)
supportFragmentManager.addOnBackStackChangedListener(mOnBackStackChangedListener)
}

bindToAudioPlayService()
}

private fun handleIntent(intent: Intent?) {
Expand Down Expand Up @@ -180,6 +223,7 @@ class ChatActivityBubbles : NoMainActivity(), PlaceProvider, AppStyleable {
NotificationHelper.resetBubbleOpened(this, true)
supportFragmentManager.removeOnBackStackChangedListener(mOnBackStackChangedListener)
ViewUtils.keyboardHide(this)
unbindFromAudioPlayService()
super.onDestroy()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package dev.ragnarok.fenrir.activity

import android.content.ComponentName
import android.content.Intent
import android.content.ServiceConnection
import android.graphics.Color
import android.os.Bundle
import android.os.IBinder
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
Expand All @@ -20,25 +23,65 @@ import dev.ragnarok.fenrir.fragment.audio.AudioPlayerFragment.Companion.newInsta
import dev.ragnarok.fenrir.fragment.messages.localjsontochat.LocalJsonToChatFragment
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.listener.AppStyleable
import dev.ragnarok.fenrir.media.music.MusicPlaybackController
import dev.ragnarok.fenrir.media.music.MusicPlaybackService
import dev.ragnarok.fenrir.model.Document
import dev.ragnarok.fenrir.place.Place
import dev.ragnarok.fenrir.place.PlaceProvider
import dev.ragnarok.fenrir.settings.CurrentTheme
import dev.ragnarok.fenrir.settings.ISettings
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Logger
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.ViewUtils

class LocalJsonToChatActivity : NoMainActivity(), PlaceProvider, AppStyleable {
class LocalJsonToChatActivity : NoMainActivity(), PlaceProvider, AppStyleable, ServiceConnection {
private val mOnBackStackChangedListener =
FragmentManager.OnBackStackChangedListener { keyboardHide() }

private var mAudioPlayServiceToken: MusicPlaybackController.ServiceToken? = null

private fun bindToAudioPlayService() {
if (mAudioPlayServiceToken == null) {
mAudioPlayServiceToken = MusicPlaybackController.bindToServiceWithoutStart(this, this)
}
}

private fun unbindFromAudioPlayService() {
if (mAudioPlayServiceToken != null) {
if (isChangingConfigurations) {
MusicPlaybackController.doNotDestroyWhenActivityRecreated()
}
MusicPlaybackController.unbindFromService(mAudioPlayServiceToken)
mAudioPlayServiceToken = null
}
}

private val TAG = "LocalJsonToChatActivity_LOG"

override fun onServiceConnected(name: ComponentName, service: IBinder) {
if (name.className == MusicPlaybackService::class.java.name) {
Logger.d(TAG, "Connected to MusicPlaybackService")
}
}

override fun onServiceDisconnected(name: ComponentName) {
if (mAudioPlayServiceToken == null) return
if (name.className == MusicPlaybackService::class.java.name) {
Logger.d(TAG, "Disconnected from MusicPlaybackService")
mAudioPlayServiceToken = null
bindToAudioPlayService()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
handleIntent(intent)
supportFragmentManager.addOnBackStackChangedListener(mOnBackStackChangedListener)
}

bindToAudioPlayService()
}

override fun onNewIntent(intent: Intent) {
Expand Down Expand Up @@ -146,6 +189,8 @@ class LocalJsonToChatActivity : NoMainActivity(), PlaceProvider, AppStyleable {
public override fun onDestroy() {
supportFragmentManager.removeOnBackStackChangedListener(mOnBackStackChangedListener)
ViewUtils.keyboardHide(this)

unbindFromAudioPlayService()
super.onDestroy()
}

Expand Down
Loading

0 comments on commit 2879ea1

Please sign in to comment.