Skip to content

Commit

Permalink
Add action to show reminder right now (for developers)
Browse files Browse the repository at this point in the history
  • Loading branch information
iSoron committed Nov 15, 2017
1 parent e91f1c3 commit 2a4a7c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ import org.isoron.androidbase.activities.*
import org.isoron.uhabits.*
import org.isoron.uhabits.activities.habits.list.views.*
import org.isoron.uhabits.core.commands.*
import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.core.ui.*
import org.isoron.uhabits.core.ui.screens.habits.list.*
import org.isoron.uhabits.core.utils.*
import javax.inject.*

@ActivityScope
class ListHabitsSelectionMenu @Inject constructor(
private val screen: ListHabitsScreen,
private val listAdapter: HabitCardListAdapter,
var commandRunner: CommandRunner,
private val prefs: Preferences,
private val behavior: ListHabitsSelectionMenuBehavior,
private val listController: Lazy<HabitCardListController>
private val listController: Lazy<HabitCardListController>,
private val notificationTray: NotificationTray
) : BaseSelectionMenu() {

override fun onFinish() {
Expand Down Expand Up @@ -69,6 +74,12 @@ class ListHabitsSelectionMenu @Inject constructor(
return true
}

R.id.action_notify -> {
for(h in listAdapter.selected)
notificationTray.show(h, DateUtils.getToday(), 0)
return true
}

else -> return false
}
}
Expand All @@ -78,12 +89,14 @@ class ListHabitsSelectionMenu @Inject constructor(
val itemColor = menu.findItem(R.id.action_color)
val itemArchive = menu.findItem(R.id.action_archive_habit)
val itemUnarchive = menu.findItem(R.id.action_unarchive_habit)
val itemNotify = menu.findItem(R.id.action_notify)

itemColor.isVisible = true
itemEdit.isVisible = behavior.canEdit()
itemArchive.isVisible = behavior.canArchive()
itemUnarchive.isVisible = behavior.canUnarchive()
setTitle(Integer.toString(listAdapter.selected.size))
itemNotify.isVisible = prefs.isDeveloper

return true
}
Expand Down
5 changes: 5 additions & 0 deletions uhabits-android/src/main/res/menu/list_habits_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@
android:title="@string/delete"
app:showAsAction="never"/>

<item
android:id="@+id/action_notify"
android:title="@string/reminder"
app:showAsAction="never"/>

</menu>

0 comments on commit 2a4a7c9

Please sign in to comment.