made the popup and the updating of the widget work.

pull/499/head
thomas 6 years ago
parent 3d039db61c
commit 26d91a2d1d

@ -93,6 +93,16 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.habits.list.ListHabitsActivity"/>
</activity>
<activity
android:name=".widgets.activities.NumericalCheckmarkWidgetActivity"
android:label="NumericalCheckmarkWidget"
android:noHistory="true"
android:excludeFromRecents="true"
android:theme="@style/Theme.AppCompat.Light.Dialog">
<intent-filter>
<action android:name="org.isoron.uhabits.ACTION_SHOW_NUMERICAL_VALUE_ACTIVITY"/>
</intent-filter>
</activity>
<activity android:name=".notifications.SnoozeDelayPickerActivity"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
@ -175,6 +185,15 @@
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="org.isoron.uhabits.ACTION_SAVE_NUMERICAL_VALUE"/>
<data
android:host="org.isoron.uhabits"
android:scheme="content"/>
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="org.isoron.uhabits.ACTION_TOGGLE_REPETITION"/>
<data

@ -29,17 +29,19 @@ import org.isoron.androidbase.activities.*
import org.isoron.androidbase.utils.*
import org.isoron.uhabits.*
import org.isoron.uhabits.core.ui.screens.habits.list.*
import javax.annotation.Nullable
import javax.inject.*
class NumberPickerFactory
@Inject constructor(
@ActivityContext private val context: Context
) {
fun create(value: Double,
unit: String,
callback: ListHabitsBehavior.NumberPickerCallback): AlertDialog {
val inflater = LayoutInflater.from(context)
val inflater : LayoutInflater = LayoutInflater.from(context)
val view = inflater.inflate(R.layout.number_picker_dialog, null)
val picker = view.findViewById<NumberPicker>(R.id.picker)

@ -36,6 +36,11 @@ class IntentParser
return CheckmarkIntentData(parseHabit(uri), parseTimestamp(intent))
}
fun copyIntentData(source: Intent, destination: Intent){
destination.data=source.data;
destination.putExtra("timestamp",source.getLongExtra("timestamp",getToday()))
}
private fun parseHabit(uri: Uri): Habit {
val habit = habits.getById(parseId(uri)) ?:
throw IllegalArgumentException("habit not found")
@ -43,7 +48,7 @@ class IntentParser
}
private fun parseTimestamp(intent: Intent): Timestamp {
val today = DateUtils.getToday().unixTime
val today = getToday()
var timestamp = intent.getLongExtra("timestamp", today)
timestamp = DateUtils.getStartOfDay(timestamp)
@ -53,5 +58,9 @@ class IntentParser
return Timestamp(timestamp)
}
private fun getToday() : Long{
return DateUtils.getToday().unixTime
}
class CheckmarkIntentData(var habit: Habit, var timestamp: Timestamp)
}

