@@ -24,6 +24,10 @@ import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.activities.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.tasks.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.inject.*;
|
||||
|
||||
@@ -33,12 +37,38 @@ public class ShowHabitsMenu extends BaseMenu
|
||||
@NonNull
|
||||
private final ShowHabitScreen screen;
|
||||
|
||||
@NonNull
|
||||
private final Habit habit;
|
||||
|
||||
@NonNull
|
||||
private final TaskRunner taskRunner;
|
||||
|
||||
@NonNull
|
||||
private ExportCSVTaskFactory exportCSVFactory;
|
||||
|
||||
@Inject
|
||||
public ShowHabitsMenu(@NonNull BaseActivity activity,
|
||||
@NonNull ShowHabitScreen screen)
|
||||
@NonNull ShowHabitScreen screen,
|
||||
@NonNull Habit habit,
|
||||
@NonNull ExportCSVTaskFactory exportCSVFactory,
|
||||
@NonNull TaskRunner taskRunner)
|
||||
{
|
||||
super(activity);
|
||||
this.screen = screen;
|
||||
this.habit = habit;
|
||||
this.taskRunner = taskRunner;
|
||||
this.exportCSVFactory = exportCSVFactory;
|
||||
}
|
||||
|
||||
public void downloadHabit()
|
||||
{
|
||||
List<Habit> selected = new LinkedList<>();
|
||||
selected.add(habit);
|
||||
ExportCSVTask task = exportCSVFactory.create(selected, filename -> {
|
||||
if (filename != null) screen.showSendFileScreen(filename);
|
||||
else screen.showMessage(R.string.could_not_export);
|
||||
});
|
||||
taskRunner.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,6 +80,10 @@ public class ShowHabitsMenu extends BaseMenu
|
||||
screen.showEditHabitDialog();
|
||||
return true;
|
||||
|
||||
case R.id.download:
|
||||
this.downloadHabit();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_action_download_dark.png
Normal file
|
After Width: | Height: | Size: 249 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_download_light.png
Normal file
|
After Width: | Height: | Size: 280 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_download_dark.png
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_download_light.png
Normal file
|
After Width: | Height: | Size: 236 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_download_dark.png
Normal file
|
After Width: | Height: | Size: 279 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_download_light.png
Normal file
|
After Width: | Height: | Size: 319 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_download_dark.png
Normal file
|
After Width: | Height: | Size: 366 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_download_light.png
Normal file
|
After Width: | Height: | Size: 397 B |
@@ -21,6 +21,12 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/download"
|
||||
android:icon="?iconDownload"
|
||||
android:title="@string/download"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit_habit"
|
||||
android:icon="?iconEdit"
|
||||
|
||||
@@ -103,13 +103,13 @@ Loop hat eine minimale Oberfläche und ist deshalb einfach zu benutzen. Es folgt
|
||||
|
||||
<!-- Fuzzy -->
|
||||
<string name="store_feature_score">"<b>Habit Wertung</b>
|
||||
Um dir deine kleinen Schwächen zu zeigen hat Loop einen Algorithmus, um deine Gewohnheiten zu erkennen. Jede Wiederholung verstärkt diese und jedes Aussetzen schwächt sie. Aber ein paar Verfehlungen nach langem Durchhalten machen natürlich nicht gleich alles zu Nichte."</string>
|
||||
Um dir deine kleinen Schwächen zu zeigen hat Loop einen Algorithmus entwickelt, um deine Gewohnheiten zu erkennen. Jede Wiederholung verstärkt diese und jedes Aussetzen schwächt sie. Aber ein paar Fehltage nach langem Durchhalten machen natürlich nicht gleich alles zu Nichte."</string>
|
||||
<string name="store_feature_statistics">"<b>Statistiken</b>
|
||||
Schau dir an, wie sich deine Gewohnheiten im Laufe der Zeit entwickelt haben. Schau auf die schönen Diagramme und gehe zurück im gesamten Verlauf."</string>
|
||||
Schau dir an, wie sich deine Gewohnheiten im Laufe der Zeit entwickelt haben. Schaue dir die Diagramme an oder gehe zurück im gesamten Verlauf."</string>
|
||||
<string name="store_feature_schedules">"<b>Flexible Zeiten</b>
|
||||
Unterstützt sowohl tägliche Vorgaben, als auch komplexere Pläne, wie etwa 3 Mal pro Woche; einmal in jeder anderen Woche; oder jeden anderen Tag."</string>
|
||||
<string name="store_feature_reminders">"<b>Erinnerungen</b>
|
||||
Erstelle individuelle Erinnerungen und wann diese dich benachrichtigen sollen. Kontrolliere deine Vorhaben ganz einfach und lehne sie bei Bedarf direkt ab, ohne die App zu öffnen."</string>
|
||||
Erstelle individuelle Erinnerungen und wann diese dich benachrichtigen sollen. Kontrolliere dein Vorhaben ganz einfach und lehne sie bei Bedarf direkt ab, ohne die App zu öffnen."</string>
|
||||
<string name="store_feature_opensource">"<b>Komplett werbefrei und Open Source</b>
|
||||
Es gibt absolut keine Werbung, nervende Einblendungen oder merkwürdige Berechtigungen in dieser App und das wird auch so bleiben. Der komplette Quellcode steht unter der GPLv3."</string>
|
||||
<string name="store_feature_wear">"<b>Optimiert für Smartwatches</b>
|
||||
@@ -142,7 +142,7 @@ Erinnerungen können direkt von deiner Android Wear Watch abgehakt, pausiert ode
|
||||
|
||||
<!-- "All time" number of repetitions. Or number of repetitions "since the beginning". -->
|
||||
<!-- Fuzzy -->
|
||||
<string name="all_time">"Allzeit"</string>
|
||||
<string name="all_time">"Jederzeit"</string>
|
||||
<string name="every_day">"Jeden Tag"</string>
|
||||
<string name="every_week">"Jede Woche"</string>
|
||||
<string name="two_times_per_week">"2 Mal pro Woche"</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<attr name="iconAdd" format="reference"/>
|
||||
<attr name="iconArchive" format="reference"/>
|
||||
<attr name="iconChangeColor" format="reference"/>
|
||||
<attr name="iconDownload" format="reference"/>
|
||||
<attr name="iconEdit" format="reference"/>
|
||||
<attr name="iconUnarchive" format="reference"/>
|
||||
<attr name="dialogIconChangeColor" format="reference"/>
|
||||
|
||||
@@ -202,4 +202,5 @@
|
||||
<string name="by_name">By name</string>
|
||||
<string name="by_color">By color</string>
|
||||
<string name="by_score">By score</string>
|
||||
<string name="download">Download</string>
|
||||
</resources>
|
||||
@@ -53,6 +53,7 @@
|
||||
<item name="iconAdd">@drawable/ic_action_add_dark</item>
|
||||
<item name="iconArchive">@drawable/ic_action_archive_dark</item>
|
||||
<item name="iconEdit">@drawable/ic_action_edit_dark</item>
|
||||
<item name="iconDownload">@drawable/ic_action_download_dark</item>
|
||||
<item name="iconUnarchive">@drawable/ic_action_unarchive_dark</item>
|
||||
<item name="iconChangeColor">@drawable/ic_action_color_dark</item>
|
||||
<item name="iconFilter">@drawable/ic_action_filter_dark</item>
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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.activities.habits.show;
|
||||
|
||||
import android.view.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.tasks.*;
|
||||
import org.junit.*;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class ShowHabitsMenuTest extends BaseUnitTest
|
||||
{
|
||||
private ShowHabitActivity activity;
|
||||
|
||||
private ShowHabitScreen screen;
|
||||
|
||||
private ShowHabitsMenu menu;
|
||||
|
||||
private Habit habit;
|
||||
|
||||
private ExportCSVTaskFactory exportCSVFactory;
|
||||
|
||||
private TaskRunner taskRunner;
|
||||
|
||||
private ExportCSVTask task;
|
||||
|
||||
@Override
|
||||
public void setUp()
|
||||
{
|
||||
super.setUp();
|
||||
activity = mock(ShowHabitActivity.class);
|
||||
screen = mock(ShowHabitScreen.class);
|
||||
habit = mock(Habit.class);
|
||||
exportCSVFactory = mock(ExportCSVTaskFactory.class);
|
||||
taskRunner = mock(TaskRunner.class);
|
||||
menu = new ShowHabitsMenu(activity, screen, habit, exportCSVFactory,
|
||||
taskRunner);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnDownloadHabit()
|
||||
{
|
||||
onItemSelected(R.id.download);
|
||||
verify(taskRunner).execute(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnEditHabit()
|
||||
{
|
||||
onItemSelected(R.id.action_edit_habit);
|
||||
verify(screen).showEditHabitDialog();
|
||||
}
|
||||
|
||||
protected void onItemSelected(int actionId)
|
||||
{
|
||||
MenuItem item = mock(MenuItem.class);
|
||||
when(item.getItemId()).thenReturn(actionId);
|
||||
menu.onItemSelected(item);
|
||||
}
|
||||
}
|
||||