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