@ -104,12 +104,22 @@ class PendingIntentFactory
},
FLAG_UPDATE_CURRENT)
fun setNumericalValue(habit: Habit, numericalValue: Int, timestamp: Long?): PendingIntent =
fun setNumericalValue(widgetContext: Context, habit: Habit, numericalValue: Int, timestamp: Long?): PendingIntent =
PendingIntent.getBroadcast(
widgetContext, 2,
Intent(widgetContext, WidgetReceiver::class.java).apply {
data = Uri.parse(habit.uriString)
action = WidgetReceiver.ACTION_SET_NUMERICAL_VALUE
putExtra("numericalValue",numericalValue);
if (timestamp != null) putExtra("timestamp", timestamp)
},
FLAG_UPDATE_CURRENT)
fun saveNumericalValue(habit: Habit, numericalValue: Int, timestamp: Long?): PendingIntent =
PendingIntent.getBroadcast(
context, 2,
Intent(context, WidgetReceiver::class.java).apply {
data = Uri.parse(habit.uriString)
action = WidgetReceiver.ACTION_SET_NUMERICAL_VALUE
action = WidgetReceiver.ACTION_SAVE_NUMERICAL_VALUE
putExtra("numericalValue",numericalValue);
if (timestamp != null) putExtra("timestamp", timestamp)
},

@ -1,113 +0,0 @@
/*
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.receivers;
import android.content.*;
import android.util.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.core.preferences.*;
import org.isoron.uhabits.core.ui.widgets.*;
import org.isoron.uhabits.intents.*;
import org.isoron.uhabits.sync.*;
import dagger.*;
/**
* The Android BroadcastReceiver for Loop Habit Tracker.
* <p>
* All broadcast messages are received and processed by this class.
*/
public class WidgetReceiver extends BroadcastReceiver
{
public static final String ACTION_ADD_REPETITION =
"org.isoron.uhabits.ACTION_ADD_REPETITION";
public static final String ACTION_DISMISS_REMINDER =
"org.isoron.uhabits.ACTION_DISMISS_REMINDER";
public static final String ACTION_REMOVE_REPETITION =
"org.isoron.uhabits.ACTION_REMOVE_REPETITION";
public static final String ACTION_TOGGLE_REPETITION =
"org.isoron.uhabits.ACTION_TOGGLE_REPETITION";
public static final String ACTION_SET_NUMERICAL_VALUE =
"org.isoron.uhabits.ACTION_SET_NUMERICAL_VALUE";
@Override
public void onReceive(final Context context, Intent intent)
{
HabitsApplication app =
(HabitsApplication) context.getApplicationContext();
WidgetComponent component = DaggerWidgetReceiver_WidgetComponent
.builder()
.habitsApplicationComponent(app.getComponent())
.build();
IntentParser parser = app.getComponent().getIntentParser();
WidgetBehavior controller = component.getWidgetController();
Preferences prefs = app.getComponent().getPreferences();
if(prefs.isSyncEnabled())
context.startService(new Intent(context, SyncService.class));
try
{
IntentParser.CheckmarkIntentData data;
data = parser.parseCheckmarkIntent(intent);
switch (intent.getAction())
{
case ACTION_ADD_REPETITION:
controller.onAddRepetition(data.getHabit(),
data.getTimestamp());
break;
case ACTION_TOGGLE_REPETITION:
controller.onToggleRepetition(data.getHabit(),
data.getTimestamp());
break;
case ACTION_REMOVE_REPETITION:
controller.onRemoveRepetition(data.getHabit(),
data.getTimestamp());
break;
case ACTION_SET_NUMERICAL_VALUE:
//controller.onToggleRepetition(data.getHabit(),
// data.getTimestamp());
break;
}
}
catch (RuntimeException e)
{
Log.e("WidgetReceiver", "could not process intent", e);
}
}
@ReceiverScope
@Component(dependencies = HabitsApplicationComponent.class)
interface WidgetComponent
{
WidgetBehavior getWidgetController();
}
}

@ -0,0 +1,106 @@
/*
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.receivers
import android.content.*
import android.util.*
import org.isoron.uhabits.*
import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.core.ui.widgets.*
import org.isoron.uhabits.intents.*
import org.isoron.uhabits.sync.*
import dagger.*
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsBehavior
import org.isoron.uhabits.widgets.activities.NumericalCheckmarkWidgetActivity
import android.content.Intent
/**
* The Android BroadcastReceiver for Loop Habit Tracker.
*
*
* All broadcast messages are received and processed by this class.
*/
class WidgetReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val app = context.applicationContext as HabitsApplication
val component = DaggerWidgetReceiver_WidgetComponent
.builder()
.habitsApplicationComponent(app.component)
.build()
val parser = app.component.intentParser
val controller = component.widgetController
val prefs = app.component.preferences
if (prefs.isSyncEnabled)
context.startService(Intent(context, SyncService::class.java))
try {
val data: IntentParser.CheckmarkIntentData = parser.parseCheckmarkIntent(intent)
when (intent.action) {
ACTION_ADD_REPETITION -> controller.onAddRepetition(data.habit, data.timestamp)
ACTION_TOGGLE_REPETITION -> controller.onToggleRepetition(data.habit, data.timestamp)
ACTION_REMOVE_REPETITION -> controller.onRemoveRepetition(data.habit, data.timestamp)
ACTION_SET_NUMERICAL_VALUE -> {
val numberSelectorIntent = Intent(context, NumericalCheckmarkWidgetActivity::class.java)
numberSelectorIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
numberSelectorIntent.action = NumericalCheckmarkWidgetActivity.ACTION_SHOW_NUMERICAL_VALUE_ACTIVITY
parser.copyIntentData(intent,numberSelectorIntent)//give the habit and timestamp data to the numericalCheckmarkWidgetActivity
context.startActivity(numberSelectorIntent)
}
}
} catch (e: RuntimeException) {
Log.e("WidgetReceiver", "could not process intent", e)
}
}
@ReceiverScope
@Component(dependencies = [HabitsApplicationComponent::class])
internal interface WidgetComponent {
val widgetController: WidgetBehavior
}
companion object {
val ACTION_ADD_REPETITION = "org.isoron.uhabits.ACTION_ADD_REPETITION"
val ACTION_DISMISS_REMINDER = "org.isoron.uhabits.ACTION_DISMISS_REMINDER"
val ACTION_REMOVE_REPETITION = "org.isoron.uhabits.ACTION_REMOVE_REPETITION"
val ACTION_TOGGLE_REPETITION = "org.isoron.uhabits.ACTION_TOGGLE_REPETITION"
val ACTION_SET_NUMERICAL_VALUE = "org.isoron.uhabits.ACTION_SET_NUMERICAL_VALUE"
}
}

