adding a text color changer at the widget config screen
This commit is contained in:
parent
4752d54109
commit
dd537c63f3
7 changed files with 41 additions and 7 deletions
|
@ -22,6 +22,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
private var mWidgetId = 0
|
private var mWidgetId = 0
|
||||||
private var mBgColor = 0
|
private var mBgColor = 0
|
||||||
private var mBgColorWithoutTransparency = 0
|
private var mBgColorWithoutTransparency = 0
|
||||||
|
private var mTextColor = 0
|
||||||
private var mFolderPath = ""
|
private var mFolderPath = ""
|
||||||
private var mDirectories = ArrayList<Directory>()
|
private var mDirectories = ArrayList<Directory>()
|
||||||
|
|
||||||
|
@ -40,10 +41,11 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
|
|
||||||
config_save.setOnClickListener { saveConfig() }
|
config_save.setOnClickListener { saveConfig() }
|
||||||
config_bg_color.setOnClickListener { pickBackgroundColor() }
|
config_bg_color.setOnClickListener { pickBackgroundColor() }
|
||||||
|
config_text_color.setOnClickListener { pickTextColor() }
|
||||||
folder_picker_value.setOnClickListener { changeSelectedFolder() }
|
folder_picker_value.setOnClickListener { changeSelectedFolder() }
|
||||||
config_image_holder.setOnClickListener { changeSelectedFolder() }
|
config_image_holder.setOnClickListener { changeSelectedFolder() }
|
||||||
folder_picker_show_folder_name_holder.setOnClickListener { }
|
folder_picker_show_folder_name.isChecked = config.showWidgetFolderName
|
||||||
config_save.setTextColor(getAdjustedPrimaryColor())
|
folder_picker_show_folder_name_holder.setOnClickListener { toggleFolderNameDisplay() }
|
||||||
updateTextColors(folder_picker_holder)
|
updateTextColors(folder_picker_holder)
|
||||||
folder_picker_holder.background = ColorDrawable(config.backgroundColor)
|
folder_picker_holder.background = ColorDrawable(config.backgroundColor)
|
||||||
|
|
||||||
|
@ -75,12 +77,16 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateBackgroundColor()
|
updateBackgroundColor()
|
||||||
|
|
||||||
|
mTextColor = config.widgetTextColor
|
||||||
|
updateTextColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveConfig() {
|
private fun saveConfig() {
|
||||||
val views = RemoteViews(packageName, R.layout.widget)
|
val views = RemoteViews(packageName, R.layout.widget)
|
||||||
views.setBackgroundColor(R.id.widget_holder, mBgColor)
|
views.setBackgroundColor(R.id.widget_holder, mBgColor)
|
||||||
AppWidgetManager.getInstance(this).updateAppWidget(mWidgetId, views)
|
AppWidgetManager.getInstance(this).updateAppWidget(mWidgetId, views)
|
||||||
|
config.showWidgetFolderName = folder_picker_show_folder_name.isChecked
|
||||||
val widget = Widget(null, mWidgetId, mFolderPath)
|
val widget = Widget(null, mWidgetId, mFolderPath)
|
||||||
Thread {
|
Thread {
|
||||||
widgetsDB.insertOrUpdate(widget)
|
widgetsDB.insertOrUpdate(widget)
|
||||||
|
@ -116,6 +122,11 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateTextColor() {
|
||||||
|
config_save.setTextColor(mTextColor)
|
||||||
|
config_text_color.setFillWithStroke(mTextColor, Color.BLACK)
|
||||||
|
}
|
||||||
|
|
||||||
private fun pickBackgroundColor() {
|
private fun pickBackgroundColor() {
|
||||||
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
|
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
|
||||||
if (wasPositivePressed) {
|
if (wasPositivePressed) {
|
||||||
|
@ -125,6 +136,15 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun pickTextColor() {
|
||||||
|
ColorPickerDialog(this, mTextColor) { wasPositivePressed, color ->
|
||||||
|
if (wasPositivePressed) {
|
||||||
|
mTextColor = color
|
||||||
|
updateTextColor()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun changeSelectedFolder() {
|
private fun changeSelectedFolder() {
|
||||||
PickDirectoryDialog(this, mFolderPath, false) {
|
PickDirectoryDialog(this, mFolderPath, false) {
|
||||||
updateFolderImage(it)
|
updateFolderImage(it)
|
||||||
|
@ -142,4 +162,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun toggleFolderNameDisplay() {
|
||||||
|
folder_picker_show_folder_name.toggle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -427,4 +427,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
var groupDirectSubfolders: Boolean
|
var groupDirectSubfolders: Boolean
|
||||||
get() = prefs.getBoolean(GROUP_DIRECT_SUBFOLDERS, false)
|
get() = prefs.getBoolean(GROUP_DIRECT_SUBFOLDERS, false)
|
||||||
set(groupDirectSubfolders) = prefs.edit().putBoolean(GROUP_DIRECT_SUBFOLDERS, groupDirectSubfolders).apply()
|
set(groupDirectSubfolders) = prefs.edit().putBoolean(GROUP_DIRECT_SUBFOLDERS, groupDirectSubfolders).apply()
|
||||||
|
|
||||||
|
var showWidgetFolderName: Boolean
|
||||||
|
get() = prefs.getBoolean(SHOW_WIDGET_FOLDER_NAME, true)
|
||||||
|
set(showWidgetFolderName) = prefs.edit().putBoolean(SHOW_WIDGET_FOLDER_NAME, showWidgetFolderName).apply()
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ const val LAST_EDITOR_CROP_ASPECT_RATIO = "last_editor_crop_aspect_ratio"
|
||||||
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X = "last_editor_crop_other_aspect_ratio_x"
|
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_X = "last_editor_crop_other_aspect_ratio_x"
|
||||||
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y"
|
const val LAST_EDITOR_CROP_OTHER_ASPECT_RATIO_Y = "last_editor_crop_other_aspect_ratio_y"
|
||||||
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
|
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
|
||||||
|
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
|
||||||
|
|
||||||
// slideshow
|
// slideshow
|
||||||
const val SLIDESHOW_INTERVAL = "slideshow_interval"
|
const val SLIDESHOW_INTERVAL = "slideshow_interval"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
|
@ -47,7 +46,7 @@ class MyWidgetProvider : AppWidgetProvider() {
|
||||||
if (context.config.cropThumbnails) options.centerCrop() else options.fitCenter()
|
if (context.config.cropThumbnails) options.centerCrop() else options.fitCenter()
|
||||||
|
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
val widgetSize = context.resources.getDimension(R.dimen.widget_initial_width).toInt()
|
val widgetSize = context.resources.getDimension(R.dimen.widget_initial_size).toInt()
|
||||||
val componentName = ComponentName(context, MyWidgetProvider::class.java)
|
val componentName = ComponentName(context, MyWidgetProvider::class.java)
|
||||||
val appWidgetTarget = object : AppWidgetTarget(context, widgetSize, widgetSize, R.id.widget_imageview, views, componentName) {}
|
val appWidgetTarget = object : AppWidgetTarget(context, widgetSize, widgetSize, R.id.widget_imageview, views, componentName) {}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,12 @@
|
||||||
android:paddingRight="@dimen/activity_margin"/>
|
android:paddingRight="@dimen/activity_margin"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/config_text_color"
|
||||||
|
android:layout_width="@dimen/widget_colorpicker_size"
|
||||||
|
android:layout_height="@dimen/widget_colorpicker_size"
|
||||||
|
android:layout_alignParentBottom="true"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/config_save"
|
android:id="@+id/config_save"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -15,5 +15,5 @@
|
||||||
<dimen name="bottom_filters_height">90dp</dimen>
|
<dimen name="bottom_filters_height">90dp</dimen>
|
||||||
<dimen name="bottom_editor_actions_shadow_height">180dp</dimen>
|
<dimen name="bottom_editor_actions_shadow_height">180dp</dimen>
|
||||||
<dimen name="default_status_action_height">86dp</dimen>
|
<dimen name="default_status_action_height">86dp</dimen>
|
||||||
<dimen name="widget_initial_width">110dp</dimen>
|
<dimen name="widget_initial_size">110dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:configure="com.simplemobiletools.gallery.pro.activities.WidgetConfigureActivity"
|
android:configure="com.simplemobiletools.gallery.pro.activities.WidgetConfigureActivity"
|
||||||
android:initialLayout="@layout/widget"
|
android:initialLayout="@layout/widget"
|
||||||
android:minWidth="@dimen/widget_initial_width"
|
android:minWidth="@dimen/widget_initial_size"
|
||||||
android:minHeight="40dp"
|
android:minHeight="@dimen/widget_initial_size"
|
||||||
android:minResizeWidth="40dp"
|
android:minResizeWidth="40dp"
|
||||||
android:minResizeHeight="40dp"
|
android:minResizeHeight="40dp"
|
||||||
android:resizeMode="horizontal|vertical"/>
|
android:resizeMode="horizontal|vertical"/>
|
||||||
|
|
Loading…
Reference in a new issue