Skip to content

Commit

Permalink
74
Browse files Browse the repository at this point in the history
74
  • Loading branch information
umerov1999 committed Nov 20, 2024
1 parent 2f5c432 commit 1633bc0
Show file tree
Hide file tree
Showing 484 changed files with 20,127 additions and 38,307 deletions.
1 change: 0 additions & 1 deletion app_fenrir/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@
android:configChanges="keyboardHidden|orientation"
android:exported="true"
android:label="@string/lottie_preview"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden"
tools:ignore="DiscouragedApi,LockedOrientationActivity">

Expand Down
6 changes: 3 additions & 3 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ object Constants {

const val FILE_PROVIDER_AUTHORITY: String = "${BuildConfig.APPLICATION_ID}.file_provider"
const val VK_ANDROID_APP_VERSION_NAME = "8.15"
const val VK_ANDROID_APP_VERSION_CODE = "15271"
const val VK_ANDROID_APP_VERSION_CODE = 15271
const val KATE_APP_VERSION_NAME = "118 lite"
const val KATE_APP_VERSION_CODE = "566"
const val KATE_APP_VERSION_CODE = 566

const val IOS_APP_VERSION_CODE = "3893"
const val IOS_APP_VERSION_CODE = 3893

const val API_ID: Int = BuildConfig.VK_API_APP_ID
const val SECRET: String = BuildConfig.VK_CLIENT_SECRET
Expand Down
16 changes: 8 additions & 8 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/UserAgentTool.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object UserAgentTool {

private val KATE_USER_AGENT = String.format(
Locale.US,
"KateMobileAndroid/%s-%s (Android %s; SDK %d; %s; %s; %s; %s)",
"KateMobileAndroid/%s-%d (Android %s; SDK %d; %s; %s; %s; %s)",
Constants.KATE_APP_VERSION_NAME,
Constants.KATE_APP_VERSION_CODE,
Build.VERSION.RELEASE,
Expand All @@ -33,7 +33,7 @@ object UserAgentTool {

private val KATE_USER_AGENT_FAKE = String.format(
Locale.US,
"KateMobileAndroid/%s-%s (Android %s; SDK %d; %s; %s; %s; %s)",
"KateMobileAndroid/%s-%d (Android %s; SDK %d; %s; %s; %s; %s)",
Constants.KATE_APP_VERSION_NAME,
Constants.KATE_APP_VERSION_CODE,
Build.VERSION.RELEASE,
Expand All @@ -46,7 +46,7 @@ object UserAgentTool {

private val VK_ANDROID_USER_AGENT = String.format(
Locale.US,
"VKAndroidApp/%s-%s (Android %s; SDK %d; %s; %s; %s; %s)",
"VKAndroidApp/%s-%d (Android %s; SDK %d; %s; %s; %s; %s)",
Constants.VK_ANDROID_APP_VERSION_NAME,
Constants.VK_ANDROID_APP_VERSION_CODE,
Build.VERSION.RELEASE,
Expand All @@ -59,7 +59,7 @@ object UserAgentTool {

private val VK_ANDROID_USER_AGENT_FAKE = String.format(
Locale.US,
"VKAndroidApp/%s-%s (Android %s; SDK %d; %s; %s; %s; %s)",
"VKAndroidApp/%s-%d (Android %s; SDK %d; %s; %s; %s; %s)",
Constants.VK_ANDROID_APP_VERSION_NAME,
Constants.VK_ANDROID_APP_VERSION_CODE,
Build.VERSION.RELEASE,
Expand All @@ -72,7 +72,7 @@ object UserAgentTool {

private val VK_iOS_USER_AGENT_FAKE = String.format(
Locale.US,
"com.vk.vkclient/%s (iPhone, iOS 16.1, iPhone11,2, Scale/3.0)",
"com.vk.vkclient/%d (iPhone, iOS 16.1, iPhone11,2, Scale/3.0)",
Constants.IOS_APP_VERSION_CODE
)

Expand All @@ -82,7 +82,7 @@ object UserAgentTool {
return when (type) {
AccountType.KATE_HIDDEN -> String.format(
Locale.US,
"KateMobileAndroid/%s-%s (Android %s; SDK %d; %s; %s; %s; %s)",
"KateMobileAndroid/%s-%d (Android %s; SDK %d; %s; %s; %s; %s)",
Constants.KATE_APP_VERSION_NAME,
Constants.KATE_APP_VERSION_CODE,
Build.VERSION.RELEASE,
Expand All @@ -95,14 +95,14 @@ object UserAgentTool {

AccountType.IOS_HIDDEN -> String.format(
Locale.US,
"com.vk.vkclient/%s (iPhone, iOS 16.1, %s, Scale/3.0)",
"com.vk.vkclient/%d (iPhone, iOS 16.1, %s, Scale/3.0)",
Constants.IOS_APP_VERSION_CODE,
device
)

else -> String.format(
Locale.US,
"VKAndroidApp/%s-%s (Android %s; SDK %d; %s; %s; %s; %s)",
"VKAndroidApp/%s-%d (Android %s; SDK %d; %s; %s; %s; %s)",
Constants.VK_ANDROID_APP_VERSION_NAME,
Constants.VK_ANDROID_APP_VERSION_CODE,
Build.VERSION.RELEASE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import androidx.documentfile.provider.DocumentFile
import com.google.android.material.button.MaterialButton
import dev.ragnarok.fenrir.Extra
import dev.ragnarok.fenrir.R
import dev.ragnarok.fenrir.module.BufferWriteNative
import dev.ragnarok.fenrir.module.FenrirNative
import dev.ragnarok.fenrir.module.rlottie.RLottie2Gif
import dev.ragnarok.fenrir.module.rlottie.RLottie2Gif.Lottie2GifListener
import dev.ragnarok.fenrir.module.animation.thorvg.ThorVGLottie2Gif
import dev.ragnarok.fenrir.module.animation.thorvg.ThorVGLottie2Gif.Lottie2GifListener
import dev.ragnarok.fenrir.settings.CurrentTheme
import dev.ragnarok.fenrir.settings.ISettings
import dev.ragnarok.fenrir.settings.Settings
Expand All @@ -26,7 +25,11 @@ import dev.ragnarok.fenrir.util.AppPerms
import dev.ragnarok.fenrir.util.AppPerms.requestPermissionsAbs
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.hasVanillaIceCreamTarget
import dev.ragnarok.fenrir.view.natives.rlottie.RLottieImageView
import dev.ragnarok.fenrir.view.natives.animation.ThorVGLottieView
import okio.BufferedSource
import okio.buffer
import okio.sink
import okio.source
import java.io.File

class LottieActivity : AppCompatActivity() {
Expand Down Expand Up @@ -56,46 +59,40 @@ class LottieActivity : AppCompatActivity() {
result.data?.getStringExtra(Extra.PATH), title
)
toGif?.isEnabled = false
RLottie2Gif.create(
BufferWriteNative.fromStreamEndlessNull(
contentResolver.openInputStream(
intent.data ?: return@registerForActivityResult
) ?: return@registerForActivityResult
)
).setListener(object : Lottie2GifListener {
var start: Long = 0
var logs: String? = null
override fun onStarted() {
start = System.currentTimeMillis()
logs = "Wait a moment...\r\n"
log(logs)
}
ThorVGLottie2Gif.create(File(parentDir(), "lottie_view.json"))
.setListener(object : Lottie2GifListener {
var start: Long = 0
var logs: String? = null
override fun onStarted() {
start = System.currentTimeMillis()
logs = "Wait a moment...\r\n"
log(logs)
}

@SuppressLint("SetTextI18n")
override fun onProgress(frame: Int, totalFrame: Int) {
log(logs + "progress : " + frame + "/" + totalFrame)
}
@SuppressLint("SetTextI18n")
override fun onProgress(frame: Int, totalFrame: Int) {
log(logs + "progress : " + frame + "/" + totalFrame)
}

override fun onFinished() {
logs =
"GIF created (" + (System.currentTimeMillis() - start) + "ms)\r\n" +
"Resolution : " + 500 + "x" + 500 + "\r\n" +
"Path : " + file + "\r\n" +
"File Size : " + file.length() / 1024 + "kb"
log(logs)
toGif?.post { toGif?.isEnabled = true }
}
})
override fun onFinished() {
logs =
"GIF created (" + (System.currentTimeMillis() - start) + "ms)\r\n" +
"Resolution : " + 500 + "x" + 500 + "\r\n" +
"Path : " + file + "\r\n" +
"File Size : " + file.length() / 1024 + "kb"
log(logs)
toGif?.post { toGif?.isEnabled = true }
}
})
.setBackgroundColor(Color.TRANSPARENT)
.setOutputPath(file)
.setSize(500, 500)
.setBackgroundTask(true)
.setDithering(false)
.build()
}
}

private var lottie: RLottieImageView? = null
private var lottie: ThorVGLottieView? = null
private var lg: TextView? = null
internal fun log(log: String?) {
lg?.post { lg?.text = log?.trim() }
Expand Down Expand Up @@ -141,7 +138,30 @@ class LottieActivity : AppCompatActivity() {
}
if (savedInstanceState == null) {
handleIntent(intent)
} else {
lottie?.fromFile(File(parentDir(), "lottie_view.json"), true)
lottie?.startAnimation()
}
}

private fun parentDir(): File {
val file = File(cacheDir, "lottie_cache")
if (file.isFile) {
file.delete()
}
if (!file.exists()) {
file.mkdirs()
}
return file
}

private fun writeTempCacheFile(source: BufferedSource): File {
val file = File(parentDir(), "lottie_view.json")

file.sink().buffer().use { output ->
output.writeAll(source)
}
return file
}

private fun handleIntent(intent: Intent?) {
Expand All @@ -157,15 +177,14 @@ class LottieActivity : AppCompatActivity() {
val action = intent.action
if (Intent.ACTION_VIEW == action) {
try {
lottie?.setAutoRepeat(true)
lottie?.fromString(
BufferWriteNative.fromStreamEndlessNull(
contentResolver.openInputStream(
getIntent().data ?: return
) ?: return
), Utils.dp(500f), Utils.dp(500f)
writeTempCacheFile(
(contentResolver.openInputStream(
getIntent().data ?: return
) ?: return).source().buffer()
)
lottie?.playAnimation()

lottie?.fromFile(File(parentDir(), "lottie_view.json"), true)
lottie?.startAnimation()
} catch (e: Throwable) {
e.printStackTrace()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect
}

private fun updateNotificationCount(account: Long) {
if (account == ISettings.IAccountsSettings.INVALID_ID) {
removeNotificationsBadge()
return
}
mCompositeJob.add(CountersInteractor(networkInterfaces).getApiCounters(account)
.fromIOToMain({ counters -> updateNotificationsBadge(counters) }) { removeNotificationsBadge() })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import dev.ragnarok.fenrir.util.coroutines.CoroutinesUtils.toMain
import dev.ragnarok.fenrir.util.toast.CustomToast
import dev.ragnarok.fenrir.view.CircleCounterButton
import dev.ragnarok.fenrir.view.TouchImageView
import dev.ragnarok.fenrir.view.natives.rlottie.RLottieImageView
import dev.ragnarok.fenrir.view.natives.animation.ThorVGLottieView
import dev.ragnarok.fenrir.view.pager.WeakPicassoLoadCallback
import java.io.File
import java.lang.ref.WeakReference
Expand Down Expand Up @@ -232,7 +232,7 @@ class SinglePhotoActivity : NoMainActivity(), PlaceProvider, AppStyleable {
val reload: FloatingActionButton
private val mPicassoLoadCallback: WeakPicassoLoadCallback
val photo: TouchImageView
val progress: RLottieImageView
val progress: ThorVGLottieView
var animationDispose = CancelableJob()
private var mAnimationLoaded = false
private var mLoadingNow = false
Expand All @@ -258,38 +258,45 @@ class SinglePhotoActivity : NoMainActivity(), PlaceProvider, AppStyleable {
val k = ObjectAnimator.ofFloat(progress, View.ALPHA, 0.0f).setDuration(1000)
k.addListener(object : StubAnimatorListener() {
override fun onAnimationEnd(animation: Animator) {
progress.clearAnimationDrawable()
progress.clearAnimationDrawable(
callSuper = true, clearState = true,
cancelTask = true
)
progress.visibility = View.GONE
progress.alpha = 1f
}

override fun onAnimationCancel(animation: Animator) {
progress.clearAnimationDrawable()
progress.clearAnimationDrawable(
callSuper = true, clearState = true,
cancelTask = true
)
progress.visibility = View.GONE
progress.alpha = 1f
}
})
k.start()
} else if (mAnimationLoaded && !mLoadingNow) {
mAnimationLoaded = false
progress.clearAnimationDrawable()
progress.clearAnimationDrawable(
callSuper = true, clearState = true,
cancelTask = true
)
progress.visibility = View.GONE
} else if (mLoadingNow) {
animationDispose += delayTaskFlow(300).toMain {
mAnimationLoaded = true
progress.visibility = View.VISIBLE
progress.fromRes(
dev.ragnarok.fenrir_common.R.raw.loading,
Utils.dp(100F),
Utils.dp(100F),
intArrayOf(
0x000000,
CurrentTheme.getColorPrimary(ref.get()),
0x777777,
CurrentTheme.getColorSecondary(ref.get())
)
)
progress.playAnimation()
progress.startAnimation()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,12 @@ class GifPagerActivity : AbsDocumentPreviewActivity<GifPagerPresenter, IGifPager
}

override fun onBindViewHolder(holder: Holder, position: Int) {
holder.mGifView.fromNet(
holder.mGifView.fromAnimationNet(
data[position].ownerId.toString() + "_" + data[position].id.toString(),
data[position].videoPreview?.src,
data[position].getPreviewWithSize(PhotoSize.W, false),
Utils.createOkHttp(Constants.GIF_TIMEOUT, true)
Utils.createOkHttp(Constants.GIF_TIMEOUT, true),
true
)
}

Expand Down
Loading

0 comments on commit 1633bc0

Please sign in to comment.