From f3c0bee1315f3463767c58c68b9e61427b761e2f Mon Sep 17 00:00:00 2001 From: h4h13 Date: Tue, 30 Jul 2019 09:11:53 +0530 Subject: [PATCH] Updated views constructor like koltin style --- app/build.gradle | 11 ++--- .../retromusic/dialogs/AddToPlaylistDialog.kt | 10 +++- .../player/classic/ClassicPlayerFragment.kt | 2 - .../common/prefs/ATEColorPreference.kt | 43 +++++++++-------- .../prefs/supportv7/ATEColorPreference.kt | 37 ++++++++------- .../prefs/supportv7/ATEDialogPreference.kt | 45 +++++++++--------- .../prefs/supportv7/ATEEditTextPreference.kt | 47 +++++++++---------- .../prefs/supportv7/ATEListPreference.kt | 41 ++++++++-------- .../common/prefs/supportv7/ATEPreference.kt | 43 +++++++++-------- .../prefs/supportv7/ATEPreferenceCategory.kt | 42 +++++++++-------- .../prefs/supportv7/ATESeekBarPreference.kt | 40 +++++++++------- .../common/views/ATEAccentTextView.kt | 19 +++----- .../common/views/ATECheckBox.kt | 41 ++++++++-------- .../common/views/ATEEditText.kt | 38 ++++++++------- .../views/ATEExtendedFloatingActionButton.kt | 32 ------------- .../common/views/ATEPrimaryTextView.kt | 42 ++++++++--------- .../common/views/ATEProgressBar.kt | 38 --------------- .../common/views/ATERadioButton.kt | 37 --------------- .../common/views/ATESecondaryTextView.kt | 40 ++++++++-------- .../appthemehelper/common/views/ATESeekBar.kt | 38 --------------- .../common/views/ATEStockSwitch.kt | 36 -------------- .../common/views/ATETextInputLayout.java | 47 ------------------- 22 files changed, 272 insertions(+), 497 deletions(-) delete mode 100644 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEExtendedFloatingActionButton.kt delete mode 100755 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEProgressBar.kt delete mode 100755 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATERadioButton.kt delete mode 100755 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESeekBar.kt delete mode 100755 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEStockSwitch.kt delete mode 100644 appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATETextInputLayout.java diff --git a/app/build.gradle b/app/build.gradle index f04044e3..c7879949 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -119,18 +119,17 @@ static def getDate() { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.fragment:fragment:1.1.0-beta01' - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' - implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha06' + implementation 'androidx.fragment:fragment:1.2.0-alpha01' + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' + implementation 'androidx.recyclerview:recyclerview:1.1.0-beta01' implementation "androidx.gridlayout:gridlayout:1.0.0" implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.palette:palette:1.0.0" implementation 'androidx.annotation:annotation:1.1.0' - implementation 'androidx.preference:preference:1.1.0-beta01' + implementation 'androidx.preference:preference:1.1.0-rc01' implementation 'androidx.palette:palette-ktx:1.0.0' - implementation 'com.google.android.material:material:1.1.0-alpha07' - implementation 'com.google.android.material:material:1.1.0-alpha07' + implementation 'com.google.android.material:material:1.1.0-alpha08' implementation 'com.squareup.retrofit2:retrofit:2.6.0' implementation 'com.squareup.retrofit2:converter-gson:2.6.0' diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt index 578012c1..d757f28a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt @@ -14,10 +14,12 @@ package code.name.monkey.retromusic.dialogs +import android.app.Dialog import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.appthemehelper.ThemeStore @@ -30,7 +32,13 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment import kotlinx.android.synthetic.main.dialog_add_to_playlist.* -class AddToPlaylistDialog : RoundedBottomSheetDialogFragment() { +class AddToPlaylistDialog : DialogFragment() { + + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + + return super.onCreateDialog(savedInstanceState) + } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt index cd735ec0..a5f8b221 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt @@ -114,8 +114,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Call private lateinit var wrappedAdapter: RecyclerView.Adapter<*> private lateinit var recyclerViewDragDropManager: RecyclerViewDragDropManager - private var lyricsClassic: Lyrics? = null - private lateinit var impl: Impl override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/ATEColorPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/ATEColorPreference.kt index 43554563..47850ee4 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/ATEColorPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/ATEColorPreference.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs import android.content.Context @@ -6,33 +20,18 @@ import android.util.AttributeSet import android.view.View import code.name.monkey.appthemehelper.R -/** - * @author Aidan Follestad (afollestad) - */ -class ATEColorPreference : Preference { +class ATEColorPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : Preference(context, attrs, defStyleAttr, defStyleRes) { private var mView: View? = null private var color: Int = 0 private var border: Int = 0 - constructor(context: Context) : super(context) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - - private fun init() { + init { layoutResource = R.layout.ate_preference_custom widgetLayoutResource = R.layout.ate_preference_color isPersistent = false diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEColorPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEColorPreference.kt index 3909961b..492d5f7c 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEColorPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEColorPreference.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context @@ -10,34 +24,21 @@ import code.name.monkey.appthemehelper.R import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.common.prefs.BorderCircleView -/** - * @author Aidan Follestad (afollestad) - */ -class ATEColorPreference(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : Preference(context, attrs, defStyleAttr) { +class ATEColorPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : Preference(context, attrs, defStyleAttr) { private var mView: View? = null private var color: Int = 0 private var border: Int = 0 - constructor(context: Context) : this(context, null, 0) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) { - init() - } - init { - init() - - } - - private fun init() { layoutResource = R.layout.ate_preference_custom_support widgetLayoutResource = R.layout.ate_preference_color isPersistent = false - icon?.setColorFilter(ThemeStore.textColorSecondary(context), PorterDuff.Mode.SRC_IN) } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEDialogPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEDialogPreference.kt index 54a6c429..94365b90 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEDialogPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEDialogPreference.kt @@ -1,34 +1,31 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context -import androidx.preference.DialogPreference import android.util.AttributeSet - +import androidx.preference.DialogPreference import code.name.monkey.appthemehelper.R +open class ATEDialogPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, defStyleRes: Int = 0 +) : DialogPreference(context, attrs, defStyleAttr, defStyleRes) { -/** - * @author Aidan Follestad (afollestad) - */ -open class ATEDialogPreference : DialogPreference { - - constructor(context: Context) : super(context) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - private fun init() { + init { layoutResource = R.layout.ate_preference_custom_support } } \ No newline at end of file diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEEditTextPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEEditTextPreference.kt index 9439a34a..18767846 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEEditTextPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEEditTextPreference.kt @@ -1,35 +1,32 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context -import androidx.preference.EditTextPreference import android.util.AttributeSet - +import androidx.preference.EditTextPreference import code.name.monkey.appthemehelper.R +class ATEEditTextPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : EditTextPreference(context, attrs, defStyleAttr, defStyleRes) { -/** - * @author Aidan Follestad (afollestad) - */ -class ATEEditTextPreference : EditTextPreference { - - constructor(context: Context) : super(context) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - - private fun init() { + init { layoutResource = R.layout.ate_preference_custom_support } } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEListPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEListPreference.kt index 14505346..da7a47a8 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEListPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEListPreference.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context @@ -7,28 +21,15 @@ import androidx.preference.ListPreference import code.name.monkey.appthemehelper.R import code.name.monkey.appthemehelper.ThemeStore -/** - * @author Aidan Follestad (afollestad) - */ -class ATEListPreference : ListPreference { - constructor(context: Context) : super(context) { - init() - } +class ATEListPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : ListPreference(context, attrs, defStyleAttr, defStyleRes) { - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - private fun init() { + init { icon?.setColorFilter(ThemeStore.textColorSecondary(context), PorterDuff.Mode.SRC_IN) layoutResource = R.layout.ate_preference_custom_support if (summary == null || summary.toString().trim { it <= ' ' }.isEmpty()) diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreference.kt index 7abb7053..de30caa6 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreference.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context @@ -7,29 +21,14 @@ import androidx.preference.Preference import code.name.monkey.appthemehelper.R import code.name.monkey.appthemehelper.ThemeStore -/** - * @author Aidan Follestad (afollestad) - */ -class ATEPreference : Preference { +class ATEPreference @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : Preference(context, attrs, defStyleAttr, defStyleRes) { - constructor(context: Context) : super(context) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - - private fun init() { + init { layoutResource = R.layout.ate_preference_custom_support icon?.setColorFilter(ThemeStore.textColorSecondary(context), PorterDuff.Mode.SRC_IN) } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt index bd521c9d..98e6270c 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATEPreferenceCategory.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context @@ -8,32 +22,20 @@ import androidx.preference.PreferenceViewHolder import code.name.monkey.appthemehelper.R import code.name.monkey.appthemehelper.ThemeStore -class ATEPreferenceCategory : PreferenceCategory { +class ATEPreferenceCategory @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : PreferenceCategory(context, attrs, defStyleAttr, defStyleRes) { - constructor(context: Context) : super(context) { - init() + init { + layoutResource = R.layout.ate_preference_category } - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - override fun onBindViewHolder(holder: PreferenceViewHolder) { super.onBindViewHolder(holder) val mTitle = holder.itemView as TextView mTitle.setTextColor(ThemeStore.accentColor(context)) } - - private fun init() { - layoutResource = R.layout.ate_preference_category - } } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt index 3cd3db72..e0b60b55 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/prefs/supportv7/ATESeekBarPreference.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.prefs.supportv7 import android.content.Context @@ -10,24 +24,14 @@ import code.name.monkey.appthemehelper.R import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.util.TintHelper -class ATESeekBarPreference : SeekBarPreference { - constructor(context: Context) : super(context) { - init() - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init() - } - - private fun init() { +class ATESeekBarPreference +@JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : SeekBarPreference(context, attrs, defStyleAttr, defStyleRes) { + init { icon?.setColorFilter(ThemeStore.textColorSecondary(context), PorterDuff.Mode.SRC_IN) } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt index dc8dbb82..1ac734ef 100644 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEAccentTextView.kt @@ -20,20 +20,13 @@ import android.util.AttributeSet import androidx.appcompat.widget.AppCompatTextView import code.name.monkey.appthemehelper.ThemeStore -open class ATEAccentTextView : AppCompatTextView { - constructor(context: Context) : super(context) { - init(context) - } +class ATEAccentTextView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AppCompatTextView(context, attrs, defStyleAttr) { - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - private fun init(context: Context) { + init { setTextColor(ThemeStore.accentColor(context)) } } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt index f72fddba..a95eddb2 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATECheckBox.kt @@ -1,31 +1,32 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.views import android.content.Context -import androidx.appcompat.widget.AppCompatCheckBox import android.util.AttributeSet - +import androidx.appcompat.widget.AppCompatCheckBox import code.name.monkey.appthemehelper.ATH import code.name.monkey.appthemehelper.ThemeStore +class ATECheckBox @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AppCompatCheckBox(context, attrs, defStyleAttr) { -/** - * @author Aidan Follestad (afollestad) - */ -class ATECheckBox : AppCompatCheckBox { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - private fun init(context: Context) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) } } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEEditText.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEEditText.kt index 5a2f7157..b53be36f 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEEditText.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEEditText.kt @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.views import android.content.Context @@ -6,25 +20,13 @@ import code.name.monkey.appthemehelper.ATH import code.name.monkey.appthemehelper.ThemeStore import com.google.android.material.textfield.TextInputEditText +class ATEEditText @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : TextInputEditText(context, attrs, defStyleAttr) { -/** - * @author Aidan Follestad (afollestad) - */ -class ATEEditText : TextInputEditText { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - private fun init(context: Context) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) setTextColor(ThemeStore.textColorPrimary(context)) } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEExtendedFloatingActionButton.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEExtendedFloatingActionButton.kt deleted file mode 100644 index 60766d23..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEExtendedFloatingActionButton.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 Hemanth Savarala. - * - * Licensed under the GNU General Public License v3 - * - * This is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by - * the Free Software Foundation either version 3 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - */ - -package code.name.monkey.appthemehelper.common.views - -import android.content.Context -import android.content.res.ColorStateList -import android.util.AttributeSet -import code.name.monkey.appthemehelper.ThemeStore -import code.name.monkey.appthemehelper.util.ColorUtil -import code.name.monkey.appthemehelper.util.MaterialValueHelper -import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton - -class ATEExtendedFloatingActionButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = -1) : ExtendedFloatingActionButton(context, attrs, defStyleAttr) { - - init { - backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(context)) - setTextColor(ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(context, ColorUtil.isColorLight(ThemeStore.accentColor(context))))) - } - -} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt index 0dded8dc..6ae74ef1 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEPrimaryTextView.kt @@ -1,31 +1,31 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.views import android.content.Context -import androidx.appcompat.widget.AppCompatTextView - import android.util.AttributeSet - +import androidx.appcompat.widget.AppCompatTextView import code.name.monkey.appthemehelper.ThemeStore +class ATEPrimaryTextView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AppCompatTextView(context, attrs, defStyleAttr) { -/** - * @author Aidan Follestad (afollestad) - */ -class ATEPrimaryTextView : AppCompatTextView { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - private fun init(context: Context) { + init { setTextColor(ThemeStore.textColorPrimary(context)) } } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEProgressBar.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEProgressBar.kt deleted file mode 100755 index 36facb3c..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEProgressBar.kt +++ /dev/null @@ -1,38 +0,0 @@ -package code.name.monkey.appthemehelper.common.views - -import android.annotation.TargetApi -import android.content.Context -import android.os.Build -import android.util.AttributeSet -import android.widget.ProgressBar - -import code.name.monkey.appthemehelper.ATH -import code.name.monkey.appthemehelper.ThemeStore - - -/** - * @author Aidan Follestad (afollestad) - */ -class ATEProgressBar : ProgressBar { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init(context) - } - - private fun init(context: Context) { - ATH.setTint(this, ThemeStore.accentColor(context)) - } -} \ No newline at end of file diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATERadioButton.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATERadioButton.kt deleted file mode 100755 index f5df00a9..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATERadioButton.kt +++ /dev/null @@ -1,37 +0,0 @@ -package code.name.monkey.appthemehelper.common.views - -import android.annotation.TargetApi -import android.content.Context -import android.os.Build -import android.util.AttributeSet -import android.widget.RadioButton - -import code.name.monkey.appthemehelper.ATH -import code.name.monkey.appthemehelper.ThemeStore - -/** - * @author Aidan Follestad (afollestad) - */ -class ATERadioButton : RadioButton { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init(context) - } - - private fun init(context: Context) { - ATH.setTint(this, ThemeStore.accentColor(context)) - } -} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt index 4fc08039..e6a203fa 100755 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt +++ b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESecondaryTextView.kt @@ -1,29 +1,31 @@ +/* + * Copyright (c) 2019 Hemanth Savarala. + * + * Licensed under the GNU General Public License v3 + * + * This is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by + * the Free Software Foundation either version 3 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + */ + package code.name.monkey.appthemehelper.common.views import android.content.Context -import androidx.appcompat.widget.AppCompatTextView import android.util.AttributeSet - +import androidx.appcompat.widget.AppCompatTextView import code.name.monkey.appthemehelper.ThemeStore -/** - * @author Aidan Follestad (afollestad) - */ -open class ATESecondaryTextView : AppCompatTextView { +class ATESecondaryTextView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AppCompatTextView(context, attrs, defStyleAttr) { - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - private fun init(context: Context) { + init { setTextColor(ThemeStore.textColorSecondary(context)) } } diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESeekBar.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESeekBar.kt deleted file mode 100755 index 59890651..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATESeekBar.kt +++ /dev/null @@ -1,38 +0,0 @@ -package code.name.monkey.appthemehelper.common.views - -import android.annotation.TargetApi -import android.content.Context -import android.os.Build -import android.util.AttributeSet -import android.widget.SeekBar - -import code.name.monkey.appthemehelper.ATH -import code.name.monkey.appthemehelper.ThemeStore - - -/** - * @author Aidan Follestad (afollestad) - */ -class ATESeekBar : SeekBar { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { - init(context) - } - - private fun init(context: Context) { - ATH.setTint(this, ThemeStore.accentColor(context)) - } -} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEStockSwitch.kt b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEStockSwitch.kt deleted file mode 100755 index bbf78952..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATEStockSwitch.kt +++ /dev/null @@ -1,36 +0,0 @@ -package code.name.monkey.appthemehelper.common.views - -import android.content.Context -import android.util.AttributeSet -import android.view.View -import android.widget.Switch - -import code.name.monkey.appthemehelper.ATH -import code.name.monkey.appthemehelper.ThemeStore - - -/** - * @author Aidan Follestad (afollestad) - */ -class ATEStockSwitch : Switch { - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } - - private fun init(context: Context) { - ATH.setTint(this, ThemeStore.accentColor(context)) - } - - override fun isShown(): Boolean { - return parent != null && visibility == View.VISIBLE - } -} diff --git a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATETextInputLayout.java b/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATETextInputLayout.java deleted file mode 100644 index c1040c70..00000000 --- a/appthemehelper/src/main/java/code/name/monkey/appthemehelper/common/views/ATETextInputLayout.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2019 Hemanth Savarala. - * - * Licensed under the GNU General Public License v3 - * - * This is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by - * the Free Software Foundation either version 3 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - */ - -package code.name.monkey.appthemehelper.common.views; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.util.AttributeSet; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.google.android.material.textfield.TextInputLayout; - -import code.name.monkey.appthemehelper.ThemeStore; - -/** - * Created by hemanths on 3/12/19 - */ -public class ATETextInputLayout extends TextInputLayout { - public ATETextInputLayout(@NonNull Context context) { - this(context, null); - } - - public ATETextInputLayout(@NonNull Context context, @Nullable AttributeSet attrs) { - this(context, attrs, -1); - } - - public ATETextInputLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - setBoxBackgroundMode(BOX_BACKGROUND_FILLED); - setHintAnimationEnabled(true); - setHintEnabled(true); - setBackgroundTintList(ColorStateList.valueOf(ThemeStore.Companion.accentColor(context))); - } -}