aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/main/kotlin')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt16
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/dialogs/color/ColorPickerDialog.kt4
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt6
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt4
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/views/BoundedCardView.kt (renamed from library/src/main/kotlin/ca/allanwang/kau/views/KauBoundedCardView.kt)8
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/views/CutoutTextView.kt (renamed from library/src/main/kotlin/ca/allanwang/kau/views/KauCutoutTextView.kt)16
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/widgets/ElasticDragDismissFrameLayout.kt (renamed from library/src/main/kotlin/ca/allanwang/kau/widgets/KauElasticDragDismissFrameLayout.kt)25
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/widgets/InkPageIndicator.java (renamed from library/src/main/kotlin/ca/allanwang/kau/widgets/KauInkPageIndicator.java)22
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/widgets/TextSlider.kt (renamed from library/src/main/kotlin/ca/allanwang/kau/widgets/KauTextSlider.kt)6
9 files changed, 49 insertions, 58 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/library/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
index 476b7f8..63af3cf 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
@@ -17,9 +17,9 @@ import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.dimenPixelSize
import ca.allanwang.kau.utils.string
-import ca.allanwang.kau.views.KauCutoutTextView
-import ca.allanwang.kau.widgets.KauElasticDragDismissFrameLayout
-import ca.allanwang.kau.widgets.KauInkPageIndicator
+import ca.allanwang.kau.views.CutoutTextView
+import ca.allanwang.kau.widgets.ElasticDragDismissFrameLayout
+import ca.allanwang.kau.widgets.InkPageIndicator
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
@@ -39,9 +39,9 @@ import java.security.InvalidParameterException
*/
abstract class AboutActivityBase(val rClass: Class<*>, val configBuilder: Configs.() -> Unit = {}) : AppCompatActivity() {
- val draggableFrame: KauElasticDragDismissFrameLayout by bindView(R.id.about_draggable_frame)
+ val draggableFrame: ElasticDragDismissFrameLayout by bindView(R.id.about_draggable_frame)
val pager: ViewPager by bindView(R.id.about_pager)
- val indicator: KauInkPageIndicator by bindView(R.id.about_indicator)
+ val indicator: InkPageIndicator by bindView(R.id.about_indicator)
val configs: Configs by lazy { Configs().apply { configBuilder() } }
override fun onCreate(savedInstanceState: Bundle?) {
@@ -52,7 +52,7 @@ abstract class AboutActivityBase(val rClass: Class<*>, val configBuilder: Config
pageMargin = dimenPixelSize(R.dimen.kau_spacing_normal)
}
indicator.setViewPager(pager)
- draggableFrame.addListener(object : KauElasticDragDismissFrameLayout.SystemChromeFader(this) {
+ draggableFrame.addListener(object : ElasticDragDismissFrameLayout.SystemChromeFader(this) {
override fun onDragDismissed() {
// if we drag dismiss downward then the default reversal of the enter
// transition would slide content upward which looks weird. So reverse it.
@@ -91,14 +91,14 @@ abstract class AboutActivityBase(val rClass: Class<*>, val configBuilder: Config
fun inflateMainPage(layoutInflater: LayoutInflater, parent: ViewGroup): View {
val v = layoutInflater.inflate(R.layout.kau_about_section_main, parent, false)
postInflateMainPage(
- v.findViewById<KauCutoutTextView>(R.id.about_main_cutout),
+ v.findViewById<CutoutTextView>(R.id.about_main_cutout),
v.findViewById<FrameLayout>(R.id.about_main_bottom_container),
v.findViewById<TextView>(R.id.about_main_bottom_text)
)
return v
}
- open fun postInflateMainPage(cutout: KauCutoutTextView, bottomContainer: FrameLayout, bottomText: TextView) {
+ open fun postInflateMainPage(cutout: CutoutTextView, bottomContainer: FrameLayout, bottomText: TextView) {
with (configs) {
cutout.text = string(cutoutTextRes, cutoutText)
bottomText.text = string(mainPageTitleRes, mainPageTitle)
diff --git a/library/src/main/kotlin/ca/allanwang/kau/dialogs/color/ColorPickerDialog.kt b/library/src/main/kotlin/ca/allanwang/kau/dialogs/color/ColorPickerDialog.kt
index 07f5e17..7c57c26 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/dialogs/color/ColorPickerDialog.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/dialogs/color/ColorPickerDialog.kt
@@ -71,8 +71,8 @@ fun Context.colorPickerDialog(contract: ColorContract): MaterialDialog {
negativeText(contract.cancelText)
if (contract.allowCustom) neutralText(contract.presetText)
onPositive { dialog, _ -> contract.colorCallback?.invoke(view.selectedColor); dialog.dismiss() }
- onNegative { dialog, _ -> view.backOrCancel() }
- if (contract.allowCustom) onNeutral { dialog, _ -> view.toggleCustom() }
+ onNegative { _, _ -> view.backOrCancel() }
+ if (contract.allowCustom) onNeutral { _, _ -> view.toggleCustom() }
showListener { view.refreshColors() }
if (contract.theme != null) theme(contract.theme!!)
build()
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt
index a2985f0..9a9f7d4 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefActivity.kt
@@ -17,7 +17,7 @@ import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.resolveColor
import ca.allanwang.kau.utils.statusBarColor
import ca.allanwang.kau.utils.string
-import ca.allanwang.kau.widgets.KauTextSlider
+import ca.allanwang.kau.widgets.TextSlider
import ca.allanwang.kau.views.RippleCanvas
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
@@ -32,13 +32,13 @@ abstract class KPrefActivity : AppCompatActivity(), KPrefActivityContract {
val bgCanvas: RippleCanvas by bindView(R.id.kau_ripple)
val toolbarCanvas: RippleCanvas by bindView(R.id.kau_toolbar_ripple)
val toolbar: Toolbar by bindView(R.id.kau_toolbar)
- val toolbarTitle: KauTextSlider by bindView(R.id.kau_toolbar_text)
+ val toolbarTitle: TextSlider by bindView(R.id.kau_toolbar_text)
val prefHolder: ViewAnimator by bindView(R.id.kau_holder)
private lateinit var globalOptions: GlobalOptions
var animate: Boolean = true
set(value) {
field = value
- toolbarTitle.animationType = if (value) KauTextSlider.ANIMATION_SLIDE_HORIZONTAL else KauTextSlider.ANIMATION_NONE
+ toolbarTitle.animationType = if (value) TextSlider.ANIMATION_SLIDE_HORIZONTAL else TextSlider.ANIMATION_NONE
}
private val SLIDE_IN_LEFT_ITEMS: Animation by lazy { AnimationUtils.loadAnimation(this, R.anim.kau_slide_in_left) }
diff --git a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
index b2490ac..c077a06 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
@@ -21,7 +21,7 @@ import ca.allanwang.kau.animators.NoAnimator
import ca.allanwang.kau.kotlin.nonReadable
import ca.allanwang.kau.searchview.SearchView.Configs
import ca.allanwang.kau.utils.*
-import ca.allanwang.kau.views.KauBoundedCardView
+import ca.allanwang.kau.views.BoundedCardView
import com.jakewharton.rxbinding2.widget.RxTextView
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
import com.mikepenz.google_material_typeface_library.GoogleMaterial
@@ -207,7 +207,7 @@ class SearchView @JvmOverloads constructor(
val configs = Configs()
//views
private val shadow: View by bindView(R.id.search_shadow)
- private val card: KauBoundedCardView by bindView(R.id.search_cardview)
+ private val card: BoundedCardView by bindView(R.id.search_cardview)
private val iconNav: ImageView by bindView(R.id.search_nav)
private val editText: AppCompatEditText by bindView(R.id.search_edit_text)
val textEvents: Observable<String>
diff --git a/library/src/main/kotlin/ca/allanwang/kau/views/KauBoundedCardView.kt b/library/src/main/kotlin/ca/allanwang/kau/views/BoundedCardView.kt
index 60f5176..0cb65d0 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/views/KauBoundedCardView.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/views/BoundedCardView.kt
@@ -16,7 +16,7 @@ import ca.allanwang.kau.utils.parentVisibleHeight
* This view should be used with wrap_content as its height
* Defaults to at most the parent's visible height
*/
-class KauBoundedCardView @JvmOverloads constructor(
+class BoundedCardView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : CardView(context, attrs, defStyleAttr) {
@@ -33,9 +33,9 @@ class KauBoundedCardView @JvmOverloads constructor(
init {
if (attrs != null) {
- val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.KauBoundedCardView)
- maxHeight = styledAttrs.getDimensionPixelSize(R.styleable.KauBoundedCardView_kau_maxHeight, -1)
- maxHeightPercent = styledAttrs.getFloat(R.styleable.KauBoundedCardView_kau_maxHeightPercent, -1.0f)
+ val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.BoundedCardView)
+ maxHeight = styledAttrs.getDimensionPixelSize(R.styleable.BoundedCardView_maxHeight, -1)
+ maxHeightPercent = styledAttrs.getFloat(R.styleable.BoundedCardView_maxHeightPercent, -1.0f)
styledAttrs.recycle()
}
}
diff --git a/library/src/main/kotlin/ca/allanwang/kau/views/KauCutoutTextView.kt b/library/src/main/kotlin/ca/allanwang/kau/views/CutoutTextView.kt
index 8df604a..b113c3d 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/views/KauCutoutTextView.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/views/CutoutTextView.kt
@@ -32,7 +32,7 @@ import ca.allanwang.kau.utils.parentVisibleHeight
/**
* A view which punches out some text from an opaque color block, allowing you to see through it.
*/
-class KauCutoutTextView @JvmOverloads constructor(
+class CutoutTextView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
private val textPaint: TextPaint = TextPaint(Paint.ANTI_ALIAS_FLAG)
@@ -49,13 +49,13 @@ class KauCutoutTextView @JvmOverloads constructor(
init {
if (attrs != null) {
- val a = context.obtainStyledAttributes(attrs, R.styleable.KauCutoutTextView, 0, 0)
- if (a.hasValue(R.styleable.KauCutoutTextView_kau_font))
- textPaint.typeface = context.getFont(a.getString(R.styleable.KauCutoutTextView_kau_font))
- foregroundColor = a.getColor(R.styleable.KauCutoutTextView_kau_foregroundColor, foregroundColor)
- text = a.getString(R.styleable.KauCutoutTextView_android_text) ?: text
- minHeight = a.getDimension(R.styleable.KauCutoutTextView_android_minHeight, minHeight)
- heightPercentage = a.getFloat(R.styleable.KauCutoutTextView_kau_heightPercentageToScreen, heightPercentage)
+ val a = context.obtainStyledAttributes(attrs, R.styleable.CutoutTextView, 0, 0)
+ if (a.hasValue(R.styleable.CutoutTextView_font))
+ textPaint.typeface = context.getFont(a.getString(R.styleable.CutoutTextView_font))
+ foregroundColor = a.getColor(R.styleable.CutoutTextView_foregroundColor, foregroundColor)
+ text = a.getString(R.styleable.CutoutTextView_android_text) ?: text
+ minHeight = a.getDimension(R.styleable.CutoutTextView_android_minHeight, minHeight)
+ heightPercentage = a.getFloat(R.styleable.CutoutTextView_heightPercentageToScreen, heightPercentage)
a.recycle()
}
maxTextSize = context.dimenPixelSize(R.dimen.kau_display_4_text_size).toFloat()
diff --git a/library/src/main/kotlin/ca/allanwang/kau/widgets/KauElasticDragDismissFrameLayout.kt b/library/src/main/kotlin/ca/allanwang/kau/widgets/ElasticDragDismissFrameLayout.kt
index d186647..081db22 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/widgets/KauElasticDragDismissFrameLayout.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/widgets/ElasticDragDismissFrameLayout.kt
@@ -31,7 +31,7 @@ import ca.allanwang.kau.utils.*
* Applies an elasticity factor to reduce movement as you approach the given dismiss distance.
* Optionally also scales down content during drag.
*/
-class KauElasticDragDismissFrameLayout @JvmOverloads constructor(
+class ElasticDragDismissFrameLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
@@ -50,24 +50,15 @@ class KauElasticDragDismissFrameLayout @JvmOverloads constructor(
private var callbacks: MutableList<ElasticDragDismissCallback> = mutableListOf()
init {
-
- val a = getContext().obtainStyledAttributes(
- attrs, R.styleable.KauElasticDragDismissFrameLayout, 0, 0)
-
- if (a.hasValue(R.styleable.KauElasticDragDismissFrameLayout_kau_dragDismissDistance)) {
- dragDismissDistance = a.getDimensionPixelSize(R.styleable.KauElasticDragDismissFrameLayout_kau_dragDismissDistance, 0).toFloat()
- } else if (a.hasValue(R.styleable.KauElasticDragDismissFrameLayout_kau_dragDismissFraction)) {
- dragDismissFraction = a.getFloat(R.styleable.KauElasticDragDismissFrameLayout_kau_dragDismissFraction, dragDismissFraction)
- }
- if (a.hasValue(R.styleable.KauElasticDragDismissFrameLayout_kau_dragDismissScale)) {
- dragDismissScale = a.getFloat(R.styleable.KauElasticDragDismissFrameLayout_kau_dragDismissScale, dragDismissScale)
+ if (attrs != null) {
+ val a = getContext().obtainStyledAttributes(attrs, R.styleable.ElasticDragDismissFrameLayout, 0, 0)
+ dragDismissDistance = a.getDimensionPixelSize(R.styleable.ElasticDragDismissFrameLayout_dragDismissDistance, Int.MAX_VALUE).toFloat()
+ dragDismissFraction = a.getFloat(R.styleable.ElasticDragDismissFrameLayout_dragDismissFraction, dragDismissFraction)
+ dragDismissScale = a.getFloat(R.styleable.ElasticDragDismissFrameLayout_dragDismissScale, dragDismissScale)
shouldScale = dragDismissScale != 1f
+ dragElacticity = a.getFloat(R.styleable.ElasticDragDismissFrameLayout_dragElasticity, dragElacticity)
+ a.recycle()
}
- if (a.hasValue(R.styleable.KauElasticDragDismissFrameLayout_kau_dragElasticity)) {
- dragElacticity = a.getFloat(R.styleable.KauElasticDragDismissFrameLayout_kau_dragElasticity,
- dragElacticity)
- }
- a.recycle()
}
abstract class ElasticDragDismissCallback {
diff --git a/library/src/main/kotlin/ca/allanwang/kau/widgets/KauInkPageIndicator.java b/library/src/main/kotlin/ca/allanwang/kau/widgets/InkPageIndicator.java
index 1f2dc9a..8bdfd5c 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/widgets/KauInkPageIndicator.java
+++ b/library/src/main/kotlin/ca/allanwang/kau/widgets/InkPageIndicator.java
@@ -41,7 +41,7 @@ import ca.allanwang.kau.utils.AnimHolder;
/**
* An ink inspired widget for indicating pages in a {@link ViewPager}.
*/
-public class KauInkPageIndicator extends View implements ViewPager.OnPageChangeListener,
+public class InkPageIndicator extends View implements ViewPager.OnPageChangeListener,
View.OnAttachStateChangeListener {
// defaults
@@ -113,35 +113,35 @@ public class KauInkPageIndicator extends View implements ViewPager.OnPageChangeL
float controlX2;
float controlY2;
- public KauInkPageIndicator(Context context) {
+ public InkPageIndicator(Context context) {
this(context, null, 0);
}
- public KauInkPageIndicator(Context context, AttributeSet attrs) {
+ public InkPageIndicator(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
- public KauInkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
+ public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final int density = (int) context.getResources().getDisplayMetrics().density;
// Load attributes
final TypedArray a = getContext().obtainStyledAttributes(
- attrs, R.styleable.KauInkPageIndicator, defStyle, 0);
+ attrs, R.styleable.InkPageIndicator, defStyle, 0);
- dotDiameter = a.getDimensionPixelSize(R.styleable.KauInkPageIndicator_kau_dotDiameter,
+ dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
DEFAULT_DOT_SIZE * density);
dotRadius = dotDiameter / 2;
halfDotRadius = dotRadius / 2;
- gap = a.getDimensionPixelSize(R.styleable.KauInkPageIndicator_kau_dotGap,
+ gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
DEFAULT_GAP * density);
- animDuration = (long) a.getInteger(R.styleable.KauInkPageIndicator_kau_animationDuration,
+ animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
DEFAULT_ANIM_DURATION);
animHalfDuration = animDuration / 2;
- unselectedColour = a.getColor(R.styleable.KauInkPageIndicator_kau_pageIndicatorColor,
+ unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
DEFAULT_UNSELECTED_COLOUR);
- selectedColour = a.getColor(R.styleable.KauInkPageIndicator_kau_currentPageIndicatorColor,
+ selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
DEFAULT_SELECTED_COLOUR);
a.recycle();
@@ -169,7 +169,7 @@ public class KauInkPageIndicator extends View implements ViewPager.OnPageChangeL
viewPager.getAdapter().registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
- setPageCount(KauInkPageIndicator.this.viewPager.getAdapter().getCount());
+ setPageCount(InkPageIndicator.this.viewPager.getAdapter().getCount());
}
});
setCurrentPageImmediate();
diff --git a/library/src/main/kotlin/ca/allanwang/kau/widgets/KauTextSlider.kt b/library/src/main/kotlin/ca/allanwang/kau/widgets/TextSlider.kt
index 02b4912..528dabc 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/widgets/KauTextSlider.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/widgets/TextSlider.kt
@@ -19,7 +19,7 @@ import java.util.*
* Text switcher with global text color and embedded sliding animations
* Also has a stack to keep track of title changes
*/
-class KauTextSlider @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null
+class TextSlider @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null
) : TextSwitcher(context, attrs) {
val titleStack: Stack<CharSequence?> = Stack()
@@ -68,8 +68,8 @@ class KauTextSlider @JvmOverloads constructor(context: Context, attrs: Attribute
init {
if (attrs != null) {
- val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.KauTextSlider)
- animationType = styledAttrs.getInteger(R.styleable.KauTextSlider_kau_animation_type, ANIMATION_SLIDE_HORIZONTAL)
+ val styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.TextSlider)
+ animationType = styledAttrs.getInteger(R.styleable.TextSlider_animation_type, ANIMATION_SLIDE_HORIZONTAL)
styledAttrs.recycle()
}
}