mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
Remove CheckmarkDialog
This commit is contained in:
@@ -1,119 +0,0 @@
|
|||||||
package org.isoron.uhabits.activities.common.dialogs
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.Typeface
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
|
||||||
import android.widget.Button
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import org.isoron.platform.gui.toInt
|
|
||||||
import org.isoron.platform.time.JavaLocalDateFormatter
|
|
||||||
import org.isoron.platform.time.LocalDate
|
|
||||||
import org.isoron.uhabits.R
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.NO
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.SKIP
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.YES_AUTO
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
|
|
||||||
import org.isoron.uhabits.core.models.PaletteColor
|
|
||||||
import org.isoron.uhabits.core.preferences.Preferences
|
|
||||||
import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsBehavior
|
|
||||||
import org.isoron.uhabits.core.ui.views.Theme
|
|
||||||
import org.isoron.uhabits.databinding.CheckmarkDialogBinding
|
|
||||||
import org.isoron.uhabits.inject.ActivityContext
|
|
||||||
import org.isoron.uhabits.utils.InterfaceUtils
|
|
||||||
import org.isoron.uhabits.utils.StyledResources
|
|
||||||
import java.util.Locale
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class CheckmarkDialog
|
|
||||||
@Inject constructor(
|
|
||||||
@ActivityContext private val context: Context,
|
|
||||||
private val preferences: Preferences,
|
|
||||||
) : View.OnClickListener {
|
|
||||||
|
|
||||||
private lateinit var binding: CheckmarkDialogBinding
|
|
||||||
private lateinit var fontAwesome: Typeface
|
|
||||||
private val allButtons = mutableListOf<Button>()
|
|
||||||
private var selectedButton: Button? = null
|
|
||||||
|
|
||||||
fun create(
|
|
||||||
selectedValue: Int,
|
|
||||||
notes: String,
|
|
||||||
date: LocalDate,
|
|
||||||
paletteColor: PaletteColor,
|
|
||||||
callback: ListHabitsBehavior.CheckMarkDialogCallback,
|
|
||||||
theme: Theme,
|
|
||||||
): AlertDialog {
|
|
||||||
binding = CheckmarkDialogBinding.inflate(LayoutInflater.from(context))
|
|
||||||
fontAwesome = InterfaceUtils.getFontAwesome(context)!!
|
|
||||||
binding.etNotes.append(notes)
|
|
||||||
setUpButtons(selectedValue, theme.color(paletteColor).toInt())
|
|
||||||
|
|
||||||
val dialog = AlertDialog.Builder(context)
|
|
||||||
.setView(binding.root)
|
|
||||||
.setTitle(JavaLocalDateFormatter(Locale.getDefault()).longFormat(date))
|
|
||||||
.setPositiveButton(R.string.save) { _, _ ->
|
|
||||||
val newValue = when (selectedButton?.id) {
|
|
||||||
R.id.yesBtn -> YES_MANUAL
|
|
||||||
R.id.noBtn -> NO
|
|
||||||
R.id.skippedBtn -> SKIP
|
|
||||||
else -> UNKNOWN
|
|
||||||
}
|
|
||||||
callback.onNotesSaved(newValue, binding.etNotes.text.toString())
|
|
||||||
}
|
|
||||||
.setNegativeButton(android.R.string.cancel) { _, _ ->
|
|
||||||
callback.onNotesDismissed()
|
|
||||||
}
|
|
||||||
.setOnDismissListener {
|
|
||||||
callback.onNotesDismissed()
|
|
||||||
}
|
|
||||||
.create()
|
|
||||||
|
|
||||||
dialog.setOnShowListener {
|
|
||||||
binding.etNotes.requestFocus()
|
|
||||||
dialog.window?.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setUpButtons(value: Int, color: Int) {
|
|
||||||
val sres = StyledResources(context)
|
|
||||||
val mediumContrastColor = sres.getColor(R.attr.contrast60)
|
|
||||||
setButtonAttrs(binding.yesBtn, color)
|
|
||||||
setButtonAttrs(binding.noBtn, mediumContrastColor)
|
|
||||||
setButtonAttrs(binding.skippedBtn, color, visible = preferences.isSkipEnabled)
|
|
||||||
setButtonAttrs(binding.questionBtn, mediumContrastColor, visible = preferences.areQuestionMarksEnabled)
|
|
||||||
when (value) {
|
|
||||||
UNKNOWN -> if (preferences.areQuestionMarksEnabled) {
|
|
||||||
binding.questionBtn.performClick()
|
|
||||||
} else {
|
|
||||||
binding.noBtn.performClick()
|
|
||||||
}
|
|
||||||
SKIP -> binding.skippedBtn.performClick()
|
|
||||||
YES_MANUAL -> binding.yesBtn.performClick()
|
|
||||||
YES_AUTO, NO -> binding.noBtn.performClick()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setButtonAttrs(button: Button, color: Int, visible: Boolean = true) {
|
|
||||||
button.apply {
|
|
||||||
visibility = if (visible) View.VISIBLE else View.GONE
|
|
||||||
typeface = fontAwesome
|
|
||||||
setTextColor(color)
|
|
||||||
setOnClickListener(this@CheckmarkDialog)
|
|
||||||
}
|
|
||||||
allButtons.add(button)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(v: View?) {
|
|
||||||
allButtons.forEach {
|
|
||||||
if (v?.id == it.id) {
|
|
||||||
it.isSelected = true
|
|
||||||
selectedButton = it
|
|
||||||
} else it.isSelected = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,9 +26,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import org.isoron.platform.gui.ScreenLocation
|
import org.isoron.platform.gui.ScreenLocation
|
||||||
import org.isoron.platform.gui.toInt
|
import org.isoron.platform.gui.toInt
|
||||||
import org.isoron.platform.time.LocalDate
|
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkDialog
|
|
||||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
|
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
|
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
||||||
@@ -98,7 +96,6 @@ class ListHabitsScreen
|
|||||||
private val importTaskFactory: ImportDataTaskFactory,
|
private val importTaskFactory: ImportDataTaskFactory,
|
||||||
private val colorPickerFactory: ColorPickerDialogFactory,
|
private val colorPickerFactory: ColorPickerDialogFactory,
|
||||||
private val numberPickerFactory: NumberPickerFactory,
|
private val numberPickerFactory: NumberPickerFactory,
|
||||||
private val checkMarkDialog: CheckmarkDialog,
|
|
||||||
private val behavior: Lazy<ListHabitsBehavior>,
|
private val behavior: Lazy<ListHabitsBehavior>,
|
||||||
private val preferences: Preferences,
|
private val preferences: Preferences,
|
||||||
private val rootView: Lazy<ListHabitsRootView>,
|
private val rootView: Lazy<ListHabitsRootView>,
|
||||||
@@ -271,24 +268,6 @@ class ListHabitsScreen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showCheckmarkDialog(
|
|
||||||
selectedValue: Int,
|
|
||||||
notes: String,
|
|
||||||
date: LocalDate,
|
|
||||||
dateString: String,
|
|
||||||
color: PaletteColor,
|
|
||||||
callback: ListHabitsBehavior.CheckMarkDialogCallback
|
|
||||||
) {
|
|
||||||
checkMarkDialog.create(
|
|
||||||
selectedValue,
|
|
||||||
notes,
|
|
||||||
date,
|
|
||||||
color,
|
|
||||||
callback,
|
|
||||||
themeSwitcher.currentTheme!!,
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getExecuteString(command: Command): String? {
|
private fun getExecuteString(command: Command): String? {
|
||||||
when (command) {
|
when (command) {
|
||||||
is ArchiveHabitsCommand -> {
|
is ArchiveHabitsCommand -> {
|
||||||
|
|||||||
@@ -29,13 +29,11 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.isoron.platform.gui.ScreenLocation
|
import org.isoron.platform.gui.ScreenLocation
|
||||||
import org.isoron.platform.gui.toInt
|
import org.isoron.platform.gui.toInt
|
||||||
import org.isoron.platform.time.LocalDate
|
|
||||||
import org.isoron.uhabits.AndroidDirFinder
|
import org.isoron.uhabits.AndroidDirFinder
|
||||||
import org.isoron.uhabits.HabitsApplication
|
import org.isoron.uhabits.HabitsApplication
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
import org.isoron.uhabits.activities.AndroidThemeSwitcher
|
||||||
import org.isoron.uhabits.activities.HabitsDirFinder
|
import org.isoron.uhabits.activities.HabitsDirFinder
|
||||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkDialog
|
|
||||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
|
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
||||||
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
|
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
|
||||||
@@ -189,24 +187,6 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showCheckmarkDialog(
|
|
||||||
selectedValue: Int,
|
|
||||||
notes: String,
|
|
||||||
date: LocalDate,
|
|
||||||
preferences: Preferences,
|
|
||||||
color: PaletteColor,
|
|
||||||
callback: ListHabitsBehavior.CheckMarkDialogCallback
|
|
||||||
) {
|
|
||||||
CheckmarkDialog(this@ShowHabitActivity, preferences).create(
|
|
||||||
selectedValue,
|
|
||||||
notes,
|
|
||||||
date,
|
|
||||||
color,
|
|
||||||
callback,
|
|
||||||
themeSwitcher.currentTheme!!,
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun showCheckmarkPopup(
|
override fun showCheckmarkPopup(
|
||||||
selectedValue: Int,
|
selectedValue: Int,
|
||||||
notes: String,
|
notes: String,
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingTop="12dp"
|
|
||||||
android:paddingStart="10dp"
|
|
||||||
android:paddingEnd="10dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:baselineAligned="false">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
style="@style/FormOuterBox"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
<LinearLayout style="@style/DialogFormInnerBox">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/DialogFormLabel"
|
|
||||||
android:text="@string/value" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginBottom="8dp">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/yesBtn"
|
|
||||||
android:text="@string/fa_check"
|
|
||||||
style="@style/CheckmarkDialogBtn"/>
|
|
||||||
<Button
|
|
||||||
android:id="@+id/skippedBtn"
|
|
||||||
android:text="@string/fa_skipped"
|
|
||||||
android:visibility="gone"
|
|
||||||
style="@style/CheckmarkDialogBtn"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/noBtn"
|
|
||||||
android:text="@string/fa_times"
|
|
||||||
style="@style/CheckmarkDialogBtn"/>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/questionBtn"
|
|
||||||
android:text="@string/fa_question"
|
|
||||||
android:visibility="gone"
|
|
||||||
style="@style/CheckmarkDialogBtn"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:baselineAligned="false">
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
style="@style/FormOuterBox"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_weight="1">
|
|
||||||
|
|
||||||
<LinearLayout style="@style/DialogFormInnerBox">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/DialogFormLabel"
|
|
||||||
android:text="@string/notes" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/etNotes"
|
|
||||||
android:inputType="textCapSentences|textMultiLine"
|
|
||||||
style="@style/FormInput"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:hint="@string/example_notes"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -387,18 +387,6 @@
|
|||||||
<item name="android:textSize">@dimen/smallTextSize</item>
|
<item name="android:textSize">@dimen/smallTextSize</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CheckmarkDialogBtn">
|
|
||||||
<item name="android:layout_width">48dp</item>
|
|
||||||
<item name="android:layout_height">48dp</item>
|
|
||||||
<item name="android:layout_marginTop">8dp</item>
|
|
||||||
<item name="android:layout_marginBottom">8dp</item>
|
|
||||||
<item name="android:layout_marginEnd">12dp</item>
|
|
||||||
<item name="android:textSize">@dimen/regularTextSize</item>
|
|
||||||
<item name="backgroundTint">@null</item>
|
|
||||||
<item name="android:background">@drawable/bg_select_button</item>
|
|
||||||
<item name="selectable">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="CheckmarkPopupBtn">
|
<style name="CheckmarkPopupBtn">
|
||||||
<item name="android:layout_width">0dp</item>
|
<item name="android:layout_width">0dp</item>
|
||||||
<item name="android:layout_weight">1</item>
|
<item name="android:layout_weight">1</item>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package org.isoron.uhabits.core.ui.screens.habits.list
|
package org.isoron.uhabits.core.ui.screens.habits.list
|
||||||
|
|
||||||
import org.isoron.platform.gui.ScreenLocation
|
import org.isoron.platform.gui.ScreenLocation
|
||||||
import org.isoron.platform.time.LocalDate
|
|
||||||
import org.isoron.uhabits.core.commands.CommandRunner
|
import org.isoron.uhabits.core.commands.CommandRunner
|
||||||
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
|
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
|
||||||
import org.isoron.uhabits.core.models.Frequency
|
import org.isoron.uhabits.core.models.Frequency
|
||||||
@@ -178,15 +177,6 @@ open class ListHabitsBehavior @Inject constructor(
|
|||||||
location: ScreenLocation,
|
location: ScreenLocation,
|
||||||
callback: CheckMarkDialogCallback
|
callback: CheckMarkDialogCallback
|
||||||
)
|
)
|
||||||
fun showCheckmarkDialog(
|
|
||||||
selectedValue: Int,
|
|
||||||
notes: String,
|
|
||||||
date: LocalDate,
|
|
||||||
dateString: String,
|
|
||||||
color: PaletteColor,
|
|
||||||
callback: CheckMarkDialogCallback
|
|
||||||
)
|
|
||||||
|
|
||||||
fun showSendBugReportToDeveloperScreen(log: String)
|
fun showSendBugReportToDeveloperScreen(log: String)
|
||||||
fun showSendFileScreen(filename: String)
|
fun showSendFileScreen(filename: String)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,15 +214,6 @@ class HistoryCardPresenter(
|
|||||||
callback: ListHabitsBehavior.NumberPickerCallback
|
callback: ListHabitsBehavior.NumberPickerCallback
|
||||||
)
|
)
|
||||||
|
|
||||||
fun showCheckmarkDialog(
|
|
||||||
selectedValue: Int,
|
|
||||||
notes: String,
|
|
||||||
date: LocalDate,
|
|
||||||
preferences: Preferences,
|
|
||||||
color: PaletteColor,
|
|
||||||
callback: ListHabitsBehavior.CheckMarkDialogCallback,
|
|
||||||
)
|
|
||||||
|
|
||||||
fun showCheckmarkPopup(
|
fun showCheckmarkPopup(
|
||||||
selectedValue: Int,
|
selectedValue: Int,
|
||||||
notes: String,
|
notes: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user