Merge pull request #452 from h4h13/current

Fix search keyboard not popping
This commit is contained in:
Hemanth S 2019-07-31 01:53:01 +05:30 committed by GitHub
commit 1145405832
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 224 deletions

View file

@ -31,8 +31,8 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
versionCode 342
versionName '3.2.136'
versionCode 343
versionName '3.2.200'
multiDexEnabled true

File diff suppressed because one or more lines are too long

View file

@ -1,186 +0,0 @@
package code.name.monkey.retromusic.activities
import android.os.Bundle
import android.transition.TransitionManager
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.SeekBar
import android.widget.TextView
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.extensions.applyToolbar
import code.name.monkey.retromusic.helper.EqualizerHelper
import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.activity_equalizer.*
import kotlinx.android.synthetic.main.activity_equalizer.appBarLayout
import kotlinx.android.synthetic.main.activity_equalizer.toolbar
import kotlinx.android.synthetic.main.activity_playing_queue.*
/**
* @author Hemanth S (h4h13).
*/
class EqualizerActivity : AbsMusicServiceActivity(), AdapterView.OnItemSelectedListener {
private val seekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) {
if (seekBar === bassBoostStrength) {
bassBoost.isEnabled = progress > 0
EqualizerHelper.instance!!.bassBoostStrength = progress
EqualizerHelper.instance!!.isBassBoostEnabled = progress > 0
} else if (seekBar === virtualizerStrength) {
virtualizer.isEnabled = progress > 0
EqualizerHelper.instance!!.isVirtualizerEnabled = progress > 0
EqualizerHelper.instance!!.virtualizerStrength = progress
}
}
}
override fun onStartTrackingTouch(seekBar: SeekBar) {
}
override fun onStopTrackingTouch(seekBar: SeekBar) {
}
}
private var presetsNamesAdapter: ArrayAdapter<String>? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_equalizer)
setStatusbarColorAuto()
setNavigationbarColorAuto()
setTaskDescriptionColorAuto()
setLightNavigationBar(true)
setupToolbar()
equalizerSwitch.isChecked = EqualizerHelper.instance!!.equalizer.enabled
equalizerSwitch.setBackgroundColor(ThemeStore.accentColor(this))
val widgetColor = MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))
equalizerSwitch.setTextColor(widgetColor)
TintHelper.setTintAuto(equalizerSwitch, widgetColor, false)
equalizerSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
when (buttonView.id) {
R.id.equalizerSwitch -> {
EqualizerHelper.instance!!.equalizer.enabled = isChecked
TransitionManager.beginDelayedTransition(content)
content.visibility = if (isChecked) View.VISIBLE else View.GONE
}
}
}
presetsNamesAdapter = ArrayAdapter(this, android.R.layout.simple_list_item_1)
presets.adapter = presetsNamesAdapter
presets.onItemSelectedListener = this
bassBoostStrength.progress = EqualizerHelper.instance!!.bassBoostStrength
ViewUtil.setProgressDrawable(bassBoostStrength, ThemeStore.accentColor(this))
bassBoostStrength.setOnSeekBarChangeListener(seekBarChangeListener)
virtualizerStrength.progress = EqualizerHelper.instance!!.virtualizerStrength
ViewUtil.setProgressDrawable(virtualizerStrength, ThemeStore.accentColor(this))
virtualizerStrength.setOnSeekBarChangeListener(seekBarChangeListener)
setupUI()
addPresets()
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
onBackPressed()
return true
}
return super.onOptionsItemSelected(item)
}
private fun setupToolbar() {
val primaryColor = ThemeStore.primaryColor(this)
appBarLayout.setBackgroundColor(primaryColor)
applyToolbar(toolbar)
}
private fun addPresets() {
presetsNamesAdapter!!.clear()
presetsNamesAdapter!!.add("Custom")
for (j in 0 until EqualizerHelper.instance!!.equalizer.numberOfPresets) {
presetsNamesAdapter!!
.add(EqualizerHelper.instance!!.equalizer.getPresetName(j.toShort()))
presetsNamesAdapter!!.notifyDataSetChanged()
}
presets.setSelection(EqualizerHelper.instance!!.equalizer.currentPreset.toInt() + 1)
}
private fun setupUI() {
frequencyBands.removeAllViews()
val bands: Short
try {
// get number of supported bands
bands = EqualizerHelper.instance!!.numberOfBands.toShort()
// for each of the supported bands, we will set up a slider from -10dB to 10dB boost/attenuation,
// as well as text labels to assist the user
for (i in 0 until bands) {
val view = LayoutInflater.from(this).inflate(R.layout.retro_seekbar, frequencyBands, false)
val freqTextView = view.findViewById<TextView>(R.id.hurtz)
freqTextView.text = String.format("%d Hz", EqualizerHelper.instance!!.getCenterFreq(i) / 1000)
val minDbTextView = view.findViewById<TextView>(R.id.minus_db)
minDbTextView.text = String.format("%d dB", EqualizerHelper.instance!!.bandLevelLow / 100)
val maxDbTextView = view.findViewById<TextView>(R.id.plus_db)
maxDbTextView.text = String.format("%d dB", EqualizerHelper.instance!!.bandLevelHigh / 100)
val bar = view.findViewById<SeekBar>(R.id.seekbar)
ViewUtil.setProgressDrawable(bar, ThemeStore.accentColor(this))
bar.max = EqualizerHelper.instance!!.bandLevelHigh - EqualizerHelper.instance!!
.bandLevelLow
bar.progress = EqualizerHelper.instance!!.getBandLevel(i) - EqualizerHelper.instance!!
.bandLevelLow
bar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
EqualizerHelper.instance!!.setBandLevel(i,
progress + EqualizerHelper.instance!!.bandLevelLow)
if (fromUser) {
presets.setSelection(0)
}
}
override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {}
})
frequencyBands.addView(view)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
if (position == 0) {
return
}
EqualizerHelper.instance!!.equalizer.usePreset((position - 1).toShort())
setupUI()
}
override fun onNothingSelected(parent: AdapterView<*>) {
}
}

View file

@ -64,7 +64,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, SearchCon
keyboardPopup.setOnClickListener {
val inputManager = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.showSoftInput(searchView, 0)
inputManager.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT)
}
keyboardPopup.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))

View file

@ -23,6 +23,7 @@ import androidx.preference.Preference
import androidx.preference.TwoStatePreference
import code.name.monkey.appthemehelper.*
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.App
@ -41,12 +42,21 @@ import com.afollestad.materialdialogs.color.colorChooser
class ThemeSettingsFragment : AbsSettingsFragment() {
override fun invalidateSettings() {
val primaryColorPref: ATEColorPreference? = findPreference("primary_color")
primaryColorPref?.let {
it.isVisible = PreferenceUtil.getInstance().generalTheme == R.style.Theme_RetroMusic_Color
val categoryColor: ATEPreferenceCategory? = findPreference("category_color")
val primaryColorPref = ATEColorPreference(preferenceScreen.context)
val primaryColor = ThemeStore.primaryColor(activity!!)
it.setColor(primaryColor, ColorUtil.darkenColor(primaryColor))
it.setOnPreferenceClickListener {
primaryColorPref.apply {
key = "primary_color"
isPersistent = false
setSummary(R.string.primary_color_desc)
setTitle(R.string.primary_color)
isCopyingEnabled = true
setIcon(R.drawable.ic_colorize_white_24dp)
setColor(primaryColor, ColorUtil.darkenColor(primaryColor))
setOnPreferenceClickListener {
MaterialDialog(activity!!, BottomSheet()).show {
title(R.string.primary_color)
positiveButton(R.string.set)
@ -83,10 +93,6 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
return@setOnPreferenceChangeListener false
}
if (theme == "color") {
primaryColorPref?.isVisible = true
}
setSummary(generalTheme, newValue)
when (theme) {
@ -144,6 +150,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
}
}
if (PreferenceUtil.getInstance().generalTheme == R.style.Theme_RetroMusic_Color && App.isProVersion) {
categoryColor?.addPreference(primaryColorPref)
}
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {

View file

@ -41,7 +41,7 @@
app:srcCompat="@drawable/ic_keyboard_backspace_black_24dp" />
<code.name.monkey.appthemehelper.common.views.ATEEditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -52,7 +52,7 @@
android:padding="12dp">
<requestFocus />
</code.name.monkey.appthemehelper.common.views.ATEEditText>
</com.google.android.material.textfield.TextInputEditText>
<code.name.monkey.retromusic.views.IconImageView
android:id="@+id/voiceSearch"

View file

@ -59,7 +59,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<code.name.monkey.appthemehelper.common.views.ATEEditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/songText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -77,7 +77,7 @@
android:layout_marginTop="8dp"
app:hintEnabled="true">
<code.name.monkey.appthemehelper.common.views.ATEEditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/albumText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -239,10 +239,7 @@
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton

View file

@ -13,23 +13,9 @@
app:enableCopying="true"
app:icon="@drawable/ic_color_lens_white_24dp" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/colors">
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="primary_color"
android:persistent="false"
android:summary="@string/primary_color_desc"
android:title="@string/primary_color"
app:enableCopying="true"
app:icon="@drawable/ic_colorize_white_24dp" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="accent_color"
android:persistent="false"
android:summary="@string/accent_color_desc"
android:title="@string/accent_color"
app:enableCopying="true"
app:icon="@drawable/ic_colorize_white_24dp" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
android:key="category_color"
android:title="@string/colors">
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
@ -51,5 +37,14 @@
android:summary="@string/pref_summary_dominant_color"
android:title="@string/pref_title_toggle_dominant_color"
app:enableCopying="true" />
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference
android:key="accent_color"
android:persistent="false"
android:summary="@string/accent_color_desc"
android:title="@string/accent_color"
app:enableCopying="true"
app:icon="@drawable/ic_colorize_white_24dp" />
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
</androidx.preference.PreferenceScreen>