mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 01:28:52 -06:00
Compare commits
1 Commits
hotfix/2.1
...
25a3509988
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25a3509988 |
@@ -1,10 +1,6 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [2.1.1] -- 2022-09-24
|
## [2.1.0] -- Unreleased
|
||||||
### Fixed
|
|
||||||
- Fix Tasker plugin (@iSoron, #1503)
|
|
||||||
|
|
||||||
## [2.1.0] -- 2022-09-10
|
|
||||||
### Added
|
### Added
|
||||||
- Allow user to add notes to specific dates (@vbh, #1103)
|
- Allow user to add notes to specific dates (@vbh, #1103)
|
||||||
- Allow user to track "at most" numerical habits (@KristianTashkov, #1101)
|
- Allow user to track "at most" numerical habits (@KristianTashkov, #1101)
|
||||||
@@ -13,7 +9,6 @@
|
|||||||
- Improve number picker (@hiqua, @iSoron, #1082, #1370)
|
- Improve number picker (@hiqua, @iSoron, #1082, #1370)
|
||||||
- Add new checkmark and number picker (@iSoron, #1370)
|
- Add new checkmark and number picker (@iSoron, #1370)
|
||||||
- Allow user to import numerical habits from HabitBull (@hiqua, #1278)
|
- Allow user to import numerical habits from HabitBull (@hiqua, #1278)
|
||||||
- Add support for Android 13 themed icons (@cheeeeer, #1497)
|
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Hide snooze button Android 12 notifications (@hiqua, #1226)
|
- Hide snooze button Android 12 notifications (@hiqua, #1226)
|
||||||
@@ -33,7 +28,6 @@
|
|||||||
- Fix small issues in calendar chart (@kalina559, #1314)
|
- Fix small issues in calendar chart (@kalina559, #1314)
|
||||||
- Resort habit list after edit (@hiqua, #1350)
|
- Resort habit list after edit (@hiqua, #1350)
|
||||||
- Fix marker scaling in frequency display (@eduebernal, #1425)
|
- Fix marker scaling in frequency display (@eduebernal, #1425)
|
||||||
- Fix widgets not working correctly on API 33 (@iSoron, #1488)
|
|
||||||
|
|
||||||
### Refactoring & Testing
|
### Refactoring & Testing
|
||||||
- Replace raster icons by vector assets (@kalina559)
|
- Replace raster icons by vector assets (@kalina559)
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ android {
|
|||||||
compileSdk = 31
|
compileSdk = 31
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
versionCode = 20101
|
versionCode = 20100
|
||||||
versionName = "2.1.1"
|
versionName = "2.1.0"
|
||||||
minSdk = 23
|
minSdk = 23
|
||||||
targetSdk = 31
|
targetSdk = 31
|
||||||
applicationId = "org.isoron.uhabits"
|
applicationId = "org.isoron.uhabits"
|
||||||
|
|||||||
@@ -270,7 +270,7 @@
|
|||||||
<!-- Locale/Tasker -->
|
<!-- Locale/Tasker -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".automation.FireSettingReceiver"
|
android:name=".automation.FireSettingReceiver"
|
||||||
android:exported="true">
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
|
<action android:name="com.twofortyfouram.locale.intent.action.FIRE_SETTING" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import org.isoron.uhabits.core.preferences.Preferences
|
|||||||
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
||||||
import org.isoron.uhabits.utils.InterfaceUtils.getFontAwesome
|
import org.isoron.uhabits.utils.InterfaceUtils.getFontAwesome
|
||||||
import org.isoron.uhabits.utils.dimBehind
|
import org.isoron.uhabits.utils.dimBehind
|
||||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
|
||||||
import org.isoron.uhabits.utils.dp
|
import org.isoron.uhabits.utils.dp
|
||||||
import org.isoron.uhabits.utils.sres
|
import org.isoron.uhabits.utils.sres
|
||||||
|
|
||||||
@@ -118,7 +117,7 @@ class CheckmarkPopup(
|
|||||||
view.unknownBtn.setOnClickListener { onClick(UNKNOWN) }
|
view.unknownBtn.setOnClickListener { onClick(UNKNOWN) }
|
||||||
dialog.setCanceledOnTouchOutside(true)
|
dialog.setCanceledOnTouchOutside(true)
|
||||||
dialog.dimBehind()
|
dialog.dimBehind()
|
||||||
dialog.dismissCurrentAndShow()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun save() {
|
fun save() {
|
||||||
|
|||||||
@@ -149,10 +149,8 @@ class FrequencyPickerDialog(
|
|||||||
}
|
}
|
||||||
contentView.xTimesPerYDaysRadioButton.isChecked -> {
|
contentView.xTimesPerYDaysRadioButton.isChecked -> {
|
||||||
if (contentView.xTimesPerYDaysXTextView.text.isNotEmpty() && contentView.xTimesPerYDaysYTextView.text.isNotEmpty()) {
|
if (contentView.xTimesPerYDaysXTextView.text.isNotEmpty() && contentView.xTimesPerYDaysYTextView.text.isNotEmpty()) {
|
||||||
numerator =
|
numerator = Integer.parseInt(contentView.xTimesPerYDaysXTextView.text.toString())
|
||||||
Integer.parseInt(contentView.xTimesPerYDaysXTextView.text.toString())
|
denominator = Integer.parseInt(contentView.xTimesPerYDaysYTextView.text.toString())
|
||||||
denominator =
|
|
||||||
Integer.parseInt(contentView.xTimesPerYDaysYTextView.text.toString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package org.isoron.uhabits.activities.common.dialogs
|
package org.isoron.uhabits.activities.common.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatDialogFragment
|
import androidx.appcompat.app.AppCompatDialogFragment
|
||||||
import org.isoron.platform.gui.AndroidDataView
|
import org.isoron.platform.gui.AndroidDataView
|
||||||
@@ -50,7 +49,6 @@ class HistoryEditorDialog : AppCompatDialogFragment(), CommandRunner.Listener {
|
|||||||
private var onDateClickedListener: OnDateClickedListener? = null
|
private var onDateClickedListener: OnDateClickedListener? = null
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
clearCurrentDialog()
|
|
||||||
val component = (activity!!.application as HabitsApplication).component
|
val component = (activity!!.application as HabitsApplication).component
|
||||||
commandRunner = component.commandRunner
|
commandRunner = component.commandRunner
|
||||||
habit = component.habitList.getById(arguments!!.getLong("habit"))!!
|
habit = component.habitList.getById(arguments!!.getLong("habit"))!!
|
||||||
@@ -74,20 +72,12 @@ class HistoryEditorDialog : AppCompatDialogFragment(), CommandRunner.Listener {
|
|||||||
dataView = AndroidDataView(context!!, null)
|
dataView = AndroidDataView(context!!, null)
|
||||||
dataView.view = chart!!
|
dataView.view = chart!!
|
||||||
|
|
||||||
val dialog = Dialog(context!!).apply {
|
return Dialog(context!!).apply {
|
||||||
val metrics = resources.displayMetrics
|
val metrics = resources.displayMetrics
|
||||||
val maxHeight = resources.getDimensionPixelSize(R.dimen.history_editor_max_height)
|
val maxHeight = resources.getDimensionPixelSize(R.dimen.history_editor_max_height)
|
||||||
setContentView(dataView)
|
setContentView(dataView)
|
||||||
window!!.setLayout(metrics.widthPixels, min(metrics.heightPixels, maxHeight))
|
window!!.setLayout(metrics.widthPixels, min(metrics.heightPixels, maxHeight))
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDialog = dialog
|
|
||||||
return dialog
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDismiss(dialog: DialogInterface) {
|
|
||||||
super.onDismiss(dialog)
|
|
||||||
currentDialog = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
@@ -121,14 +111,4 @@ class HistoryEditorDialog : AppCompatDialogFragment(), CommandRunner.Listener {
|
|||||||
override fun onCommandFinished(command: Command) {
|
override fun onCommandFinished(command: Command) {
|
||||||
refreshData()
|
refreshData()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
// HistoryEditorDialog handles multiple dialogs on its own,
|
|
||||||
// because sometimes we want it to be shown under another dialog (e.g. NumberPopup)
|
|
||||||
var currentDialog: Dialog? = null
|
|
||||||
fun clearCurrentDialog() {
|
|
||||||
currentDialog?.dismiss()
|
|
||||||
currentDialog = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.isoron.uhabits.core.models.Entry
|
|||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
|
||||||
import org.isoron.uhabits.utils.dimBehind
|
import org.isoron.uhabits.utils.dimBehind
|
||||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
|
||||||
import org.isoron.uhabits.utils.dp
|
import org.isoron.uhabits.utils.dp
|
||||||
import org.isoron.uhabits.utils.requestFocusWithKeyboard
|
import org.isoron.uhabits.utils.requestFocusWithKeyboard
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
@@ -74,6 +73,7 @@ class NumberPopup(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun show() {
|
fun show() {
|
||||||
|
clearCurrentDialog()
|
||||||
dialog = Dialog(context, android.R.style.Theme_NoTitleBar)
|
dialog = Dialog(context, android.R.style.Theme_NoTitleBar)
|
||||||
dialog.setContentView(view.root)
|
dialog.setContentView(view.root)
|
||||||
dialog.window?.apply {
|
dialog.window?.apply {
|
||||||
@@ -85,6 +85,7 @@ class NumberPopup(
|
|||||||
}
|
}
|
||||||
dialog.setOnDismissListener {
|
dialog.setOnDismissListener {
|
||||||
onDismiss()
|
onDismiss()
|
||||||
|
currentDialog = null
|
||||||
}
|
}
|
||||||
|
|
||||||
view.value.setOnKeyListener { _, keyCode, event ->
|
view.value.setOnKeyListener { _, keyCode, event ->
|
||||||
@@ -104,7 +105,8 @@ class NumberPopup(
|
|||||||
view.value.requestFocusWithKeyboard()
|
view.value.requestFocusWithKeyboard()
|
||||||
dialog.setCanceledOnTouchOutside(true)
|
dialog.setCanceledOnTouchOutside(true)
|
||||||
dialog.dimBehind()
|
dialog.dimBehind()
|
||||||
dialog.dismissCurrentAndShow()
|
currentDialog = dialog
|
||||||
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun save() {
|
fun save() {
|
||||||
@@ -113,4 +115,14 @@ class NumberPopup(
|
|||||||
onToggle(value, notes)
|
onToggle(value, notes)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
// Used to make sure that 2 popups aren't shown on top of each other
|
||||||
|
// If dialog that's already shown is detected, it's dismissed before the next one is opened.
|
||||||
|
private var currentDialog: Dialog? = null
|
||||||
|
fun clearCurrentDialog() {
|
||||||
|
currentDialog?.dismiss()
|
||||||
|
currentDialog = null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ class WeekdayPickerDialog :
|
|||||||
.setNegativeButton(
|
.setNegativeButton(
|
||||||
android.R.string.cancel
|
android.R.string.cancel
|
||||||
) { _: DialogInterface?, _: Int -> dismiss() }
|
) { _: DialogInterface?, _: Int -> dismiss() }
|
||||||
|
|
||||||
return builder.create()
|
return builder.create()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ class FrequencyChart : ScrollableChart {
|
|||||||
private var primaryColor = 0
|
private var primaryColor = 0
|
||||||
private var isBackgroundTransparent = false
|
private var isBackgroundTransparent = false
|
||||||
private lateinit var frequency: HashMap<Timestamp, Array<Int>>
|
private lateinit var frequency: HashMap<Timestamp, Array<Int>>
|
||||||
private var maxFreq = 0
|
|
||||||
private var firstWeekday = Calendar.SUNDAY
|
private var firstWeekday = Calendar.SUNDAY
|
||||||
private var isNumerical: Boolean = false
|
|
||||||
|
|
||||||
constructor(context: Context?) : super(context) {
|
constructor(context: Context?) : super(context) {
|
||||||
init()
|
init()
|
||||||
@@ -82,14 +80,8 @@ class FrequencyChart : ScrollableChart {
|
|||||||
postInvalidate()
|
postInvalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setIsNumerical(type: Boolean) {
|
|
||||||
isNumerical = type
|
|
||||||
postInvalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setFrequency(frequency: java.util.HashMap<Timestamp, Array<Int>>) {
|
fun setFrequency(frequency: java.util.HashMap<Timestamp, Array<Int>>) {
|
||||||
this.frequency = frequency
|
this.frequency = frequency
|
||||||
maxFreq = getMaxFreq(frequency)
|
|
||||||
postInvalidate()
|
postInvalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,15 +90,6 @@ class FrequencyChart : ScrollableChart {
|
|||||||
postInvalidate()
|
postInvalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getMaxFreq(frequency: HashMap<Timestamp, Array<Int>>): Int {
|
|
||||||
var maxValue = 1
|
|
||||||
for (values in frequency.values) for (value in values) maxValue = max(
|
|
||||||
value,
|
|
||||||
maxValue
|
|
||||||
)
|
|
||||||
return maxValue
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setIsBackgroundTransparent(isBackgroundTransparent: Boolean) {
|
fun setIsBackgroundTransparent(isBackgroundTransparent: Boolean) {
|
||||||
this.isBackgroundTransparent = isBackgroundTransparent
|
this.isBackgroundTransparent = isBackgroundTransparent
|
||||||
initColors()
|
initColors()
|
||||||
@@ -230,7 +213,7 @@ class FrequencyChart : ScrollableChart {
|
|||||||
canvas.drawLine(rGrid.left, rGrid.top, rGrid.right, rGrid.top, pGrid!!)
|
canvas.drawLine(rGrid.left, rGrid.top, rGrid.right, rGrid.top, pGrid!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawMarker(canvas: Canvas, rect: RectF?, value: Int?, weekdayFrequency: Int) {
|
private fun drawMarker(canvas: Canvas, rect: RectF?, value: Int?, frequency: Int) {
|
||||||
// value can be negative when the entry is skipped
|
// value can be negative when the entry is skipped
|
||||||
val valueCopy = value?.let { max(0, it) }
|
val valueCopy = value?.let { max(0, it) }
|
||||||
|
|
||||||
@@ -238,8 +221,8 @@ class FrequencyChart : ScrollableChart {
|
|||||||
// maximal allowed mark radius
|
// maximal allowed mark radius
|
||||||
val maxRadius = (rect.height() - 2 * padding) / 2.0f
|
val maxRadius = (rect.height() - 2 * padding) / 2.0f
|
||||||
// the real mark radius is scaled down by a factor depending on the maximal frequency
|
// the real mark radius is scaled down by a factor depending on the maximal frequency
|
||||||
val scalingFactor = if (isNumerical) maxFreq else weekdayFrequency
|
|
||||||
val scale = 1.0f / scalingFactor * valueCopy!!
|
val scale = 1.0f / frequency * valueCopy!!
|
||||||
val radius = maxRadius * scale
|
val radius = maxRadius * scale
|
||||||
val colorIndex = min((colors.size - 1), ((colors.size - 1) * scale).roundToInt())
|
val colorIndex = min((colors.size - 1), ((colors.size - 1) * scale).roundToInt())
|
||||||
pGraph!!.color = colors[colorIndex]
|
pGraph!!.color = colors[colorIndex]
|
||||||
@@ -302,6 +285,5 @@ class FrequencyChart : ScrollableChart {
|
|||||||
frequency[Timestamp(date)] = values
|
frequency[Timestamp(date)] = values
|
||||||
date.add(Calendar.MONTH, -1)
|
date.add(Calendar.MONTH, -1)
|
||||||
}
|
}
|
||||||
maxFreq = getMaxFreq(frequency)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import org.isoron.uhabits.core.models.Reminder
|
|||||||
import org.isoron.uhabits.core.models.WeekdayList
|
import org.isoron.uhabits.core.models.WeekdayList
|
||||||
import org.isoron.uhabits.databinding.ActivityEditHabitBinding
|
import org.isoron.uhabits.databinding.ActivityEditHabitBinding
|
||||||
import org.isoron.uhabits.utils.ColorUtils
|
import org.isoron.uhabits.utils.ColorUtils
|
||||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
|
||||||
import org.isoron.uhabits.utils.formatTime
|
import org.isoron.uhabits.utils.formatTime
|
||||||
import org.isoron.uhabits.utils.toFormattedString
|
import org.isoron.uhabits.utils.toFormattedString
|
||||||
|
|
||||||
@@ -157,23 +156,23 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val colorPickerDialogFactory = ColorPickerDialogFactory(this)
|
val colorPickerDialogFactory = ColorPickerDialogFactory(this)
|
||||||
binding.colorButton.setOnClickListener {
|
binding.colorButton.setOnClickListener {
|
||||||
val picker = colorPickerDialogFactory.create(color, themeSwitcher.currentTheme)
|
val dialog = colorPickerDialogFactory.create(color, themeSwitcher.currentTheme)
|
||||||
picker.setListener { paletteColor ->
|
dialog.setListener { paletteColor ->
|
||||||
this.color = paletteColor
|
this.color = paletteColor
|
||||||
updateColors()
|
updateColors()
|
||||||
}
|
}
|
||||||
picker.dismissCurrentAndShow(supportFragmentManager, "colorPicker")
|
dialog.show(supportFragmentManager, "colorPicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
populateFrequency()
|
populateFrequency()
|
||||||
binding.booleanFrequencyPicker.setOnClickListener {
|
binding.booleanFrequencyPicker.setOnClickListener {
|
||||||
val picker = FrequencyPickerDialog(freqNum, freqDen)
|
val dialog = FrequencyPickerDialog(freqNum, freqDen)
|
||||||
picker.onFrequencyPicked = { num, den ->
|
dialog.onFrequencyPicked = { num, den ->
|
||||||
freqNum = num
|
freqNum = num
|
||||||
freqDen = den
|
freqDen = den
|
||||||
populateFrequency()
|
populateFrequency()
|
||||||
}
|
}
|
||||||
picker.dismissCurrentAndShow(supportFragmentManager, "frequencyPicker")
|
dialog.show(supportFragmentManager, "frequencyPicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
populateTargetType()
|
populateTargetType()
|
||||||
@@ -190,8 +189,7 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
populateTargetType()
|
populateTargetType()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
val dialog = builder.create()
|
builder.show()
|
||||||
dialog.dismissCurrentAndShow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.numericalFrequencyPicker.setOnClickListener {
|
binding.numericalFrequencyPicker.setOnClickListener {
|
||||||
@@ -237,7 +235,7 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
is24HourMode,
|
is24HourMode,
|
||||||
androidColor
|
androidColor
|
||||||
)
|
)
|
||||||
dialog.dismissCurrentAndShow(supportFragmentManager, "timePicker")
|
dialog.show(supportFragmentManager, "timePicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.reminderDatePicker.setOnClickListener {
|
binding.reminderDatePicker.setOnClickListener {
|
||||||
@@ -249,7 +247,7 @@ class EditHabitActivity : AppCompatActivity() {
|
|||||||
populateReminder()
|
populateReminder()
|
||||||
}
|
}
|
||||||
dialog.setSelectedDays(reminderDays)
|
dialog.setSelectedDays(reminderDays)
|
||||||
dialog.dismissCurrentAndShow(supportFragmentManager, "dayPicker")
|
dialog.show(supportFragmentManager, "dayPicker")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.buttonSave.setOnClickListener {
|
binding.buttonSave.setOnClickListener {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package org.isoron.uhabits.activities.habits.list
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -85,6 +84,7 @@ class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
|||||||
Thread.setDefaultUncaughtExceptionHandler(BaseExceptionHandler(this))
|
Thread.setDefaultUncaughtExceptionHandler(BaseExceptionHandler(this))
|
||||||
component.listHabitsBehavior.onStartup()
|
component.listHabitsBehavior.onStartup()
|
||||||
setContentView(rootView)
|
setContentView(rootView)
|
||||||
|
parseIntents()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@@ -100,17 +100,11 @@ class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
|||||||
rootView.postInvalidate()
|
rootView.postInvalidate()
|
||||||
midnightTimer.onResume()
|
midnightTimer.onResume()
|
||||||
taskRunner.run {
|
taskRunner.run {
|
||||||
try {
|
AutoBackup(this@ListHabitsActivity).run()
|
||||||
AutoBackup(this@ListHabitsActivity).run()
|
|
||||||
appComponent.widgetUpdater.updateWidgets()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("ListHabitActivity", "TaskRunner failed", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (prefs.theme == THEME_DARK && prefs.isPureBlackEnabled != pureBlack) {
|
if (prefs.theme == THEME_DARK && prefs.isPureBlackEnabled != pureBlack) {
|
||||||
restartWithFade(ListHabitsActivity::class.java)
|
restartWithFade(ListHabitsActivity::class.java)
|
||||||
}
|
}
|
||||||
parseIntents()
|
|
||||||
super.onResume()
|
super.onResume()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +124,6 @@ class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun parseIntents() {
|
private fun parseIntents() {
|
||||||
if (intent == null) return
|
|
||||||
if (intent.action == ACTION_EDIT) {
|
if (intent.action == ACTION_EDIT) {
|
||||||
val habitId = intent.extras?.getLong("habit")
|
val habitId = intent.extras?.getLong("habit")
|
||||||
val timestamp = intent.extras?.getLong("timestamp")
|
val timestamp = intent.extras?.getLong("timestamp")
|
||||||
@@ -139,12 +132,6 @@ class ListHabitsActivity : AppCompatActivity(), Preferences.Listener {
|
|||||||
component.listHabitsBehavior.onEdit(habit, Timestamp(timestamp))
|
component.listHabitsBehavior.onEdit(habit, Timestamp(timestamp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intent = null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
|
||||||
super.onNewIntent(intent)
|
|
||||||
setIntent(intent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ import org.isoron.uhabits.tasks.ImportDataTask
|
|||||||
import org.isoron.uhabits.tasks.ImportDataTaskFactory
|
import org.isoron.uhabits.tasks.ImportDataTaskFactory
|
||||||
import org.isoron.uhabits.utils.copyTo
|
import org.isoron.uhabits.utils.copyTo
|
||||||
import org.isoron.uhabits.utils.currentTheme
|
import org.isoron.uhabits.utils.currentTheme
|
||||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
|
||||||
import org.isoron.uhabits.utils.restartWithFade
|
import org.isoron.uhabits.utils.restartWithFade
|
||||||
import org.isoron.uhabits.utils.showMessage
|
import org.isoron.uhabits.utils.showMessage
|
||||||
import org.isoron.uhabits.utils.showSendEmailScreen
|
import org.isoron.uhabits.utils.showSendEmailScreen
|
||||||
@@ -164,7 +163,7 @@ class ListHabitsScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback, quantity: Int) {
|
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback, quantity: Int) {
|
||||||
ConfirmDeleteDialog(activity, callback, quantity).dismissCurrentAndShow()
|
ConfirmDeleteDialog(activity, callback, quantity).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEditHabitsScreen(selected: List<Habit>) {
|
override fun showEditHabitsScreen(selected: List<Habit>) {
|
||||||
@@ -225,7 +224,7 @@ class ListHabitsScreen
|
|||||||
override fun showColorPicker(defaultColor: PaletteColor, callback: OnColorPickedCallback) {
|
override fun showColorPicker(defaultColor: PaletteColor, callback: OnColorPickedCallback) {
|
||||||
val picker = colorPickerFactory.create(defaultColor, themeSwitcher.currentTheme!!)
|
val picker = colorPickerFactory.create(defaultColor, themeSwitcher.currentTheme!!)
|
||||||
picker.setListener(callback)
|
picker.setListener(callback)
|
||||||
picker.dismissCurrentAndShow(activity.supportFragmentManager, "picker")
|
picker.show(activity.supportFragmentManager, "picker")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNumberPopup(
|
override fun showNumberPopup(
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitPresenter
|
|||||||
import org.isoron.uhabits.core.ui.views.OnDateClickedListener
|
import org.isoron.uhabits.core.ui.views.OnDateClickedListener
|
||||||
import org.isoron.uhabits.intents.IntentFactory
|
import org.isoron.uhabits.intents.IntentFactory
|
||||||
import org.isoron.uhabits.utils.currentTheme
|
import org.isoron.uhabits.utils.currentTheme
|
||||||
import org.isoron.uhabits.utils.dismissCurrentAndShow
|
|
||||||
import org.isoron.uhabits.utils.showMessage
|
import org.isoron.uhabits.utils.showMessage
|
||||||
import org.isoron.uhabits.utils.showSendFileScreen
|
import org.isoron.uhabits.utils.showSendFileScreen
|
||||||
import org.isoron.uhabits.widgets.WidgetUpdater
|
import org.isoron.uhabits.widgets.WidgetUpdater
|
||||||
@@ -229,7 +228,7 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
||||||
ConfirmDeleteDialog(this@ShowHabitActivity, callback, 1).dismissCurrentAndShow()
|
ConfirmDeleteDialog(this@ShowHabitActivity, callback, 1).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class FrequencyCardView(context: Context, attrs: AttributeSet) : LinearLayout(co
|
|||||||
fun setState(state: FrequencyCardState) {
|
fun setState(state: FrequencyCardState) {
|
||||||
val androidColor = state.theme.color(state.color).toInt()
|
val androidColor = state.theme.color(state.color).toInt()
|
||||||
binding.frequencyChart.setFrequency(state.frequency)
|
binding.frequencyChart.setFrequency(state.frequency)
|
||||||
binding.frequencyChart.setIsNumerical(state.isNumerical)
|
|
||||||
binding.frequencyChart.setFirstWeekday(state.firstWeekday)
|
binding.frequencyChart.setFirstWeekday(state.firstWeekday)
|
||||||
binding.title.setTextColor(androidColor)
|
binding.title.setTextColor(androidColor)
|
||||||
binding.frequencyChart.setColor(androidColor)
|
binding.frequencyChart.setColor(androidColor)
|
||||||
|
|||||||
@@ -21,16 +21,13 @@ package org.isoron.uhabits.intents
|
|||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.app.PendingIntent.FLAG_IMMUTABLE
|
import android.app.PendingIntent.FLAG_IMMUTABLE
|
||||||
import android.app.PendingIntent.FLAG_MUTABLE
|
|
||||||
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
|
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
import android.app.PendingIntent.getActivity
|
import android.app.PendingIntent.getActivity
|
||||||
import android.app.PendingIntent.getBroadcast
|
import android.app.PendingIntent.getBroadcast
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import org.isoron.uhabits.activities.habits.list.ListHabitsActivity
|
import org.isoron.uhabits.activities.habits.list.ListHabitsActivity
|
||||||
import org.isoron.uhabits.activities.habits.show.ShowHabitActivity
|
|
||||||
import org.isoron.uhabits.core.AppScope
|
import org.isoron.uhabits.core.AppScope
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.isoron.uhabits.core.models.Timestamp
|
import org.isoron.uhabits.core.models.Timestamp
|
||||||
@@ -92,20 +89,6 @@ class PendingIntentFactory
|
|||||||
)
|
)
|
||||||
.getPendingIntent(0, FLAG_IMMUTABLE or FLAG_UPDATE_CURRENT)!!
|
.getPendingIntent(0, FLAG_IMMUTABLE or FLAG_UPDATE_CURRENT)!!
|
||||||
|
|
||||||
fun showHabitTemplate(): PendingIntent {
|
|
||||||
return getActivity(
|
|
||||||
context,
|
|
||||||
0,
|
|
||||||
Intent(context, ShowHabitActivity::class.java),
|
|
||||||
getIntentTemplateFlags()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showHabitFillIn(habit: Habit) =
|
|
||||||
Intent().apply {
|
|
||||||
data = Uri.parse(habit.uriString)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showReminder(
|
fun showReminder(
|
||||||
habit: Habit,
|
habit: Habit,
|
||||||
reminderTime: Long?,
|
reminderTime: Long?,
|
||||||
@@ -159,7 +142,7 @@ class PendingIntentFactory
|
|||||||
fun showNumberPicker(habit: Habit, timestamp: Timestamp): PendingIntent? {
|
fun showNumberPicker(habit: Habit, timestamp: Timestamp): PendingIntent? {
|
||||||
return getActivity(
|
return getActivity(
|
||||||
context,
|
context,
|
||||||
(habit.id!! % Integer.MAX_VALUE).toInt() + 1,
|
0,
|
||||||
Intent(context, ListHabitsActivity::class.java).apply {
|
Intent(context, ListHabitsActivity::class.java).apply {
|
||||||
action = ListHabitsActivity.ACTION_EDIT
|
action = ListHabitsActivity.ACTION_EDIT
|
||||||
putExtra("habit", habit.id)
|
putExtra("habit", habit.id)
|
||||||
@@ -168,43 +151,4 @@ class PendingIntentFactory
|
|||||||
FLAG_IMMUTABLE or FLAG_UPDATE_CURRENT
|
FLAG_IMMUTABLE or FLAG_UPDATE_CURRENT
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showNumberPickerTemplate(): PendingIntent {
|
|
||||||
return getActivity(
|
|
||||||
context,
|
|
||||||
1,
|
|
||||||
Intent(context, ListHabitsActivity::class.java).apply {
|
|
||||||
action = ListHabitsActivity.ACTION_EDIT
|
|
||||||
},
|
|
||||||
getIntentTemplateFlags()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showNumberPickerFillIn(habit: Habit, timestamp: Timestamp) = Intent().apply {
|
|
||||||
putExtra("habit", habit.id)
|
|
||||||
putExtra("timestamp", timestamp.unixTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getIntentTemplateFlags(): Int {
|
|
||||||
var flags = 0
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
flags = flags or FLAG_MUTABLE
|
|
||||||
}
|
|
||||||
return flags
|
|
||||||
}
|
|
||||||
|
|
||||||
fun toggleCheckmarkTemplate(): PendingIntent =
|
|
||||||
getBroadcast(
|
|
||||||
context,
|
|
||||||
2,
|
|
||||||
Intent(context, WidgetReceiver::class.java).apply {
|
|
||||||
action = WidgetReceiver.ACTION_TOGGLE_REPETITION
|
|
||||||
},
|
|
||||||
getIntentTemplateFlags()
|
|
||||||
)
|
|
||||||
|
|
||||||
fun toggleCheckmarkFillIn(habit: Habit, timestamp: Timestamp) = Intent().apply {
|
|
||||||
data = Uri.parse(habit.uriString)
|
|
||||||
putExtra("timestamp", timestamp.unixTime)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package org.isoron.uhabits.utils
|
|
||||||
|
|
||||||
import android.app.Dialog
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import androidx.fragment.app.FragmentManager
|
|
||||||
import java.lang.ref.WeakReference
|
|
||||||
|
|
||||||
var currentDialog: WeakReference<Dialog> = WeakReference(null)
|
|
||||||
|
|
||||||
fun Dialog.dismissCurrentAndShow() {
|
|
||||||
currentDialog.get()?.dismiss()
|
|
||||||
currentDialog = WeakReference(this)
|
|
||||||
show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun DialogFragment.dismissCurrentAndShow(fragmentManager: FragmentManager, tag: String) {
|
|
||||||
currentDialog.get()?.dismiss()
|
|
||||||
show(fragmentManager, tag)
|
|
||||||
fragmentManager.executePendingTransactions()
|
|
||||||
currentDialog = WeakReference(this.dialog)
|
|
||||||
}
|
|
||||||
@@ -49,7 +49,6 @@ class FrequencyWidget(
|
|||||||
(widgetView.dataView as FrequencyChart).apply {
|
(widgetView.dataView as FrequencyChart).apply {
|
||||||
setFirstWeekday(firstWeekday)
|
setFirstWeekday(firstWeekday)
|
||||||
setColor(WidgetTheme().color(habit.color).toInt())
|
setColor(WidgetTheme().color(habit.color).toInt())
|
||||||
setIsNumerical(habit.isNumerical)
|
|
||||||
setFrequency(habit.originalEntries.computeWeekdayFrequency(habit.isNumerical))
|
setFrequency(habit.originalEntries.computeWeekdayFrequency(habit.isNumerical))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,10 +73,6 @@ class StackWidget(
|
|||||||
StackWidgetType.getStackWidgetAdapterViewId(widgetType),
|
StackWidgetType.getStackWidgetAdapterViewId(widgetType),
|
||||||
StackWidgetType.getStackWidgetEmptyViewId(widgetType)
|
StackWidgetType.getStackWidgetEmptyViewId(widgetType)
|
||||||
)
|
)
|
||||||
remoteViews.setPendingIntentTemplate(
|
|
||||||
StackWidgetType.getStackWidgetAdapterViewId(widgetType),
|
|
||||||
StackWidgetType.getPendingIntentTemplate(pendingIntentFactory, widgetType, habits)
|
|
||||||
)
|
|
||||||
return remoteViews
|
return remoteViews
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,14 +29,11 @@ import android.widget.RemoteViewsService
|
|||||||
import android.widget.RemoteViewsService.RemoteViewsFactory
|
import android.widget.RemoteViewsService.RemoteViewsFactory
|
||||||
import org.isoron.platform.utils.StringUtils.Companion.splitLongs
|
import org.isoron.platform.utils.StringUtils.Companion.splitLongs
|
||||||
import org.isoron.uhabits.HabitsApplication
|
import org.isoron.uhabits.HabitsApplication
|
||||||
import org.isoron.uhabits.R
|
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.isoron.uhabits.core.models.HabitNotFoundException
|
import org.isoron.uhabits.core.models.HabitNotFoundException
|
||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getToday
|
|
||||||
import org.isoron.uhabits.intents.IntentFactory
|
|
||||||
import org.isoron.uhabits.intents.PendingIntentFactory
|
|
||||||
import org.isoron.uhabits.utils.InterfaceUtils.dpToPixels
|
import org.isoron.uhabits.utils.InterfaceUtils.dpToPixels
|
||||||
|
import java.util.ArrayList
|
||||||
|
|
||||||
class StackWidgetService : RemoteViewsService() {
|
class StackWidgetService : RemoteViewsService() {
|
||||||
override fun onGetViewFactory(intent: Intent): RemoteViewsFactory {
|
override fun onGetViewFactory(intent: Intent): RemoteViewsFactory {
|
||||||
@@ -57,6 +54,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|||||||
)
|
)
|
||||||
private val habitIds: LongArray
|
private val habitIds: LongArray
|
||||||
private val widgetType: StackWidgetType
|
private val widgetType: StackWidgetType
|
||||||
|
private var remoteViews = ArrayList<RemoteViews>()
|
||||||
override fun onCreate() {}
|
override fun onCreate() {}
|
||||||
override fun onDestroy() {}
|
override fun onDestroy() {}
|
||||||
override fun getCount(): Int {
|
override fun getCount(): Int {
|
||||||
@@ -87,26 +85,8 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getViewAt(position: Int): RemoteViews? {
|
override fun getViewAt(position: Int): RemoteViews? {
|
||||||
Log.i("StackRemoteViewsFactory", "getViewAt $position started")
|
Log.i("StackRemoteViewsFactory", "getViewAt $position")
|
||||||
if (position < 0 || position >= habitIds.size) return null
|
return if (0 <= position && position < remoteViews.size) remoteViews[position] else null
|
||||||
val app = context.applicationContext as HabitsApplication
|
|
||||||
val prefs = app.component.preferences
|
|
||||||
val habitList = app.component.habitList
|
|
||||||
val options = AppWidgetManager.getInstance(context).getAppWidgetOptions(widgetId)
|
|
||||||
if (Looper.myLooper() == null) Looper.prepare()
|
|
||||||
val habits = habitIds.map { habitList.getById(it) ?: throw HabitNotFoundException() }
|
|
||||||
val h = habits[position]
|
|
||||||
val widget = constructWidget(h, prefs)
|
|
||||||
widget.setDimensions(getDimensionsFromOptions(context, options))
|
|
||||||
val landscapeViews = widget.landscapeRemoteViews
|
|
||||||
val portraitViews = widget.portraitRemoteViews
|
|
||||||
val factory = PendingIntentFactory(context, IntentFactory())
|
|
||||||
val intent = StackWidgetType.getIntentFillIn(factory, widgetType, h, habits, getToday())
|
|
||||||
landscapeViews.setOnClickFillInIntent(R.id.button, intent)
|
|
||||||
portraitViews.setOnClickFillInIntent(R.id.button, intent)
|
|
||||||
val remoteViews = RemoteViews(landscapeViews, portraitViews)
|
|
||||||
Log.i("StackRemoteViewsFactory", "getViewAt $position ended")
|
|
||||||
return remoteViews
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun constructWidget(
|
private fun constructWidget(
|
||||||
@@ -151,6 +131,24 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDataSetChanged() {
|
override fun onDataSetChanged() {
|
||||||
|
Log.i("StackRemoteViewsFactory", "onDataSetChanged started")
|
||||||
|
val app = context.applicationContext as HabitsApplication
|
||||||
|
val prefs = app.component.preferences
|
||||||
|
val habitList = app.component.habitList
|
||||||
|
val options = AppWidgetManager.getInstance(context).getAppWidgetOptions(widgetId)
|
||||||
|
val newRemoteViews = ArrayList<RemoteViews>()
|
||||||
|
if (Looper.myLooper() == null) Looper.prepare()
|
||||||
|
for (id in habitIds) {
|
||||||
|
val h = habitList.getById(id) ?: throw HabitNotFoundException()
|
||||||
|
val widget = constructWidget(h, prefs)
|
||||||
|
widget.setDimensions(getDimensionsFromOptions(context, options))
|
||||||
|
val landscapeViews = widget.landscapeRemoteViews
|
||||||
|
val portraitViews = widget.portraitRemoteViews
|
||||||
|
newRemoteViews.add(RemoteViews(landscapeViews, portraitViews))
|
||||||
|
Log.i("StackRemoteViewsFactory", "onDataSetChanged constructed widget $id")
|
||||||
|
}
|
||||||
|
remoteViews = newRemoteViews
|
||||||
|
Log.i("StackRemoteViewsFactory", "onDataSetChanged ended")
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -18,12 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.isoron.uhabits.widgets
|
package org.isoron.uhabits.widgets
|
||||||
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.Intent
|
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.core.models.Habit
|
|
||||||
import org.isoron.uhabits.core.models.Timestamp
|
|
||||||
import org.isoron.uhabits.intents.PendingIntentFactory
|
|
||||||
import java.lang.IllegalStateException
|
import java.lang.IllegalStateException
|
||||||
|
|
||||||
enum class StackWidgetType(val value: Int) {
|
enum class StackWidgetType(val value: Int) {
|
||||||
@@ -78,39 +73,5 @@ enum class StackWidgetType(val value: Int) {
|
|||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPendingIntentTemplate(
|
|
||||||
factory: PendingIntentFactory,
|
|
||||||
widgetType: StackWidgetType,
|
|
||||||
habits: List<Habit>
|
|
||||||
): PendingIntent {
|
|
||||||
val containsNumerical = habits.any { it.isNumerical }
|
|
||||||
return when (widgetType) {
|
|
||||||
CHECKMARK -> if (containsNumerical) {
|
|
||||||
factory.showNumberPickerTemplate()
|
|
||||||
} else {
|
|
||||||
factory.toggleCheckmarkTemplate()
|
|
||||||
}
|
|
||||||
FREQUENCY, SCORE, HISTORY, STREAKS, TARGET -> factory.showHabitTemplate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getIntentFillIn(
|
|
||||||
factory: PendingIntentFactory,
|
|
||||||
widgetType: StackWidgetType,
|
|
||||||
habit: Habit,
|
|
||||||
allHabitsInStackWidget: List<Habit>,
|
|
||||||
timestamp: Timestamp
|
|
||||||
): Intent {
|
|
||||||
val containsNumerical = allHabitsInStackWidget.any { it.isNumerical }
|
|
||||||
return when (widgetType) {
|
|
||||||
CHECKMARK -> if (containsNumerical) {
|
|
||||||
factory.showNumberPickerFillIn(habit, timestamp)
|
|
||||||
} else {
|
|
||||||
factory.toggleCheckmarkFillIn(habit, timestamp)
|
|
||||||
}
|
|
||||||
FREQUENCY, SCORE, HISTORY, STREAKS, TARGET -> factory.showHabitFillIn(habit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
2.1.1:
|
|
||||||
* Fix Tasker plugin
|
|
||||||
|
|
||||||
2.1:
|
2.1:
|
||||||
* Add notes to specific dates
|
* Add notes to specific dates
|
||||||
* Track at-most measurable habits
|
* Track at-most measurable habits
|
||||||
* Add skips to measurable habits
|
* Add skips to measurable habits
|
||||||
* Bring back custom frequencies
|
* Bring back custom frequencies
|
||||||
* Other minor improvements and bug fixes
|
* Other minor improvements and bug fixes
|
||||||
@@ -21,5 +21,4 @@
|
|||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
|
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.4 KiB |
@@ -25,12 +25,6 @@ class StringUtils {
|
|||||||
|
|
||||||
fun joinLongs(values: LongArray): String = values.joinToString(separator = ",")
|
fun joinLongs(values: LongArray): String = values.joinToString(separator = ",")
|
||||||
|
|
||||||
fun splitLongs(str: String): LongArray {
|
fun splitLongs(str: String): LongArray = str.split(",").map { it.toLong() }.toLongArray()
|
||||||
return try {
|
|
||||||
str.split(",").map { it.toLong() }.toLongArray()
|
|
||||||
} catch (e: NumberFormatException) {
|
|
||||||
LongArray(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ data class FrequencyCardState(
|
|||||||
val firstWeekday: Int,
|
val firstWeekday: Int,
|
||||||
val frequency: HashMap<Timestamp, Array<Int>>,
|
val frequency: HashMap<Timestamp, Array<Int>>,
|
||||||
val theme: Theme,
|
val theme: Theme,
|
||||||
val isNumerical: Boolean
|
|
||||||
)
|
)
|
||||||
|
|
||||||
class FrequencyCardPresenter {
|
class FrequencyCardPresenter {
|
||||||
@@ -41,7 +40,6 @@ class FrequencyCardPresenter {
|
|||||||
theme: Theme
|
theme: Theme
|
||||||
) = FrequencyCardState(
|
) = FrequencyCardState(
|
||||||
color = habit.color,
|
color = habit.color,
|
||||||
isNumerical = habit.isNumerical,
|
|
||||||
frequency = habit.originalEntries.computeWeekdayFrequency(
|
frequency = habit.originalEntries.computeWeekdayFrequency(
|
||||||
isNumerical = habit.isNumerical
|
isNumerical = habit.isNumerical
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class BarChart(
|
|||||||
val r = round(barWidth * 0.15)
|
val r = round(barWidth * 0.15)
|
||||||
if (2 * r < barHeight) {
|
if (2 * r < barHeight) {
|
||||||
canvas.fillRect(x, y + r, barWidth, barHeight - r)
|
canvas.fillRect(x, y + r, barWidth, barHeight - r)
|
||||||
canvas.fillRect(x + r, y, barWidth - 2 * r, r + 1)
|
canvas.fillRect(x + r, y, barWidth - 2 * r, r)
|
||||||
canvas.fillCircle(x + r, y + r, r)
|
canvas.fillCircle(x + r, y + r, r)
|
||||||
canvas.fillCircle(x + barWidth - r, y + r, r)
|
canvas.fillCircle(x + barWidth - r, y + r, r)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user