|
|
@ -9,6 +9,7 @@ import android.graphics.Typeface;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Vibrator;
|
|
|
|
import android.os.Vibrator;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.ContextMenu;
|
|
|
|
import android.view.ContextMenu;
|
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
|
|
|
import android.view.Display;
|
|
|
|
import android.view.Display;
|
|
|
@ -34,6 +35,7 @@ import com.mobeta.android.dslv.DragSortController;
|
|
|
|
import com.mobeta.android.dslv.DragSortListView;
|
|
|
|
import com.mobeta.android.dslv.DragSortListView;
|
|
|
|
import com.mobeta.android.dslv.DragSortListView.DropListener;
|
|
|
|
import com.mobeta.android.dslv.DragSortListView.DropListener;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.isoron.helpers.ColorHelper;
|
|
|
|
import org.isoron.helpers.Command;
|
|
|
|
import org.isoron.helpers.Command;
|
|
|
|
import org.isoron.helpers.DateHelper;
|
|
|
|
import org.isoron.helpers.DateHelper;
|
|
|
|
import org.isoron.helpers.DialogHelper.OnSavedListener;
|
|
|
|
import org.isoron.helpers.DialogHelper.OnSavedListener;
|
|
|
@ -153,22 +155,33 @@ public class ListHabitsFragment extends Fragment
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
inflater.inflate(R.menu.show_habits_options, menu);
|
|
|
|
inflater.inflate(R.menu.list_habits_options, menu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MenuItem showArchivedItem = menu.findItem(R.id.action_show_archived);
|
|
|
|
|
|
|
|
showArchivedItem.setChecked(Habit.isIncludeArchived());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo)
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super.onCreateContextMenu(menu, view, menuInfo);
|
|
|
|
super.onCreateContextMenu(menu, view, menuInfo);
|
|
|
|
getActivity().getMenuInflater().inflate(R.menu.show_habits_context, menu);
|
|
|
|
getActivity().getMenuInflater().inflate(R.menu.list_habits_context, menu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
|
|
|
|
|
|
|
final Habit habit = Habit.get(info.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(habit.isArchived())
|
|
|
|
|
|
|
|
menu.findItem(R.id.action_archive_habit).setVisible(false);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
menu.findItem(R.id.action_unarchive_habit).setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int id = item.getItemId();
|
|
|
|
switch(item.getItemId())
|
|
|
|
|
|
|
|
{
|
|
|
|
if (id == R.id.action_add)
|
|
|
|
case R.id.action_add:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EditHabitFragment frag = EditHabitFragment.createHabitFragment();
|
|
|
|
EditHabitFragment frag = EditHabitFragment.createHabitFragment();
|
|
|
|
frag.setOnSavedListener(this);
|
|
|
|
frag.setOnSavedListener(this);
|
|
|
@ -176,8 +189,18 @@ public class ListHabitsFragment extends Fragment
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case R.id.action_show_archived:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Habit.setIncludeArchived(!Habit.isIncludeArchived());
|
|
|
|
|
|
|
|
notifyDataSetChanged();
|
|
|
|
|
|
|
|
activity.invalidateOptionsMenu();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onContextItemSelected(MenuItem menuItem)
|
|
|
|
public boolean onContextItemSelected(MenuItem menuItem)
|
|
|
@ -193,12 +216,16 @@ public class ListHabitsFragment extends Fragment
|
|
|
|
frag.show(getFragmentManager(), "dialog");
|
|
|
|
frag.show(getFragmentManager(), "dialog");
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (id == R.id.action_archive_habit)
|
|
|
|
if (id == R.id.action_archive_habit)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Command c = habit.new ArchiveCommand();
|
|
|
|
Command c = habit.new ArchiveCommand();
|
|
|
|
executeCommand(c);
|
|
|
|
executeCommand(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (id == R.id.action_unarchive_habit)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Command c = habit.new UnarchiveCommand();
|
|
|
|
|
|
|
|
executeCommand(c);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return super.onContextItemSelected(menuItem);
|
|
|
|
return super.onContextItemSelected(menuItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -353,6 +380,16 @@ public class ListHabitsFragment extends Fragment
|
|
|
|
tvName.setText(habit.name);
|
|
|
|
tvName.setText(habit.name);
|
|
|
|
tvName.setTextColor(activeColor);
|
|
|
|
tvName.setTextColor(activeColor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(habit.isArchived())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
activeColor = ColorHelper.palette[12];
|
|
|
|
|
|
|
|
tvName.setTextColor(activeColor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tvStar.setText(context.getString(R.string.fa_archive));
|
|
|
|
|
|
|
|
tvStar.setTextColor(activeColor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
int score = habit.getScore();
|
|
|
|
int score = habit.getScore();
|
|
|
|
|
|
|
|
|
|
|
|
if (score < Habit.HALF_STAR_CUTOFF)
|
|
|
|
if (score < Habit.HALF_STAR_CUTOFF)
|
|
|
@ -370,6 +407,8 @@ public class ListHabitsFragment extends Fragment
|
|
|
|
tvStar.setText(context.getString(R.string.fa_star));
|
|
|
|
tvStar.setText(context.getString(R.string.fa_star));
|
|
|
|
tvStar.setTextColor(activeColor);
|
|
|
|
tvStar.setTextColor(activeColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LinearLayout llButtons = (LinearLayout) view.findViewById(R.id.llButtons);
|
|
|
|
LinearLayout llButtons = (LinearLayout) view.findViewById(R.id.llButtons);
|
|
|
|
int m = llButtons.getChildCount();
|
|
|
|
int m = llButtons.getChildCount();
|
|
|
|