Skip to content

Commit

Permalink
EOF-21
Browse files Browse the repository at this point in the history
EOF-21
  • Loading branch information
umerov1999 committed Aug 12, 2023
1 parent 63e7cfc commit 57819c5
Show file tree
Hide file tree
Showing 461 changed files with 7,871 additions and 3,349 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<b>Инструкция по сборке:</b>
Требуется:
1) Android Studio Giraffe (2022.3.1) или выше. Kotlin 1.9.*
1) Android Studio Hedgehog (2023.1.1) или выше. Kotlin 1.9.*
2) Android SDK 34
3) Android NDK 26.0.10404224

Expand Down
1 change: 1 addition & 0 deletions app_fenrir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ android {
namespace "dev.ragnarok.fenrir"
buildFeatures {
aidl = true
buildConfig = true
}
packagingOptions {
exclude("META-INF/notice.txt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Constants {
const val API_VERSION = "5.131"
const val AUTH_VERSION = API_VERSION

const val DATABASE_FENRIR_VERSION = 28
const val DATABASE_FENRIR_VERSION = 40
const val DATABASE_TEMPORARY_VERSION = 6
const val EXPORT_SETTINGS_FORMAT = 1
const val forceDeveloperMode = BuildConfig.FORCE_DEVELOPER_MODE
Expand Down
6 changes: 5 additions & 1 deletion app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import androidx.core.database.getStringOrNull
import dev.ragnarok.fenrir.util.rxutils.RxUtils
import dev.ragnarok.fenrir.util.rxutils.io.AndroidSchedulers
import dev.ragnarok.fenrir.util.serializeble.json.Json
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.functions.Consumer
import io.reactivex.rxjava3.schedulers.Schedulers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ package dev.ragnarok.fenrir.activity
import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder
import android.app.Activity
import android.content.*
import android.content.ClipData
import android.content.ClipboardManager
import android.content.ComponentName
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.ServiceConnection
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.view.*
import android.view.MenuItem
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.animation.LinearInterpolator
import android.view.inputmethod.InputMethodManager
import androidx.activity.OnBackPressedCallback
Expand All @@ -30,11 +40,14 @@ import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.navigation.NavigationBarView
import com.google.android.material.snackbar.BaseTransientBottomBar
import dev.ragnarok.fenrir.*
import dev.ragnarok.fenrir.AccountType
import dev.ragnarok.fenrir.Extra
import dev.ragnarok.fenrir.Includes
import dev.ragnarok.fenrir.Includes.networkInterfaces
import dev.ragnarok.fenrir.Includes.provideMainThreadScheduler
import dev.ragnarok.fenrir.Includes.proxySettings
import dev.ragnarok.fenrir.Includes.pushRegistrationResolver
import dev.ragnarok.fenrir.R
import dev.ragnarok.fenrir.activity.ActivityUtils.checkInputExist
import dev.ragnarok.fenrir.activity.ActivityUtils.isMimeAudio
import dev.ragnarok.fenrir.activity.EnterPinActivity.Companion.getClass
Expand All @@ -47,8 +60,12 @@ import dev.ragnarok.fenrir.db.Stores
import dev.ragnarok.fenrir.dialog.ResolveDomainDialog
import dev.ragnarok.fenrir.domain.InteractorFactory
import dev.ragnarok.fenrir.domain.impl.CountersInteractor
import dev.ragnarok.fenrir.fragment.*
import dev.ragnarok.fenrir.fragment.BrowserFragment
import dev.ragnarok.fenrir.fragment.DocPreviewFragment
import dev.ragnarok.fenrir.fragment.NotificationPreferencesFragment
import dev.ragnarok.fenrir.fragment.PreferencesFragment
import dev.ragnarok.fenrir.fragment.PreferencesFragment.Companion.cleanCache
import dev.ragnarok.fenrir.fragment.SecurityPreferencesFragment
import dev.ragnarok.fenrir.fragment.attachments.commentcreate.CommentCreateFragment
import dev.ragnarok.fenrir.fragment.attachments.commentedit.CommentEditFragment
import dev.ragnarok.fenrir.fragment.attachments.postcreate.PostCreateFragment
Expand Down Expand Up @@ -133,8 +150,17 @@ import dev.ragnarok.fenrir.fragment.wall.userdetails.UserDetailsFragment.Compani
import dev.ragnarok.fenrir.fragment.wall.wallattachments.WallAttachmentsFragmentFactory
import dev.ragnarok.fenrir.fragment.wall.wallattachments.wallsearchcommentsattachments.WallSearchCommentsAttachmentsFragment
import dev.ragnarok.fenrir.fragment.wall.wallpost.WallPostFragment
import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.getParcelableArrayListCompat
import dev.ragnarok.fenrir.getParcelableArrayListExtraCompat
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.getParcelableExtraCompat
import dev.ragnarok.fenrir.link.LinkHelper
import dev.ragnarok.fenrir.listener.*
import dev.ragnarok.fenrir.listener.AppStyleable
import dev.ragnarok.fenrir.listener.BackPressCallback
import dev.ragnarok.fenrir.listener.CanBackPressedCallback
import dev.ragnarok.fenrir.listener.OnSectionResumeCallback
import dev.ragnarok.fenrir.listener.UpdatableNavigation
import dev.ragnarok.fenrir.media.music.MusicPlaybackController
import dev.ragnarok.fenrir.media.music.MusicPlaybackController.ServiceToken
import dev.ragnarok.fenrir.media.music.MusicPlaybackController.bindToServiceWithoutStart
Expand All @@ -145,10 +171,19 @@ import dev.ragnarok.fenrir.media.music.MusicPlaybackService
import dev.ragnarok.fenrir.media.music.MusicPlaybackService.Companion.startForPlayList
import dev.ragnarok.fenrir.modalbottomsheetdialogfragment.ModalBottomSheetDialogFragment
import dev.ragnarok.fenrir.modalbottomsheetdialogfragment.OptionRequest
import dev.ragnarok.fenrir.model.*
import dev.ragnarok.fenrir.model.Audio
import dev.ragnarok.fenrir.model.Banned
import dev.ragnarok.fenrir.model.Comment
import dev.ragnarok.fenrir.model.Document
import dev.ragnarok.fenrir.model.Manager
import dev.ragnarok.fenrir.model.Peer
import dev.ragnarok.fenrir.model.SectionCounters
import dev.ragnarok.fenrir.model.User
import dev.ragnarok.fenrir.model.UserDetails
import dev.ragnarok.fenrir.model.drawer.AbsMenuItem
import dev.ragnarok.fenrir.model.drawer.RecentChat
import dev.ragnarok.fenrir.model.drawer.SectionMenuItem
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.place.Place
import dev.ragnarok.fenrir.place.PlaceFactory
import dev.ragnarok.fenrir.place.PlaceProvider
Expand All @@ -158,10 +193,17 @@ import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.settings.SwipesChatMode
import dev.ragnarok.fenrir.settings.theme.ThemesController.currentStyle
import dev.ragnarok.fenrir.settings.theme.ThemesController.nextRandom
import dev.ragnarok.fenrir.toMainThread
import dev.ragnarok.fenrir.upload.UploadUtils
import dev.ragnarok.fenrir.util.*
import dev.ragnarok.fenrir.util.Accounts
import dev.ragnarok.fenrir.util.Action
import dev.ragnarok.fenrir.util.HelperSimple
import dev.ragnarok.fenrir.util.HelperSimple.needHelp
import dev.ragnarok.fenrir.util.Logger
import dev.ragnarok.fenrir.util.MainActivityTransforms
import dev.ragnarok.fenrir.util.Pair
import dev.ragnarok.fenrir.util.Pair.Companion.create
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.rxutils.RxUtils
import dev.ragnarok.fenrir.util.toast.CustomSnackbars
import dev.ragnarok.fenrir.util.toast.CustomToast.Companion.createCustomToast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
import android.os.Process
Expand All @@ -27,6 +29,8 @@ import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.customview.widget.ViewDragHelper.STATE_IDLE
import com.squareup.picasso3.BitmapTarget
import com.squareup.picasso3.Picasso
import dev.ragnarok.fenrir.*
import dev.ragnarok.fenrir.Includes.proxySettings
import dev.ragnarok.fenrir.activity.SwipebleActivity.Companion.applyIntent
Expand All @@ -41,6 +45,8 @@ import dev.ragnarok.fenrir.model.Commented
import dev.ragnarok.fenrir.model.InternalVideoSize
import dev.ragnarok.fenrir.model.Video
import dev.ragnarok.fenrir.model.VideoSize
import dev.ragnarok.fenrir.picasso.PicassoInstance
import dev.ragnarok.fenrir.picasso.transforms.CropTransformation
import dev.ragnarok.fenrir.place.PlaceFactory
import dev.ragnarok.fenrir.push.OwnerInfo
import dev.ragnarok.fenrir.settings.CurrentTheme
Expand All @@ -51,13 +57,16 @@ import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.toast.CustomToast
import dev.ragnarok.fenrir.view.ExpandableSurfaceView
import dev.ragnarok.fenrir.view.VideoControllerView
import dev.ragnarok.fenrir.view.natives.animation.AnimatedShapeableImageView
import io.reactivex.rxjava3.disposables.CompositeDisposable
import kotlin.math.floor

class VideoPlayerActivity : AppCompatActivity(), SurfaceHolder.Callback,
VideoControllerView.MediaPlayerControl, IVideoPlayer.IVideoSizeChangeListener, AppStyleable {
private val mCompositeDisposable = CompositeDisposable()
private var mDecorView: View? = null
private var mPlaySpeed: ImageView? = null
private var mItemTimelineImage: AnimatedShapeableImageView? = null
private var mControllerView: VideoControllerView? = null
private var mSurfaceView: ExpandableSurfaceView? = null
private var mPlayer: IVideoPlayer? = null
Expand Down Expand Up @@ -196,6 +205,7 @@ class VideoPlayerActivity : AppCompatActivity(), SurfaceHolder.Callback,
}
mControllerView = VideoControllerView(this)
mSurfaceView = findViewById(R.id.videoSurface)
mItemTimelineImage = findViewById(R.id.item_timeline_image)
if (Settings.get().other().isVideo_swipes) {
attach(
this,
Expand Down Expand Up @@ -528,6 +538,57 @@ class VideoPlayerActivity : AppCompatActivity(), SurfaceHolder.Callback,
}
}

private val targetTimeline = object : BitmapTarget {
override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom) {
if (!isFinishing) {
mItemTimelineImage?.setImageBitmap(bitmap)
}
}

override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
}

override fun onBitmapFailed(e: Exception, errorDrawable: Drawable?) {
if (!isFinishing) {
mItemTimelineImage?.setImageDrawable(null)
}
}
}

private var p = Pair(0, 0)

override fun onScrolling(position: Long) {
video?.timelineThumbs?.let {
mItemTimelineImage?.let { si ->
if (it.isUv && it.links.nonNullNoEmpty()) {
val k = position.toDouble() / it.frequency / 1000
val index =
Utils.clamp((k / it.countPerImage).toInt(), 0, it.links?.size.orZero() - 1)
val x = it.frameWidth * (k % it.countPerRow).toInt()
val y = it.frameHeight * floor((k % it.countPerImage / it.countPerRow)).toInt()

if (p.first != x || p.second != y) {
p = Pair(x, y)
si.visibility = View.VISIBLE
PicassoInstance.with().cancelRequest(targetTimeline)

it.links?.get(index)?.nonNullNoEmpty { vi ->
PicassoInstance.with()
.load(vi)
.tag(Constants.PICASSO_TAG)
.transform(CropTransformation(x, y, it.frameWidth, it.frameHeight))
.into(targetTimeline)
}
}
}
}
}
}

override fun onScrollingStop() {
mItemTimelineImage?.visibility = View.GONE
}

private val fileUrl: String
get() = when (size) {
InternalVideoSize.SIZE_240 -> video?.mp4link240 ?: run { finish(); return "null" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dev.ragnarok.fenrir.api.model.VKApiVideo
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
Expand Down Expand Up @@ -75,6 +76,23 @@ class VideoDtoAdapter : AbsDtoAdapter<VKApiVideo>("VKApiVideo") {
dto.hls = optString(filesRoot, listOf("hls", "hls_ondemand"))
dto.live = optString(filesRoot, "live")
}
if (hasObject(root, "trailer")) {
val trailerRoot = root["trailer"]?.jsonObject
dto.trailer = Utils.firstNonEmptyString(
optString(trailerRoot, "mp4_720"),
optString(trailerRoot, "mp4_1080"),
optString(trailerRoot, "mp4_480")
)
}

if (hasObject(root, "timeline_thumbs")) {
dto.timeline_thumbs = root["timeline_thumbs"]?.let {
kJson.decodeFromJsonElement(
VKApiVideo.VKApiVideoTimeline.serializer(),
it
)
}
}
val sz =
if (dto.external.nonNullNoEmpty() && dto.external?.contains("youtube") == true) 320 else 800
if (hasArray(root, "image")) {
Expand Down
19 changes: 15 additions & 4 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/AbsApi.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package dev.ragnarok.fenrir.api.impl

import android.os.SystemClock
import dev.ragnarok.fenrir.*
import dev.ragnarok.fenrir.api.*
import dev.ragnarok.fenrir.Includes
import dev.ragnarok.fenrir.api.AbsVKApiInterceptor
import dev.ragnarok.fenrir.api.ApiException
import dev.ragnarok.fenrir.api.IServiceProvider
import dev.ragnarok.fenrir.api.OutOfDateException
import dev.ragnarok.fenrir.api.TokenType
import dev.ragnarok.fenrir.api.model.Captcha
import dev.ragnarok.fenrir.api.model.Error
import dev.ragnarok.fenrir.api.model.Params
Expand All @@ -11,6 +15,11 @@ import dev.ragnarok.fenrir.api.model.response.BaseResponse
import dev.ragnarok.fenrir.api.model.response.VKResponse
import dev.ragnarok.fenrir.api.rest.HttpException
import dev.ragnarok.fenrir.api.rest.IServiceRest
import dev.ragnarok.fenrir.isMsgPack
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.nullOrEmpty
import dev.ragnarok.fenrir.requireNonNull
import dev.ragnarok.fenrir.service.ApiErrorCodes
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.refresh.RefreshToken
Expand All @@ -22,7 +31,9 @@ import io.reactivex.rxjava3.core.SingleEmitter
import io.reactivex.rxjava3.exceptions.Exceptions
import io.reactivex.rxjava3.functions.Function
import kotlinx.serialization.KSerializer
import okhttp3.*
import okhttp3.FormBody
import okhttp3.Request
import okhttp3.Response
import kotlin.random.Random

internal open class AbsApi(val accountId: Long, private val restProvider: IServiceProvider) {
Expand Down Expand Up @@ -198,7 +209,7 @@ internal open class AbsApi(val accountId: Long, private val restProvider: IServi
break
}
}
if (code != null) {
if (code.nonNullNoEmpty() && captcha.sid.nonNullNoEmpty()) {
params["captcha_sid"] = captcha.sid
params["captcha_key"] = code
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ open class VKApiOwner
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as VKApiOwner

if (id != other.id) return false

return true
return id == other.id
}

open val fullName: String?
Expand Down
Loading

0 comments on commit 57819c5

Please sign in to comment.