show a preview of app icon at changing the color
This commit is contained in:
parent
13690245fd
commit
62a6a45e53
6 changed files with 33 additions and 5 deletions
|
@ -179,7 +179,12 @@ open class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
fun startCustomizationActivity() = startActivity(Intent(this, CustomizationActivity::class.java))
|
||||
fun startCustomizationActivity(appIconIDs: ArrayList<Int>? = null) {
|
||||
Intent(applicationContext, CustomizationActivity::class.java).apply {
|
||||
putExtra(APP_ICON_IDS, appIconIDs)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun handleSAFDialog(path: String, callback: () -> Unit): Boolean {
|
||||
return if (!path.startsWith(OTG_PATH) && isShowingSAFDialog(path, baseConfig.treeUri, OPEN_DOCUMENT_TREE)) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.MenuItem
|
|||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.dialogs.*
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.APP_ICON_IDS
|
||||
import com.simplemobiletools.commons.helpers.MyContentProvider
|
||||
import com.simplemobiletools.commons.models.MyTheme
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
|
@ -336,7 +337,7 @@ class CustomizationActivity : BaseSimpleActivity() {
|
|||
}
|
||||
|
||||
private fun pickAppIconColor() {
|
||||
LineColorPickerDialog(this, curAppIconColor, false, R.array.md_app_icon_colors) { wasPositivePressed, color ->
|
||||
LineColorPickerDialog(this, curAppIconColor, false, R.array.md_app_icon_colors, intent.getIntegerArrayListExtra(APP_ICON_IDS)) { wasPositivePressed, color ->
|
||||
if (wasPositivePressed) {
|
||||
if (hasColorChanged(curAppIconColor, color)) {
|
||||
curAppIconColor = color
|
||||
|
|
|
@ -10,8 +10,9 @@ import com.simplemobiletools.commons.interfaces.LineColorPickerListener
|
|||
import kotlinx.android.synthetic.main.dialog_line_color_picker.view.*
|
||||
import java.util.*
|
||||
|
||||
class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, val isPrimaryColorPicker: Boolean,
|
||||
val primaryColors: Int = R.array.md_primary_colors, val callback: (wasPositivePressed: Boolean, color: Int) -> Unit) {
|
||||
class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, val isPrimaryColorPicker: Boolean, val primaryColors: Int = R.array.md_primary_colors,
|
||||
val appIconIDs: ArrayList<Int>? = null, val callback: (wasPositivePressed: Boolean, color: Int) -> Unit) {
|
||||
|
||||
private val PRIMARY_COLORS_COUNT = 19
|
||||
private val DEFAULT_PRIMARY_COLOR_INDEX = 14
|
||||
private val DEFAULT_SECONDARY_COLOR_INDEX = 6
|
||||
|
@ -25,6 +26,7 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
|
|||
view = activity.layoutInflater.inflate(R.layout.dialog_line_color_picker, null).apply {
|
||||
hex_code.text = color.toHex()
|
||||
hex_code.setOnLongClickListener { activity.copyToClipboard(hex_code.value.substring(1)); true }
|
||||
line_color_picker_icon.beGoneIf(isPrimaryColorPicker)
|
||||
val indexes = getColorIndexes(color)
|
||||
|
||||
primary_line_color_picker.updateColors(getColors(primaryColors), indexes.first)
|
||||
|
@ -35,6 +37,10 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
|
|||
|
||||
val newColor = if (isPrimaryColorPicker) secondary_line_color_picker.getCurrentColor() else color
|
||||
colorUpdated(newColor)
|
||||
|
||||
if (!isPrimaryColorPicker) {
|
||||
primaryColorChanged(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +92,10 @@ class LineColorPickerDialog(val activity: BaseSimpleActivity, val color: Int, va
|
|||
return getDefaultColorPair()
|
||||
}
|
||||
|
||||
private fun primaryColorChanged(index: Int) {
|
||||
view.line_color_picker_icon.setImageResource(appIconIDs?.getOrNull(index) ?: 0)
|
||||
}
|
||||
|
||||
private fun getDefaultColorPair() = Pair(DEFAULT_PRIMARY_COLOR_INDEX, DEFAULT_SECONDARY_COLOR_INDEX)
|
||||
|
||||
private fun dialogDismissed() {
|
||||
|
|
|
@ -7,6 +7,7 @@ const val APP_NAME = "app_name"
|
|||
const val APP_LICENSES = "app_licenses"
|
||||
const val APP_FAQ = "app_faq"
|
||||
const val APP_VERSION_NAME = "app_version_name"
|
||||
const val APP_ICON_IDS = "app_icon_ids"
|
||||
const val REAL_FILE_PATH = "real_file_path_2"
|
||||
const val IS_FROM_GALLERY = "is_from_gallery"
|
||||
const val BROADCAST_REFRESH_MEDIA = "com.simplemobiletools.REFRESH_MEDIA"
|
||||
|
|
|
@ -7,10 +7,20 @@
|
|||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/line_color_picker_icon"
|
||||
android:layout_width="@dimen/line_color_picker_app_icon_size"
|
||||
android:layout_height="@dimen/line_color_picker_app_icon_size"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="@dimen/normal_margin"
|
||||
android:src="@drawable/ic_bell"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.LineColorPicker
|
||||
android:id="@+id/primary_line_color_picker"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/line_color_picker_height"/>
|
||||
android:layout_height="@dimen/line_color_picker_height"
|
||||
android:layout_below="@+id/line_color_picker_icon"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.LineColorPicker
|
||||
android:id="@+id/secondary_line_color_picker"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<dimen name="widget_colorpicker_size">50dp</dimen>
|
||||
<dimen name="line_color_picker_height">80dp</dimen>
|
||||
<dimen name="line_color_picker_margin">10dp</dimen>
|
||||
<dimen name="line_color_picker_app_icon_size">44dp</dimen>
|
||||
|
||||
<dimen name="tiny_text_size">8sp</dimen>
|
||||
<dimen name="small_text_size">10sp</dimen>
|
||||
|
|
Loading…
Reference in a new issue