Compare commits
10 commits
dev
...
revert-712
Author | SHA1 | Date | |
---|---|---|---|
|
a051bb7722 | ||
|
886112d7df | ||
|
98f1d23ebe | ||
|
5de5fc1c3a | ||
|
f2be4720ad | ||
|
459b1bd668 | ||
|
6065c994ad | ||
|
23c882bdb7 | ||
|
5d34055fd0 | ||
|
967c6fb5ac |
53 changed files with 2249 additions and 249 deletions
|
@ -99,6 +99,11 @@ android {
|
|||
kapt {
|
||||
generateStubs = true
|
||||
}
|
||||
kotlin {
|
||||
experimental {
|
||||
coroutines "enable"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -168,6 +173,9 @@ dependencies {
|
|||
def kotlin_coroutines_version = "1.3.3"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
||||
def arch_version = '2.2.0'
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$arch_version"
|
||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$arch_version"
|
||||
|
||||
implementation 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:3.4.0.201406110918-r'
|
||||
|
||||
|
@ -176,6 +184,8 @@ dependencies {
|
|||
|
||||
implementation 'com.github.AdrienPoupa:jaudiotagger:2.2.3'
|
||||
|
||||
implementation 'com.github.ologe:scroll-helper:2.0.0-beta01'
|
||||
|
||||
implementation 'com.anjlab.android.iab.v3:library:1.1.0'
|
||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||
implementation 'com.heinrichreimersoftware:material-intro:1.6'
|
||||
|
@ -184,4 +194,8 @@ dependencies {
|
|||
def dagger_version = "2.23.1"
|
||||
implementation "com.google.dagger:dagger:$dagger_version"
|
||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
}
|
||||
|
||||
implementation 'com.github.ologe:scroll-helper:1.1.5'
|
||||
implementation 'com.diogobernardino:williamchart:2.2'
|
||||
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.0'
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
|
@ -30,6 +29,7 @@
|
|||
android:usesCleartextTraffic="false"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
|
||||
tools:targetApi="m">
|
||||
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
|
@ -122,20 +122,19 @@
|
|||
<activity android:name=".activities.bugreport.BugReportActivity" />
|
||||
<activity android:name=".activities.ShareInstagramStory" />
|
||||
<activity android:name=".activities.DriveModeActivity" />
|
||||
<activity android:name=".activities.EqualizerActivity" />
|
||||
<activity android:name=".activities.TestActivity" />
|
||||
<activity
|
||||
android:name=".activities.SearchActivity"
|
||||
android:windowSoftInputMode="stateVisible" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.LockScreenActivity"
|
||||
android:noHistory="true"
|
||||
android:showOnLockScreen="true" />
|
||||
|
||||
<activity
|
||||
android:name=".appshortcuts.AppShortcutLauncherActivity"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
|
||||
|
||||
<activity
|
||||
android:name=".activities.saf.SAFGuideActivity"
|
||||
android:theme="@style/Theme.Intro" />
|
||||
|
@ -149,8 +148,6 @@
|
|||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}"
|
||||
|
@ -166,14 +163,12 @@
|
|||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".appwidgets.BootReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".appwidgets.AppWidgetBig"
|
||||
android:exported="false"
|
||||
|
@ -186,7 +181,6 @@
|
|||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/app_widget_big_info" />
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".appwidgets.AppWidgetClassic"
|
||||
android:exported="false"
|
||||
|
@ -236,6 +230,16 @@
|
|||
android:resource="@xml/app_widget_card_info" />
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".equalizer.AudioEffectsReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="org.oucho.musicplayer.OPEN_AUDIO_EFFECT_SESSION" />
|
||||
<action android:name="org.oucho.musicplayer.CLOSE_AUDIO_EFFECT_SESSION" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".service.MusicService"
|
||||
android:enabled="true"
|
||||
|
@ -250,15 +254,12 @@
|
|||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="2.1" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.lge.support.SPLIT_WINDOW"
|
||||
android:value="true" />
|
||||
|
||||
<meta-data
|
||||
android:name="code.name.monkey.retromusic.glide.RetroMusicGlideModule"
|
||||
android:value="GlideModule" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.bumptech.glide.integration.okhttp3.OkHttpGlideModule"
|
||||
android:value="GlideModule" />
|
||||
|
@ -266,4 +267,5 @@
|
|||
android:name="com.android.vending.splits.required"
|
||||
android:value="true" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
</manifest>
|
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
|||
import code.name.monkey.retromusic.dagger.DaggerMusicComponent
|
||||
import code.name.monkey.retromusic.dagger.MusicComponent
|
||||
import code.name.monkey.retromusic.dagger.module.AppModule
|
||||
import code.name.monkey.retromusic.equalizer.AudioEffects
|
||||
import com.anjlab.android.iab.v3.BillingProcessor
|
||||
import com.anjlab.android.iab.v3.TransactionDetails
|
||||
|
||||
|
@ -63,6 +64,8 @@ class App : MultiDexApplication() {
|
|||
|
||||
override fun onBillingInitialized() {}
|
||||
})
|
||||
|
||||
AudioEffects.init(this)
|
||||
}
|
||||
|
||||
private fun initDagger(app: App): MusicComponent =
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package code.name.monkey.retromusic
|
||||
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
|
||||
import dev.olog.scrollhelper.ScrollHelper
|
||||
|
||||
class RetroScrollHelper(
|
||||
private val activity: FragmentActivity
|
||||
) : ScrollHelper(activity,
|
||||
true,
|
||||
false // TODO when true, scrolls both bottomsheet and bottom navigation
|
||||
) {
|
||||
|
||||
private val skipFragment = listOf(
|
||||
PlayerFragment::class.java.name
|
||||
)
|
||||
|
||||
// TODO every fragment has to have it's unique tag in order to work correctly
|
||||
// here you can decide what fragment will be processed by the library
|
||||
// probably you want to skip player fragments, ecc ..
|
||||
override fun shouldSkipFragment(fragment: Fragment): Boolean {
|
||||
return fragment::class.java.name in skipFragment
|
||||
}
|
||||
|
||||
override fun findBottomNavigation(): View? {
|
||||
return activity.findViewById(R.id.bottomNavigationView)
|
||||
}
|
||||
|
||||
override fun findBottomSheet(): View? {
|
||||
return activity.findViewById(R.id.slidingPanel)
|
||||
}
|
||||
|
||||
override fun findFab(fragment: Fragment): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun findRecyclerView(fragment: Fragment): RecyclerView? {
|
||||
return fragment.requireView().findViewById(R.id.recyclerView)
|
||||
}
|
||||
|
||||
override fun findToolbar(fragment: Fragment): View? {
|
||||
return fragment.requireActivity().findViewById(R.id.toolbarContainer)
|
||||
}
|
||||
|
||||
override fun findTabLayout(fragment: Fragment): View? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun findViewPager(fragment: Fragment): ViewPager2? {
|
||||
return null
|
||||
}
|
||||
|
||||
// TODO override this if you want to apply custom padding
|
||||
override fun updateRecyclerViewPadding(
|
||||
fragment: Fragment,
|
||||
recyclerView: RecyclerView,
|
||||
topPadding: Int,
|
||||
bottomPadding: Int
|
||||
) {
|
||||
super.updateRecyclerViewPadding(fragment, recyclerView, topPadding, bottomPadding)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
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.*
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
|
||||
import code.name.monkey.retromusic.equalizer.AudioEffects
|
||||
import code.name.monkey.retromusic.helper.EqualizerHelper
|
||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import kotlinx.android.synthetic.main.activity_equalizer.*
|
||||
|
||||
/**
|
||||
* @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 lateinit var presetsNamesAdapter: ArrayAdapter<String>
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_equalizer)
|
||||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
setupToolbar()
|
||||
|
||||
equalizerSwitch.isChecked = AudioEffects.areAudioEffectsEnabled()
|
||||
val widgetColor = MaterialValueHelper.getPrimaryTextColor(
|
||||
this,
|
||||
ColorUtil.isColorLight(ThemeStore.accentColor(this))
|
||||
)
|
||||
equalizerSwitch.setTextColor(widgetColor)
|
||||
TintHelper.setTintAuto(equalizerSwitch, ThemeStore.accentColor(this), false)
|
||||
equalizerSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
when (buttonView.id) {
|
||||
R.id.equalizerSwitch -> {
|
||||
AudioEffects.setAudioEffectsEnabled(isChecked)
|
||||
TransitionManager.beginDelayedTransition(content)
|
||||
content.visibility = if (isChecked) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
presetsNamesAdapter =
|
||||
ArrayAdapter(this, R.layout.dropdown_item, AudioEffects.getEqualizerPresets(this))
|
||||
presets.adapter = presetsNamesAdapter
|
||||
presets.onItemSelectedListener = this
|
||||
presets.setSelection(AudioEffects.getCurrentPreset())
|
||||
|
||||
bassBoostStrength.progress = AudioEffects.getBassBoostStrength().toInt()
|
||||
ViewUtil.setProgressDrawable(bassBoostStrength, ThemeStore.accentColor(this), true)
|
||||
bassBoostStrength.setOnSeekBarChangeListener(seekBarChangeListener)
|
||||
|
||||
virtualizerStrength.progress = AudioEffects.getVirtualizerStrength().toInt()
|
||||
ViewUtil.setProgressDrawable(virtualizerStrength, ThemeStore.accentColor(this), true)
|
||||
virtualizerStrength.setOnSeekBarChangeListener(seekBarChangeListener)
|
||||
|
||||
setupUI()
|
||||
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
toolbar.setBackgroundColor(toolbarColor)
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
|
||||
|
||||
private fun setupUI() {
|
||||
frequencyBands.removeAllViews()
|
||||
// get number of supported bands
|
||||
|
||||
try {
|
||||
val bands: Short = AudioEffects.getNumberOfBands()
|
||||
val range: ShortArray = AudioEffects.getBandLevelRange()
|
||||
|
||||
// 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 (band 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(band) / 1000)
|
||||
|
||||
val bar = view.findViewById<SeekBar>(R.id.seekbar)
|
||||
ViewUtil.setProgressDrawable(bar, ThemeStore.accentColor(this), true)
|
||||
val seekBarMax = range[1] - range[0]
|
||||
bar.max = seekBarMax
|
||||
println("AudioEffect ${AudioEffects.getBandLevel(band.toShort())}")
|
||||
bar.progress = EqualizerHelper.instance!!.getBandLevel(band)
|
||||
|
||||
bar.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
|
||||
override fun onProgressChanged(
|
||||
seekBar: SeekBar,
|
||||
progress: Int,
|
||||
fromUser: Boolean
|
||||
) {
|
||||
if (fromUser) {
|
||||
//val level: Short = (progress + AudioEffects.getBandLevelRange(0)).toShort()
|
||||
//AudioEffects.setBandLevel(band.toShort(), level)
|
||||
EqualizerHelper.instance!!.setBandLevel(
|
||||
band, progress + EqualizerHelper.instance!!.bandLevelLow
|
||||
)
|
||||
println("AudioEffect: ${progress + EqualizerHelper.instance!!.bandLevelLow}")
|
||||
presets.setSelection(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
frequencyBands.addView(view)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
println("AudioEffect: $position")
|
||||
AudioEffects.usePreset((position).toShort())
|
||||
//EqualizerHelper.instance!!.equalizer.usePreset((position - 1).toShort())
|
||||
setupUI()
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||
|
||||
}
|
||||
}
|
|
@ -55,6 +55,7 @@ import java.util.List;
|
|||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.RetroScrollHelper;
|
||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity;
|
||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
|
||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
||||
|
@ -83,6 +84,7 @@ import code.name.monkey.retromusic.util.NavigationUtil;
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil;
|
||||
import code.name.monkey.retromusic.util.RetroUtil;
|
||||
import dev.olog.scrollhelper.ScrollHelper;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2020-02-19.
|
||||
|
@ -119,6 +121,9 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
private Toolbar mToolbar;
|
||||
private MaterialCardView mToolbarContainer;
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private ScrollHelper scrollHelper;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
|
@ -151,6 +156,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
|||
checkShowChangelog();
|
||||
AppRater.appLaunched(this);
|
||||
setupToolbar();
|
||||
|
||||
scrollHelper = new RetroScrollHelper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
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.fragments.EqualizerFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote.audioSessionId
|
||||
import kotlinx.android.synthetic.main.activity_about.*
|
||||
|
||||
class TestActivity : AbsMusicServiceActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.test)
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||
toolbar.setBackgroundColor(toolbarColor)
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
val equalizerFragment = EqualizerFragment.newInstance(audioSessionId)
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.contentFrame, equalizerFragment)
|
||||
.commit()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
}
|
|
@ -111,10 +111,14 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator?.cancel() // just in case
|
||||
navigationBarColorAnimator?.cancel() // just in case
|
||||
}
|
||||
|
||||
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
|
||||
|
@ -142,7 +146,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
// necessary to make the views below clickable
|
||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||
|
||||
bottomNavigationView.translationY = progress * 500
|
||||
//bottomNavigationView.alpha = alpha
|
||||
}
|
||||
|
||||
|
@ -217,8 +220,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
}
|
||||
}
|
||||
|
||||
fun setBottomBarVisibility(gone: Int) {
|
||||
bottomNavigationView.visibility = gone
|
||||
fun setBottomBarVisibility(visibility: Int) {
|
||||
bottomNavigationView.visibility = visibility
|
||||
hideBottomBar(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ import android.app.Activity
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.GenreAdapter.ViewHolder
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
|
@ -19,7 +21,7 @@ class GenreAdapter(
|
|||
private val activity: Activity,
|
||||
var dataSet: List<Genre>,
|
||||
private val mItemLayoutRes: Int
|
||||
) : RecyclerView.Adapter<GenreAdapter.ViewHolder>() {
|
||||
) : ListAdapter<Genre, ViewHolder>(GenreDiffCallback()) {
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
|
@ -54,3 +56,19 @@ class GenreAdapter(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for calculating the diff between two non-null items in a list.
|
||||
*
|
||||
* Used by ListAdapter to calculate the minimum number of changes between and old list and a new
|
||||
* list that's been passed to `submitList`.
|
||||
*/
|
||||
class GenreDiffCallback : DiffUtil.ItemCallback<Genre>() {
|
||||
override fun areItemsTheSame(oldItem: Genre, newItem: Genre): Boolean {
|
||||
return oldItem.id == newItem.id
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: Genre, newItem: Genre): Boolean {
|
||||
return oldItem == newItem
|
||||
}
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
package code.name.monkey.retromusic.equalizer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
|
||||
/**
|
||||
* Created by Harjot on 23-May-16.
|
||||
*/
|
||||
public class AnalogController extends View {
|
||||
|
||||
public Paint circlePaint2;
|
||||
public Paint linePaint;
|
||||
float midx, midy;
|
||||
Paint textPaint;
|
||||
Paint circlePaint;
|
||||
String angle;
|
||||
float currdeg, deg = 3, downdeg;
|
||||
|
||||
int progressColor, lineColor;
|
||||
|
||||
onProgressChangedListener mListener;
|
||||
|
||||
String label;
|
||||
|
||||
public AnalogController(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public AnalogController(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public AnalogController(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setOnProgressChangedListener(onProgressChangedListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
void init() {
|
||||
textPaint = new Paint();
|
||||
textPaint.setColor(ATHUtil.INSTANCE.resolveColor(getContext(), android.R.attr.textColorSecondary));
|
||||
textPaint.setStyle(Paint.Style.FILL);
|
||||
textPaint.setTextSize(33);
|
||||
textPaint.setFakeBoldText(true);
|
||||
textPaint.setTextAlign(Paint.Align.CENTER);
|
||||
circlePaint = new Paint();
|
||||
circlePaint.setColor(Color.BLUE);
|
||||
circlePaint.setStyle(Paint.Style.FILL);
|
||||
circlePaint2 = new Paint();
|
||||
circlePaint2.setColor(Color.RED);
|
||||
circlePaint2.setStyle(Paint.Style.FILL);
|
||||
linePaint = new Paint();
|
||||
linePaint.setColor(ThemeStore.Companion.accentColor(getContext()));
|
||||
linePaint.setStrokeWidth(16);
|
||||
angle = "0.0";
|
||||
label = "Label";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
midx = canvas.getWidth() / 2;
|
||||
midy = canvas.getHeight() / 2;
|
||||
|
||||
int ang = 0;
|
||||
float x = 0, y = 0;
|
||||
int radius = (int) (Math.min(midx, midy) * ((float) 14.5 / 16));
|
||||
float deg2 = Math.max(3, deg);
|
||||
float deg3 = Math.min(deg, 21);
|
||||
for (int i = (int) (deg2); i < 22; i++) {
|
||||
float tmp = (float) i / 24;
|
||||
x = midx + (float) (radius * Math.sin(2 * Math.PI * (1.0 - tmp)));
|
||||
y = midy + (float) (radius * Math.cos(2 * Math.PI * (1.0 - tmp)));
|
||||
circlePaint.setColor(Color.parseColor("#777777"));
|
||||
canvas.drawCircle(x, y, ((float) radius / 15), circlePaint);
|
||||
}
|
||||
for (int i = 3; i <= deg3; i++) {
|
||||
float tmp = (float) i / 24;
|
||||
x = midx + (float) (radius * Math.sin(2 * Math.PI * (1.0 - tmp)));
|
||||
y = midy + (float) (radius * Math.cos(2 * Math.PI * (1.0 - tmp)));
|
||||
canvas.drawCircle(x, y, ((float) radius / 15), circlePaint2);
|
||||
}
|
||||
|
||||
float tmp2 = deg / 24;
|
||||
float x1 = midx + (float) (radius * ((float) 2 / 5) * Math.sin(2 * Math.PI * (1.0 - tmp2)));
|
||||
float y1 = midy + (float) (radius * ((float) 2 / 5) * Math.cos(2 * Math.PI * (1.0 - tmp2)));
|
||||
float x2 = midx + (float) (radius * ((float) 3 / 5) * Math.sin(2 * Math.PI * (1.0 - tmp2)));
|
||||
float y2 = midy + (float) (radius * ((float) 3 / 5) * Math.cos(2 * Math.PI * (1.0 - tmp2)));
|
||||
|
||||
circlePaint.setColor(Color.parseColor("#888888"));
|
||||
canvas.drawCircle(midx, midy, radius * ((float) 13 / 15), circlePaint);
|
||||
circlePaint.setColor(Color.parseColor("#999999"));
|
||||
canvas.drawCircle(midx, midy, radius * ((float) 11 / 15), circlePaint);
|
||||
canvas.drawText(label, midx, midy + (float) (radius * 1.1), textPaint);
|
||||
canvas.drawLine(x1, y1, x2, y2, linePaint);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
|
||||
mListener.onProgressChanged((int) (deg - 2));
|
||||
|
||||
if (e.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
float dx = e.getX() - midx;
|
||||
float dy = e.getY() - midy;
|
||||
downdeg = (float) ((Math.atan2(dy, dx) * 180) / Math.PI);
|
||||
downdeg -= 90;
|
||||
if (downdeg < 0) {
|
||||
downdeg += 360;
|
||||
}
|
||||
downdeg = (float) Math.floor(downdeg / 15);
|
||||
return true;
|
||||
}
|
||||
if (e.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
float dx = e.getX() - midx;
|
||||
float dy = e.getY() - midy;
|
||||
currdeg = (float) ((Math.atan2(dy, dx) * 180) / Math.PI);
|
||||
currdeg -= 90;
|
||||
if (currdeg < 0) {
|
||||
currdeg += 360;
|
||||
}
|
||||
currdeg = (float) Math.floor(currdeg / 15);
|
||||
|
||||
if (currdeg == 0 && downdeg == 23) {
|
||||
deg++;
|
||||
if (deg > 21) {
|
||||
deg = 21;
|
||||
}
|
||||
downdeg = currdeg;
|
||||
} else if (currdeg == 23 && downdeg == 0) {
|
||||
deg--;
|
||||
if (deg < 3) {
|
||||
deg = 3;
|
||||
}
|
||||
downdeg = currdeg;
|
||||
} else {
|
||||
deg += (currdeg - downdeg);
|
||||
if (deg > 21) {
|
||||
deg = 21;
|
||||
}
|
||||
if (deg < 3) {
|
||||
deg = 3;
|
||||
}
|
||||
downdeg = currdeg;
|
||||
}
|
||||
|
||||
angle = String.valueOf(deg);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
return e.getAction() == MotionEvent.ACTION_UP || super.onTouchEvent(e);
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return (int) (deg - 2);
|
||||
}
|
||||
|
||||
public void setProgress(int param) {
|
||||
deg = param + 2;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String txt) {
|
||||
label = txt;
|
||||
}
|
||||
|
||||
public int getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
public void setLineColor(int lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public int getProgressColor() {
|
||||
return progressColor;
|
||||
}
|
||||
|
||||
public void setProgressColor(int progressColor) {
|
||||
this.progressColor = progressColor;
|
||||
}
|
||||
|
||||
public interface onProgressChangedListener {
|
||||
void onProgressChanged(int progress);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,342 @@
|
|||
package code.name.monkey.retromusic.equalizer;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.audiofx.BassBoost;
|
||||
import android.media.audiofx.Equalizer;
|
||||
import android.media.audiofx.Virtualizer;
|
||||
import android.util.Log;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
|
||||
|
||||
public class AudioEffects {
|
||||
|
||||
public static final short BASSBOOST_MAX_STRENGTH = 1000;
|
||||
private static final String PREF_EQ_ENABLED = "enabled";
|
||||
private static final String PREF_VIRTUALIZER_ENABLED = "pref_virtualizer_enabled";
|
||||
private static final String PREF_BAND_LEVEL = "level";
|
||||
private static final String PREF_PRESET = "preset";
|
||||
private static final String PREF_BASSBOOST = "bassboost";
|
||||
private static final String PREF_VIRTUALIZER = "pref_virtualizer";
|
||||
private static final String AUDIO_EFFECTS_PREFS = "audioeffects";
|
||||
|
||||
private static final BassBoostValues sBassBoostValues = new BassBoostValues();
|
||||
private static final VirtualizerValues sVirtualizerValues = new VirtualizerValues();
|
||||
private static final EqualizerValues sEqualizerValues = new EqualizerValues();
|
||||
private static BassBoost sBassBoost;
|
||||
private static Equalizer sEqualizer;
|
||||
private static Virtualizer sVirtualizer;
|
||||
private static boolean sCustomPreset;
|
||||
|
||||
public static void init(Context context) {
|
||||
SharedPreferences prefs = context.getSharedPreferences(AUDIO_EFFECTS_PREFS, Context.MODE_PRIVATE);
|
||||
initBassBoostValues(prefs);
|
||||
initEqualizerValues(prefs);
|
||||
}
|
||||
|
||||
|
||||
public static void openAudioEffectSession(Context context, int audioSessionId) {
|
||||
SharedPreferences prefs = context.getSharedPreferences(AUDIO_EFFECTS_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
initBassBoost(audioSessionId);
|
||||
initEqualizer(prefs, audioSessionId);
|
||||
}
|
||||
|
||||
public static void closeAudioEffectSession() {
|
||||
if (sBassBoost != null) {
|
||||
sBassBoost.release();
|
||||
sBassBoost = null;
|
||||
}
|
||||
|
||||
if (sEqualizer != null) {
|
||||
sEqualizer.release();
|
||||
sEqualizer = null;
|
||||
}
|
||||
if (sVirtualizer != null) {
|
||||
sVirtualizer.release();
|
||||
sVirtualizer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void initBassBoostValues(SharedPreferences prefs) {
|
||||
sBassBoostValues.enabled = prefs.getBoolean(PREF_EQ_ENABLED, false);
|
||||
sBassBoostValues.strength = (short) prefs.getInt(PREF_BASSBOOST, 0);
|
||||
|
||||
sVirtualizerValues.enabled = prefs.getBoolean(PREF_VIRTUALIZER_ENABLED, false);
|
||||
sVirtualizerValues.strength = (short) prefs.getInt(PREF_VIRTUALIZER, 0);
|
||||
}
|
||||
|
||||
private static void initBassBoost(int audioSessionId) {
|
||||
if (sBassBoost != null) {
|
||||
sBassBoost.release();
|
||||
sBassBoost = null;
|
||||
}
|
||||
sBassBoost = new BassBoost(0, audioSessionId);
|
||||
sBassBoost.setEnabled(sBassBoostValues.enabled);
|
||||
|
||||
short strength = sBassBoostValues.strength;
|
||||
|
||||
if (strength >= 0 && strength <= BASSBOOST_MAX_STRENGTH) {
|
||||
sBassBoost.setStrength(strength);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initVirtualizerBoost(int audioSessionId) {
|
||||
if (sVirtualizer != null) {
|
||||
sVirtualizer.release();
|
||||
sVirtualizer = null;
|
||||
}
|
||||
sVirtualizer = new Virtualizer(0, audioSessionId);
|
||||
sVirtualizer.setEnabled(sVirtualizerValues.enabled);
|
||||
|
||||
short strength = sVirtualizerValues.strength;
|
||||
|
||||
if (strength >= 0 && strength <= BASSBOOST_MAX_STRENGTH) {
|
||||
sVirtualizer.setStrength(strength);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initEqualizerValues(SharedPreferences prefs) {
|
||||
sEqualizerValues.enabled = prefs.getBoolean(PREF_EQ_ENABLED, false);
|
||||
sEqualizerValues.preset = (short) prefs.getInt(PREF_PRESET, -1);
|
||||
if (sEqualizerValues.preset == -1) {
|
||||
sCustomPreset = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void initEqualizer(SharedPreferences prefs, int audioSessionId) {
|
||||
|
||||
if (sEqualizer != null) {
|
||||
sEqualizer.release();
|
||||
sEqualizer = null;
|
||||
}
|
||||
if (sVirtualizer != null) {
|
||||
sVirtualizer.release();
|
||||
sVirtualizer = null;
|
||||
}
|
||||
sEqualizer = new Equalizer(0, audioSessionId);
|
||||
sEqualizer.setEnabled(sEqualizerValues.enabled);
|
||||
|
||||
sVirtualizer = new Virtualizer(0, audioSessionId);
|
||||
sVirtualizer.setEnabled(sEqualizerValues.enabled);
|
||||
|
||||
if (!sCustomPreset) {
|
||||
usePreset(sEqualizerValues.preset);
|
||||
|
||||
}
|
||||
|
||||
sEqualizerValues.numberOfBands = sEqualizer.getNumberOfBands();
|
||||
|
||||
|
||||
if (!sEqualizerValues.levelsSet) {
|
||||
sEqualizerValues.bandLevels = new short[sEqualizerValues.numberOfBands];
|
||||
}
|
||||
for (short b = 0; b < sEqualizerValues.numberOfBands; b++) {
|
||||
if (!sEqualizerValues.levelsSet) {
|
||||
short level = (short) prefs.getInt(PREF_BAND_LEVEL + b, sEqualizer.getBandLevel(b));
|
||||
sEqualizerValues.bandLevels[b] = level;
|
||||
if (sCustomPreset) {
|
||||
|
||||
sEqualizer.setBandLevel(b, level);
|
||||
}
|
||||
} else {
|
||||
sEqualizer.setBandLevel(b, sEqualizerValues.bandLevels[b]);
|
||||
}
|
||||
}
|
||||
|
||||
sEqualizerValues.levelsSet = true;
|
||||
|
||||
}
|
||||
|
||||
public static short getBassBoostStrength() {
|
||||
return sBassBoostValues.strength;
|
||||
}
|
||||
|
||||
public static void setBassBoostStrength(short strength) {
|
||||
sBassBoostValues.strength = strength;
|
||||
if (sBassBoost != null) {
|
||||
sBassBoost.setStrength(strength);
|
||||
}
|
||||
}
|
||||
|
||||
public static short getVirtualizerStrength() {
|
||||
return sVirtualizer.getRoundedStrength();
|
||||
}
|
||||
|
||||
public static void setVirtualizerStrength(short strength) {
|
||||
sVirtualizerValues.strength = strength;
|
||||
if (sVirtualizer != null) {
|
||||
sVirtualizer.setStrength(strength);
|
||||
}
|
||||
}
|
||||
|
||||
public static short[] getBandLevelRange() {
|
||||
if (sEqualizer == null) {
|
||||
return null;
|
||||
}
|
||||
return sEqualizer.getBandLevelRange();
|
||||
}
|
||||
|
||||
public static short getBandLevel(short band) {
|
||||
/*if (sEqualizer == null) {
|
||||
if (sEqualizerValues.levelsSet && sEqualizerValues.bandLevels.length > band) {
|
||||
return sEqualizerValues.bandLevels[band];
|
||||
}
|
||||
}*/
|
||||
if (sEqualizer != null) {
|
||||
Log.d("audiofx", "eeeD");
|
||||
return sEqualizer.getBandLevel(band);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static short getBandLevelRange(int i) {
|
||||
if (sEqualizer != null) {
|
||||
Log.i("AudioEffect", "getBandLevelRange: " + sEqualizer.getBandLevelRange()[i]);
|
||||
return sEqualizer.getBandLevelRange()[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getBandLevelOfPreset(short i) {
|
||||
if (sEqualizer != null) {
|
||||
return (int) sEqualizer.getBandLevel(i) - getBandLevelRange(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean areAudioEffectsEnabled() {
|
||||
if (sEqualizer == null) {
|
||||
return sEqualizerValues.enabled;
|
||||
}
|
||||
return sEqualizer.getEnabled();
|
||||
}
|
||||
|
||||
public static void setAudioEffectsEnabled(boolean enabled) {
|
||||
if (sEqualizer == null || sBassBoost == null) {
|
||||
return;
|
||||
}
|
||||
sBassBoost.setEnabled(true);
|
||||
sEqualizer.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public static void setBandLevel(short band, short level) {
|
||||
sCustomPreset = true;
|
||||
|
||||
if (sEqualizerValues.bandLevels.length > band) {
|
||||
sEqualizerValues.preset = -1;
|
||||
sEqualizerValues.bandLevels[band] = level;
|
||||
}
|
||||
|
||||
if (sEqualizer != null) {
|
||||
sEqualizer.setBandLevel(band, level);
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] getEqualizerPresets(Context context) {
|
||||
if (sEqualizer == null) {
|
||||
return new String[]{};
|
||||
}
|
||||
short numberOfPresets = sEqualizer.getNumberOfPresets();
|
||||
|
||||
String[] presets = new String[numberOfPresets + 1];
|
||||
|
||||
presets[0] = context.getResources().getString(R.string.custom);
|
||||
|
||||
for (short n = 0; n < numberOfPresets; n++) {
|
||||
presets[n + 1] = sEqualizer.getPresetName(n);
|
||||
}
|
||||
|
||||
return presets;
|
||||
}
|
||||
|
||||
public static int getCurrentPreset() {
|
||||
if (sEqualizer == null || sCustomPreset) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sEqualizer.getCurrentPreset() + 1;
|
||||
}
|
||||
|
||||
public static void usePreset(short preset) {
|
||||
if (sEqualizer == null) {
|
||||
return;
|
||||
}
|
||||
sCustomPreset = false;
|
||||
sEqualizer.usePreset(preset);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static short getNumberOfBands() {
|
||||
if (sEqualizer == null) {
|
||||
return 0;
|
||||
}
|
||||
return sEqualizer.getNumberOfBands();
|
||||
}
|
||||
|
||||
public static int getCenterFreq(short band) {
|
||||
if (sEqualizer == null) {
|
||||
return 0;
|
||||
}
|
||||
return sEqualizer.getCenterFreq(band);
|
||||
}
|
||||
|
||||
@SuppressLint("CommitPrefEdits")
|
||||
public static void savePrefs(Context context) {
|
||||
if (sEqualizer == null || sBassBoost == null) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences prefs = context.getSharedPreferences(AUDIO_EFFECTS_PREFS,
|
||||
Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
editor.putInt(PREF_BASSBOOST, sBassBoostValues.strength);
|
||||
|
||||
short preset = sCustomPreset ? -1 : sEqualizer.getCurrentPreset();
|
||||
editor.putInt(PREF_PRESET, preset);
|
||||
|
||||
|
||||
short bands = sEqualizer.getNumberOfBands();
|
||||
|
||||
for (short b = 0; b < bands; b++) {
|
||||
short level = sEqualizer.getBandLevel(b);
|
||||
|
||||
editor.putInt(PREF_BAND_LEVEL + b, level);
|
||||
}
|
||||
editor.putBoolean(PREF_EQ_ENABLED,
|
||||
sEqualizer.getEnabled());
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
|
||||
public static String getPresetAtIndex(short i) {
|
||||
if (sEqualizer != null) {
|
||||
return sEqualizer.getPresetName(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class BassBoostValues {
|
||||
public boolean enabled;
|
||||
public short strength;
|
||||
}
|
||||
|
||||
private static class VirtualizerValues {
|
||||
public boolean enabled;
|
||||
public short strength;
|
||||
}
|
||||
|
||||
private static class EqualizerValues {
|
||||
public boolean enabled;
|
||||
public short preset;
|
||||
public short numberOfBands;
|
||||
public short[] bandLevels;
|
||||
|
||||
public boolean levelsSet = false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package code.name.monkey.retromusic.equalizer;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public class AudioEffectsReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String EXTRA_AUDIO_SESSION_ID = "org.oucho.musicplayer.EXTRA_AUDIO_SESSION_ID";
|
||||
|
||||
public static final String ACTION_OPEN_AUDIO_EFFECT_SESSION = "org.oucho.musicplayer.OPEN_AUDIO_EFFECT_SESSION";
|
||||
public static final String ACTION_CLOSE_AUDIO_EFFECT_SESSION = "org.oucho.musicplayer.CLOSE_AUDIO_EFFECT_SESSION";
|
||||
|
||||
public AudioEffectsReceiver() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
int audioSessionId = intent.getIntExtra(EXTRA_AUDIO_SESSION_ID, 0);
|
||||
if (ACTION_OPEN_AUDIO_EFFECT_SESSION.equals(action)) {
|
||||
AudioEffects.openAudioEffectSession(context, audioSessionId);
|
||||
} else if (ACTION_CLOSE_AUDIO_EFFECT_SESSION.equals(action)) {
|
||||
AudioEffects.closeAudioEffectSession();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package code.name.monkey.retromusic.equalizer;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Harjot on 09-Dec-16.
|
||||
*/
|
||||
|
||||
public class EqualizerModel implements Serializable {
|
||||
private boolean isEqualizerEnabled;
|
||||
private int[] seekbarpos = new int[5];
|
||||
private int presetPos;
|
||||
private short reverbPreset;
|
||||
private short bassStrength;
|
||||
private short virtualizerStrength;
|
||||
|
||||
public EqualizerModel() {
|
||||
isEqualizerEnabled = true;
|
||||
reverbPreset = -1;
|
||||
bassStrength = -1;
|
||||
}
|
||||
|
||||
public boolean isEqualizerEnabled() {
|
||||
return isEqualizerEnabled;
|
||||
}
|
||||
|
||||
public void setEqualizerEnabled(boolean equalizerEnabled) {
|
||||
isEqualizerEnabled = equalizerEnabled;
|
||||
}
|
||||
|
||||
public int[] getSeekbarpos() {
|
||||
return seekbarpos;
|
||||
}
|
||||
|
||||
public void setSeekbarpos(int[] seekbarpos) {
|
||||
this.seekbarpos = seekbarpos;
|
||||
}
|
||||
|
||||
public int getPresetPos() {
|
||||
return presetPos;
|
||||
}
|
||||
|
||||
public void setPresetPos(int presetPos) {
|
||||
this.presetPos = presetPos;
|
||||
}
|
||||
|
||||
public short getReverbPreset() {
|
||||
return reverbPreset;
|
||||
}
|
||||
|
||||
public void setReverbPreset(short reverbPreset) {
|
||||
this.reverbPreset = reverbPreset;
|
||||
}
|
||||
|
||||
public short getBassStrength() {
|
||||
return bassStrength;
|
||||
}
|
||||
|
||||
public void setBassStrength(short bassStrength) {
|
||||
this.bassStrength = bassStrength;
|
||||
}
|
||||
|
||||
public short getVirtualizerStrength() {
|
||||
return virtualizerStrength;
|
||||
}
|
||||
|
||||
public void setVirtualizerStrength(short virtualizerStrength) {
|
||||
this.virtualizerStrength = virtualizerStrength;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package code.name.monkey.retromusic.equalizer;
|
||||
|
||||
public class Settings {
|
||||
public static boolean isEqualizerEnabled = true;
|
||||
public static boolean isEqualizerReloaded = true;
|
||||
public static int[] seekbarpos = new int[6];
|
||||
public static int presetPos;
|
||||
public static short reverbPreset = -1, bassStrength = -1, virtualizerStrength = -1;
|
||||
public static EqualizerModel equalizerModel;
|
||||
public static double ratio = 1.0;
|
||||
public static boolean isEditing = false;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.DimenRes
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Context.dip(value: Int): Int = (value * resources.displayMetrics.density).toInt()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun Context.dimen(@DimenRes resource: Int): Int = resources.getDimensionPixelSize(resource)
|
|
@ -0,0 +1,399 @@
|
|||
package code.name.monkey.retromusic.fragments;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.media.audiofx.BassBoost;
|
||||
import android.media.audiofx.Equalizer;
|
||||
import android.media.audiofx.PresetReverb;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.equalizer.EqualizerModel;
|
||||
import code.name.monkey.retromusic.equalizer.Settings;
|
||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener;
|
||||
import code.name.monkey.retromusic.util.ViewUtil;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
*/
|
||||
public class EqualizerFragment extends Fragment {
|
||||
|
||||
private static final String ARG_AUDIO_SESSIOIN_ID = "audio_session_id";
|
||||
|
||||
private Equalizer mEqualizer;
|
||||
private BassBoost bassBoost;
|
||||
private PresetReverb presetReverb;
|
||||
|
||||
private int y = 0;
|
||||
private SeekBar[] seekBarFinal = new SeekBar[5];
|
||||
private Spinner presetSpinner;
|
||||
private int audioSesionId;
|
||||
|
||||
public EqualizerFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static EqualizerFragment newInstance(int audioSessionId) {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_AUDIO_SESSIOIN_ID, audioSessionId);
|
||||
|
||||
EqualizerFragment fragment = new EqualizerFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Settings.isEditing = true;
|
||||
|
||||
if (getArguments() != null && getArguments().containsKey(ARG_AUDIO_SESSIOIN_ID)) {
|
||||
audioSesionId = getArguments().getInt(ARG_AUDIO_SESSIOIN_ID);
|
||||
}
|
||||
|
||||
if (Settings.equalizerModel == null) {
|
||||
Settings.equalizerModel = new EqualizerModel();
|
||||
Settings.equalizerModel.setReverbPreset(PresetReverb.PRESET_NONE);
|
||||
Settings.equalizerModel.setBassStrength((short) (1000 / 19));
|
||||
}
|
||||
|
||||
mEqualizer = new Equalizer(0, audioSesionId);
|
||||
|
||||
bassBoost = new BassBoost(0, audioSesionId);
|
||||
bassBoost.setEnabled(Settings.isEqualizerEnabled);
|
||||
BassBoost.Settings bassBoostSettingTemp = bassBoost.getProperties();
|
||||
BassBoost.Settings bassBoostSetting = new BassBoost.Settings(bassBoostSettingTemp.toString());
|
||||
bassBoostSetting.strength = Settings.equalizerModel.getBassStrength();
|
||||
bassBoost.setProperties(bassBoostSetting);
|
||||
|
||||
presetReverb = new PresetReverb(0, audioSesionId);
|
||||
presetReverb.setPreset(Settings.equalizerModel.getReverbPreset());
|
||||
presetReverb.setEnabled(Settings.isEqualizerEnabled);
|
||||
|
||||
mEqualizer.setEnabled(Settings.isEqualizerEnabled);
|
||||
|
||||
if (Settings.presetPos == 0) {
|
||||
for (short bandIdx = 0; bandIdx < mEqualizer.getNumberOfBands(); bandIdx++) {
|
||||
mEqualizer.setBandLevel(bandIdx, (short) Settings.seekbarpos[bandIdx]);
|
||||
}
|
||||
} else {
|
||||
mEqualizer.usePreset((short) Settings.presetPos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_equalizer, container, false);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
SwitchCompat equalizerSwitch = view.findViewById(R.id.equalizer_switch);
|
||||
equalizerSwitch.setChecked(Settings.isEqualizerEnabled);
|
||||
TintHelper.setTint(equalizerSwitch, ThemeStore.Companion.accentColor(requireContext()), ATHUtil.INSTANCE.isWindowBackgroundDark(requireContext()));
|
||||
equalizerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
mEqualizer.setEnabled(isChecked);
|
||||
bassBoost.setEnabled(isChecked);
|
||||
presetReverb.setEnabled(isChecked);
|
||||
Settings.isEqualizerEnabled = isChecked;
|
||||
Settings.equalizerModel.setEqualizerEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
presetSpinner = view.findViewById(R.id.equalizer_preset_spinner);
|
||||
|
||||
FrameLayout equalizerBlocker = view.findViewById(R.id.equalizerBlocker);
|
||||
|
||||
SeekBar bassController = view.findViewById(R.id.bassController);
|
||||
SeekBar reverbController = view.findViewById(R.id.reverbController);
|
||||
|
||||
if (!Settings.isEqualizerReloaded) {
|
||||
int x = 0;
|
||||
if (bassBoost != null) {
|
||||
try {
|
||||
x = ((bassBoost.getRoundedStrength() * 19) / 1000);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (presetReverb != null) {
|
||||
try {
|
||||
y = (presetReverb.getPreset() * 19) / 6;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (x == 0) {
|
||||
bassController.setProgress(1);
|
||||
} else {
|
||||
bassController.setProgress(x);
|
||||
}
|
||||
|
||||
if (y == 0) {
|
||||
reverbController.setProgress(1);
|
||||
} else {
|
||||
reverbController.setProgress(y);
|
||||
}
|
||||
} else {
|
||||
int x = ((Settings.bassStrength * 19) / 1000);
|
||||
y = (Settings.reverbPreset * 19) / 6;
|
||||
if (x == 0) {
|
||||
bassController.setProgress(1);
|
||||
} else {
|
||||
bassController.setProgress(x);
|
||||
}
|
||||
|
||||
if (y == 0) {
|
||||
reverbController.setProgress(1);
|
||||
} else {
|
||||
reverbController.setProgress(y);
|
||||
}
|
||||
}
|
||||
TintHelper.setTint(bassController, ThemeStore.Companion.accentColor(requireContext()), ATHUtil.INSTANCE.isWindowBackgroundDark(requireContext()));
|
||||
bassController.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(@NotNull SeekBar seekBar, int progress, boolean fromUser) {
|
||||
super.onProgressChanged(seekBar, progress, fromUser);
|
||||
Settings.bassStrength = (short) (((float) 1000 / 19) * (progress));
|
||||
try {
|
||||
bassBoost.setStrength(Settings.bassStrength);
|
||||
Settings.equalizerModel.setBassStrength(Settings.bassStrength);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TintHelper.setTint(reverbController, ThemeStore.Companion.accentColor(requireContext()), ATHUtil.INSTANCE.isWindowBackgroundDark(requireContext()));
|
||||
reverbController.setOnSeekBarChangeListener(new SimpleOnSeekbarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(@NotNull SeekBar seekBar, int progress, boolean fromUser) {
|
||||
super.onProgressChanged(seekBar, progress, fromUser);
|
||||
Settings.reverbPreset = (short) ((progress * 6) / 19);
|
||||
Settings.equalizerModel.setReverbPreset(Settings.reverbPreset);
|
||||
try {
|
||||
presetReverb.setPreset(Settings.reverbPreset);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
y = progress;
|
||||
}
|
||||
});
|
||||
|
||||
TextView equalizerHeading = new TextView(getContext());
|
||||
equalizerHeading.setText(R.string.equalizer);
|
||||
equalizerHeading.setTextSize(20);
|
||||
equalizerHeading.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
|
||||
short numberOfFrequencyBands = 5;
|
||||
|
||||
|
||||
final short lowerEqualizerBandLevel = mEqualizer.getBandLevelRange()[0];
|
||||
final short upperEqualizerBandLevel = mEqualizer.getBandLevelRange()[1];
|
||||
|
||||
for (short i = 0; i < numberOfFrequencyBands; i++) {
|
||||
final short equalizerBandIndex = i;
|
||||
final TextView frequencyHeaderTextView = new TextView(getContext());
|
||||
frequencyHeaderTextView.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
frequencyHeaderTextView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
frequencyHeaderTextView.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
frequencyHeaderTextView.setText((mEqualizer.getCenterFreq(equalizerBandIndex) / 1000) + "Hz");
|
||||
|
||||
LinearLayout seekBarRowLayout = new LinearLayout(getContext());
|
||||
seekBarRowLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
TextView lowerEqualizerBandLevelTextView = new TextView(getContext());
|
||||
lowerEqualizerBandLevelTextView.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
));
|
||||
lowerEqualizerBandLevelTextView.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
lowerEqualizerBandLevelTextView.setText((lowerEqualizerBandLevel / 100) + "dB");
|
||||
|
||||
TextView upperEqualizerBandLevelTextView = new TextView(getContext());
|
||||
lowerEqualizerBandLevelTextView.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
upperEqualizerBandLevelTextView.setTextColor(Color.parseColor("#FFFFFF"));
|
||||
upperEqualizerBandLevelTextView.setText((upperEqualizerBandLevel / 100) + "dB");
|
||||
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
layoutParams.weight = 1;
|
||||
|
||||
SeekBar seekBar = new SeekBar(getContext());
|
||||
TextView textView = new TextView(getContext());
|
||||
switch (i) {
|
||||
case 0:
|
||||
seekBar = view.findViewById(R.id.seekBar1);
|
||||
textView = view.findViewById(R.id.textView1);
|
||||
break;
|
||||
case 1:
|
||||
seekBar = view.findViewById(R.id.seekBar2);
|
||||
textView = view.findViewById(R.id.textView2);
|
||||
break;
|
||||
case 2:
|
||||
seekBar = view.findViewById(R.id.seekBar3);
|
||||
textView = view.findViewById(R.id.textView3);
|
||||
break;
|
||||
case 3:
|
||||
seekBar = view.findViewById(R.id.seekBar4);
|
||||
textView = view.findViewById(R.id.textView4);
|
||||
break;
|
||||
case 4:
|
||||
seekBar = view.findViewById(R.id.seekBar5);
|
||||
textView = view.findViewById(R.id.textView5);
|
||||
break;
|
||||
}
|
||||
seekBarFinal[i] = seekBar;
|
||||
ViewUtil.INSTANCE.setProgressDrawable(seekBar, ThemeStore.Companion.accentColor(requireContext()), true);
|
||||
seekBar.setId(i);
|
||||
seekBar.setMax(upperEqualizerBandLevel - lowerEqualizerBandLevel);
|
||||
|
||||
textView.setText(frequencyHeaderTextView.getText());
|
||||
|
||||
if (Settings.isEqualizerReloaded) {
|
||||
|
||||
seekBar.setProgress(Settings.seekbarpos[i] - lowerEqualizerBandLevel);
|
||||
} else {
|
||||
|
||||
seekBar.setProgress(mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel);
|
||||
Settings.seekbarpos[i] = mEqualizer.getBandLevel(equalizerBandIndex);
|
||||
Settings.isEqualizerReloaded = true;
|
||||
}
|
||||
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
mEqualizer.setBandLevel(equalizerBandIndex, (short) (progress + lowerEqualizerBandLevel));
|
||||
|
||||
Settings.seekbarpos[seekBar.getId()] = (progress + lowerEqualizerBandLevel);
|
||||
Settings.equalizerModel.getSeekbarpos()[seekBar.getId()] = (progress + lowerEqualizerBandLevel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
presetSpinner.setSelection(0);
|
||||
Settings.presetPos = 0;
|
||||
Settings.equalizerModel.setPresetPos(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
equalizeSound();
|
||||
|
||||
}
|
||||
|
||||
void equalizeSound() {
|
||||
ArrayList<String> equalizerPresetNames = new ArrayList<>();
|
||||
ArrayAdapter<String> equalizerPresetSpinnerAdapter = new ArrayAdapter<>(requireContext(),
|
||||
R.layout.dropdown_item,
|
||||
equalizerPresetNames);
|
||||
equalizerPresetSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
equalizerPresetNames.add("Custom");
|
||||
|
||||
for (short i = 0; i < mEqualizer.getNumberOfPresets(); i++) {
|
||||
equalizerPresetNames.add(mEqualizer.getPresetName(i));
|
||||
}
|
||||
|
||||
presetSpinner.setAdapter(equalizerPresetSpinnerAdapter);
|
||||
if (Settings.isEqualizerReloaded && Settings.presetPos != 0) {
|
||||
presetSpinner.setSelection(Settings.presetPos);
|
||||
}
|
||||
|
||||
presetSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
try {
|
||||
if (position != 0) {
|
||||
mEqualizer.usePreset((short) (position - 1));
|
||||
Settings.presetPos = position;
|
||||
short numberOfFreqBands = 5;
|
||||
|
||||
final short lowerEqualizerBandLevel = mEqualizer.getBandLevelRange()[0];
|
||||
|
||||
for (short i = 0; i < numberOfFreqBands; i++) {
|
||||
seekBarFinal[i].setProgress(mEqualizer.getBandLevel(i) - lowerEqualizerBandLevel);
|
||||
|
||||
Settings.seekbarpos[i] = mEqualizer.getBandLevel(i);
|
||||
Settings.equalizerModel.getSeekbarpos()[i] = mEqualizer.getBandLevel(i);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(requireContext(), "Error while updating Equalizer", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
Settings.equalizerModel.setPresetPos(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mEqualizer != null) {
|
||||
mEqualizer.release();
|
||||
}
|
||||
|
||||
if (bassBoost != null) {
|
||||
bassBoost.release();
|
||||
}
|
||||
|
||||
if (presetReverb != null) {
|
||||
presetReverb.release();
|
||||
}
|
||||
|
||||
Settings.isEditing = false;
|
||||
}
|
||||
}
|
|
@ -8,17 +8,13 @@ import androidx.annotation.NonNull
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.*
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
|
||||
abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
|
||||
AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener {
|
||||
AbsLibraryPagerFragment() {
|
||||
|
||||
protected var adapter: A? = null
|
||||
protected var layoutManager: LM? = null
|
||||
|
@ -31,7 +27,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mainActivity.addOnAppBarOffsetChangedListener(this)
|
||||
initLayoutManager()
|
||||
initAdapter()
|
||||
setUpRecyclerView()
|
||||
|
@ -41,13 +36,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
val fastScroller = create(recyclerView)
|
||||
recyclerView.setOnApplyWindowInsetsListener(
|
||||
ScrollingViewOnApplyWindowInsetsListener(
|
||||
recyclerView,
|
||||
fastScroller
|
||||
)
|
||||
)
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
protected open fun createFastScroller(recyclerView: RecyclerView): FastScroller {
|
||||
|
@ -60,7 +48,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
checkIsEmpty()
|
||||
checkForPadding()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -78,18 +65,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
empty.visibility = if (adapter!!.itemCount == 0) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
private fun checkForPadding() {
|
||||
val itemCount: Int = adapter?.itemCount ?: 0
|
||||
val params = container.layoutParams as ViewGroup.MarginLayoutParams
|
||||
if (itemCount > 0 && MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
val height = DensityUtil.dip2px(requireContext(), 104f)
|
||||
params.bottomMargin = height
|
||||
} else {
|
||||
val height = DensityUtil.dip2px(requireContext(), 52f)
|
||||
params.bottomMargin = height
|
||||
}
|
||||
}
|
||||
|
||||
private fun initLayoutManager() {
|
||||
layoutManager = createLayoutManager()
|
||||
}
|
||||
|
@ -99,25 +74,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
@NonNull
|
||||
protected abstract fun createAdapter(): A
|
||||
|
||||
override fun onOffsetChanged(p0: AppBarLayout?, i: Int) {
|
||||
container.setPadding(
|
||||
container.paddingLeft,
|
||||
container.paddingTop,
|
||||
container.paddingRight,
|
||||
mainActivity.totalAppBarScrollingRange + i
|
||||
)
|
||||
}
|
||||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
checkForPadding()
|
||||
}
|
||||
|
||||
protected fun invalidateLayoutManager() {
|
||||
initLayoutManager()
|
||||
recyclerView.layoutManager = layoutManager
|
||||
|
@ -129,11 +85,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mainActivity.removeOnAppBarOffsetChangedListener(this)
|
||||
}
|
||||
|
||||
fun recyclerView(): RecyclerView {
|
||||
return recyclerView
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import code.name.monkey.retromusic.model.Album
|
|||
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.AlbumsView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class AlbumsFragment :
|
||||
|
@ -51,7 +52,7 @@ class AlbumsFragment :
|
|||
get() = R.string.no_albums
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireActivity(), getGridSize())
|
||||
return OverScrollGridLayoutManager(requireActivity(), getGridSize())
|
||||
}
|
||||
|
||||
override fun createAdapter(): AlbumAdapter {
|
||||
|
|
|
@ -12,6 +12,7 @@ import code.name.monkey.retromusic.model.Artist
|
|||
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.ArtistsView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class ArtistsFragment :
|
||||
|
@ -63,7 +64,7 @@ class ArtistsFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireActivity(), getGridSize())
|
||||
return OverScrollGridLayoutManager(requireActivity(), getGridSize())
|
||||
}
|
||||
|
||||
override fun createAdapter(): ArtistAdapter {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.util.DisplayMetrics
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.Constants
|
||||
|
@ -41,9 +42,12 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.abs_playlists.*
|
||||
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
||||
import kotlinx.android.synthetic.main.home_content.*
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
@ -119,7 +123,10 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
}
|
||||
|
||||
actionShuffle.setOnClickListener {
|
||||
MusicPlayerRemote.openAndShuffleQueue(SongLoader.getAllSongs(requireActivity()), true)
|
||||
lifecycleScope.launch {
|
||||
val songs = async { SongLoader.getAllSongs(requireContext()) }
|
||||
MusicPlayerRemote.openAndShuffleQueue(songs.await(), true)
|
||||
}
|
||||
}
|
||||
|
||||
history.setOnClickListener {
|
||||
|
@ -141,7 +148,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
|||
homeAdapter = HomeAdapter(mainActivity, displayMetrics)
|
||||
|
||||
recyclerView.apply {
|
||||
layoutManager = LinearLayoutManager(mainActivity)
|
||||
layoutManager = OverScrollLinearLayoutManager(mainActivity)
|
||||
adapter = homeAdapter
|
||||
}
|
||||
homePresenter.attachView(this)
|
||||
|
|
|
@ -74,6 +74,7 @@ import code.name.monkey.retromusic.util.RetroColorUtil;
|
|||
import code.name.monkey.retromusic.util.ThemedFastScroller;
|
||||
import code.name.monkey.retromusic.views.BreadCrumbLayout;
|
||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener;
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager;
|
||||
import me.zhanghai.android.fastscroll.FastScroller;
|
||||
|
||||
public class FoldersFragment extends AbsMainActivityFragment implements
|
||||
|
@ -478,7 +479,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
|
||||
private void setUpRecyclerView() {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
recyclerView.setLayoutManager(new OverScrollLinearLayoutManager(getActivity()));
|
||||
FastScroller fastScroller = ThemedFastScroller.INSTANCE.create(recyclerView);
|
||||
recyclerView.setOnApplyWindowInsetsListener(
|
||||
new ScrollingViewOnApplyWindowInsetsListener(recyclerView, fastScroller));
|
||||
|
|
|
@ -25,6 +25,7 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
|||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.GenresView
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
||||
|
@ -42,7 +43,7 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
return LinearLayoutManager(activity)
|
||||
return OverScrollLinearLayoutManager(activity)
|
||||
}
|
||||
|
||||
override fun createAdapter(): GenreAdapter {
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropM
|
|||
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollLinearLayoutManager
|
||||
import kotlinx.android.synthetic.main.activity_playing_queue.*
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ class PlayingQueueFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
return LinearLayoutManager(requireContext())
|
||||
return OverScrollLinearLayoutManager(requireContext())
|
||||
}
|
||||
|
||||
override fun createAdapter(): PlayingQueueAdapter {
|
||||
|
|
|
@ -13,6 +13,7 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
|||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistView
|
||||
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import javax.inject.Inject
|
||||
|
||||
class PlaylistsFragment :
|
||||
|
@ -40,7 +41,7 @@ class PlaylistsFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireContext(), 1)
|
||||
return OverScrollGridLayoutManager(requireContext(), 1)
|
||||
}
|
||||
|
||||
override fun createAdapter(): PlaylistAdapter {
|
||||
|
|
|
@ -14,6 +14,7 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import dev.olog.scrollhelper.layoutmanagers.OverScrollGridLayoutManager
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -39,7 +40,7 @@ class SongsFragment :
|
|||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(requireActivity(), getGridSize()).apply {
|
||||
return OverScrollGridLayoutManager(requireActivity(), getGridSize()).apply {
|
||||
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||
override fun getSpanSize(position: Int): Int {
|
||||
return if (position == 0) {
|
||||
|
|
|
@ -16,7 +16,6 @@ package code.name.monkey.retromusic.fragments.settings
|
|||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.TwoStatePreference
|
||||
import code.name.monkey.appthemehelper.ACCENT_COLORS
|
||||
|
@ -54,9 +53,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue(theme))
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
}
|
||||
Handler().postDelayed({
|
||||
requireActivity().recreate()
|
||||
}, 400)
|
||||
requireActivity().recreate()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
@ -78,9 +75,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
ThemeStore.editTheme(requireContext()).accentColor(color).commit()
|
||||
if (VersionUtils.hasNougatMR())
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
Handler().postDelayed({
|
||||
requireActivity().recreate()
|
||||
}, 400)
|
||||
requireActivity().recreate()
|
||||
}
|
||||
}
|
||||
return@setOnPreferenceClickListener true
|
||||
|
@ -96,9 +91,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue("black"))
|
||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||
}
|
||||
Handler().postDelayed({
|
||||
requireActivity().recreate()
|
||||
}, 400)
|
||||
requireActivity().recreate()
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -109,9 +102,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
|||
ThemeStore.prefs(requireContext()).edit().putBoolean("desaturated_color", desaturated)
|
||||
.apply()
|
||||
PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated)
|
||||
Handler().postDelayed({
|
||||
requireActivity().recreate()
|
||||
}, 400)
|
||||
requireActivity().recreate()
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package code.name.monkey.retromusic.model;
|
||||
|
||||
public class Band {
|
||||
public final int centerFreq;
|
||||
public short level;
|
||||
|
||||
private final int[] freqRange;
|
||||
public final int freqLow;
|
||||
public final int freqHigh;
|
||||
public final short rangeMin;
|
||||
public final short rangeMax;
|
||||
|
||||
public Band(int centerFreq, short level, int[] freqRange, short rangeMin, short rangeMax) {
|
||||
this.centerFreq = centerFreq;
|
||||
this.level = level;
|
||||
this.freqRange = freqRange;
|
||||
|
||||
if (0 < freqRange.length) {
|
||||
freqLow = freqRange[0];
|
||||
freqHigh = freqRange[freqRange.length - 1];
|
||||
} else {
|
||||
freqLow = 0;
|
||||
freqHigh = 0;
|
||||
}
|
||||
|
||||
this.rangeMin = rangeMin;
|
||||
this.rangeMax = rangeMax;
|
||||
}
|
||||
}
|
|
@ -68,6 +68,7 @@ import code.name.monkey.retromusic.appwidgets.AppWidgetCard;
|
|||
import code.name.monkey.retromusic.appwidgets.AppWidgetClassic;
|
||||
import code.name.monkey.retromusic.appwidgets.AppWidgetSmall;
|
||||
import code.name.monkey.retromusic.appwidgets.AppWidgetText;
|
||||
import code.name.monkey.retromusic.equalizer.AudioEffectsReceiver;
|
||||
import code.name.monkey.retromusic.glide.BlurTransformation;
|
||||
import code.name.monkey.retromusic.glide.SongGlideRequest;
|
||||
import code.name.monkey.retromusic.helper.ShuffleHelper;
|
||||
|
@ -392,6 +393,11 @@ public class MusicService extends Service implements
|
|||
|
||||
registerHeadsetEvents();
|
||||
registerBluetoothConnected();
|
||||
|
||||
Intent i = new Intent(this, AudioEffectsReceiver.class);
|
||||
i.setAction(AudioEffectsReceiver.ACTION_OPEN_AUDIO_EFFECT_SESSION);
|
||||
i.putExtra(AudioEffectsReceiver.EXTRA_AUDIO_SESSION_ID, getAudioSessionId());
|
||||
sendBroadcast(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -416,7 +422,9 @@ public class MusicService extends Service implements
|
|||
getContentResolver().unregisterContentObserver(mediaStoreObserver);
|
||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
|
||||
wakeLock.release();
|
||||
|
||||
Intent i = new Intent(this, AudioEffectsReceiver.class);
|
||||
i.setAction(AudioEffectsReceiver.ACTION_CLOSE_AUDIO_EFFECT_SESSION);
|
||||
sendBroadcast(i);
|
||||
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED"));
|
||||
}
|
||||
|
||||
|
|
|
@ -168,4 +168,4 @@ class PlaybackHandler extends Handler {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package code.name.monkey.retromusic.util
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
const val THREAD_COUNT = 3
|
||||
|
||||
/**
|
||||
* Global executor pools for the whole application.
|
||||
*
|
||||
* Grouping tasks like this avoids the effects of task starvation (e.g. disk reads don't wait behind
|
||||
* webservice requests).
|
||||
*/
|
||||
open class AppExecutors constructor(
|
||||
val ioContext: CoroutineDispatcher = Dispatchers.IO
|
||||
)
|
|
@ -18,11 +18,13 @@ import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
|||
import code.name.monkey.appthemehelper.util.ColorUtil.isColorLight
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper.getPrimaryTextColor
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.dimen
|
||||
import code.name.monkey.retromusic.extensions.dip
|
||||
import code.name.monkey.retromusic.views.PopupBackground
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
import me.zhanghai.android.fastscroll.PopupStyles
|
||||
import me.zhanghai.android.fastscroll.R
|
||||
|
||||
object ThemedFastScroller {
|
||||
fun create(view: ViewGroup): FastScroller {
|
||||
|
@ -37,6 +39,13 @@ object ThemedFastScroller {
|
|||
popupText.setTextColor(textColor)
|
||||
}
|
||||
|
||||
fastScrollerBuilder.setPadding(
|
||||
0,
|
||||
view.context.dimen(R.dimen.toolbar_height) + view.context.dip(8),
|
||||
0,
|
||||
view.context.dimen(R.dimen.mini_player_height)
|
||||
)
|
||||
|
||||
fastScrollerBuilder.setThumbDrawable(
|
||||
TintHelper.createTintedDrawable(
|
||||
context,
|
||||
|
|
|
@ -1,59 +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.retromusic.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class StatusBarView extends View {
|
||||
|
||||
|
||||
public StatusBarView(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public StatusBarView(@NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public StatusBarView(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(@NonNull Resources r) {
|
||||
int result = 0;
|
||||
int resourceId = r.getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = r.getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), getStatusBarHeight(getResources()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package code.name.monkey.retromusic.views
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
|
||||
class StatusBarView(
|
||||
context: Context,
|
||||
attrs: AttributeSet
|
||||
) : View(context, attrs) {
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
if (isInEditMode){
|
||||
return
|
||||
}
|
||||
setOnApplyWindowInsetsListener { _, insets ->
|
||||
val height = insets?.systemWindowInsetTop ?: 0
|
||||
setHeight(height)
|
||||
insets
|
||||
}
|
||||
}
|
||||
|
||||
private fun setHeight(px: Int) {
|
||||
val params = layoutParams ?: return
|
||||
params.height = px
|
||||
layoutParams = params
|
||||
}
|
||||
|
||||
}
|
8
app/src/main/res/drawable/custom_equalizer_thumb.xml
Executable file
8
app/src/main/res/drawable/custom_equalizer_thumb.xml
Executable file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/custom_thumb_src" android:state_enabled="false" />
|
||||
<item android:drawable="@drawable/custom_thumb_src" android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/custom_thumb_src" android:state_selected="true" />
|
||||
<item android:drawable="@drawable/custom_thumb_src" />
|
||||
</selector>
|
11
app/src/main/res/drawable/custom_thumb_src.xml
Executable file
11
app/src/main/res/drawable/custom_thumb_src.xml
Executable file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<solid android:color="#FFFFFF" />
|
||||
<!--<solid android:color="#FFA036" />-->
|
||||
|
||||
<size
|
||||
android:width="16dp"
|
||||
android:height="16dp" />
|
||||
</shape>
|
BIN
app/src/main/res/drawable/graph_back_2.png
Executable file
BIN
app/src/main/res/drawable/graph_back_2.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<corners android:radius="35dp" />
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/md_white_1000" />
|
||||
android:width="1dp"
|
||||
android:color="?android:attr/textColorSecondary" />
|
||||
|
||||
</shape>
|
145
app/src/main/res/layout/activity_equalizer.xml
Normal file
145
app/src/main/res/layout/activity_equalizer.xml
Normal file
|
@ -0,0 +1,145 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout 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">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_collapseMode="pin"
|
||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
|
||||
app:title="@string/equalizer">
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/equalizerSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:padding="16dp"
|
||||
android:textAppearance="@style/TextViewSubtitle2" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/line_button"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:padding="16dp"
|
||||
android:text="@string/select_preset"
|
||||
android:textAppearance="@style/TextViewSubtitle1" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/presets"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:spinnerMode="dialog" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/frequencyBands"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="16dp"
|
||||
android:background="?android:attr/dividerHorizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/bassBoost"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:padding="16dp"
|
||||
android:text="@string/bass_boost"
|
||||
android:textAppearance="@style/TextViewSubtitle1" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/bassBoostStrength"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:max="1000"
|
||||
android:maxHeight="3dp"
|
||||
android:padding="16dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:splitTrack="false"
|
||||
tools:progress="20" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/virtualizer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:padding="16dp"
|
||||
android:text="@string/virtualizer"
|
||||
android:textAppearance="@style/TextViewSubtitle1" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/virtualizerStrength"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:max="1000"
|
||||
android:maxHeight="3dp"
|
||||
android:padding="16dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:splitTrack="false"
|
||||
tools:progress="20" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:text="*Warning: It's alpha version. We don't recommend to use Equalizer, We believe without using Equalizer songs has better sound quality." />
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -1,79 +1,71 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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:background="?colorSurface"
|
||||
android:orientation="vertical">
|
||||
android:background="?colorSurface">
|
||||
|
||||
<!-- TODO in order to work, children has to be defined in reverse drawing order-->
|
||||
<!-- TODO so: first fragment_container, than toolbar, than statusbar -->
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/status_bar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
app:layout_constraintTop_toBottomOf="@+id/status_bar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:elevation="0dp"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<include layout="@layout/status_bar" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:elevation="0dp"
|
||||
app:elevation="0dp"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:background="?attr/colorSurface"
|
||||
app:popupTheme="?attr/toolbarPopupTheme"
|
||||
app:titleTextColor="?attr/colorControlNormal"
|
||||
app:titleTextAppearance="@style/TextViewHeadline6"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/appTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="?attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextViewHeadline6" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/cab_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height" />
|
||||
</FrameLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:layout_scrollFlags="scroll|enterAlways">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:background="?attr/colorSurface"
|
||||
app:popupTheme="?attr/toolbarPopupTheme"
|
||||
app:titleTextColor="?attr/colorControlNormal"
|
||||
app:titleTextAppearance="@style/TextViewHeadline6"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/appTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="?attr/colorControlNormal"
|
||||
android:textAppearance="@style/TextViewHeadline6" />
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/cab_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height" />
|
||||
</FrameLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<include layout="@layout/status_bar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_width="0dp"
|
||||
tools:layout_height="24dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -97,7 +97,8 @@
|
|||
app:retroCornerSize="36dp"
|
||||
app:srcCompat="@drawable/ic_person_flat"
|
||||
app:strokeColor="?attr/colorSurface"
|
||||
app:strokeWidth="2dp" />
|
||||
app:strokeWidth="2dp"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
9
app/src/main/res/layout/dropdown_item.xml
Normal file
9
app/src/main/res/layout/dropdown_item.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.textview.MaterialTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:textAppearance="@style/TextViewBody1"
|
||||
tools:text="@tools:sample/full_names" />
|
33
app/src/main/res/layout/equalizer_slider.xml
Normal file
33
app/src/main/res/layout/equalizer_slider.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/frequency"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:maxLines="1" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/seekBar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="5" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dbLevel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:maxLines="1" />
|
||||
|
||||
</LinearLayout>
|
|
@ -17,6 +17,7 @@
|
|||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/toolbar_height"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
318
app/src/main/res/layout/fragment_equalizer.xml
Normal file
318
app/src/main/res/layout/fragment_equalizer.xml
Normal file
|
@ -0,0 +1,318 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout 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">
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/equalizer_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/equalizer_preset_spinner"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:background="@drawable/line_button"
|
||||
android:spinnerMode="dialog"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/equalizer_switch" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/equalizerContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintDimensionRatio="4:3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/equalizer_preset_spinner">
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
|
||||
android:id="@+id/seekBar1Wrap"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/textView1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/seekBar2Wrap"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
|
||||
android:id="@+id/seekBar1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:seekBarRotation="CW270"
|
||||
tools:progress="100" />
|
||||
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/seekBar1Wrap"
|
||||
app:layout_constraintStart_toStartOf="@id/seekBar1Wrap"
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar1Wrap"
|
||||
tools:text="10000 Hz" />
|
||||
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
|
||||
android:id="@+id/seekBar2Wrap"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/textView2"
|
||||
app:layout_constraintEnd_toStartOf="@+id/seekBar3Wrap"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/seekBar1Wrap"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
|
||||
android:id="@+id/seekBar2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:seekBarRotation="CW270"
|
||||
tools:progress="100" />
|
||||
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/seekBar2Wrap"
|
||||
app:layout_constraintStart_toStartOf="@id/seekBar2Wrap"
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar2Wrap"
|
||||
tools:text="10000 Hz" />
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
|
||||
android:id="@+id/seekBar3Wrap"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="8"
|
||||
app:layout_constraintBottom_toTopOf="@id/textView3"
|
||||
app:layout_constraintEnd_toStartOf="@+id/seekBar4Wrap"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/seekBar2Wrap"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteY="3dp">
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
|
||||
android:id="@+id/seekBar3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:seekBarRotation="CW270" />
|
||||
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/seekBar3Wrap"
|
||||
app:layout_constraintStart_toStartOf="@id/seekBar3Wrap"
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar3Wrap"
|
||||
tools:text="10000 Hz" />
|
||||
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
|
||||
android:id="@+id/seekBar4Wrap"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/textView4"
|
||||
app:layout_constraintEnd_toStartOf="@+id/seekBar5Wrap"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/seekBar3Wrap"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteY="3dp">
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
|
||||
android:id="@+id/seekBar4"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:seekBarRotation="CW270" />
|
||||
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/seekBar4Wrap"
|
||||
app:layout_constraintStart_toStartOf="@id/seekBar4Wrap"
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar4Wrap"
|
||||
tools:text="10000 Hz" />
|
||||
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper
|
||||
android:id="@+id/seekBar5Wrap"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/textView5"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/seekBar4Wrap"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteY="3dp">
|
||||
|
||||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBar
|
||||
android:id="@+id/seekBar5"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:seekBarRotation="CW270" />
|
||||
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper>
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@id/seekBar5Wrap"
|
||||
app:layout_constraintStart_toStartOf="@id/seekBar5Wrap"
|
||||
app:layout_constraintTop_toBottomOf="@id/seekBar5Wrap"
|
||||
tools:text="10000 Hz" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/equalizerContainer" />
|
||||
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/bassBoostText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:text="@string/bass_boost"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/divider"
|
||||
app:layout_constraintVertical_bias="0.5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/bassController"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:layout_constraintBottom_toBottomOf="@id/bassBoostText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/bassBoostText"
|
||||
app:layout_constraintTop_toTopOf="@id/bassBoostText" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/controllerText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:text="@string/virtualizer"
|
||||
android:textAppearance="@style/TextViewNormal"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/bassBoostText"
|
||||
app:layout_constraintVertical_bias="0.5" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/reverbController"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
app:layout_constraintBottom_toBottomOf="@id/controllerText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/controllerText"
|
||||
app:layout_constraintTop_toTopOf="@id/controllerText" />
|
||||
|
||||
<!--<code.name.monkey.retromusic.equalizer.AnalogController
|
||||
android:id="@+id/controllerBass"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/controller3D"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/equalizer_preset_spinner" />
|
||||
|
||||
|
||||
<code.name.monkey.retromusic.equalizer.AnalogController
|
||||
android:id="@+id/controller3D"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/controllerBass"
|
||||
app:layout_constraintTop_toBottomOf="@id/equalizer_preset_spinner" />-->
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/equalizerBlocker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:alpha="0.7"
|
||||
android:background="@android:color/transparent"
|
||||
android:clickable="true"
|
||||
android:visibility="invisible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -17,6 +17,7 @@
|
|||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/toolbar_height"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- TODO note that recycler view has to cover the entire screen -->
|
||||
<!-- TODO so has to be drawn under bottom navigation, toolbar, ecc, but has to be below statusbar-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none"
|
||||
app:layout_dodgeInsetEdges="bottom"
|
||||
tools:listitem="@layout/item_list" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
27
app/src/main/res/layout/freq_level_item.xml
Normal file
27
app/src/main/res/layout/freq_level_item.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/centerFreq"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="12Khz" />
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/seekBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/currentLevel"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</LinearLayout>
|
42
app/src/main/res/layout/retro_seekbar.xml
Normal file
42
app/src/main/res/layout/retro_seekbar.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/hurtz"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="0dp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintEnd_toStartOf="@id/guideline"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="10000 Hz" />
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/seekbar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="3dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:splitTrack="false"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/guideline"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:progress="20" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintGuide_begin="72dp" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -37,7 +37,7 @@
|
|||
android:id="@+id/miniPlayerFragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.MiniPlayerFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_height="@dimen/mini_player_height"
|
||||
tools:layout="@layout/fragment_mini_player" />
|
||||
|
||||
</FrameLayout>
|
||||
|
|
28
app/src/main/res/layout/test.xml
Normal file
28
app/src/main/res/layout/test.xml
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
style="@style/Toolbar"
|
||||
app:layout_collapseMode="pin"
|
||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
|
||||
app:title="@string/equalizer"
|
||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/contentFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -844,5 +844,7 @@
|
|||
<string name="start_payment">Start payment</string>
|
||||
<string name="pref_title_expand_now_playing_panel">Show now playing screen</string>
|
||||
<string name="pref_summary_expand_now_playing_panel">Clicking on the notification will show now playing screen instead of the home screen</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="select_preset">Select preset</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
<style name="Theme.RetroMusic" parent="Theme.RetroMusic.Base" />
|
||||
|
||||
<style name="Theme.RetroMusic.Light" parent="Theme.RetroMusic.Base.Light" >
|
||||
<style name="Theme.RetroMusic.Light" parent="Theme.RetroMusic.Base.Light">
|
||||
<item name="android:windowBackground">@color/window_color_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.Black" parent="Theme.RetroMusic.Base.Black" >
|
||||
<style name="Theme.RetroMusic.Black" parent="Theme.RetroMusic.Base.Black">
|
||||
<item name="android:windowBackground">@color/window_color_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.RetroMusic.FollowSystem" parent="Theme.RetroMusic.Base.Adaptive" >
|
||||
<style name="Theme.RetroMusic.FollowSystem" parent="Theme.RetroMusic.Base.Adaptive">
|
||||
<item name="android:windowBackground">@color/window_color</item>
|
||||
</style>
|
||||
|
||||
|
@ -211,4 +211,10 @@
|
|||
<item name="android:background">@color/md_white_1000</item>
|
||||
<item name="android:textColor">@color/md_red_400</item>
|
||||
</style>
|
||||
|
||||
<style name="AppRadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton">
|
||||
<item name="android:textSize">16dp</item>
|
||||
<item name="android:textColor">#b4b4ba</item>
|
||||
<item name="android:minHeight">40dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -10,22 +10,14 @@ import code.name.monkey.appthemehelper.ThemeStore
|
|||
/**
|
||||
* @author Aidan Follestad (afollestad)
|
||||
*/
|
||||
class ATESwitch : SwitchCompat {
|
||||
class ATESwitch @JvmOverloads constructor(
|
||||
context: Context?,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : SwitchCompat(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) {
|
||||
ATH.setTint(this, ThemeStore.accentColor(context))
|
||||
init {
|
||||
ATH.setTint(this, ThemeStore.accentColor(getContext()))
|
||||
}
|
||||
|
||||
override fun isShown(): Boolean {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue