Open palette picker instead of wheel first

pull/935/head
Alex Baker 5 years ago
parent a8424e63f1
commit 459434f30d

@ -123,7 +123,7 @@ public abstract class BaseListSettingsActivity extends ThemedInjectingAppCompatA
@OnClick(R.id.color_row)
protected void showThemePicker() {
ColorWheelPicker.Companion.newColorWheel(null, 0, selectedColor)
ColorPalettePicker.Companion.newColorPalette(null, 0, selectedColor)
.show(getSupportFragmentManager(), FRAG_TAG_COLOR_PICKER);
}

@ -16,6 +16,7 @@ import org.tasks.Callback
import org.tasks.R
import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseDialog
import org.tasks.dialogs.ColorWheelPicker.Companion.newColorWheel
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.themes.ThemeAccent
@ -27,16 +28,35 @@ class ColorPalettePicker : InjectingDialogFragment() {
companion object {
private const val FRAG_TAG_PURCHASE = "frag_tag_purchase"
private const val FRAG_TAG_COLOR_PICKER = "frag_tag_color_picker"
private const val EXTRA_PALETTE = "extra_palette"
const val EXTRA_SELECTED = ColorWheelPicker.EXTRA_SELECTED
fun newColorPalette(
target: Fragment?,
rc: Int,
selected: Int
): ColorPalettePicker {
return newColorPalette(target, rc, selected, ColorPickerAdapter.Palette.COLORS)
}
fun newColorPalette(
target: Fragment?,
rc: Int,
palette: ColorPickerAdapter.Palette
): ColorPalettePicker {
return newColorPalette(target, rc, 0, palette)
}
fun newColorPalette(
target: Fragment?,
rc: Int,
selected: Int,
palette: ColorPickerAdapter.Palette
): ColorPalettePicker {
val args = Bundle()
args.putSerializable(EXTRA_PALETTE, palette)
args.putInt(EXTRA_SELECTED, selected)
val dialog = ColorPalettePicker()
dialog.setTargetFragment(target, rc)
dialog.arguments = args
@ -89,6 +109,13 @@ class ColorPalettePicker : InjectingDialogFragment() {
dialogBuilder
.newDialog()
.setView(view)
if (palette == ColorPickerAdapter.Palette.COLORS) {
builder.setNeutralButton(R.string.color_wheel) { _, _ ->
val selected = arguments?.getInt(EXTRA_SELECTED) ?: 0
newColorWheel(targetFragment, targetRequestCode, selected)
.show(parentFragmentManager, FRAG_TAG_COLOR_PICKER)
}
}
if (inventory.purchasedThemes()) {
builder.setNegativeButton(android.R.string.cancel, null)
} else {

@ -14,7 +14,6 @@ import com.flask.colorpicker.builder.ColorPickerDialogBuilder
import org.tasks.R
import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseActivity
import org.tasks.dialogs.ColorPalettePicker.Companion.newColorPalette
import org.tasks.injection.DialogFragmentComponent
import org.tasks.injection.InjectingDialogFragment
import org.tasks.ui.NavigationDrawerFragment.REQUEST_PURCHASE
@ -25,7 +24,6 @@ private const val REQUEST_PURCHASE = 10010
class ColorWheelPicker : InjectingDialogFragment() {
companion object {
private const val FRAG_TAG_COLOR_PICKER = "frag_tag_color_picker"
const val EXTRA_SELECTED = "extra_selected"
fun newColorWheel(target: Fragment?, rc: Int, selected: Int): ColorWheelPicker {
@ -72,14 +70,10 @@ class ColorWheelPicker : InjectingDialogFragment() {
startActivityForResult(Intent(activity, PurchaseActivity::class.java), REQUEST_PURCHASE)
}
}
.setNegativeButton(android.R.string.cancel, null)
if (selected != 0) {
builder.initialColor(selected)
}
val buttonText = if (inventory.purchasedThemes()) R.string.material_palette else R.string.free_colors
builder.setNegativeButton(buttonText) { _, _ ->
newColorPalette(targetFragment, targetRequestCode, ColorPickerAdapter.Palette.COLORS)
.show(parentFragmentManager, FRAG_TAG_COLOR_PICKER)
}
dialog = builder.build()
return dialog as Dialog
}

@ -25,7 +25,6 @@ import org.tasks.dialogs.ColorPalettePicker
import org.tasks.dialogs.ColorPalettePicker.Companion.newColorPalette
import org.tasks.dialogs.ColorPickerAdapter
import org.tasks.dialogs.ColorWheelPicker
import org.tasks.dialogs.ColorWheelPicker.Companion.newColorWheel
import org.tasks.dialogs.MyTimePickerDialog.newTimePicker
import org.tasks.dialogs.ThemePickerDialog
import org.tasks.dialogs.ThemePickerDialog.Companion.newThemePickerDialog
@ -388,13 +387,8 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange
) {
tintColorPreference(prefId, color)
findPreference(prefId).setOnPreferenceClickListener {
if (palette == ColorPickerAdapter.Palette.COLORS) {
newColorWheel(this, requestCode, color)
newColorPalette(this, requestCode, color, palette)
.show(parentFragmentManager, FRAG_TAG_COLOR_PICKER)
} else {
newColorPalette(this, requestCode, palette)
.show(parentFragmentManager, FRAG_TAG_COLOR_PICKER)
}
false
}
}

@ -12,7 +12,6 @@ import org.tasks.LocalBroadcastManager
import org.tasks.R
import org.tasks.activities.FilterSelectionActivity
import org.tasks.dialogs.ColorWheelPicker
import org.tasks.dialogs.ColorWheelPicker.Companion.newColorWheel
import org.tasks.dialogs.ColorPalettePicker
import org.tasks.dialogs.ColorPalettePicker.Companion.newColorPalette
import org.tasks.dialogs.ColorPickerAdapter
@ -89,7 +88,7 @@ class ScrollableWidget : InjectingPreferenceFragment() {
val colorPreference = findPreference(R.string.p_widget_color_v2)
colorPreference.dependency = showHeader.key
colorPreference.onPreferenceClickListener = Preference.OnPreferenceClickListener {
newColorWheel(this, REQUEST_COLOR_SELECTION, widgetPreferences.color)
newColorPalette(this, REQUEST_COLOR_SELECTION, widgetPreferences.color)
.show(parentFragmentManager, FRAG_TAG_COLOR_PICKER)
false
}

@ -558,7 +558,5 @@
<string name="more_settings">Más ajustes</string>
<string name="more_notification_settings_summary">Tono de llamada, vibraciones y más</string>
<string name="invalid_username_or_password">Nombre de usuario o contraseña inválidos</string>
<string name="free_colors">Colores libres</string>
<string name="material_palette">Paleta de materiales</string>
<string name="theme_system_default">El sistema por defecto</string>
</resources>

@ -554,7 +554,5 @@ est configuré correctement</string>
<string name="more_settings">Plus de paramètres</string>
<string name="more_notification_settings_summary">Sonnerie, vibrations, et plus encore</string>
<string name="invalid_username_or_password">Nom d\'utilisateur ou mot de passe invalide</string>
<string name="free_colors">Couleurs gratuites</string>
<string name="material_palette">Palette de matériaux</string>
<string name="theme_system_default">Défaut du système</string>
</resources>

@ -561,7 +561,6 @@ File %1$s contained %2$s.\n\n
<string name="disable_battery_optimizations">Disable battery optimizations</string>
<string name="more_settings">More settings</string>
<string name="more_notification_settings_summary">Ringtone, vibrations, and more</string>
<string name="free_colors">Free colors</string>
<string name="material_palette">Material palette</string>
<string name="invalid_username_or_password">Invalid username or password</string>
<string name="color_wheel">Color wheel</string>
</resources>

Loading…
Cancel
Save