upgrade ktlint plugin to 12.0.3 (#4169)
There are some new rules, I think they mostly make sense, except for the max line length which I had to disable because we are over it in a lot of places. --------- Co-authored-by: Goooler <wangzongler@gmail.com>
This commit is contained in:
parent
33cd6fdb98
commit
5192fb08a5
215 changed files with 2813 additions and 1177 deletions
|
|
@ -59,8 +59,8 @@ import com.keylesspalace.tusky.util.openLink
|
|||
import com.keylesspalace.tusky.util.parseAsMastodonHtml
|
||||
import com.keylesspalace.tusky.view.showMuteAccountDialog
|
||||
import com.keylesspalace.tusky.viewdata.AttachmentViewData
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/* Note from Andrew on Jan. 22, 2017: This class is a design problem for me, so I left it with an
|
||||
* awkward name. TimelineFragment and NotificationFragment have significant overlap but the nature
|
||||
|
|
@ -158,7 +158,14 @@ abstract class SFragment : Fragment(), Injectable {
|
|||
val menu = popup.menu
|
||||
when (status.visibility) {
|
||||
Status.Visibility.PUBLIC, Status.Visibility.UNLISTED -> {
|
||||
menu.add(0, R.id.pin, 1, getString(if (status.isPinned()) R.string.unpin_action else R.string.pin_action))
|
||||
menu.add(
|
||||
0,
|
||||
R.id.pin,
|
||||
1,
|
||||
getString(
|
||||
if (status.isPinned()) R.string.unpin_action else R.string.pin_action
|
||||
)
|
||||
)
|
||||
}
|
||||
Status.Visibility.PRIVATE -> {
|
||||
val reblogged = status.reblog?.reblogged ?: status.reblogged
|
||||
|
|
@ -227,7 +234,11 @@ abstract class SFragment : Fragment(), Injectable {
|
|||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
R.id.status_copy_link -> {
|
||||
(requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).apply {
|
||||
(
|
||||
requireActivity().getSystemService(
|
||||
Context.CLIPBOARD_SERVICE
|
||||
) as ClipboardManager
|
||||
).apply {
|
||||
setPrimaryClip(ClipData.newPlainText(null, statusUrl))
|
||||
}
|
||||
return@setOnMenuItemClickListener true
|
||||
|
|
@ -295,7 +306,10 @@ abstract class SFragment : Fragment(), Injectable {
|
|||
}
|
||||
|
||||
private fun onMute(accountId: String, accountUsername: String) {
|
||||
showMuteAccountDialog(this.requireActivity(), accountUsername) { notifications: Boolean?, duration: Int? ->
|
||||
showMuteAccountDialog(
|
||||
this.requireActivity(),
|
||||
accountUsername
|
||||
) { notifications: Boolean?, duration: Int? ->
|
||||
lifecycleScope.launch {
|
||||
timelineCases.mute(accountId, notifications == true, duration)
|
||||
}
|
||||
|
|
@ -459,13 +473,18 @@ abstract class SFragment : Fragment(), Injectable {
|
|||
|
||||
private fun downloadAllMedia(status: Status) {
|
||||
Toast.makeText(context, R.string.downloading_media, Toast.LENGTH_SHORT).show()
|
||||
val downloadManager = requireActivity().getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||
val downloadManager = requireActivity().getSystemService(
|
||||
Context.DOWNLOAD_SERVICE
|
||||
) as DownloadManager
|
||||
|
||||
for ((_, url) in status.attachments) {
|
||||
val uri = Uri.parse(url)
|
||||
downloadManager.enqueue(
|
||||
DownloadManager.Request(uri).apply {
|
||||
setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, uri.lastPathSegment)
|
||||
setDestinationInExternalPublicDir(
|
||||
Environment.DIRECTORY_DOWNLOADS,
|
||||
uri.lastPathSegment
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -492,7 +511,10 @@ abstract class SFragment : Fragment(), Injectable {
|
|||
|
||||
companion object {
|
||||
private const val TAG = "SFragment"
|
||||
private fun accountIsInMentions(account: AccountEntity?, mentions: List<Status.Mention>): Boolean {
|
||||
private fun accountIsInMentions(
|
||||
account: AccountEntity?,
|
||||
mentions: List<Status.Mention>
|
||||
): Boolean {
|
||||
return mentions.any { mention ->
|
||||
account?.username == mention.username && account.domain == Uri.parse(mention.url)?.host
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,11 @@ class ViewImageFragment : ViewMediaFragment() {
|
|||
loadImageFromNetwork(url, previewUrl, binding.photoView)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
toolbar = (requireActivity() as ViewMediaActivity).toolbar
|
||||
this.transition = BehaviorSubject.create()
|
||||
return inflater.inflate(R.layout.fragment_view_image, container, false)
|
||||
|
|
@ -96,7 +100,11 @@ class ViewImageFragment : ViewMediaFragment() {
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val arguments = this.requireArguments()
|
||||
val attachment = BundleCompat.getParcelable(arguments, ARG_ATTACHMENT, Attachment::class.java)
|
||||
val attachment = BundleCompat.getParcelable(
|
||||
arguments,
|
||||
ARG_ATTACHMENT,
|
||||
Attachment::class.java
|
||||
)
|
||||
this.shouldStartTransition = arguments.getBoolean(ARG_START_POSTPONED_TRANSITION)
|
||||
val url: String?
|
||||
var description: String? = null
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ abstract class ViewMediaFragment : Fragment() {
|
|||
|
||||
@JvmStatic
|
||||
@OptIn(UnstableApi::class)
|
||||
fun newInstance(attachment: Attachment, shouldStartPostponedTransition: Boolean): ViewMediaFragment {
|
||||
fun newInstance(
|
||||
attachment: Attachment,
|
||||
shouldStartPostponedTransition: Boolean
|
||||
): ViewMediaFragment {
|
||||
val arguments = Bundle(2)
|
||||
arguments.putParcelable(ARG_ATTACHMENT, attachment)
|
||||
arguments.putBoolean(ARG_START_POSTPONED_TRANSITION, shouldStartPostponedTransition)
|
||||
|
|
@ -85,7 +88,12 @@ abstract class ViewMediaFragment : Fragment() {
|
|||
|
||||
showingDescription = !TextUtils.isEmpty(description)
|
||||
isDescriptionVisible = showingDescription
|
||||
setupMediaView(url, previewUrl, description, showingDescription && mediaActivity.isToolbarVisible)
|
||||
setupMediaView(
|
||||
url,
|
||||
previewUrl,
|
||||
description,
|
||||
showingDescription && mediaActivity.isToolbarVisible
|
||||
)
|
||||
|
||||
toolbarVisibilityDisposable = (activity as ViewMediaActivity)
|
||||
.addToolbarVisibilityListener { isVisible ->
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ import com.keylesspalace.tusky.entity.Attachment
|
|||
import com.keylesspalace.tusky.util.hide
|
||||
import com.keylesspalace.tusky.util.viewBinding
|
||||
import com.keylesspalace.tusky.util.visible
|
||||
import okhttp3.OkHttpClient
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.abs
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@UnstableApi
|
||||
class ViewVideoFragment : ViewMediaFragment(), Injectable {
|
||||
|
|
@ -113,13 +113,19 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable {
|
|||
}
|
||||
|
||||
@SuppressLint("PrivateResource", "MissingInflatedId")
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
mediaActivity = activity as ViewMediaActivity
|
||||
toolbar = mediaActivity.toolbar
|
||||
val rootView = inflater.inflate(R.layout.fragment_view_video, container, false)
|
||||
|
||||
// Move the controls to the bottom of the screen, with enough bottom margin to clear the seekbar
|
||||
val controls = rootView.findViewById<LinearLayout>(androidx.media3.ui.R.id.exo_center_controls)
|
||||
val controls = rootView.findViewById<LinearLayout>(
|
||||
androidx.media3.ui.R.id.exo_center_controls
|
||||
)
|
||||
val layoutParams = controls.layoutParams as FrameLayout.LayoutParams
|
||||
layoutParams.gravity = Gravity.CENTER_HORIZONTAL or Gravity.BOTTOM
|
||||
layoutParams.bottomMargin = rootView.context.resources.getDimension(androidx.media3.ui.R.dimen.exo_styled_bottom_bar_height)
|
||||
|
|
@ -147,7 +153,9 @@ class ViewVideoFragment : ViewMediaFragment(), Injectable {
|
|||
/** The view that contains the playing content */
|
||||
// binding.videoView is fullscreen, and includes the controls, so don't use that
|
||||
// when scaling in response to the user dragging on the screen
|
||||
val contentFrame = binding.videoView.findViewById<AspectRatioFrameLayout>(androidx.media3.ui.R.id.exo_content_frame)
|
||||
val contentFrame = binding.videoView.findViewById<AspectRatioFrameLayout>(
|
||||
androidx.media3.ui.R.id.exo_content_frame
|
||||
)
|
||||
|
||||
/** Handle taps and flings */
|
||||
val simpleGestureDetector = GestureDetectorCompat(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue