|
|
@ -20,7 +20,6 @@
|
|
|
|
package org.isoron.uhabits.activities.habits.list.views;
|
|
|
|
package org.isoron.uhabits.activities.habits.list.views;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.*;
|
|
|
|
import android.content.*;
|
|
|
|
import android.graphics.*;
|
|
|
|
|
|
|
|
import android.support.annotation.*;
|
|
|
|
import android.support.annotation.*;
|
|
|
|
import android.util.*;
|
|
|
|
import android.util.*;
|
|
|
|
import android.view.*;
|
|
|
|
import android.view.*;
|
|
|
@ -32,7 +31,7 @@ import org.isoron.uhabits.utils.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
public class HeaderView extends LinearLayout
|
|
|
|
public class HeaderView extends LinearLayout implements Preferences.Listener
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private final Context context;
|
|
|
|
private final Context context;
|
|
|
|
|
|
|
|
|
|
|
@ -52,13 +51,19 @@ public class HeaderView extends LinearLayout
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Context appContext = context.getApplicationContext();
|
|
|
|
Context appContext = context.getApplicationContext();
|
|
|
|
if(appContext instanceof HabitsApplication)
|
|
|
|
if (appContext instanceof HabitsApplication)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HabitsApplication app = (HabitsApplication) appContext;
|
|
|
|
HabitsApplication app = (HabitsApplication) appContext;
|
|
|
|
prefs = app.getComponent().getPreferences();
|
|
|
|
prefs = app.getComponent().getPreferences();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onCheckmarkOrderChanged()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
createButtons();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setButtonCount(int buttonCount)
|
|
|
|
public void setButtonCount(int buttonCount)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.buttonCount = buttonCount;
|
|
|
|
this.buttonCount = buttonCount;
|
|
|
@ -66,10 +71,28 @@ public class HeaderView extends LinearLayout
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas)
|
|
|
|
protected void onAttachedToWindow()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
super.onAttachedToWindow();
|
|
|
|
|
|
|
|
if (prefs != null) prefs.addListener(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onDetachedFromWindow()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (prefs != null) prefs.removeListener(this);
|
|
|
|
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createButtons()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
removeAllViews();
|
|
|
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
|
|
|
GregorianCalendar day = DateUtils.getStartOfTodayCalendar();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < buttonCount; i++)
|
|
|
|
|
|
|
|
addView(
|
|
|
|
|
|
|
|
inflate(context, R.layout.list_habits_header_checkmark, null));
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < getChildCount(); i++)
|
|
|
|
for (int i = 0; i < getChildCount(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int position = i;
|
|
|
|
int position = i;
|
|
|
@ -80,22 +103,11 @@ public class HeaderView extends LinearLayout
|
|
|
|
label.setText(DateUtils.formatHeaderDate(day));
|
|
|
|
label.setText(DateUtils.formatHeaderDate(day));
|
|
|
|
day.add(GregorianCalendar.DAY_OF_MONTH, -1);
|
|
|
|
day.add(GregorianCalendar.DAY_OF_MONTH, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
super.onDraw(canvas);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createButtons()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int layout = R.layout.list_habits_header_checkmark;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
removeAllViews();
|
|
|
|
|
|
|
|
for (int i = 0; i < buttonCount; i++)
|
|
|
|
|
|
|
|
addView(inflate(context, layout, null));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean shouldReverseCheckmarks()
|
|
|
|
private boolean shouldReverseCheckmarks()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(prefs == null) return false;
|
|
|
|
if (prefs == null) return false;
|
|
|
|
return prefs.shouldReverseCheckmarks();
|
|
|
|
return prefs.shouldReverseCheckmarks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|