Skip to content

Commit

Permalink
19
Browse files Browse the repository at this point in the history
19
  • Loading branch information
umerov1999 committed Apr 2, 2023
1 parent e7ea306 commit 8da0f5a
Show file tree
Hide file tree
Showing 99 changed files with 1,592 additions and 789 deletions.
4 changes: 2 additions & 2 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ 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 KATE_APP_VERSION_NAME = "97.1 lite"
const val KATE_APP_VERSION_CODE = "532"
const val KATE_APP_VERSION_NAME = "99 lite"
const val KATE_APP_VERSION_CODE = "535"
const val API_ID: Int = BuildConfig.VK_API_APP_ID
const val SECRET: String = BuildConfig.VK_CLIENT_SECRET
const val PHOTOS_PATH = "DCIM/Fenrir"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ open class PhotoPagerPresenter internal constructor(

override fun onViewHostAttached(view: IPhotoPagerView) {
super.onViewHostAttached(view)
resolveOptionMenu()
resolveOptionMenu(view)
}

private fun resolveOptionMenu() {
view?.setupOptionMenu(
private fun resolveOptionMenu(view: IPhotoPagerView) {
view.setupOptionMenu(
canSaveYourself(),
canDelete()
)
Expand Down Expand Up @@ -198,7 +198,7 @@ open class PhotoPagerPresenter internal constructor(
private fun onPositionChanged() {
refreshInfoViews(true)
resolveRestoreButtonVisibility()
resolveOptionMenu()
view?.let { resolveOptionMenu(it) }
}

private fun showPhotoInfo(photo: Photo, album: PhotoAlbum?, bundle: IOwnersBundle?) {
Expand Down Expand Up @@ -301,7 +301,7 @@ open class PhotoPagerPresenter internal constructor(
resolveWithUserView()
resolveShareView()
resolveCommentsView()
resolveOptionMenu()
view?.let { resolveOptionMenu(it) }
if (need_update && need_update_info() && hasPhotos()) {
val photo = current
if (photo.albumId != -311) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ object HttpLoggerAndParser {
return this
}

val DEFAULT_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
private val DEFAULT_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
OkHttp3LoggingInterceptor().setLevel(OkHttp3LoggingInterceptor.Level.BODY)
}

val UPLOAD_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
private val UPLOAD_LOGGING_INTERCEPTOR: OkHttp3LoggingInterceptor by lazy {
//OkHttp3LoggingInterceptor().setLevel(OkHttp3LoggingInterceptor.Level.HEADERS)
OkHttp3LoggingInterceptor().setLevel(OkHttp3LoggingInterceptor.Level.BODY)
}
Expand Down
13 changes: 0 additions & 13 deletions app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/impl/DocsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import dev.ragnarok.fenrir.api.model.AccessIdPair
import dev.ragnarok.fenrir.api.model.Items
import dev.ragnarok.fenrir.api.model.VKApiDoc
import dev.ragnarok.fenrir.api.model.server.VKApiDocsUploadServer
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import dev.ragnarok.fenrir.api.services.IDocsService
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -75,18 +74,6 @@ internal class DocsApi(accountId: Long, provider: IServiceProvider) : AbsApi(acc
}
}

override fun getVideoServer(
isPrivate: Int?,
group_id: Long?,
name: String?
): Single<VKApiVideosUploadServer> {
return provideService(IDocsService(), TokenType.USER)
.flatMap { service ->
service.getVideoServer(isPrivate, group_id, name)
.map(extractResponseWithErrorHandling())
}
}

override fun get(
ownerId: Long?,
count: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import dev.ragnarok.fenrir.api.model.VKApiVideoAlbum
import dev.ragnarok.fenrir.api.model.interfaces.IAttachmentToken
import dev.ragnarok.fenrir.api.model.response.DefaultCommentsResponse
import dev.ragnarok.fenrir.api.model.response.SearchVideoResponse
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import dev.ragnarok.fenrir.api.services.IVideoService
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -183,4 +184,20 @@ internal class VideoApi(accountId: Long, provider: IServiceProvider) :
.map { it == 1 }
}
}

override fun getVideoServer(
isPrivate: Int?,
group_id: Long?,
name: String?
): Single<VKApiVideosUploadServer> {
return provideService(IVideoService(), TokenType.USER)
.flatMap { service ->
var finalName = name
if (finalName?.startsWith("VID_", false) == true) {
finalName = "Telegram $finalName"
}
service.getVideoServer(isPrivate, group_id, finalName)
.map(extractResponseWithErrorHandling())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import dev.ragnarok.fenrir.api.model.AccessIdPair
import dev.ragnarok.fenrir.api.model.Items
import dev.ragnarok.fenrir.api.model.VKApiDoc
import dev.ragnarok.fenrir.api.model.server.VKApiDocsUploadServer
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import io.reactivex.rxjava3.core.Single

interface IDocsApi {
Expand All @@ -30,13 +29,6 @@ interface IDocsApi {
@CheckResult
fun getMessagesUploadServer(peerId: Long?, type: String?): Single<VKApiDocsUploadServer>

@CheckResult
fun getVideoServer(
isPrivate: Int?,
group_id: Long?,
name: String?
): Single<VKApiVideosUploadServer>

@CheckResult
operator fun get(
ownerId: Long?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dev.ragnarok.fenrir.api.model.VKApiVideoAlbum
import dev.ragnarok.fenrir.api.model.interfaces.IAttachmentToken
import dev.ragnarok.fenrir.api.model.response.DefaultCommentsResponse
import dev.ragnarok.fenrir.api.model.response.SearchVideoResponse
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import io.reactivex.rxjava3.core.Single

interface IVideoApi {
Expand Down Expand Up @@ -75,4 +76,11 @@ interface IVideoApi {

@CheckResult
fun edit(ownerId: Long, video_id: Int, name: String?, desc: String?): Single<Boolean>

@CheckResult
fun getVideoServer(
isPrivate: Int?,
group_id: Long?,
name: String?
): Single<VKApiVideosUploadServer>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import dev.ragnarok.fenrir.api.model.Items
import dev.ragnarok.fenrir.api.model.VKApiDoc
import dev.ragnarok.fenrir.api.model.response.BaseResponse
import dev.ragnarok.fenrir.api.model.server.VKApiDocsUploadServer
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import dev.ragnarok.fenrir.api.rest.IServiceRest
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -126,20 +125,6 @@ class IDocsService : IServiceRest() {
)
}

fun getVideoServer(
is_private: Int?,
group_id: Long?,
name: String?
): Single<BaseResponse<VKApiVideosUploadServer>> {
return rest.request(
"video.save", form(
"is_private" to is_private,
"group_id" to group_id,
"name" to name
), base(VKApiVideosUploadServer.serializer())
)
}

/**
* Returns detailed information about user or community documents.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dev.ragnarok.fenrir.api.model.VKApiVideoAlbum
import dev.ragnarok.fenrir.api.model.response.BaseResponse
import dev.ragnarok.fenrir.api.model.response.DefaultCommentsResponse
import dev.ragnarok.fenrir.api.model.response.SearchVideoResponse
import dev.ragnarok.fenrir.api.model.server.VKApiVideosUploadServer
import dev.ragnarok.fenrir.api.rest.IServiceRest
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -227,4 +228,18 @@ class IVideoService : IServiceRest() {
), baseInt
)
}

fun getVideoServer(
is_private: Int?,
group_id: Long?,
name: String?
): Single<BaseResponse<VKApiVideosUploadServer>> {
return rest.request(
"video.save", form(
"is_private" to is_private,
"group_id" to group_id,
"name" to name
), base(VKApiVideosUploadServer.serializer())
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class WallAdapter(
}

TYPE_SCHEDULED -> {
val scheludedHolder = viewHolder as ScheludedHolder
configNormalPost(scheludedHolder, item)
bindScheludedButtonsBlock(scheludedHolder, item)
val scheduledHolder = viewHolder as ScheduledHolder
configNormalPost(scheduledHolder, item)
bindScheludedButtonsBlock(scheduledHolder, item)
}

TYPE_DELETED -> bindDeleted(viewHolder as DeletedHolder, item)
Expand All @@ -73,7 +73,7 @@ class WallAdapter(
nonPublishedPostActionListener = listener
}

private fun bindScheludedButtonsBlock(holder: ScheludedHolder, post: Post) {
private fun bindScheludedButtonsBlock(holder: ScheduledHolder, post: Post) {
holder.deleteButton.setOnClickListener {
nonPublishedPostActionListener?.onButtonRemoveClick(post)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ class WallAdapter(
when (type) {
TYPE_NORMAL -> return NormalHolder(view)
TYPE_DELETED -> return DeletedHolder(view)
TYPE_SCHEDULED -> return ScheludedHolder(view)
TYPE_SCHEDULED -> return ScheduledHolder(view)
}
throw IllegalArgumentException()
}
Expand Down Expand Up @@ -287,7 +287,7 @@ class WallAdapter(

}

private inner class ScheludedHolder(view: View) : AbsPostHolder(view) {
private inner class ScheduledHolder(view: View) : AbsPostHolder(view) {
val deleteButton: CircleCounterButton = root.findViewById(R.id.button_delete)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AttchmentsEditorAdapter(
sharedHolders.put(attachment.id, viewHolder)
configView(attachment, viewHolder)
viewHolder.vRemove.setOnClickListener {
val dataposition = viewHolder.bindingAdapterPosition - headersCount
val dataposition = getItemRawPosition(viewHolder.bindingAdapterPosition)
callback.onRemoveClick(dataposition, attachment)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,9 @@ class AudioRecyclerAdapter(
}
viewHolder.play.setOnClickListener { v: View ->
if (Settings.get().main().isRevert_play_audio) {
doMenu(viewHolder, position, v, audio)
doMenu(viewHolder, getItemRawPosition(viewHolder.bindingAdapterPosition), v, audio)
} else {
doPlay(position, audio)
doPlay(getItemRawPosition(viewHolder.bindingAdapterPosition), audio)
}
}
if (!iSSelectMode) {
Expand Down Expand Up @@ -785,9 +785,14 @@ class AudioRecyclerAdapter(
viewHolder.cancelSelectionAnimation()
viewHolder.startSomeAnimation()
if (Settings.get().main().isRevert_play_audio) {
doPlay(position, audio)
doPlay(getItemRawPosition(viewHolder.bindingAdapterPosition), audio)
} else {
doMenu(viewHolder, position, view, audio)
doMenu(
viewHolder,
getItemRawPosition(viewHolder.bindingAdapterPosition),
view,
audio
)
}
}
} else {
Expand Down Expand Up @@ -854,7 +859,7 @@ class AudioRecyclerAdapter(
val Track: View = itemView.findViewById(R.id.track_option)
val selectionView: MaterialCardView = itemView.findViewById(R.id.item_audio_selection)
val isSelectedView: MaterialCardView = itemView.findViewById(R.id.item_audio_select_add)
val animationAdapter: Animator.AnimatorListener
private val animationAdapter: Animator.AnimatorListener
var animator: ObjectAnimator? = null
fun startSelectionAnimation() {
selectionView.setCardBackgroundColor(CurrentTheme.getColorPrimary(mContext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,9 @@ class CatalogV2SectionAdapter(
}
play.setOnClickListener { v: View ->
if (Settings.get().main().isRevert_play_audio) {
doMenu(this, position, v, audio)
doMenu(this, getItemRawPosition(bindingAdapterPosition), v, audio)
} else {
doPlay(position, audio)
doPlay(getItemRawPosition(bindingAdapterPosition), audio)
}
}
if (isLongPressDownload) {
Expand Down Expand Up @@ -1121,9 +1121,9 @@ class CatalogV2SectionAdapter(
cancelSelectionAnimation()
startSomeAnimation()
if (Settings.get().main().isRevert_play_audio) {
doPlay(position, audio)
doPlay(getItemRawPosition(bindingAdapterPosition), audio)
} else {
doMenu(this, position, view, audio)
doMenu(this, getItemRawPosition(bindingAdapterPosition), view, audio)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,18 @@ class AudioLocalRecyclerAdapter(private val mContext: Context, private var data:
}
holder.play.setOnClickListener { v: View ->
if (Settings.get().main().isRevert_play_audio) {
doMenu(position, v, audio)
doMenu(holder.bindingAdapterPosition, v, audio)
} else {
doPlay(position, audio)
doPlay(holder.bindingAdapterPosition, audio)
}
}
holder.Track.setOnClickListener { view: View ->
holder.cancelSelectionAnimation()
holder.startSomeAnimation()
if (Settings.get().main().isRevert_play_audio) {
doPlay(position, audio)
doPlay(holder.bindingAdapterPosition, audio)
} else {
doMenu(position, view, audio)
doMenu(holder.bindingAdapterPosition, view, audio)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ class HorizontalMenuAdapter(data: MutableList<CommunityDetails.Menu>) :
viewHolder.menu_image.visibility = View.VISIBLE
displayAvatar(viewHolder.menu_image, null, item.cover, Constants.PICASSO_TAG)
} else viewHolder.menu_image.visibility = View.INVISIBLE
viewHolder.itemView.setOnClickListener { listener?.onWallMenuClick(item, position) }
viewHolder.itemView.setOnClickListener {
listener?.onWallMenuClick(
item,
getItemRawPosition(viewHolder.bindingAdapterPosition)
)
}
viewHolder.itemView.setOnLongClickListener {
listener?.onWallMenuLongClick(item, position)
listener?.onWallMenuLongClick(
item,
getItemRawPosition(viewHolder.bindingAdapterPosition)
)
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class HorizontalOptionsAdapter<T : Entry>(data: MutableList<T>) :
viewHolder.delete.visibility = if (item.isCustom) View.VISIBLE else View.GONE
viewHolder.delete.setOnClickListener {
if (item.isCustom) {
delete_listener?.onDeleteOptionClick(item, position)
delete_listener?.onDeleteOptionClick(
item,
getItemRawPosition(viewHolder.bindingAdapterPosition)
)
}
}
}
Expand Down
Loading

0 comments on commit 8da0f5a

Please sign in to comment.