Improve mouse accessibility
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package org.koitharu.kotatsu.core.ui.widgets
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.text.Selection
|
||||
import android.text.Spannable
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.PointerIcon
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.core.view.PointerIconCompat
|
||||
import com.google.android.material.textview.MaterialTextView
|
||||
|
||||
class SelectableTextView @JvmOverloads constructor(
|
||||
@@ -14,6 +17,12 @@ class SelectableTextView @JvmOverloads constructor(
|
||||
@AttrRes defStyleAttr: Int = android.R.attr.textViewStyle,
|
||||
) : MaterialTextView(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
pointerIcon = PointerIcon.getSystemIcon(context, PointerIconCompat.TYPE_TEXT)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
|
||||
fixSelectionRange()
|
||||
return super.dispatchTouchEvent(event)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.koitharu.kotatsu.details.ui.adapter
|
||||
|
||||
import android.graphics.Typeface
|
||||
import androidx.appcompat.widget.TooltipCompat
|
||||
import androidx.core.view.isVisible
|
||||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||
import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter
|
||||
@@ -22,6 +23,7 @@ fun chapterGridItemAD(
|
||||
bind { payloads ->
|
||||
if (payloads.isEmpty()) {
|
||||
binding.textViewTitle.text = item.chapter.numberString() ?: "?"
|
||||
TooltipCompat.setTooltipText(itemView, item.chapter.title)
|
||||
}
|
||||
binding.imageViewNew.isVisible = item.isNew
|
||||
binding.imageViewCurrent.isVisible = item.isCurrent
|
||||
|
||||
@@ -10,12 +10,15 @@ import android.content.IntentFilter
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup.MarginLayoutParams
|
||||
import android.widget.TextView
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updatePadding
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.noties.markwon.Markwon
|
||||
@@ -91,12 +94,15 @@ class AppUpdateActivity : BaseActivity<ActivityAppUpdateBinding>(), View.OnClick
|
||||
insets: WindowInsetsCompat
|
||||
): WindowInsetsCompat {
|
||||
val barsInsets = insets.systemBarsInsets
|
||||
val basePadding = resources.getDimensionPixelOffset(R.dimen.screen_padding)
|
||||
viewBinding.root.setPadding(
|
||||
barsInsets.left + basePadding,
|
||||
barsInsets.top + basePadding,
|
||||
barsInsets.right + basePadding,
|
||||
barsInsets.bottom + basePadding,
|
||||
viewBinding.root.updatePadding(top = barsInsets.top)
|
||||
viewBinding.dockedToolbarChild.updateLayoutParams<MarginLayoutParams> {
|
||||
leftMargin = barsInsets.left
|
||||
rightMargin = barsInsets.right
|
||||
bottomMargin = barsInsets.bottom
|
||||
}
|
||||
viewBinding.scrollView.updatePadding(
|
||||
left = barsInsets.left,
|
||||
right = barsInsets.right,
|
||||
)
|
||||
return insets.consumeAllSystemBarsInsets()
|
||||
}
|
||||
|
||||
@@ -1,94 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/screen_padding">
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:drawablePadding="16dp"
|
||||
android:layout_marginHorizontal="@dimen/screen_padding"
|
||||
android:layout_marginTop="24dp"
|
||||
android:drawablePadding="@dimen/screen_padding"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/app_update_available"
|
||||
android:textAppearance="?textAppearanceHeadline5"
|
||||
app:drawableTint="?colorPrimary"
|
||||
app:drawableTopCompat="@drawable/ic_app_update"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:drawableTopCompat="@drawable/ic_app_update" />
|
||||
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/screen_padding"
|
||||
android:layout_marginTop="@dimen/screen_padding"
|
||||
android:max="100"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/textView_title"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_error"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/screen_padding"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textColor="?colorError"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/progressBar"
|
||||
tools:text="@string/error_corrupted_file"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginVertical="@dimen/screen_padding"
|
||||
app:layout_constraintBottom_toTopOf="@id/barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/textView_error">
|
||||
android:layout_marginTop="@dimen/screen_padding"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="@dimen/screen_padding"
|
||||
android:paddingBottom="@dimen/screen_padding"
|
||||
android:textAppearance="?textAppearanceBodyMedium"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_cancel"
|
||||
style="?materialButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
<com.google.android.material.dockedtoolbar.DockedToolbarLayout
|
||||
android:id="@+id/docked_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@android:string/cancel"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
android:fitsSystemWindows="false">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_update"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:enabled="false"
|
||||
android:text="@string/update"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
<FrameLayout
|
||||
android:id="@+id/docked_toolbar_child"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/m3_comp_toolbar_docked_container_height">
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="top"
|
||||
app:constraint_referenced_ids="button_cancel,button_update" />
|
||||
<Button
|
||||
android:id="@+id/button_cancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:text="@android:string/cancel" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<Button
|
||||
android:id="@+id/button_update"
|
||||
style="?materialButtonTonalStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|end"
|
||||
android:enabled="false"
|
||||
android:text="@string/update" />
|
||||
|
||||
</FrameLayout>
|
||||
</com.google.android.material.dockedtoolbar.DockedToolbarLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
android:contentDescription="@string/back"
|
||||
android:elevation="@dimen/m3_sys_elevation_level1"
|
||||
android:scaleType="center"
|
||||
android:tooltipText="@string/back"
|
||||
app:srcCompat="?homeAsUpIndicator" />
|
||||
|
||||
<ImageButton
|
||||
@@ -31,9 +32,10 @@
|
||||
android:layout_gravity="end"
|
||||
android:layout_margin="@dimen/screen_padding"
|
||||
android:background="@drawable/bg_circle_button"
|
||||
android:contentDescription="@string/back"
|
||||
android:contentDescription="@string/show_menu"
|
||||
android:elevation="@dimen/m3_sys_elevation_level1"
|
||||
android:scaleType="center"
|
||||
android:tooltipText="@string/show_menu"
|
||||
app:srcCompat="@drawable/abc_ic_menu_overflow_material" />
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/settings"
|
||||
android:tooltipText="@string/settings"
|
||||
android:padding="4dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:contentDescription="@string/check_for_new_chapters"
|
||||
android:tooltipText="@string/check_for_new_chapters"
|
||||
app:layout_constraintBottom_toBottomOf="@id/textView_subtitle"
|
||||
app:layout_constraintEnd_toStartOf="@id/imageView_hidden"
|
||||
app:layout_constraintStart_toEndOf="@id/textView_subtitle"
|
||||
@@ -71,7 +72,8 @@
|
||||
android:id="@+id/imageView_hidden"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:contentDescription="@string/show_on_shelf"
|
||||
android:contentDescription="@string/hide_from_main_screen"
|
||||
android:tooltipText="@string/hide_from_main_screen"
|
||||
app:layout_constraintBottom_toBottomOf="@id/textView_subtitle"
|
||||
app:layout_constraintEnd_toEndOf="@id/textView_title"
|
||||
app:layout_constraintStart_toEndOf="@id/imageView_tracker"
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:elegantTextHeight="false"
|
||||
android:ellipsize="middle"
|
||||
android:ellipsize="end"
|
||||
android:paddingTop="4dp"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?attr/textAppearanceTitleSmall"
|
||||
|
||||
@@ -45,9 +45,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/details"
|
||||
android:minWidth="?minTouchTargetSize"
|
||||
android:minHeight="?minTouchTargetSize"
|
||||
android:pointerIcon="hand"
|
||||
android:scaleType="center"
|
||||
android:tooltipText="@string/details"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
tools:drawableStart="@drawable/ic_explore_selector"
|
||||
tools:text="@string/explore" />
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/imageView_remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -37,7 +37,8 @@
|
||||
android:contentDescription="@string/remove"
|
||||
android:padding="@dimen/margin_small"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_delete" />
|
||||
android:src="@drawable/ic_delete"
|
||||
android:tooltipText="@string/remove" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_reorder"
|
||||
@@ -46,8 +47,10 @@
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/reorder"
|
||||
android:padding="@dimen/margin_small"
|
||||
android:pointerIcon="grab"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_reorder_handle" />
|
||||
android:src="@drawable/ic_reorder_handle"
|
||||
android:tooltipText="@string/reorder" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
android:layout_marginVertical="@dimen/margin_small"
|
||||
android:background="?colorOutline" />
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/imageView_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/imageView_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -67,7 +67,7 @@
|
||||
android:tooltipText="@string/more"
|
||||
app:tint="?colorControlNormal" />
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/imageView_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -78,7 +78,7 @@
|
||||
android:src="@drawable/ic_add"
|
||||
android:tooltipText="@string/add" />
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/imageView_remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/remove"
|
||||
android:padding="?listPreferredItemPaddingEnd"
|
||||
android:tooltipText="@string/remove"
|
||||
app:srcCompat="@drawable/ic_delete" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
android:background="@drawable/custom_selectable_item_background"
|
||||
android:drawablePadding="4dp"
|
||||
android:padding="4dp"
|
||||
android:pointerIcon="hand"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?textAppearanceBodyMedium"
|
||||
app:layout_constrainedWidth="true"
|
||||
|
||||
@@ -38,13 +38,14 @@
|
||||
android:textAppearance="?textAppearanceBodyLarge"
|
||||
tools:text="@string/filter" />
|
||||
|
||||
<ImageView
|
||||
<ImageButton
|
||||
android:id="@+id/sh_button_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/close"
|
||||
android:tooltipText="@string/close"
|
||||
android:padding="16dp"
|
||||
app:srcCompat="?actionModeCloseDrawable"
|
||||
app:tint="?colorControlActivated" />
|
||||
|
||||
@@ -837,4 +837,5 @@
|
||||
<string name="incognito_mode_hint_nsfw">This manga may contain adult content. Do you want to use incognito mode?</string>
|
||||
<string name="incognito_for_nsfw">Incognito mode for NSFW manga</string>
|
||||
<string name="additional_action_required">Additional action is required</string>
|
||||
<string name="hide_from_main_screen">Hide from main screen</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user