Skip to content

Commit

Permalink
25
Browse files Browse the repository at this point in the history
25
  • Loading branch information
umerov1999 committed May 6, 2023
1 parent b26e549 commit aea901a
Show file tree
Hide file tree
Showing 41 changed files with 698 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ class CameraScanActivity : NoMainActivity() {
val height = generatedQRCode.height
val pixels = IntArray(width * height)
generatedQRCode.getPixels(pixels, 0, width, 0, 0, width, height)
for (i in pixels.indices) {
if (Color.alpha(pixels[i]) < 90) {
pixels[i] = Color.WHITE
}
}
val source = RGBLuminanceSource(width, height, pixels)
val binaryBitmap = BinaryBitmap(HybridBinarizer(source))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import dev.ragnarok.fenrir.model.Commented
import dev.ragnarok.fenrir.model.Video
import dev.ragnarok.fenrir.model.VideoSize
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.AppPerms.hasReadWriteStoragePermission
import dev.ragnarok.fenrir.util.DownloadWorkUtils.doDownloadVideo
import dev.ragnarok.fenrir.util.Pair
Expand Down Expand Up @@ -266,6 +267,12 @@ class ShortVideoPagerPresenter(
}

fun fireLikeClick() {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
if (mShortVideos.isEmpty()) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ internal class VideoApi(accountId: Long, provider: IServiceProvider) :
var finalName = name
if (finalName?.startsWith("VID_", false) == true) {
finalName = "Telegram $finalName"
} else if (finalName?.startsWith("VID-", false) == true && finalName.contains(
"-WA",
false
)
) {
finalName = "WhatsApp $finalName"
}
service.getVideoServer(isPrivate, group_id, finalName)
.map(extractResponseWithErrorHandling())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1755,10 +1755,17 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
pref("account_cache_cleaner") {
titleRes = R.string.account_cache_cleaner
onClick {
DBHelper.removeDatabaseFor(requireActivity(), accountId)
cleanCache(requireActivity(), true)
Includes.stores.stickers().clearAccount(accountId).fromIOToMain()
.subscribe(RxUtils.dummy(), RxUtils.ignore())
MaterialAlertDialogBuilder(requireActivity()).setIcon(R.drawable.ic_outline_delete)
.setTitle(R.string.select)
.setMessage(R.string.do_delete)
.setPositiveButton(R.string.button_yes) { _: DialogInterface?, _: Int ->
DBHelper.removeDatabaseFor(requireActivity(), accountId)
cleanCache(requireActivity(), true)
Includes.stores.stickers().clearAccount(accountId).fromIOToMain()
.subscribe(RxUtils.dummy(), RxUtils.ignore())
}
.setNegativeButton(R.string.button_no, null)
.setCancelable(true).show()
true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import dev.ragnarok.fenrir.domain.Repository.walls
import dev.ragnarok.fenrir.fragment.base.PlaceSupportPresenter
import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.findInfoByPredicate
import dev.ragnarok.fenrir.util.rxutils.RxUtils.ignore
import io.reactivex.rxjava3.disposables.CompositeDisposable
Expand Down Expand Up @@ -140,6 +142,12 @@ class FavePostsPresenter(accountId: Long, savedInstanceState: Bundle?) :
}

fun fireLikeClick(post: Post) {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
appendDisposable(wallInteractor.like(accountId, post.ownerId, post.vkid, !post.isUserLikes)
.fromIOToMain()
.subscribe(ignore()) { t -> onLikeError(t) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.model.Commented
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.trimmedNonNullNoEmpty
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.ignore
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -83,6 +85,12 @@ class NewsFeedSearchPresenter(
}

fun fireLikeClick(post: Post) {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
appendDisposable(walls.like(accountId, post.ownerId, post.vkid, !post.isUserLikes)
.fromIOToMain()
.subscribe(ignore()) { t ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.requireNonNull
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.trimmedNonNullNoEmpty
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.ignore
import io.reactivex.rxjava3.core.Single

Expand Down Expand Up @@ -100,6 +102,12 @@ class WallSearchPresenter(
}

fun fireLikeClick(post: Post) {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
appendDisposable(walls.like(accountId, post.ownerId, post.vkid, !post.isUserLikes)
.fromIOToMain()
.subscribe(ignore()) { t ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.model.Commented
import dev.ragnarok.fenrir.model.Owner
import dev.ragnarok.fenrir.model.Video
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Pair
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.getCauseIfRuntime
import dev.ragnarok.fenrir.util.toast.CustomToast.Companion.createCustomToast

Expand Down Expand Up @@ -298,6 +300,12 @@ class VideoPreviewPresenter(
}

fun fireLikeClick() {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
video?.let {
val add = !it.isUserLikes
appendDisposable(interactor.likeOrDislike(accountId, ownerId, videoId, accessKey, add)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import dev.ragnarok.fenrir.fragment.base.PlaceSupportPresenter
import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.model.criteria.WallCriteria
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.getCauseIfRuntime
import dev.ragnarok.fenrir.util.Utils.intValueIn
import dev.ragnarok.fenrir.util.Utils.safeCountOf
Expand Down Expand Up @@ -171,6 +173,12 @@ class WallAudiosAttachmentsPresenter(
}

fun fireLikeClick(post: Post) {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
appendDisposable(fInteractor.like(accountId, post.ownerId, post.vkid, !post.isUserLikes)
.fromIOToMain()
.subscribe(ignore()) { t ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import dev.ragnarok.fenrir.fragment.base.PlaceSupportPresenter
import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.model.criteria.WallCriteria
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.getCauseIfRuntime
import dev.ragnarok.fenrir.util.Utils.intValueIn
import dev.ragnarok.fenrir.util.Utils.safeCountOf
Expand Down Expand Up @@ -189,6 +191,12 @@ class WallPostCommentAttachmentsPresenter(
}

fun fireLikeClick(post: Post) {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
appendDisposable(fInteractor.like(accountId, post.ownerId, post.vkid, !post.isUserLikes)
.fromIOToMain()
.subscribe(ignore()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import dev.ragnarok.fenrir.fragment.base.PlaceSupportPresenter
import dev.ragnarok.fenrir.fromIOToMain
import dev.ragnarok.fenrir.model.*
import dev.ragnarok.fenrir.model.criteria.WallCriteria
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.getCauseIfRuntime
import dev.ragnarok.fenrir.util.Utils.intValueIn
import dev.ragnarok.fenrir.util.Utils.safeCountOf
Expand Down Expand Up @@ -350,6 +352,12 @@ class WallPostQueryAttachmentsPresenter(
}

fun fireLikeClick(post: Post) {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
appendDisposable(fInteractor.like(accountId, post.ownerId, post.vkid, !post.isUserLikes)
.fromIOToMain()
.subscribe(ignore()) { t ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import dev.ragnarok.fenrir.model.ParcelableOwnerWrapper
import dev.ragnarok.fenrir.model.Post
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.requireNonNull
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.getCauseIfRuntime
import dev.ragnarok.fenrir.util.rxutils.RxUtils.ignore

Expand Down Expand Up @@ -255,6 +257,12 @@ class WallPostPresenter(
}

fun fireLikeClick() {
if (Settings.get().other().isDisable_likes || Utils.isHiddenAccount(
accountId
)
) {
return
}
if (post != null) {
appendDisposable(wallInteractor.like(
accountId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ import android.content.pm.ResolveInfo
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION
import androidx.core.net.toFile
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.zxing.*
import com.google.zxing.common.HybridBinarizer
import com.squareup.picasso3.BitmapTarget
import com.squareup.picasso3.Picasso
import dev.ragnarok.filegallery.R
import dev.ragnarok.filegallery.activity.qr.CameraScanActivity
import dev.ragnarok.filegallery.fragment.base.RxSupportPresenter
import dev.ragnarok.filegallery.model.Photo
import dev.ragnarok.filegallery.model.Video
Expand All @@ -32,8 +31,6 @@ import dev.ragnarok.filegallery.util.DownloadWorkUtils.doDownloadPhoto
import dev.ragnarok.filegallery.util.Utils
import java.io.File
import java.util.Calendar
import java.util.EnumMap
import java.util.EnumSet

open class PhotoPagerPresenter internal constructor(
initialData: ArrayList<Photo>,
Expand Down Expand Up @@ -151,46 +148,6 @@ open class PhotoPagerPresenter internal constructor(
return false
}

internal fun decodeFromBitmap(gen: Bitmap?): String? {
if (gen == null) {
return "error"
}
var generatedQRCode: Bitmap? = gen
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && generatedQRCode?.config == Bitmap.Config.HARDWARE) {
generatedQRCode = generatedQRCode.copy(Bitmap.Config.ARGB_8888, true)
}
if (generatedQRCode == null) {
return "error"
}
val width: Int = generatedQRCode.width
val height: Int = generatedQRCode.height
val pixels = IntArray(width * height)
generatedQRCode.getPixels(pixels, 0, width, 0, 0, width, height)
val source = RGBLuminanceSource(width, height, pixels)
val binaryBitmap = BinaryBitmap(HybridBinarizer(source))
val reader = MultiFormatReader()
val hints: MutableMap<DecodeHintType, Any> = EnumMap(DecodeHintType::class.java)
hints[DecodeHintType.POSSIBLE_FORMATS] = EnumSet.of(
BarcodeFormat.QR_CODE,
BarcodeFormat.EAN_13,
BarcodeFormat.EAN_8,
BarcodeFormat.RSS_14,
BarcodeFormat.CODE_39,
BarcodeFormat.CODE_93,
BarcodeFormat.CODE_128,
BarcodeFormat.ITF
)
reader.setHints(hints)
val result: Result = try {
reader.decodeWithState(binaryBitmap)
} catch (e: Exception) {
return e.localizedMessage
} ?: run {
return "error"
}
return result.text
}

@Suppress("deprecation")
private fun getCustomTabsPackages(context: Context): ArrayList<ResolveInfo> {
val pm = context.packageManager
Expand Down Expand Up @@ -241,7 +198,7 @@ open class PhotoPagerPresenter internal constructor(
PicassoInstance.with().load(current.photo_url)
.into(object : BitmapTarget {
override fun onBitmapLoaded(bitmap: Bitmap, from: Picasso.LoadedFrom) {
val data = decodeFromBitmap(bitmap)
val data = CameraScanActivity.decodeFromBitmap(bitmap)
MaterialAlertDialogBuilder(context)
.setIcon(R.drawable.qr_code)
.setMessage(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ class CameraScanActivity : NoMainActivity() {
val height = generatedQRCode.height
val pixels = IntArray(width * height)
generatedQRCode.getPixels(pixels, 0, width, 0, 0, width, height)
for (i in pixels.indices) {
if (Color.alpha(pixels[i]) < 90) {
pixels[i] = Color.WHITE
}
}
val source = RGBLuminanceSource(width, height, pixels)
val binaryBitmap = BinaryBitmap(HybridBinarizer(source))

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildscript {
ext.recyclerviewVersion = "1.3.0"
ext.savedStateVersion = "1.2.1"
ext.swiperefreshlayoutVersion = "1.2.0-alpha01"
ext.tracingVersion = "1.2.0-beta03"
ext.tracingVersion = "1.2.0-beta04"
ext.transitionVersion = "1.4.1"
ext.vectordrawableVersion = "1.2.0-beta01"
ext.webkitVersion = "1.7.0-beta01"
Expand All @@ -58,15 +58,15 @@ buildscript {

//common libraries
ext.kotlin_version = "1.8.21"
ext.kotlin_coroutines = "1.7.0-RC"
ext.kotlin_coroutines = "1.7.0"
ext.kotlin_serializer = "1.5.0"
ext.okhttpLibraryVersion = "5.0.0-alpha.11"
ext.okioVersion = "3.3.0"
ext.rxJavaVersion = "3.1.6"
ext.guavaVersion = "31.1-android"
ext.errorproneVersion = "2.15.0"
ext.checkerCompatQualVersion = "2.5.5"
ext.checkerQualAndroidVersion = "3.33.0"
ext.checkerQualAndroidVersion = "3.34.0"
ext.desugarLibraryVersion = "2.0.3"

//APP_PROPS
Expand All @@ -91,7 +91,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:8.0.0"
classpath "com.android.tools.build:gradle:8.0.1"
classpath "com.google.gms:google-services:4.3.15"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
Expand Down
Loading

0 comments on commit aea901a

Please sign in to comment.