pull/234/merge
JanetQC 9 years ago committed by GitHub
commit 71ff6d6056

@ -105,12 +105,17 @@ public class ListHabitsController
public void onExportCSV()
{
List<Habit> selected = new LinkedList<>();
for (Habit h : habitList) selected.add(h);
for (Habit h : habitList) selected.add(h);
taskRunner.execute(exportCSVFactory.create(selected, filename -> {
if (filename != null) screen.showSendFileScreen(filename);
else screen.showMessage(R.string.could_not_export);
}));
ExportCSVTask task = exportCSVFactory.create(selected, filename -> {
if (filename != null){
screen.showSendFileScreen(filename);
}
else {
screen.showMessage(R.string.could_not_export);
}
});
taskRunner.execute(task);
}
public void onExportDB()

@ -26,6 +26,7 @@ import android.support.annotation.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.activities.*;
import org.isoron.uhabits.activities.habits.list.ListHabitsComponent;
import org.isoron.uhabits.models.*;
/**
@ -36,12 +37,12 @@ import org.isoron.uhabits.models.*;
public class ShowHabitActivity extends BaseActivity
{
private HabitList habits;
private ListHabitsComponent listHabitComponent;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
HabitsApplication app = (HabitsApplication) getApplicationContext();
habits = app.getComponent().getHabitList();
Habit habit = getHabitFromIntent();

@ -24,40 +24,74 @@ import android.view.*;
import org.isoron.uhabits.*;
import org.isoron.uhabits.activities.*;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.tasks.ExportCSVTask;
import org.isoron.uhabits.tasks.ExportCSVTaskFactory;
import org.isoron.uhabits.tasks.TaskRunner;
import java.util.LinkedList;
import java.util.List;
import javax.inject.*;
@ActivityScope
public class ShowHabitsMenu extends BaseMenu
{
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;
}
@Override
public boolean onItemSelected(@NonNull MenuItem item)
{
switch (item.getItemId())
{
public boolean onItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit_habit:
screen.showEditHabitDialog();
return true;
case R.id.download:
this.downloadHabit();
return true;
default:
return false;
}
}
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
protected int getMenuResourceId()
{
protected int getMenuResourceId() {
return R.menu.show_habit;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

@ -21,10 +21,18 @@
<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"
android:title="@string/edit"
app:showAsAction="ifRoom"/>
</menu>

@ -103,13 +103,13 @@ Loop hat eine minimale Oberfläche und ist deshalb einfach zu benutzen. Es folgt
<!-- Fuzzy -->
<string name="store_feature_score">"&lt;b&gt;Habit Wertung&lt;/b&gt;
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">"&lt;b&gt;Statistiken&lt;/b&gt;
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">"&lt;b&gt;Flexible Zeiten&lt;/b&gt;
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">"&lt;b&gt;Erinnerungen&lt;/b&gt;
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">"&lt;b&gt;Komplett werbefrei und Open Source&lt;/b&gt;
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">"&lt;b&gt;Optimiert für Smartwatches&lt;/b&gt;
@ -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"/>

@ -23,6 +23,7 @@
<string name="app_name">Loop Habit Tracker</string>
<string name="main_activity_title">Habits</string>
<string name="action_settings">Settings</string>
<string name="download">Download</string>
<string name="edit">Edit</string>
<string name="delete">Delete</string>
<string name="archive">Archive</string>

@ -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,85 @@
/*
* 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.list;
import android.view.MenuItem;
import org.isoron.uhabits.BaseUnitTest;
import org.isoron.uhabits.R;
import org.isoron.uhabits.activities.habits.show.ShowHabitActivity;
import org.isoron.uhabits.activities.habits.show.ShowHabitScreen;
import org.isoron.uhabits.activities.habits.show.ShowHabitsMenu;
import org.isoron.uhabits.models.Habit;
import org.isoron.uhabits.tasks.ExportCSVTask;
import org.isoron.uhabits.tasks.ExportCSVTaskFactory;
import org.isoron.uhabits.tasks.TaskRunner;
import org.junit.Test;
import org.mockito.Mockito;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
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 testOnEditHabit() {
onItemSelected(R.id.action_edit_habit);
verify(screen).showEditHabitDialog();
}
@Test
public void testOnDownloadHabit() {
onItemSelected(R.id.download);
verify(taskRunner).execute(any());
}
protected void onItemSelected(int actionId) {
MenuItem item = mock(MenuItem.class);
when(item.getItemId()).thenReturn(actionId);
menu.onItemSelected(item);
}
}
Loading…
Cancel
Save