couple widget color corrections
This commit is contained in:
parent
a784d24c03
commit
aaedca38e2
3 changed files with 8 additions and 13 deletions
|
@ -2,7 +2,6 @@ package com.simplemobiletools.musicplayer.activities
|
|||
|
||||
import android.app.Activity
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
|
@ -11,10 +10,8 @@ import android.support.v7.app.AppCompatActivity
|
|||
import android.widget.RemoteViews
|
||||
import android.widget.SeekBar
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.helpers.Config
|
||||
import com.simplemobiletools.musicplayer.helpers.MyWidgetProvider
|
||||
import com.simplemobiletools.musicplayer.helpers.PREFS_KEY
|
||||
import com.simplemobiletools.musicplayer.helpers.WIDGET_BG_COLOR
|
||||
import com.simplemobiletools.musicplayer.helpers.WIDGET_TEXT_COLOR
|
||||
import com.simplemobiletools.musicplayer.services.MusicService
|
||||
import kotlinx.android.synthetic.main.widget.*
|
||||
import kotlinx.android.synthetic.main.widget_config.*
|
||||
|
@ -56,8 +53,8 @@ class WidgetConfigureActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun initVariables() {
|
||||
val prefs = getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE)
|
||||
mBgColor = prefs.getInt(WIDGET_BG_COLOR, 1)
|
||||
val config = Config.newInstance(this)
|
||||
mBgColor = config.widgetBgColor
|
||||
if (mBgColor == 1) {
|
||||
mBgColor = Color.BLACK
|
||||
mBgAlpha = .2f
|
||||
|
@ -70,7 +67,7 @@ class WidgetConfigureActivity : AppCompatActivity() {
|
|||
config_bg_seekbar.progress = (mBgAlpha * 100).toInt()
|
||||
updateBackgroundColor()
|
||||
|
||||
mTextColor = prefs.getInt(WIDGET_TEXT_COLOR, resources.getColor(R.color.color_primary))
|
||||
mTextColor = config.widgetTextColor
|
||||
updateTextColor()
|
||||
}
|
||||
|
||||
|
@ -115,8 +112,9 @@ class WidgetConfigureActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
private fun storeWidgetColors() {
|
||||
getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE).apply {
|
||||
edit().putInt(WIDGET_BG_COLOR, mBgColor).putInt(WIDGET_TEXT_COLOR, mTextColor).apply()
|
||||
Config.newInstance(this).apply {
|
||||
widgetBgColor = mBgColor
|
||||
widgetTextColor = mTextColor
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,11 @@ val SET_PROGRESS = PATH + "SET_PROGRESS"
|
|||
val SET_EQUALIZER = PATH + "SET_EQUALIZER"
|
||||
|
||||
// shared preferences
|
||||
val PREFS_KEY = "Music Player"
|
||||
val SHUFFLE = "shuffle"
|
||||
val NUMERIC_PROGRESS = "numeric_progress"
|
||||
val SORTING = "track_sorting"
|
||||
val EQUALIZER = "equalizer"
|
||||
val REPEAT_SONG = "repeat_song"
|
||||
val WIDGET_BG_COLOR = "widget_bg_color"
|
||||
val WIDGET_TEXT_COLOR = "widget_text_color"
|
||||
|
||||
// sorting
|
||||
val SORT_BY_TITLE = 1
|
||||
|
|
|
@ -136,7 +136,7 @@ class MyWidgetProvider : AppWidgetProvider() {
|
|||
val config = Config.newInstance(mContext)
|
||||
val res = mContext.resources
|
||||
val widgetBgColor = config.widgetBgColor
|
||||
val widgetTextColor = config.textColor
|
||||
val widgetTextColor = config.widgetTextColor
|
||||
var bmp = res.getColoredIcon(widgetTextColor, R.drawable.ic_previous)
|
||||
|
||||
mRemoteViews.apply {
|
||||
|
|
Loading…
Reference in a new issue