@ -0,0 +1,65 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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.commands;
|
||||||
|
|
||||||
|
import org.isoron.helpers.Command;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ArchiveHabitsCommand extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
private List<Habit> habits;
|
||||||
|
|
||||||
|
public ArchiveHabitsCommand(Habit habit)
|
||||||
|
{
|
||||||
|
habits = new LinkedList<>();
|
||||||
|
habits.add(habit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArchiveHabitsCommand(List<Habit> habits)
|
||||||
|
{
|
||||||
|
this.habits = habits;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
for(Habit h : habits)
|
||||||
|
h.archive();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo()
|
||||||
|
{
|
||||||
|
for(Habit h : habits)
|
||||||
|
h.unarchive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getExecuteStringId()
|
||||||
|
{
|
||||||
|
return R.string.toast_habit_archived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUndoStringId()
|
||||||
|
{
|
||||||
|
return R.string.toast_habit_unarchived;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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.commands;
|
||||||
|
|
||||||
|
import com.activeandroid.ActiveAndroid;
|
||||||
|
|
||||||
|
import org.isoron.helpers.Command;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ChangeHabitColorCommand extends Command
|
||||||
|
{
|
||||||
|
List<Habit> habits;
|
||||||
|
List<Integer> originalColors;
|
||||||
|
Integer newColor;
|
||||||
|
|
||||||
|
public ChangeHabitColorCommand(List<Habit> habits, Integer newColor)
|
||||||
|
{
|
||||||
|
this.habits = habits;
|
||||||
|
this.newColor = newColor;
|
||||||
|
this.originalColors = new ArrayList<>(habits.size());
|
||||||
|
|
||||||
|
for(Habit h : habits)
|
||||||
|
originalColors.add(h.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
ActiveAndroid.beginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for(Habit h : habits)
|
||||||
|
{
|
||||||
|
h.color = newColor;
|
||||||
|
h.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveAndroid.setTransactionSuccessful();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ActiveAndroid.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo()
|
||||||
|
{
|
||||||
|
ActiveAndroid.beginTransaction();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int k = 0;
|
||||||
|
for(Habit h : habits)
|
||||||
|
{
|
||||||
|
h.color = originalColors.get(k++);
|
||||||
|
h.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ActiveAndroid.setTransactionSuccessful();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ActiveAndroid.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getExecuteStringId()
|
||||||
|
{
|
||||||
|
return R.string.toast_habit_changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUndoStringId()
|
||||||
|
{
|
||||||
|
return R.string.toast_habit_changed;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/* Copyright (C) 2016 Alinson Santos Xavier
|
||||||
|
*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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.commands;
|
||||||
|
|
||||||
|
import org.isoron.helpers.Command;
|
||||||
|
import org.isoron.uhabits.R;
|
||||||
|
import org.isoron.uhabits.models.Habit;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class UnarchiveHabitsCommand extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
private List<Habit> habits;
|
||||||
|
|
||||||
|
public UnarchiveHabitsCommand(Habit habit)
|
||||||
|
{
|
||||||
|
habits = new LinkedList<>();
|
||||||
|
habits.add(habit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnarchiveHabitsCommand(List<Habit> habits)
|
||||||
|
{
|
||||||
|
this.habits = habits;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute()
|
||||||
|
{
|
||||||
|
for(Habit h : habits)
|
||||||
|
h.unarchive();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void undo()
|
||||||
|
{
|
||||||
|
for(Habit h : habits)
|
||||||
|
h.archive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getExecuteStringId()
|
||||||
|
{
|
||||||
|
return R.string.toast_habit_unarchived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUndoStringId()
|
||||||
|
{
|
||||||
|
return R.string.toast_habit_archived;
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 338 B |
After Width: | Height: | Size: 393 B |
After Width: | Height: | Size: 492 B |
After Width: | Height: | Size: 563 B |
After Width: | Height: | Size: 822 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 410 B |
After Width: | Height: | Size: 214 B |
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 319 B |
After Width: | Height: | Size: 554 B |
After Width: | Height: | Size: 207 B |
After Width: | Height: | Size: 243 B |
After Width: | Height: | Size: 338 B |
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 541 B |
After Width: | Height: | Size: 602 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 381 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 674 B |
After Width: | Height: | Size: 922 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 575 B |
After Width: | Height: | Size: 683 B |
@ -1,6 +0,0 @@
|
|||||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:color="@color/grey"> <!-- ripple color -->
|
|
||||||
|
|
||||||
<item android:drawable="@color/white"/> <!-- normal color -->
|
|
||||||
|
|
||||||
</ripple>
|
|
@ -0,0 +1,8 @@
|
|||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="?android:colorControlHighlight">
|
||||||
|
|
||||||
|
<item android:id="@android:id/mask">
|
||||||
|
<color android:color="@android:color/white" />
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</ripple>
|
@ -0,0 +1,5 @@
|
|||||||
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:color="?android:colorControlHighlight">
|
||||||
|
|
||||||
|
<item android:drawable="@color/white" />
|
||||||
|
</ripple>
|
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
|
<solid android:color="@color/grey_100" />
|
||||||
|
<stroke android:width="2dip" android:color="@color/grey_500"/>
|
||||||
|
</shape>
|
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_edit_habit"
|
||||||
|
android:title="@string/edit"
|
||||||
|
android:icon="@drawable/ic_action_edit_dark"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_color"
|
||||||
|
android:title="@string/color_picker_default_title"
|
||||||
|
android:icon="@drawable/ic_action_color_dark"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_archive_habit"
|
||||||
|
android:title="@string/archive"
|
||||||
|
android:icon="@drawable/ic_action_archive_dark" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_unarchive_habit"
|
||||||
|
android:title="@string/unarchive"
|
||||||
|
android:icon="@drawable/ic_action_unarchive_dark"/>
|
||||||
|
|
||||||
|
</menu>
|
@ -1,19 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_edit_habit"
|
android:id="@+id/action_edit_habit"
|
||||||
android:title="@string/edit">
|
android:title="@string/edit"
|
||||||
</item>
|
android:icon="@drawable/ic_action_edit_light"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_color"
|
||||||
|
android:title="@string/color_picker_default_title"
|
||||||
|
android:icon="@drawable/ic_action_color_light"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_archive_habit"
|
android:id="@+id/action_archive_habit"
|
||||||
android:title="@string/archive">
|
android:title="@string/archive"
|
||||||
</item>
|
android:icon="@drawable/ic_action_archive_light" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_unarchive_habit"
|
android:id="@+id/action_unarchive_habit"
|
||||||
android:title="@string/unarchive">
|
android:title="@string/unarchive"
|
||||||
</item>
|
android:icon="@drawable/ic_action_unarchive_light"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -1 +1 @@
|
|||||||
Subproject commit 8c9ca51f3eb8bee58d91a8d9b763a1bbefa214ef
|
Subproject commit e8905e2c78d27bc064d03496abea3a0956e49b18
|