|
|
@ -5,13 +5,19 @@ import android.graphics.Color;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
|
|
|
import android.view.Menu;
|
|
|
|
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
|
|
import org.isoron.helpers.ColorHelper;
|
|
|
|
import org.isoron.helpers.ColorHelper;
|
|
|
|
|
|
|
|
import org.isoron.helpers.Command;
|
|
|
|
|
|
|
|
import org.isoron.helpers.DialogHelper;
|
|
|
|
import org.isoron.uhabits.R;
|
|
|
|
import org.isoron.uhabits.R;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.ReminderHelper;
|
|
|
|
import org.isoron.uhabits.ShowHabitActivity;
|
|
|
|
import org.isoron.uhabits.ShowHabitActivity;
|
|
|
|
import org.isoron.uhabits.models.Habit;
|
|
|
|
import org.isoron.uhabits.models.Habit;
|
|
|
|
import org.isoron.uhabits.views.HabitHistoryView;
|
|
|
|
import org.isoron.uhabits.views.HabitHistoryView;
|
|
|
@ -19,9 +25,10 @@ import org.isoron.uhabits.views.HabitScoreView;
|
|
|
|
import org.isoron.uhabits.views.HabitStreakView;
|
|
|
|
import org.isoron.uhabits.views.HabitStreakView;
|
|
|
|
import org.isoron.uhabits.views.RingView;
|
|
|
|
import org.isoron.uhabits.views.RingView;
|
|
|
|
|
|
|
|
|
|
|
|
public class ShowHabitFragment extends Fragment
|
|
|
|
public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedListener
|
|
|
|
{
|
|
|
|
{
|
|
|
|
protected ShowHabitActivity activity;
|
|
|
|
protected ShowHabitActivity activity;
|
|
|
|
|
|
|
|
private Habit habit;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onStart()
|
|
|
|
public void onStart()
|
|
|
@ -37,7 +44,7 @@ public class ShowHabitFragment extends Fragment
|
|
|
|
|
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.show_habit, container, false);
|
|
|
|
View view = inflater.inflate(R.layout.show_habit, container, false);
|
|
|
|
activity = (ShowHabitActivity) getActivity();
|
|
|
|
activity = (ShowHabitActivity) getActivity();
|
|
|
|
Habit habit = activity.habit;
|
|
|
|
habit = activity.habit;
|
|
|
|
|
|
|
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= 21)
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= 21)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -55,8 +62,8 @@ public class ShowHabitFragment extends Fragment
|
|
|
|
tvStreaks.setTextColor(habit.color);
|
|
|
|
tvStreaks.setTextColor(habit.color);
|
|
|
|
|
|
|
|
|
|
|
|
LinearLayout llOverview = (LinearLayout) view.findViewById(R.id.llOverview);
|
|
|
|
LinearLayout llOverview = (LinearLayout) view.findViewById(R.id.llOverview);
|
|
|
|
llOverview.addView(new RingView(activity,
|
|
|
|
llOverview.addView(new RingView(activity, (int) activity.getResources().getDimension(
|
|
|
|
(int) activity.getResources().getDimension(R.dimen.small_square_size) * 4, habit.color,
|
|
|
|
R.dimen.small_square_size) * 4, habit.color,
|
|
|
|
((float) habit.getScore() / Habit.MAX_SCORE), "Habit strength"));
|
|
|
|
((float) habit.getScore() / Habit.MAX_SCORE), "Habit strength"));
|
|
|
|
|
|
|
|
|
|
|
|
LinearLayout llStrength = (LinearLayout) view.findViewById(R.id.llStrength);
|
|
|
|
LinearLayout llStrength = (LinearLayout) view.findViewById(R.id.llStrength);
|
|
|
@ -73,6 +80,38 @@ public class ShowHabitFragment extends Fragment
|
|
|
|
(int) activity.getResources().getDimension(R.dimen.small_square_size));
|
|
|
|
(int) activity.getResources().getDimension(R.dimen.small_square_size));
|
|
|
|
llStreaks.addView(hsv);
|
|
|
|
llStreaks.addView(hsv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setHasOptionsMenu(true);
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inflater.inflate(R.menu.show_habit_fragment_menu, menu);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (item.getItemId())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case R.id.action_edit_habit:
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
EditHabitFragment frag = EditHabitFragment.editSingleHabitFragment(habit.getId());
|
|
|
|
|
|
|
|
frag.setOnSavedListener(this);
|
|
|
|
|
|
|
|
frag.show(getFragmentManager(), "dialog");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSaved(Command command)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
activity.executeCommand(command);
|
|
|
|
|
|
|
|
ReminderHelper.createReminderAlarms(activity);
|
|
|
|
|
|
|
|
activity.recreate();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|