Reader Spinner Binding + rename

to MaterialSpinnerView (sorry arkon)
This commit is contained in:
Jays2Kings 2021-03-29 02:14:47 -04:00
parent 028ed3ea1e
commit 57abbd6eda
8 changed files with 27 additions and 32 deletions

View File

@ -7,7 +7,6 @@ import android.text.Spannable
import android.text.SpannableString
import android.text.style.ScaleXSpan
import android.util.AttributeSet
import android.widget.TextView
import androidx.appcompat.widget.AppCompatTextView
import eu.kanade.tachiyomi.widget.OutlineSpan
@ -39,7 +38,7 @@ class PageIndicatorTextView(
}
}
super.setText(finalText, TextView.BufferType.SPANNABLE)
super.setText(finalText, BufferType.SPANNABLE)
}
private companion object {

View File

@ -1,8 +1,9 @@
package eu.kanade.tachiyomi.ui.reader.settings
package eu.kanade.tachiyomi.widget
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.view.LayoutInflater
import android.view.MenuItem
import android.widget.FrameLayout
import androidx.annotation.ArrayRes
@ -10,9 +11,9 @@ import androidx.appcompat.widget.PopupMenu
import androidx.core.view.get
import com.tfcporciuncula.flow.Preference
import eu.kanade.tachiyomi.R
import kotlinx.android.synthetic.main.reader_preference.view.*
import eu.kanade.tachiyomi.databinding.MaterialSpinnerViewBinding
class ReaderSpinnerView @JvmOverloads constructor(context: Context, attrs: AttributeSet?) :
class MaterialSpinnerView @JvmOverloads constructor(context: Context, attrs: AttributeSet?) :
FrameLayout(context, attrs) {
private var entries = emptyList<String>()
@ -33,17 +34,19 @@ class ReaderSpinnerView @JvmOverloads constructor(context: Context, attrs: Attri
}
}
private val binding = MaterialSpinnerViewBinding.inflate(LayoutInflater.from(context), this, false)
init {
inflate(context, R.layout.reader_preference, this)
addView(binding.root)
val a = context.obtainStyledAttributes(attrs, R.styleable.ReaderSpinnerView, 0, 0)
val str = a.getString(R.styleable.ReaderSpinnerView_title) ?: ""
title_view.text = str
binding.titleView.text = str
val entries = (a.getTextArray(R.styleable.ReaderSpinnerView_android_entries) ?: emptyArray()).map { it.toString() }
this.entries = entries
detail_view.text = entries.firstOrNull().orEmpty()
binding.detailView.text = entries.firstOrNull().orEmpty()
a.recycle()
}
@ -52,7 +55,7 @@ class ReaderSpinnerView @JvmOverloads constructor(context: Context, attrs: Attri
popup?.menu?.get(selectedPosition)?.isCheckable = false
popup?.menu?.get(selectedPosition)?.isChecked = false
selectedPosition = selection
detail_view.text = entries.getOrNull(selection).orEmpty()
binding.detailView.text = entries.getOrNull(selection).orEmpty()
popup?.menu?.get(selectedPosition)?.isCheckable = true
popup?.menu?.get(selectedPosition)?.isChecked = true
}

View File

@ -115,5 +115,5 @@
android:layout_width="0dp"
android:layout_height="6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bottom_line" />
app:layout_constraintTop_toBottomOf="@id/bottom_line" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -51,10 +51,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="right"
app:constraint_referenced_ids="bottom_line,title_view" />
app:constraint_referenced_ids="halfway_point,title_view" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/bottom_line"
android:id="@+id/halfway_point"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"

View File

@ -172,7 +172,7 @@
<!-- Filter mode -->
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/color_filter_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -228,12 +228,5 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/brightness_seekbar" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/bottom_line"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.kanade.tachiyomi.ui.reader.settings.ReaderFilterView>

View File

@ -21,7 +21,7 @@
android:paddingTop="0dp"
android:paddingEnd="@dimen/material_component_dialogs_padding_around_content_area">
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/viewer_series"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -29,7 +29,7 @@
app:title="@string/viewer_for_this_series"
android:entries="@array/viewers_selector" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/rotation_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -37,7 +37,7 @@
app:title="@string/rotation"
android:entries="@array/rotation_type" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/background_color"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -16,7 +16,7 @@
android:paddingTop="0dp"
android:paddingEnd="@dimen/material_component_dialogs_padding_around_content_area">
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/pager_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -24,7 +24,7 @@
app:title="@string/nav_layout"
android:entries="@array/reader_nav" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/pager_invert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -32,7 +32,7 @@
app:title="@string/invert_tapping"
android:entries="@array/invert_tapping_mode" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/scale_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -40,7 +40,7 @@
app:title="@string/scale_type"
android:entries="@array/image_scale_type" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/extend_past_cutout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -48,7 +48,7 @@
app:title="@string/cutout_area_behavior"
android:entries="@array/cutout_behavior" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/zoom_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -74,7 +74,7 @@
android:textColor="?android:attr/textColorPrimary" />
<!-- Webtoon Prefs -->
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/webtoon_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -82,7 +82,7 @@
app:title="@string/nav_layout"
android:entries="@array/reader_nav" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/webtoon_invert"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -90,7 +90,7 @@
app:title="@string/invert_tapping"
android:entries="@array/invert_tapping_mode" />
<eu.kanade.tachiyomi.ui.reader.settings.ReaderSpinnerView
<eu.kanade.tachiyomi.widget.MaterialSpinnerView
android:id="@+id/webtoon_side_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -172,6 +172,6 @@
android:layout_width="0dp"
android:layout_height="6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/bottom_line" />
app:layout_constraintTop_toBottomOf="@id/bottom_line" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>