@ -40,7 +40,7 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
private WidgetPreferences widgetPrefs;
public static void updateAppWidget(@NonNull AppWidgetManager manager,
public static void updateAppWidget(@NonNull Context context, @NonNull AppWidgetManager manager,
@NonNull BaseWidget widget)
{
RemoteViews landscape = widget.getLandscapeRemoteViews();
@ -83,7 +83,7 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
BaseWidget widget = getWidgetFromId(context, widgetId);
WidgetDimensions dims = getDimensionsFromOptions(context, options);
widget.setDimensions(dims);
updateAppWidget(manager, widget);
updateAppWidget(context, manager, widget);
}
catch (RuntimeException e)
{
@ -179,7 +179,7 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
Bundle options = manager.getAppWidgetOptions(widgetId);
widget.setDimensions(getDimensionsFromOptions(context, options));
updateAppWidget(manager, widget);
updateAppWidget(context, manager, widget);
}
catch (RuntimeException e)
{

@ -2,8 +2,15 @@ package org.isoron.uhabits.widgets
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.View
import org.isoron.uhabits.core.models.Habit
import org.isoron.uhabits.receivers.WidgetReceiver
import org.isoron.uhabits.receivers.WidgetReceiver.Companion.ACTION_SET_NUMERICAL_VALUE
import org.isoron.uhabits.utils.PaletteUtils
import org.isoron.uhabits.widgets.activities.NumericalCheckmarkWidgetActivity
import org.isoron.uhabits.widgets.views.CheckmarkWidgetView
import org.isoron.uhabits.widgets.views.NumericalCheckmarkWidgetView
class NumericalCheckmarkWidget(context: Context, widgetId: Int, habit: Habit) : CheckmarkWidget(context, widgetId, habit) {
@ -11,12 +18,25 @@ class NumericalCheckmarkWidget(context: Context, widgetId: Int, habit: Habit) :
private lateinit var view: NumericalCheckmarkWidgetView
override fun getOnClickPendingIntent(context: Context): PendingIntent {
view.showNumberSelector()
return pendingIntentFactory.setNumericalValue(habit, 10,null)
return pendingIntentFactory.setNumericalValue(context, habit, 10,null)
}
override fun buildView(): View {
view = NumericalCheckmarkWidgetView(context)
return view;
}
override fun refreshData(v: View) {
(v as NumericalCheckmarkWidgetView).apply {
Log.d("NumericalChckmarkWidget", "Refreshing data")
setPercentage(habit.scores.todayValue.toFloat())
setActiveColor(PaletteUtils.getColor(context, habit.color))
setName(habit.name)
setCheckmarkValue(habit.checkmarks.todayValue)
refresh()
}
}
}

@ -0,0 +1,74 @@
package org.isoron.uhabits.widgets.activities
import android.app.Activity
import android.appwidget.AppWidgetManager
import org.isoron.uhabits.R
import android.content.Context
import android.os.Bundle
import android.view.Window
import org.isoron.androidbase.AppContextModule
import org.isoron.uhabits.HabitsApplication
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsBehavior
import org.isoron.uhabits.core.ui.widgets.NumericalCheckmarkWidgetBehavior
import org.isoron.uhabits.intents.IntentFactory
import org.isoron.uhabits.intents.IntentParser
import org.isoron.uhabits.intents.PendingIntentFactory
import org.isoron.uhabits.widgets.WidgetUpdater
class NumericalCheckmarkWidgetActivity : Activity() {
//private var activityComponent : NumericalCheckmarkWidgetActivityComponent? = null
private lateinit var behavior : NumericalCheckmarkWidgetBehavior
private var data: IntentParser.CheckmarkIntentData? = null
private lateinit var widgetUpdater : WidgetUpdater
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.widget_checkmark_number_screen)
val app = this.applicationContext as HabitsApplication
val component = app.component
val parser = app.component.intentParser
data = parser.parseCheckmarkIntent(intent)
behavior = NumericalCheckmarkWidgetBehavior(component.habitList,component.commandRunner)
widgetUpdater = component.widgetUpdater
showNumberSelector(this)
}
class CallBackReceiver : ListHabitsBehavior.NumberPickerCallback{
private val activity : NumericalCheckmarkWidgetActivity
constructor(activity: NumericalCheckmarkWidgetActivity){
this.activity=activity
}
override fun onNumberPicked(newValue: Double) {
activity.saveNewNumer(newValue)
}
}
fun saveNewNumer(newValue: Double){
behavior.setNumericValue(data!!.habit,data!!.timestamp,(newValue*1000).toInt())
widgetUpdater.updateWidgets()
finish()
}
fun showNumberSelector(context: Context) {
var localData = data
if(behavior!=null && localData!=null) {//if a blank screen shows up without a popup when pressing the widget, you should check if this check passes.
val numberPickerFactory = NumberPickerFactory(context)
numberPickerFactory.create( data!!.habit.checkmarks.today!!.value.toDouble()/1000, "This is a test", CallBackReceiver(this)).show()
}
}
companion object{
val ACTION_SHOW_NUMERICAL_VALUE_ACTIVITY = "org.isoron.uhabits.ACTION_SHOW_NUMERICAL_VALUE_ACTIVITY"
}
}

