add rounded corners to the widget
This commit is contained in:
parent
ae257f790c
commit
3f1073a3d4
4 changed files with 38 additions and 20 deletions
|
@ -10,7 +10,6 @@ import android.widget.SeekBar
|
|||
import com.simplemobiletools.commons.dialogs.ColorPickerDialog
|
||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.setBackgroundColor
|
||||
import com.simplemobiletools.commons.extensions.setFillWithStroke
|
||||
import com.simplemobiletools.commons.helpers.IS_CUSTOMIZING_COLORS
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
|
@ -18,6 +17,7 @@ import com.simplemobiletools.musicplayer.extensions.config
|
|||
import com.simplemobiletools.musicplayer.helpers.MyWidgetProvider
|
||||
import com.simplemobiletools.musicplayer.services.MusicService
|
||||
import kotlinx.android.synthetic.main.widget.*
|
||||
import kotlinx.android.synthetic.main.widget.view.*
|
||||
import kotlinx.android.synthetic.main.widget_config.*
|
||||
import kotlinx.android.synthetic.main.widget_controls.*
|
||||
|
||||
|
@ -73,8 +73,11 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
|
||||
private fun saveConfig() {
|
||||
val appWidgetManager = AppWidgetManager.getInstance(this)
|
||||
val views = RemoteViews(packageName, R.layout.widget)
|
||||
views.setBackgroundColor(R.id.widget_holder, mBgColor)
|
||||
val views = RemoteViews(packageName, R.layout.widget).apply {
|
||||
setInt(R.id.widget_background, "setColorFilter", mBgColor)
|
||||
setInt(R.id.widget_background, "setImageAlpha", Color.alpha(mBgColor))
|
||||
}
|
||||
|
||||
appWidgetManager.updateAppWidget(mWidgetId, views)
|
||||
|
||||
storeWidgetColors()
|
||||
|
@ -107,7 +110,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
|
||||
private fun updateBackgroundColor() {
|
||||
mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
|
||||
config_player.setBackgroundColor(mBgColor)
|
||||
config_player.widget_background.applyColorFilter(mBgColor)
|
||||
config_save.setBackgroundColor(mBgColor)
|
||||
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
||||
}
|
||||
|
@ -148,12 +151,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
updateBackgroundColor()
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {}
|
||||
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import android.appwidget.AppWidgetProvider
|
|||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.widget.RemoteViews
|
||||
import com.simplemobiletools.commons.extensions.getColoredBitmap
|
||||
import com.simplemobiletools.commons.extensions.getLaunchIntent
|
||||
import com.simplemobiletools.commons.extensions.setBackgroundColor
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SplashActivity
|
||||
import com.simplemobiletools.musicplayer.extensions.config
|
||||
|
@ -106,7 +106,8 @@ class MyWidgetProvider : AppWidgetProvider() {
|
|||
val widgetTextColor = config.widgetTextColor
|
||||
|
||||
views.apply {
|
||||
setBackgroundColor(R.id.widget_holder, widgetBgColor)
|
||||
setInt(R.id.widget_background, "setColorFilter", widgetBgColor)
|
||||
setInt(R.id.widget_background, "setImageAlpha", Color.alpha(widgetBgColor))
|
||||
setTextColor(R.id.song_info_title, widgetTextColor)
|
||||
setTextColor(R.id.song_info_artist, widgetTextColor)
|
||||
setImageViewBitmap(R.id.previous_btn, res.getColoredBitmap(R.drawable.ic_previous_vector, widgetTextColor))
|
||||
|
|
9
app/src/main/res/drawable/widget_background.xml
Normal file
9
app/src/main/res/drawable/widget_background.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="@dimen/normal_margin" />
|
||||
|
||||
<solid android:color="@color/md_grey_black" />
|
||||
|
||||
</shape>
|
|
@ -1,45 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/black"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/widget_controls"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:src="@drawable/widget_background" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_info_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:lines="1"
|
||||
android:text="@string/title"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/big_text_size"/>
|
||||
android:textSize="@dimen/big_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_info_artist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/song_info_title"
|
||||
android:layout_marginBottom="@dimen/small_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:layout_marginRight="@dimen/activity_margin"
|
||||
android:layout_marginBottom="@dimen/small_margin"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:lines="1"
|
||||
android:text="@string/artist"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/bigger_text_size"/>
|
||||
android:textSize="@dimen/bigger_text_size" />
|
||||
|
||||
<include
|
||||
android:id="@+id/widget_controls"
|
||||
layout="@layout/widget_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/controls_row_height"
|
||||
android:layout_below="@+id/song_info_artist"/>
|
||||
android:layout_below="@+id/song_info_artist" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in a new issue