mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
@@ -78,8 +78,6 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
androidTestAnnotationProcessor "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"
|
|
||||||
androidTestCompileOnly "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"
|
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-contrib:$ESPRESSO_VERSION"
|
androidTestImplementation "androidx.test.espresso:espresso-contrib:$ESPRESSO_VERSION"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-core:$ESPRESSO_VERSION"
|
androidTestImplementation "androidx.test.espresso:espresso-core:$ESPRESSO_VERSION"
|
||||||
androidTestImplementation "com.google.dagger:dagger:$DAGGER_VERSION"
|
androidTestImplementation "com.google.dagger:dagger:$DAGGER_VERSION"
|
||||||
@@ -93,8 +91,6 @@ dependencies {
|
|||||||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||||
androidTestImplementation 'androidx.test:rules:1.3.0'
|
androidTestImplementation 'androidx.test:rules:1.3.0'
|
||||||
androidTestImplementation project(":uhabits-core")
|
androidTestImplementation project(":uhabits-core")
|
||||||
annotationProcessor "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"
|
|
||||||
compileOnly "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"
|
|
||||||
compileOnly "javax.annotation:jsr250-api:1.0"
|
compileOnly "javax.annotation:jsr250-api:1.0"
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
||||||
implementation "com.github.paolorotolo:appintro:3.4.0"
|
implementation "com.github.paolorotolo:appintro:3.4.0"
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ import android.content.res.*;
|
|||||||
import androidx.annotation.*;
|
import androidx.annotation.*;
|
||||||
import androidx.appcompat.app.*;
|
import androidx.appcompat.app.*;
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
import org.isoron.uhabits.core.ui.callbacks.*;
|
import org.isoron.uhabits.core.ui.callbacks.*;
|
||||||
import org.isoron.uhabits.inject.*;
|
import org.isoron.uhabits.inject.*;
|
||||||
@@ -34,10 +32,9 @@ import org.isoron.uhabits.inject.*;
|
|||||||
/**
|
/**
|
||||||
* Dialog that asks the user confirmation before executing a delete operation.
|
* Dialog that asks the user confirmation before executing a delete operation.
|
||||||
*/
|
*/
|
||||||
@AutoFactory(allowSubclasses = true)
|
|
||||||
public class ConfirmDeleteDialog extends AlertDialog
|
public class ConfirmDeleteDialog extends AlertDialog
|
||||||
{
|
{
|
||||||
protected ConfirmDeleteDialog(@Provided @ActivityContext Context context,
|
public ConfirmDeleteDialog(@ActivityContext Context context,
|
||||||
@NonNull OnConfirmedCallback callback,
|
@NonNull OnConfirmedCallback callback,
|
||||||
int quantity)
|
int quantity)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,16 +25,13 @@ import android.content.res.*;
|
|||||||
import androidx.annotation.*;
|
import androidx.annotation.*;
|
||||||
import androidx.appcompat.app.*;
|
import androidx.appcompat.app.*;
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
import org.isoron.uhabits.*;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
|
||||||
import org.isoron.uhabits.core.ui.callbacks.*;
|
import org.isoron.uhabits.core.ui.callbacks.*;
|
||||||
import org.isoron.uhabits.inject.*;
|
import org.isoron.uhabits.inject.*;
|
||||||
|
|
||||||
@AutoFactory(allowSubclasses = true)
|
|
||||||
public class ConfirmSyncKeyDialog extends AlertDialog
|
public class ConfirmSyncKeyDialog extends AlertDialog
|
||||||
{
|
{
|
||||||
protected ConfirmSyncKeyDialog(@Provided @ActivityContext Context context,
|
public ConfirmSyncKeyDialog(@ActivityContext Context context,
|
||||||
@NonNull OnConfirmedCallback callback)
|
@NonNull OnConfirmedCallback callback)
|
||||||
{
|
{
|
||||||
super(context);
|
super(context);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
|
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialogFactory
|
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmSyncKeyDialogFactory
|
import org.isoron.uhabits.activities.common.dialogs.ConfirmSyncKeyDialog
|
||||||
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
|
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
|
||||||
import org.isoron.uhabits.activities.habits.edit.HabitTypeDialog
|
import org.isoron.uhabits.activities.habits.edit.HabitTypeDialog
|
||||||
import org.isoron.uhabits.activities.habits.list.views.HabitCardListAdapter
|
import org.isoron.uhabits.activities.habits.list.views.HabitCardListAdapter
|
||||||
@@ -91,8 +91,6 @@ class ListHabitsScreen
|
|||||||
private val taskRunner: TaskRunner,
|
private val taskRunner: TaskRunner,
|
||||||
private val exportDBFactory: ExportDBTaskFactory,
|
private val exportDBFactory: ExportDBTaskFactory,
|
||||||
private val importTaskFactory: ImportDataTaskFactory,
|
private val importTaskFactory: ImportDataTaskFactory,
|
||||||
private val confirmDeleteDialogFactory: ConfirmDeleteDialogFactory,
|
|
||||||
private val confirmSyncKeyDialogFactory: ConfirmSyncKeyDialogFactory,
|
|
||||||
private val colorPickerFactory: ColorPickerDialogFactory,
|
private val colorPickerFactory: ColorPickerDialogFactory,
|
||||||
private val numberPickerFactory: NumberPickerFactory,
|
private val numberPickerFactory: NumberPickerFactory,
|
||||||
private val behavior: Lazy<ListHabitsBehavior>
|
private val behavior: Lazy<ListHabitsBehavior>
|
||||||
@@ -172,7 +170,7 @@ class ListHabitsScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback, quantity: Int) {
|
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback, quantity: Int) {
|
||||||
confirmDeleteDialogFactory.create(callback, quantity).show()
|
ConfirmDeleteDialog(activity, callback, quantity).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEditHabitsScreen(habits: List<Habit>) {
|
override fun showEditHabitsScreen(habits: List<Habit>) {
|
||||||
@@ -250,7 +248,7 @@ class ListHabitsScreen
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showConfirmInstallSyncKey(callback: OnConfirmedCallback) {
|
override fun showConfirmInstallSyncKey(callback: OnConfirmedCallback) {
|
||||||
confirmSyncKeyDialogFactory.create(callback).show()
|
ConfirmSyncKeyDialog(activity, callback).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getExecuteString(command: Command): String? {
|
private fun getExecuteString(command: Command): String? {
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import android.text.TextPaint
|
|||||||
import android.view.HapticFeedbackConstants
|
import android.view.HapticFeedbackConstants
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.MeasureSpec.EXACTLY
|
import android.view.View.MeasureSpec.EXACTLY
|
||||||
import com.google.auto.factory.AutoFactory
|
|
||||||
import com.google.auto.factory.Provided
|
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.core.models.Entry
|
import org.isoron.uhabits.core.models.Entry
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.NO
|
import org.isoron.uhabits.core.models.Entry.Companion.NO
|
||||||
@@ -43,11 +41,19 @@ import org.isoron.uhabits.utils.getFontAwesome
|
|||||||
import org.isoron.uhabits.utils.showMessage
|
import org.isoron.uhabits.utils.showMessage
|
||||||
import org.isoron.uhabits.utils.sres
|
import org.isoron.uhabits.utils.sres
|
||||||
import org.isoron.uhabits.utils.toMeasureSpec
|
import org.isoron.uhabits.utils.toMeasureSpec
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class CheckmarkButtonViewFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@ActivityContext val context: Context,
|
||||||
|
val preferences: Preferences
|
||||||
|
) {
|
||||||
|
fun create() = CheckmarkButtonView(context, preferences)
|
||||||
|
}
|
||||||
|
|
||||||
@AutoFactory
|
|
||||||
class CheckmarkButtonView(
|
class CheckmarkButtonView(
|
||||||
@Provided @ActivityContext context: Context,
|
context: Context,
|
||||||
@Provided val preferences: Preferences
|
val preferences: Preferences
|
||||||
) : View(context),
|
) : View(context),
|
||||||
View.OnClickListener,
|
View.OnClickListener,
|
||||||
View.OnLongClickListener {
|
View.OnLongClickListener {
|
||||||
|
|||||||
@@ -20,19 +20,26 @@
|
|||||||
package org.isoron.uhabits.activities.habits.list.views
|
package org.isoron.uhabits.activities.habits.list.views
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.google.auto.factory.AutoFactory
|
|
||||||
import com.google.auto.factory.Provided
|
|
||||||
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
|
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
|
||||||
import org.isoron.uhabits.core.models.Timestamp
|
import org.isoron.uhabits.core.models.Timestamp
|
||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.core.utils.DateUtils
|
import org.isoron.uhabits.core.utils.DateUtils
|
||||||
import org.isoron.uhabits.inject.ActivityContext
|
import org.isoron.uhabits.inject.ActivityContext
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class CheckmarkPanelViewFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@ActivityContext val context: Context,
|
||||||
|
val preferences: Preferences,
|
||||||
|
private val buttonFactory: CheckmarkButtonViewFactory
|
||||||
|
) {
|
||||||
|
fun create() = CheckmarkPanelView(context, preferences, buttonFactory)
|
||||||
|
}
|
||||||
|
|
||||||
@AutoFactory
|
|
||||||
class CheckmarkPanelView(
|
class CheckmarkPanelView(
|
||||||
@Provided @ActivityContext context: Context,
|
context: Context,
|
||||||
@Provided preferences: Preferences,
|
preferences: Preferences,
|
||||||
@Provided private val buttonFactory: CheckmarkButtonViewFactory
|
private val buttonFactory: CheckmarkButtonViewFactory
|
||||||
) : ButtonPanelView<CheckmarkButtonView>(context, preferences) {
|
) : ButtonPanelView<CheckmarkButtonView>(context, preferences) {
|
||||||
|
|
||||||
var values = IntArray(0)
|
var values = IntArray(0)
|
||||||
|
|||||||
@@ -32,20 +32,28 @@ import androidx.recyclerview.widget.ItemTouchHelper.START
|
|||||||
import androidx.recyclerview.widget.ItemTouchHelper.UP
|
import androidx.recyclerview.widget.ItemTouchHelper.UP
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.auto.factory.AutoFactory
|
|
||||||
import com.google.auto.factory.Provided
|
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.common.views.BundleSavedState
|
import org.isoron.uhabits.activities.common.views.BundleSavedState
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
import org.isoron.uhabits.inject.ActivityContext
|
import org.isoron.uhabits.inject.ActivityContext
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class HabitCardListViewFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@ActivityContext val context: Context,
|
||||||
|
val adapter: HabitCardListAdapter,
|
||||||
|
val cardViewFactory: HabitCardViewFactory,
|
||||||
|
val controller: Lazy<HabitCardListController>
|
||||||
|
) {
|
||||||
|
fun create() = HabitCardListView(context, adapter, cardViewFactory, controller)
|
||||||
|
}
|
||||||
|
|
||||||
@AutoFactory
|
|
||||||
class HabitCardListView(
|
class HabitCardListView(
|
||||||
@Provided @ActivityContext context: Context,
|
@ActivityContext context: Context,
|
||||||
@Provided private val adapter: HabitCardListAdapter,
|
private val adapter: HabitCardListAdapter,
|
||||||
@Provided private val cardViewFactory: HabitCardViewFactory,
|
private val cardViewFactory: HabitCardViewFactory,
|
||||||
@Provided private val controller: Lazy<HabitCardListController>
|
private val controller: Lazy<HabitCardListController>
|
||||||
) : RecyclerView(context, null, R.attr.scrollableRecyclerViewStyle) {
|
) : RecyclerView(context, null, R.attr.scrollableRecyclerViewStyle) {
|
||||||
|
|
||||||
var checkmarkCount: Int = 0
|
var checkmarkCount: Int = 0
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.google.auto.factory.AutoFactory
|
|
||||||
import com.google.auto.factory.Provided
|
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.common.views.RingView
|
import org.isoron.uhabits.activities.common.views.RingView
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
@@ -47,13 +45,23 @@ import org.isoron.uhabits.inject.ActivityContext
|
|||||||
import org.isoron.uhabits.utils.dp
|
import org.isoron.uhabits.utils.dp
|
||||||
import org.isoron.uhabits.utils.sres
|
import org.isoron.uhabits.utils.sres
|
||||||
import org.isoron.uhabits.utils.toThemedAndroidColor
|
import org.isoron.uhabits.utils.toThemedAndroidColor
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class HabitCardViewFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@ActivityContext val context: Context,
|
||||||
|
private val checkmarkPanelFactory: CheckmarkPanelViewFactory,
|
||||||
|
private val numberPanelFactory: NumberPanelViewFactory,
|
||||||
|
private val behavior: ListHabitsBehavior
|
||||||
|
) {
|
||||||
|
fun create() = HabitCardView(context, checkmarkPanelFactory, numberPanelFactory, behavior)
|
||||||
|
}
|
||||||
|
|
||||||
@AutoFactory
|
|
||||||
class HabitCardView(
|
class HabitCardView(
|
||||||
@Provided @ActivityContext context: Context,
|
@ActivityContext context: Context,
|
||||||
@Provided private val checkmarkPanelFactory: CheckmarkPanelViewFactory,
|
private val checkmarkPanelFactory: CheckmarkPanelViewFactory,
|
||||||
@Provided private val numberPanelFactory: NumberPanelViewFactory,
|
private val numberPanelFactory: NumberPanelViewFactory,
|
||||||
@Provided private val behavior: ListHabitsBehavior
|
private val behavior: ListHabitsBehavior
|
||||||
) : FrameLayout(context),
|
) : FrameLayout(context),
|
||||||
ModelObservable.Listener {
|
ModelObservable.Listener {
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import android.text.TextPaint
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import android.view.View.OnLongClickListener
|
import android.view.View.OnLongClickListener
|
||||||
import com.google.auto.factory.AutoFactory
|
|
||||||
import com.google.auto.factory.Provided
|
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.inject.ActivityContext
|
import org.isoron.uhabits.inject.ActivityContext
|
||||||
@@ -38,6 +36,7 @@ import org.isoron.uhabits.utils.StyledResources
|
|||||||
import org.isoron.uhabits.utils.getFontAwesome
|
import org.isoron.uhabits.utils.getFontAwesome
|
||||||
import org.isoron.uhabits.utils.showMessage
|
import org.isoron.uhabits.utils.showMessage
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
private val BOLD_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.BOLD)
|
private val BOLD_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.BOLD)
|
||||||
private val NORMAL_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.NORMAL)
|
private val NORMAL_TYPEFACE = Typeface.create("sans-serif-condensed", Typeface.NORMAL)
|
||||||
@@ -55,10 +54,17 @@ fun Double.toShortString(): String = when {
|
|||||||
else -> DecimalFormat("#.##").format(this)
|
else -> DecimalFormat("#.##").format(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@AutoFactory
|
class NumberButtonViewFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@ActivityContext val context: Context,
|
||||||
|
val preferences: Preferences
|
||||||
|
) {
|
||||||
|
fun create() = NumberButtonView(context, preferences)
|
||||||
|
}
|
||||||
|
|
||||||
class NumberButtonView(
|
class NumberButtonView(
|
||||||
@Provided @ActivityContext context: Context,
|
@ActivityContext context: Context,
|
||||||
@Provided val preferences: Preferences
|
val preferences: Preferences
|
||||||
) : View(context),
|
) : View(context),
|
||||||
OnClickListener,
|
OnClickListener,
|
||||||
OnLongClickListener {
|
OnLongClickListener {
|
||||||
|
|||||||
@@ -20,18 +20,25 @@
|
|||||||
package org.isoron.uhabits.activities.habits.list.views
|
package org.isoron.uhabits.activities.habits.list.views
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.google.auto.factory.AutoFactory
|
|
||||||
import com.google.auto.factory.Provided
|
|
||||||
import org.isoron.uhabits.core.models.Timestamp
|
import org.isoron.uhabits.core.models.Timestamp
|
||||||
import org.isoron.uhabits.core.preferences.Preferences
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
import org.isoron.uhabits.core.utils.DateUtils
|
import org.isoron.uhabits.core.utils.DateUtils
|
||||||
import org.isoron.uhabits.inject.ActivityContext
|
import org.isoron.uhabits.inject.ActivityContext
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class NumberPanelViewFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@ActivityContext val context: Context,
|
||||||
|
val preferences: Preferences,
|
||||||
|
val buttonFactory: NumberButtonViewFactory
|
||||||
|
) {
|
||||||
|
fun create() = NumberPanelView(context, preferences, buttonFactory)
|
||||||
|
}
|
||||||
|
|
||||||
@AutoFactory
|
|
||||||
class NumberPanelView(
|
class NumberPanelView(
|
||||||
@Provided @ActivityContext context: Context,
|
@ActivityContext context: Context,
|
||||||
@Provided preferences: Preferences,
|
preferences: Preferences,
|
||||||
@Provided private val buttonFactory: NumberButtonViewFactory
|
private val buttonFactory: NumberButtonViewFactory
|
||||||
) : ButtonPanelView<NumberButtonView>(context, preferences) {
|
) : ButtonPanelView<NumberButtonView>(context, preferences) {
|
||||||
|
|
||||||
var values = DoubleArray(0)
|
var values = DoubleArray(0)
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import org.isoron.uhabits.AndroidDirFinder
|
|||||||
import org.isoron.uhabits.HabitsApplication
|
import org.isoron.uhabits.HabitsApplication
|
||||||
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.ConfirmDeleteDialogFactory
|
|
||||||
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
|
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
|
||||||
import org.isoron.uhabits.core.commands.Command
|
import org.isoron.uhabits.core.commands.Command
|
||||||
import org.isoron.uhabits.core.commands.CommandRunner
|
import org.isoron.uhabits.core.commands.CommandRunner
|
||||||
@@ -67,7 +66,6 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
|||||||
|
|
||||||
val screen = ShowHabitScreen(
|
val screen = ShowHabitScreen(
|
||||||
activity = this,
|
activity = this,
|
||||||
confirmDeleteDialogFactory = ConfirmDeleteDialogFactory { this },
|
|
||||||
habit = habit,
|
habit = habit,
|
||||||
intentFactory = IntentFactory(),
|
intentFactory = IntentFactory(),
|
||||||
numberPickerFactory = NumberPickerFactory(this),
|
numberPickerFactory = NumberPickerFactory(this),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
package org.isoron.uhabits.activities.habits.show
|
package org.isoron.uhabits.activities.habits.show
|
||||||
|
|
||||||
import org.isoron.uhabits.R
|
import org.isoron.uhabits.R
|
||||||
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialogFactory
|
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
|
||||||
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
|
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
|
||||||
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
|
import org.isoron.uhabits.activities.common.dialogs.NumberPickerFactory
|
||||||
import org.isoron.uhabits.core.models.Habit
|
import org.isoron.uhabits.core.models.Habit
|
||||||
@@ -36,7 +36,6 @@ import org.isoron.uhabits.widgets.WidgetUpdater
|
|||||||
|
|
||||||
class ShowHabitScreen(
|
class ShowHabitScreen(
|
||||||
val activity: ShowHabitActivity,
|
val activity: ShowHabitActivity,
|
||||||
val confirmDeleteDialogFactory: ConfirmDeleteDialogFactory,
|
|
||||||
val habit: Habit,
|
val habit: Habit,
|
||||||
val intentFactory: IntentFactory,
|
val intentFactory: IntentFactory,
|
||||||
val numberPickerFactory: NumberPickerFactory,
|
val numberPickerFactory: NumberPickerFactory,
|
||||||
@@ -79,7 +78,7 @@ class ShowHabitScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
override fun showDeleteConfirmationScreen(callback: OnConfirmedCallback) {
|
||||||
confirmDeleteDialogFactory.create(callback, 1).show()
|
ConfirmDeleteDialog(activity, callback, 1).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
|
|||||||
@@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.inject;
|
package org.isoron.uhabits.inject;
|
||||||
|
|
||||||
import android.content.*;
|
|
||||||
|
|
||||||
import dagger.*;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
public class ActivityContextModule
|
public class ActivityContextModule
|
||||||
|
|||||||
@@ -19,9 +19,10 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.inject;
|
package org.isoron.uhabits.inject;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.Context;
|
||||||
|
|
||||||
import dagger.*;
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
public class AppContextModule
|
public class AppContextModule
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ import org.isoron.uhabits.core.tasks.*;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import dagger.*;
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
public class AndroidTaskRunner implements TaskRunner
|
public class AndroidTaskRunner implements TaskRunner
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ package org.isoron.uhabits.tasks;
|
|||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.*;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.*;
|
import org.isoron.uhabits.*;
|
||||||
import org.isoron.uhabits.core.tasks.*;
|
import org.isoron.uhabits.core.tasks.*;
|
||||||
@@ -33,7 +30,6 @@ import org.isoron.uhabits.utils.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@AutoFactory(allowSubclasses = true)
|
|
||||||
public class ExportDBTask implements Task
|
public class ExportDBTask implements Task
|
||||||
{
|
{
|
||||||
private String filename;
|
private String filename;
|
||||||
@@ -46,8 +42,8 @@ public class ExportDBTask implements Task
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final Listener listener;
|
private final Listener listener;
|
||||||
|
|
||||||
public ExportDBTask(@Provided @AppContext @NonNull Context context,
|
public ExportDBTask(@AppContext @NonNull Context context,
|
||||||
@Provided @NonNull AndroidDirFinder system,
|
@NonNull AndroidDirFinder system,
|
||||||
@NonNull Listener listener)
|
@NonNull Listener listener)
|
||||||
{
|
{
|
||||||
this.system = system;
|
this.system = system;
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2020 Á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.tasks
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import org.isoron.uhabits.AndroidDirFinder
|
||||||
|
import org.isoron.uhabits.inject.AppContext
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class ExportDBTaskFactory
|
||||||
|
@Inject constructor(
|
||||||
|
@AppContext private val context: Context,
|
||||||
|
private val system: AndroidDirFinder,
|
||||||
|
) {
|
||||||
|
fun create(listener: ExportDBTask.Listener) = ExportDBTask(context, system, listener)
|
||||||
|
}
|
||||||
@@ -23,8 +23,6 @@ import android.util.*;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.core.io.*;
|
import org.isoron.uhabits.core.io.*;
|
||||||
import org.isoron.uhabits.core.models.ModelFactory;
|
import org.isoron.uhabits.core.models.ModelFactory;
|
||||||
import org.isoron.uhabits.core.models.sqlite.SQLModelFactory;
|
import org.isoron.uhabits.core.models.sqlite.SQLModelFactory;
|
||||||
@@ -32,7 +30,6 @@ import org.isoron.uhabits.core.tasks.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
@AutoFactory(allowSubclasses = true)
|
|
||||||
public class ImportDataTask implements Task
|
public class ImportDataTask implements Task
|
||||||
{
|
{
|
||||||
public static final int FAILED = 3;
|
public static final int FAILED = 3;
|
||||||
@@ -53,8 +50,8 @@ public class ImportDataTask implements Task
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final Listener listener;
|
private final Listener listener;
|
||||||
|
|
||||||
public ImportDataTask(@Provided @NonNull GenericImporter importer,
|
public ImportDataTask(@NonNull GenericImporter importer,
|
||||||
@Provided @NonNull ModelFactory modelFactory,
|
@NonNull ModelFactory modelFactory,
|
||||||
@NonNull File file,
|
@NonNull File file,
|
||||||
@NonNull Listener listener)
|
@NonNull Listener listener)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2020 Á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.tasks
|
||||||
|
|
||||||
|
import org.isoron.uhabits.core.io.GenericImporter
|
||||||
|
import org.isoron.uhabits.core.models.ModelFactory
|
||||||
|
import java.io.File
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class ImportDataTaskFactory
|
||||||
|
@Inject constructor(
|
||||||
|
private val importer: GenericImporter,
|
||||||
|
private val modelFactory: ModelFactory,
|
||||||
|
) {
|
||||||
|
fun create(file: File, listener: ImportDataTask.Listener) =
|
||||||
|
ImportDataTask(importer, modelFactory, file, listener)
|
||||||
|
}
|
||||||
@@ -3,9 +3,7 @@ apply plugin: 'java'
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
annotationProcessor "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"
|
|
||||||
annotationProcessor "com.google.dagger:dagger:$DAGGER_VERSION"
|
annotationProcessor "com.google.dagger:dagger:$DAGGER_VERSION"
|
||||||
compileOnly "com.google.auto.factory:auto-factory:$AUTO_FACTORY_VERSION"
|
|
||||||
compileOnly "com.google.dagger:dagger:$DAGGER_VERSION"
|
compileOnly "com.google.dagger:dagger:$DAGGER_VERSION"
|
||||||
compileOnly 'javax.annotation:jsr250-api:1.0'
|
compileOnly 'javax.annotation:jsr250-api:1.0'
|
||||||
compileOnly 'org.jetbrains:annotations:18.0.0'
|
compileOnly 'org.jetbrains:annotations:18.0.0'
|
||||||
|
|||||||
@@ -21,15 +21,12 @@ package org.isoron.uhabits.core.tasks;
|
|||||||
|
|
||||||
import androidx.annotation.*;
|
import androidx.annotation.*;
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.core.io.*;
|
import org.isoron.uhabits.core.io.*;
|
||||||
import org.isoron.uhabits.core.models.*;
|
import org.isoron.uhabits.core.models.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@AutoFactory(allowSubclasses = true)
|
|
||||||
public class ExportCSVTask implements Task
|
public class ExportCSVTask implements Task
|
||||||
{
|
{
|
||||||
private String archiveFilename;
|
private String archiveFilename;
|
||||||
@@ -45,7 +42,7 @@ public class ExportCSVTask implements Task
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final HabitList habitList;
|
private final HabitList habitList;
|
||||||
|
|
||||||
public ExportCSVTask(@Provided @NonNull HabitList habitList,
|
public ExportCSVTask(@NonNull HabitList habitList,
|
||||||
@NonNull List<Habit> selectedHabits,
|
@NonNull List<Habit> selectedHabits,
|
||||||
@NonNull File outputDir,
|
@NonNull File outputDir,
|
||||||
@NonNull Listener listener)
|
@NonNull Listener listener)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2020 Á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.tasks
|
||||||
|
|
||||||
|
import org.isoron.uhabits.core.models.Habit
|
||||||
|
import org.isoron.uhabits.core.models.HabitList
|
||||||
|
import java.io.File
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class ExportCSVTaskFactory
|
||||||
|
@Inject constructor(
|
||||||
|
val habitList: HabitList
|
||||||
|
) {
|
||||||
|
fun create(
|
||||||
|
selectedHabits: List<Habit>,
|
||||||
|
outputDir: File,
|
||||||
|
listener: ExportCSVTask.Listener,
|
||||||
|
) = ExportCSVTask(habitList, selectedHabits, outputDir, listener)
|
||||||
|
}
|
||||||
@@ -21,8 +21,6 @@ package org.isoron.uhabits.core.ui.screens.habits.list;
|
|||||||
|
|
||||||
import androidx.annotation.*;
|
import androidx.annotation.*;
|
||||||
|
|
||||||
import com.google.auto.factory.*;
|
|
||||||
|
|
||||||
import org.isoron.uhabits.core.models.*;
|
import org.isoron.uhabits.core.models.*;
|
||||||
import org.isoron.uhabits.core.preferences.*;
|
import org.isoron.uhabits.core.preferences.*;
|
||||||
import org.isoron.uhabits.core.utils.*;
|
import org.isoron.uhabits.core.utils.*;
|
||||||
@@ -31,7 +29,6 @@ import org.isoron.uhabits.core.utils.*;
|
|||||||
* Provides a list of hints to be shown at the application startup, and takes
|
* Provides a list of hints to be shown at the application startup, and takes
|
||||||
* care of deciding when a new hint should be shown.
|
* care of deciding when a new hint should be shown.
|
||||||
*/
|
*/
|
||||||
@AutoFactory
|
|
||||||
public class HintList
|
public class HintList
|
||||||
{
|
{
|
||||||
private final Preferences prefs;
|
private final Preferences prefs;
|
||||||
@@ -44,7 +41,7 @@ public class HintList
|
|||||||
*
|
*
|
||||||
* @param hints initial list of hints
|
* @param hints initial list of hints
|
||||||
*/
|
*/
|
||||||
public HintList(@Provided @NonNull Preferences prefs,
|
public HintList(@NonNull Preferences prefs,
|
||||||
@NonNull String hints[])
|
@NonNull String hints[])
|
||||||
{
|
{
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016-2020 Á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.ui.screens.habits.list
|
||||||
|
|
||||||
|
import org.isoron.uhabits.core.preferences.Preferences
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
class HintListFactory
|
||||||
|
@Inject constructor(
|
||||||
|
val preferences: Preferences,
|
||||||
|
) {
|
||||||
|
fun create(hints: Array<String>) = HintList(preferences, hints)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user