@ -0,0 +1,37 @@
package org.isoron.uhabits.widgets.activities;
import android.content.Context;
import org.isoron.androidbase.AppContext;
import org.isoron.androidbase.AppContextModule;
import org.isoron.uhabits.HabitsModule;
import org.isoron.uhabits.core.AppScope;
import org.isoron.uhabits.core.commands.CommandRunner;
import org.isoron.uhabits.core.models.HabitList;
import org.isoron.uhabits.core.preferences.Preferences;
import org.isoron.uhabits.core.tasks.TaskRunner;
import org.isoron.uhabits.core.ui.widgets.NumericalCheckmarkWidgetBehavior;
import org.isoron.uhabits.tasks.AndroidTaskRunner;
import dagger.Component;
@AppScope
@Component(modules = {
AppContextModule.class,
HabitsModule.class,
AndroidTaskRunner.class,
})
public interface NumericalCheckmarkWidgetActivityComponent {
NumericalCheckmarkWidgetBehavior getNumericalCheckmarkWidgetBehavior();
CommandRunner getCommandRunner();
@AppContext
Context getContext();
HabitList getHabitList();
Preferences getPreferences();
TaskRunner getTaskRunner();
}

@ -13,8 +13,6 @@ import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsBehavior
class NumericalCheckmarkWidgetView : CheckmarkWidgetView {
private var callBackReciever : CallBackReciever = CallBackReciever()
constructor(context: Context) : super(context) {}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
@ -52,16 +50,4 @@ class NumericalCheckmarkWidgetView : CheckmarkWidgetView {
postInvalidate()
}
class CallBackReciever : ListHabitsBehavior.NumberPickerCallback{
override fun onNumberPicked(newValue: Double) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
fun showNumberSelector() {
val numberPickerFactory = NumberPickerFactory(context)
numberPickerFactory.create(1000.0, "This is a test", callBackReciever).show()
}
}

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
~
~ This file is part of Loop Habit Tracker.
~
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by the
~ Free Software Foundation, either version 3 of the License, or (at your
~ option) any later version.
~
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
~ more details.
~
~ You should have received a copy of the GNU General Public License along
~ with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--
This layout is made so whenever the number selection popup shows up, there is some layout available.
The dark backdrop is supplied by @style/Theme.AppCompat.Light.Dialog
The selector dialog is supplied by numberPickerFactory.
-->
<FrameLayout
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frame"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
</FrameLayout>

@ -62,6 +62,7 @@ public class CreateRepetitionCommand extends Command
reps.add(newRep);
habit.invalidateNewerThan(timestamp);
}
@NonNull

@ -0,0 +1,105 @@
/*
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.uhabits.core.commands;
import android.support.annotation.NonNull;
import org.isoron.uhabits.core.models.Habit;
import org.isoron.uhabits.core.models.HabitList;
import org.isoron.uhabits.core.models.HabitNotFoundException;
/**
* Command to update a habit.
*/
public class UpdateHabitCommand extends Command
{
@NonNull
private HabitList list;
@NonNull
final Habit habit;
public UpdateHabitCommand(@NonNull HabitList list,
@NonNull Habit habit)
{
super();
this.list = list;
this.habit = habit;
}
@Override
public void execute()
{
list.update(habit);
}
@NonNull
public Habit getHabit()
{
return habit;
}
@Override
@NonNull
public Record toRecord()
{
return new Record(this);
}
@Override
public void undo()
{
throw new RuntimeException("Update command cannot be undone");
}
public static class Record
{
@NonNull
public String id;
@NonNull
public String event = "Update";
public long habit;
public Record(@NonNull UpdateHabitCommand command)
{
id = command.getId();
Long habitId = command.habit.getId();
if (habitId == null) throw new RuntimeException("Habit not saved");
this.habit = habitId;
}
public UpdateHabitCommand toCommand(@NonNull HabitList habitList)
{
Habit h = habitList.getById(habit);
if (h == null) throw new HabitNotFoundException();
UpdateHabitCommand command;
command = new UpdateHabitCommand(
habitList, h);
command.setId(id);
return command;
}
}
}

@ -206,7 +206,7 @@ public class Preferences
public boolean isDeveloper()
{
return storage.getBoolean("pref_developer", false);
return true;//return storage.getBoolean("pref_developer", false);
}
public void setDeveloper(boolean isDeveloper)

@ -0,0 +1,27 @@
package org.isoron.uhabits.core.ui.widgets;
import android.support.annotation.NonNull;
import org.isoron.uhabits.core.commands.CommandRunner;
import org.isoron.uhabits.core.models.HabitList;
public class BaseWidgetBehavior {
protected HabitList getHabitList() {
return habitList;
}
@NonNull
protected CommandRunner getCommandRunner() {
return commandRunner;
}
private HabitList habitList;
@NonNull
private final CommandRunner commandRunner;
public BaseWidgetBehavior(HabitList habitList, @NonNull CommandRunner commandRunner) {
this.habitList = habitList;
this.commandRunner = commandRunner;
}
}

@ -0,0 +1,25 @@
package org.isoron.uhabits.core.ui.widgets;
import android.support.annotation.NonNull;
import org.isoron.uhabits.core.commands.CommandRunner;
import org.isoron.uhabits.core.commands.CreateRepetitionCommand;
import org.isoron.uhabits.core.models.Habit;
import org.isoron.uhabits.core.models.HabitList;
import org.isoron.uhabits.core.models.Timestamp;
import javax.inject.Inject;
public class NumericalCheckmarkWidgetBehavior extends BaseWidgetBehavior{
@Inject
public NumericalCheckmarkWidgetBehavior(@NonNull HabitList habitList,
@NonNull CommandRunner commandRunner){
super(habitList, commandRunner);
}
public void setNumericValue(@NonNull Habit habit, Timestamp timestamp, int newValue) {
getCommandRunner().execute(
new CreateRepetitionCommand(habit, timestamp, newValue),
habit.getId());
}
}

@ -27,12 +27,9 @@ import org.isoron.uhabits.core.ui.*;
import javax.inject.*;
public class WidgetBehavior
public class WidgetBehavior extends BaseWidgetBehavior
{
private HabitList habitList;
@NonNull
private final CommandRunner commandRunner;
private NotificationTray notificationTray;
@ -41,8 +38,7 @@ public class WidgetBehavior
@NonNull CommandRunner commandRunner,
@NonNull NotificationTray notificationTray)
{
this.habitList = habitList;
this.commandRunner = commandRunner;
super(habitList, commandRunner);
this.notificationTray = notificationTray;
}
@ -69,8 +65,15 @@ public class WidgetBehavior
private void performToggle(@NonNull Habit habit, Timestamp timestamp)
{
commandRunner.execute(
new ToggleRepetitionCommand(habitList, habit, timestamp),
getCommandRunner().execute(
new ToggleRepetitionCommand(getHabitList(), habit, timestamp),
habit.getId());
}
public void updateWidget(@NonNull Habit habit)
{
getCommandRunner().execute(
new UpdateHabitCommand(getHabitList(), habit),
habit.getId());
}
}

Loading…
Cancel
Save