mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
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 mBgColor = 0
|
||||
private var mBgColorWithoutTransparency = 0
|
||||
private var mTextColor = 0
|
||||
private var mFolderPath = ""
|
||||
private var mDirectories = ArrayList<Directory>()
|
||||
|
||||
|
@ -40,10 +41,11 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
|
||||
config_save.setOnClickListener { saveConfig() }
|
||||
config_bg_color.setOnClickListener { pickBackgroundColor() }
|
||||
config_text_color.setOnClickListener { pickTextColor() }
|
||||
folder_picker_value.setOnClickListener { changeSelectedFolder() }
|
||||
config_image_holder.setOnClickListener { changeSelectedFolder() }
|
||||
folder_picker_show_folder_name_holder.setOnClickListener { }
|
||||
config_save.setTextColor(getAdjustedPrimaryColor())
|
||||
folder_picker_show_folder_name.isChecked = config.showWidgetFolderName
|
||||
folder_picker_show_folder_name_holder.setOnClickListener { toggleFolderNameDisplay() }
|
||||
updateTextColors(folder_picker_holder)
|
||||
folder_picker_holder.background = ColorDrawable(config.backgroundColor)
|
||||
|
||||
|
@ -75,12 +77,16 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
updateBackgroundColor()
|
||||
|
||||
mTextColor = config.widgetTextColor
|
||||
updateTextColor()
|
||||
}
|
||||
|
||||
private fun saveConfig() {
|
||||
val views = RemoteViews(packageName, R.layout.widget)
|
||||
views.setBackgroundColor(R.id.widget_holder, mBgColor)
|
||||
AppWidgetManager.getInstance(this).updateAppWidget(mWidgetId, views)
|
||||
config.showWidgetFolderName = folder_picker_show_folder_name.isChecked
|
||||
val widget = Widget(null, mWidgetId, mFolderPath)
|
||||
Thread {
|
||||
widgetsDB.insertOrUpdate(widget)
|
||||
|
@ -116,6 +122,11 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
config_bg_color.setFillWithStroke(mBgColor, Color.BLACK)
|
||||
}
|
||||
|
||||
private fun updateTextColor() {
|
||||
config_save.setTextColor(mTextColor)
|
||||
config_text_color.setFillWithStroke(mTextColor, Color.BLACK)
|
||||
}
|
||||
|
||||
private fun pickBackgroundColor() {
|
||||
ColorPickerDialog(this, mBgColorWithoutTransparency) { wasPositivePressed, color ->
|
||||
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() {
|
||||
PickDirectoryDialog(this, mFolderPath, false) {
|
||||
updateFolderImage(it)
|
||||
|
@ -142,4 +162,8 @@ class WidgetConfigureActivity : SimpleActivity() {
|
|||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun toggleFolderNameDisplay() {
|
||||
folder_picker_show_folder_name.toggle()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,4 +427,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
var groupDirectSubfolders: Boolean
|
||||
get() = prefs.getBoolean(GROUP_DIRECT_SUBFOLDERS, false)
|
||||
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_Y = "last_editor_crop_other_aspect_ratio_y"
|
||||
const val GROUP_DIRECT_SUBFOLDERS = "group_direct_subfolders"
|
||||
const val SHOW_WIDGET_FOLDER_NAME = "show_widget_folder_name"
|
||||
|
||||
// slideshow
|
||||
const val SLIDESHOW_INTERVAL = "slideshow_interval"
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.widget.RemoteViews
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
|
@ -47,7 +46,7 @@ class MyWidgetProvider : AppWidgetProvider() {
|
|||
if (context.config.cropThumbnails) options.centerCrop() else options.fitCenter()
|
||||
|
||||
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 appWidgetTarget = object : AppWidgetTarget(context, widgetSize, widgetSize, R.id.widget_imageview, views, componentName) {}
|
||||
|
||||
|
|
|
@ -96,6 +96,12 @@
|
|||
android:paddingRight="@dimen/activity_margin"/>
|
||||
</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
|
||||
android:id="@+id/config_save"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
<dimen name="bottom_filters_height">90dp</dimen>
|
||||
<dimen name="bottom_editor_actions_shadow_height">180dp</dimen>
|
||||
<dimen name="default_status_action_height">86dp</dimen>
|
||||
<dimen name="widget_initial_width">110dp</dimen>
|
||||
<dimen name="widget_initial_size">110dp</dimen>
|
||||
</resources>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:configure="com.simplemobiletools.gallery.pro.activities.WidgetConfigureActivity"
|
||||
android:initialLayout="@layout/widget"
|
||||
android:minWidth="@dimen/widget_initial_width"
|
||||
android:minHeight="40dp"
|
||||
android:minWidth="@dimen/widget_initial_size"
|
||||
android:minHeight="@dimen/widget_initial_size"
|
||||
android:minResizeWidth="40dp"
|
||||
android:minResizeHeight="40dp"
|
||||
android:resizeMode="horizontal|vertical"/>
|
||||
|
|
Loading…
Reference in a new issue