Skip to content

Commit

Permalink
32
Browse files Browse the repository at this point in the history
32
  • Loading branch information
umerov1999 committed Jun 14, 2023
1 parent 0f1f73d commit 8d53a3c
Show file tree
Hide file tree
Showing 86 changed files with 1,762 additions and 496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ class QuickAnswerActivity : AppCompatActivity() {
AttachmentsViewBinder(this, object : OnAttachmentsActionCallback {
override fun onPollOpen(poll: Poll) {}
override fun onVideoPlay(video: Video) {}
override fun onAudioPlay(position: Int, audios: ArrayList<Audio>) {
override fun onAudioPlay(
position: Int,
audios: ArrayList<Audio>,
holderPosition: Int?
) {
startForPlayList(this@QuickAnswerActivity, audios, position, false)
}

Expand Down Expand Up @@ -245,7 +249,7 @@ class QuickAnswerActivity : AppCompatActivity() {
attachmentsHolder,
true,
msg.getObjectId(),
msg.peerId
msg.peerId, null
)
attachmentsViewBinder.displayForwards(msg.fwd, forwardMessagesRoot, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ abstract class AccountDependencyDialogFragment : BaseDialogFragment(), OnAttachm
getVideoPreviewPlace(accountId, video).tryOpenWith(requireActivity())
}

override fun onAudioPlay(position: Int, audios: ArrayList<Audio>) {
override fun onAudioPlay(position: Int, audios: ArrayList<Audio>, holderPosition: Int?) {
startForPlayList(requireActivity(), audios, position, false)
if (!Settings.get().other().isShow_mini_player) getPlayerPlace(
Settings.get().accounts().current
accountId
).tryOpenWith(requireActivity())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1668,11 +1668,11 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
selItems(R.array.array_rendering_mode_names, R.array.array_rendering_mode_items),
parentFragmentManager
) {
initialSelection = "2"
initialSelection = "0"
titleRes = R.string.rendering_mode
visible = Utils.hasPie()
onSelectionChange { it ->
var sz = 2
var sz = 0
try {
sz = it.trim { it <= ' ' }.toInt()
} catch (ignored: NumberFormatException) {
Expand Down Expand Up @@ -2570,8 +2570,12 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
progress: Int,
fromUser: Boolean
) {
textVerticalSensitive.text =
getString(R.string.slidr_sensitive, progress)
if (fromUser && progress < 20) {
verticalSensitive.progress = 20
textVerticalSensitive.text = getString(R.string.slidr_sensitive, 20)
} else {
textVerticalSensitive.text = getString(R.string.slidr_sensitive, progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {}
Expand All @@ -2584,8 +2588,12 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
progress: Int,
fromUser: Boolean
) {
textHorizontalSensitive.text =
getString(R.string.slidr_sensitive, progress)
if (fromUser && progress < 20) {
horizontalSensitive.progress = 20
textHorizontalSensitive.text = getString(R.string.slidr_sensitive, 20)
} else {
textHorizontalSensitive.text = getString(R.string.slidr_sensitive, progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar) {}
Expand All @@ -2598,8 +2606,14 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
progress: Int,
fromUser: Boolean
) {
textVerticalVelocityThreshold.text =
getString(R.string.slidr_velocity_threshold, progress)
if (fromUser && progress < 4) {
verticalVelocityThreshold.progress = 4
textVerticalVelocityThreshold.text =
getString(R.string.slidr_velocity_threshold, 4)
} else {
textVerticalVelocityThreshold.text =
getString(R.string.slidr_velocity_threshold, progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {}
Expand All @@ -2612,8 +2626,14 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
progress: Int,
fromUser: Boolean
) {
textHorizontalVelocityThreshold.text =
getString(R.string.slidr_velocity_threshold, progress)
if (fromUser && progress < 4) {
horizontalVelocityThreshold.progress = 4
textHorizontalVelocityThreshold.text =
getString(R.string.slidr_velocity_threshold, 4)
} else {
textHorizontalVelocityThreshold.text =
getString(R.string.slidr_velocity_threshold, progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar) {}
Expand All @@ -2626,8 +2646,14 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
progress: Int,
fromUser: Boolean
) {
textVerticalDistanceThreshold.text =
getString(R.string.slidr_distance_threshold, progress)
if (fromUser && progress < 4) {
verticalDistanceThreshold.progress = 4
textVerticalDistanceThreshold.text =
getString(R.string.slidr_distance_threshold, 4)
} else {
textVerticalDistanceThreshold.text =
getString(R.string.slidr_distance_threshold, progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {}
Expand All @@ -2640,8 +2666,14 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
progress: Int,
fromUser: Boolean
) {
textHorizontalDistanceThreshold.text =
getString(R.string.slidr_distance_threshold, progress)
if (fromUser && progress < 4) {
horizontalDistanceThreshold.progress = 4
textHorizontalDistanceThreshold.text =
getString(R.string.slidr_distance_threshold, 4)
} else {
textHorizontalDistanceThreshold.text =
getString(R.string.slidr_distance_threshold, progress)
}
}

override fun onStartTrackingTouch(seekBar: SeekBar) {}
Expand Down Expand Up @@ -2696,8 +2728,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree
.setNegativeButton(R.string.button_cancel, null)
.setNeutralButton(R.string.set_default) { _: DialogInterface?, _: Int ->
Settings.get()
.other().slidrSettings =
SlidrSettings().set_default()
.other().slidrSettings = SlidrSettings().set_default()
parentFragmentManager.setFragmentResult(
PreferencesExtra.RECREATE_ACTIVITY_REQUEST,
Bundle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ class LocalAudioAlbumsAdapter(
notifyDataSetChanged()
}

fun getFirstWithCurrentId(): Int {
var ret = 0
var iter = 0
for (i in data) {
if (i.getId() == currentId) {
ret = iter
break
}
iter++
}
return ret
}

fun updateCurrentId(currentId: Int) {
this.currentId = currentId
notifyDataSetChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import dev.ragnarok.fenrir.fragment.base.core.IPresenterFactory
import dev.ragnarok.fenrir.fragment.photos.localimagealbums.LocalPhotoAlbumsAdapter
import dev.ragnarok.fenrir.listener.PicassoPauseOnScrollListener
import dev.ragnarok.fenrir.model.LocalImageAlbum
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.AppPerms.requestPermissionsAbs
import dev.ragnarok.fenrir.view.MySearchView
Expand All @@ -34,6 +35,7 @@ class LocalAudioAlbumsFragment :
private var mRecyclerView: RecyclerView? = null
private var mAlbumsAdapter: LocalAudioAlbumsAdapter? = null
private var listener: Listener? = null
private var manager: RecyclerView.LayoutManager? = null
override fun onCreateDialog(savedInstanceState: Bundle?): BottomSheetDialog {
val dialog = BottomSheetDialog(requireActivity(), theme)
val behavior = dialog.behavior
Expand Down Expand Up @@ -74,8 +76,7 @@ class LocalAudioAlbumsFragment :
}
})
val columnCount = resources.getInteger(R.integer.photos_albums_column_count)
val manager: RecyclerView.LayoutManager =
StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL)
manager = StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL)
mRecyclerView = view.findViewById(R.id.recycler_view)
mRecyclerView?.layoutManager = manager
mRecyclerView?.addOnScrollListener(PicassoPauseOnScrollListener(LocalPhotoAlbumsAdapter.PICASSO_TAG))
Expand Down Expand Up @@ -109,6 +110,8 @@ class LocalAudioAlbumsFragment :

override fun notifyDataChanged() {
mAlbumsAdapter?.notifyDataSetChanged()
val pos = mAlbumsAdapter?.getFirstWithCurrentId().orZero()
manager?.scrollToPosition(pos)
}

override fun requestReadExternalStoragePermission() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class AttachmentsViewBinder(
containers: AttachmentsHolder,
postsAsLinks: Boolean,
messageId: Int?,
peerId: Long?
peerId: Long?,
holderPosition: Int?
) {
if (attachments == null) {
safeSetVisibitity(containers.vgAudios, View.GONE)
Expand All @@ -84,7 +85,11 @@ class AttachmentsViewBinder(
containers.vgAudios?.dispose()
} else {
displayArticles(attachments.articles, containers.vgArticles)
containers.vgAudios?.displayAudios(attachments.audios, mAttachmentsActionCallback)
containers.vgAudios?.displayAudios(
attachments.audios,
mAttachmentsActionCallback,
holderPosition
)
displayVoiceMessages(
attachments.voiceMessages,
containers.voiceMessageRoot,
Expand Down Expand Up @@ -400,7 +405,14 @@ class AttachmentsViewBinder(
) View.VISIBLE else View.GONE
check.ownerName.text = copy.authorName
check.buttonDots.tag = copy
displayAttachments(copy.attachments, check.attachmentsHolder, false, null, null)
displayAttachments(
copy.attachments,
check.attachmentsHolder,
false,
null,
null,
null
)
} else {
postViewGroup.visibility = View.GONE
}
Expand Down Expand Up @@ -537,7 +549,8 @@ class AttachmentsViewBinder(
attachmentContainers,
postsAsLinks,
message.getObjectId(),
message.peerId
message.peerId,
null
)
} else {
itemView.visibility = View.GONE
Expand Down Expand Up @@ -566,7 +579,6 @@ class AttachmentsViewBinder(
val tvDetails = itemView.findViewById<TextView>(R.id.item_document_ext_size)
val tvPostText: EmojiconTextView = itemView.findViewById(R.id.item_message_text)
val ivPhotoT: ShapeableImageView = itemView.findViewById(R.id.item_document_image)
val ivGraffiti = itemView.findViewById<ImageView>(R.id.item_document_graffiti)
val ivPhoto_Post = itemView.findViewById<ImageView>(R.id.item_post_avatar_image)
val ivType = itemView.findViewById<ImageView>(R.id.item_document_type)
val tvShowMore = itemView.findViewById<TextView>(R.id.item_post_show_more)
Expand Down Expand Up @@ -650,7 +662,6 @@ class AttachmentsViewBinder(
attachmentsRoot.visibility = View.GONE
itemView.setOnClickListener { openDocLink(doc) }
ivPhoto_Post.visibility = View.GONE
ivGraffiti.visibility = View.GONE
when (doc.type) {
AttachmentsTypes.DOC -> if (imageUrl != null) {
ivType.visibility = View.GONE
Expand All @@ -666,8 +677,8 @@ class AttachmentsViewBinder(
ivPhotoT.visibility = View.GONE
if (imageUrl != null) {
ivType.visibility = View.GONE
ivGraffiti.visibility = View.VISIBLE
displayAvatar(ivGraffiti, null, imageUrl, Constants.PICASSO_TAG)
ivPhotoT.visibility = View.VISIBLE
displayAvatar(ivPhotoT, null, imageUrl, Constants.PICASSO_TAG)
} else {
ivType.visibility = View.VISIBLE
ivType.setImageResource(R.drawable.counter)
Expand Down Expand Up @@ -772,7 +783,7 @@ class AttachmentsViewBinder(
post.attachments,
attachmentsHolder,
false,
null, null
null, null, null
)
}

Expand All @@ -799,7 +810,7 @@ class AttachmentsViewBinder(
comment.attachments,
attachmentsHolder,
false,
null, null
null, null, null
)
}

Expand Down Expand Up @@ -1023,7 +1034,7 @@ class AttachmentsViewBinder(
interface OnAttachmentsActionCallback {
fun onPollOpen(poll: Poll)
fun onVideoPlay(video: Video)
fun onAudioPlay(position: Int, audios: ArrayList<Audio>)
fun onAudioPlay(position: Int, audios: ArrayList<Audio>, holderPosition: Int?)
fun onForwardMessagesOpen(messages: ArrayList<Message>)
fun onOpenOwner(ownerId: Long)
fun onGoToMessagesLookup(message: Message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DocLink(val attachment: AbsModel) {
val sizes = link.photo?.sizes
return sizes?.getUrlForSize(
Settings.get().main().prefPreviewImageSize,
true
false
)
}
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ abstract class PlaceSupportMvpFragment<P : PlaceSupportPresenter<V>, V> : BaseMv
presenter?.fireVideoClick(video)
}

override fun onAudioPlay(position: Int, audios: ArrayList<Audio>) {
override fun onAudioPlay(position: Int, audios: ArrayList<Audio>, holderPosition: Int?) {
presenter?.fireAudioPlayClick(position, audios)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PostImage(val attachment: AbsModel, val type: Int) {

TYPE_GIF -> {
val document = attachment as Document
return document.getPreviewWithSize(PhotoSize.Q, false)
return document.getPreviewWithSize(photoPreviewSize, false)
}
}
throw UnsupportedOperationException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class CommentsAdapter(
comment.attachments,
holder.attachmentContainers,
true,
null, null
null, null, null
)
}
holder.tvOwnerName.text = comment.fullAuthorName
Expand Down
Loading

0 comments on commit 8d53a3c

Please sign in to comment.