|
|
|
@ -45,10 +45,14 @@ import org.isoron.uhabits.views.HabitScoreView;
|
|
|
|
|
import org.isoron.uhabits.views.HabitStreakView;
|
|
|
|
|
import org.isoron.uhabits.views.RingView;
|
|
|
|
|
|
|
|
|
|
public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedListener
|
|
|
|
|
public class ShowHabitFragment extends Fragment
|
|
|
|
|
implements DialogHelper.OnSavedListener, HistoryEditorDialog.Listener
|
|
|
|
|
{
|
|
|
|
|
protected ShowHabitActivity activity;
|
|
|
|
|
private Habit habit;
|
|
|
|
|
private HabitStreakView streakView;
|
|
|
|
|
private HabitScoreView scoreView;
|
|
|
|
|
private HabitHistoryView historyView;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStart()
|
|
|
|
@ -66,29 +70,14 @@ public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedL
|
|
|
|
|
|
|
|
|
|
habit.checkmarks.rebuild();
|
|
|
|
|
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= 21)
|
|
|
|
|
{
|
|
|
|
|
int darkerHabitColor = ColorHelper.mixColors(habit.color, Color.BLACK, 0.75f);
|
|
|
|
|
activity.getWindow().setStatusBarColor(darkerHabitColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextView tvHistory = (TextView) view.findViewById(R.id.tvHistory);
|
|
|
|
|
TextView tvOverview = (TextView) view.findViewById(R.id.tvOverview);
|
|
|
|
|
TextView tvStrength = (TextView) view.findViewById(R.id.tvStrength);
|
|
|
|
|
TextView tvStreaks = (TextView) view.findViewById(R.id.tvStreaks);
|
|
|
|
|
RingView scoreRing = (RingView) view.findViewById(R.id.scoreRing);
|
|
|
|
|
Button btEditHistory = (Button) view.findViewById(R.id.btEditHistory);
|
|
|
|
|
HabitStreakView streakView = (HabitStreakView) view.findViewById(R.id.streakView);
|
|
|
|
|
HabitScoreView scoreView = (HabitScoreView) view.findViewById(R.id.scoreView);
|
|
|
|
|
HabitHistoryView historyView = (HabitHistoryView) view.findViewById(R.id.historyView);
|
|
|
|
|
streakView = (HabitStreakView) view.findViewById(R.id.streakView);
|
|
|
|
|
scoreView = (HabitScoreView) view.findViewById(R.id.scoreView);
|
|
|
|
|
historyView = (HabitHistoryView) view.findViewById(R.id.historyView);
|
|
|
|
|
|
|
|
|
|
tvHistory.setTextColor(habit.color);
|
|
|
|
|
tvOverview.setTextColor(habit.color);
|
|
|
|
|
tvStrength.setTextColor(habit.color);
|
|
|
|
|
tvStreaks.setTextColor(habit.color);
|
|
|
|
|
updateHeaders(view);
|
|
|
|
|
updateScoreRing(view);
|
|
|
|
|
|
|
|
|
|
scoreRing.setColor(habit.color);
|
|
|
|
|
scoreRing.setPercentage((float) habit.scores.getNewestValue() / Score.MAX_SCORE);
|
|
|
|
|
streakView.setHabit(habit);
|
|
|
|
|
scoreView.setHabit(habit);
|
|
|
|
|
historyView.setHabit(habit);
|
|
|
|
@ -100,6 +89,7 @@ public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedL
|
|
|
|
|
{
|
|
|
|
|
HistoryEditorDialog frag = new HistoryEditorDialog();
|
|
|
|
|
frag.setHabit(habit);
|
|
|
|
|
frag.setListener(ShowHabitFragment.this);
|
|
|
|
|
frag.show(getFragmentManager(), "dialog");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -108,6 +98,31 @@ public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedL
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateScoreRing(View view)
|
|
|
|
|
{
|
|
|
|
|
RingView scoreRing = (RingView) view.findViewById(R.id.scoreRing);
|
|
|
|
|
scoreRing.setColor(habit.color);
|
|
|
|
|
scoreRing.setPercentage((float) habit.scores.getNewestValue() / Score.MAX_SCORE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateHeaders(View view)
|
|
|
|
|
{
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= 21)
|
|
|
|
|
{
|
|
|
|
|
int darkerHabitColor = ColorHelper.mixColors(habit.color, Color.BLACK, 0.75f);
|
|
|
|
|
activity.getWindow().setStatusBarColor(darkerHabitColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextView tvHistory = (TextView) view.findViewById(R.id.tvHistory);
|
|
|
|
|
TextView tvOverview = (TextView) view.findViewById(R.id.tvOverview);
|
|
|
|
|
TextView tvStrength = (TextView) view.findViewById(R.id.tvStrength);
|
|
|
|
|
TextView tvStreaks = (TextView) view.findViewById(R.id.tvStreaks);
|
|
|
|
|
tvHistory.setTextColor(habit.color);
|
|
|
|
|
tvOverview.setTextColor(habit.color);
|
|
|
|
|
tvStrength.setTextColor(habit.color);
|
|
|
|
|
tvStreaks.setTextColor(habit.color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
|
|
|
|
|
{
|
|
|
|
@ -142,4 +157,18 @@ public class ShowHabitFragment extends Fragment implements DialogHelper.OnSavedL
|
|
|
|
|
ReminderHelper.createReminderAlarms(activity);
|
|
|
|
|
activity.recreate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onHistoryEditorClosed()
|
|
|
|
|
{
|
|
|
|
|
refreshData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void refreshData()
|
|
|
|
|
{
|
|
|
|
|
streakView.refreshData();
|
|
|
|
|
historyView.refreshData();
|
|
|
|
|
scoreView.refreshData();
|
|
|
|
|
updateScoreRing(getView());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|