Days since last checked displayed

Now lets just shorten the code
pull/626/head
aglebionek 5 years ago
parent 2fdb32c97b
commit f9226f47d1

@ -21,7 +21,10 @@ package org.isoron.uhabits.widgets
import android.app.*
import android.content.*
import android.os.Build
import android.view.*
import androidx.annotation.RequiresApi
import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.utils.*
import org.isoron.uhabits.widgets.views.*
@ -43,7 +46,7 @@ open class CheckmarkWidgetWithTime(
override fun refreshData(v: View) {
(v as CheckmarkTimeWidgetView).apply {
setBackgroundAlpha(preferedBackgroundAlpha)
setNewest(habit.repetitions.newest)
setActiveColor(PaletteUtils.getColor(context, habit.color))
setName(habit.name)
setCheckmarkValue(habit.checkmarks.todayValue)

@ -21,6 +21,7 @@ package org.isoron.uhabits.widgets.views;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.widget.TextView;
@ -32,6 +33,8 @@ import org.isoron.uhabits.R;
import org.isoron.uhabits.activities.common.views.RingView;
import org.isoron.uhabits.activities.habits.list.views.NumberButtonViewKt;
import org.isoron.uhabits.core.models.Checkmark;
import org.isoron.uhabits.core.models.Repetition;
import org.isoron.uhabits.core.models.Timestamp;
import org.isoron.uhabits.utils.PaletteUtils;
import static org.isoron.androidbase.utils.InterfaceUtils.getDimension;
@ -48,6 +51,8 @@ public class CheckmarkTimeWidgetView extends HabitWidgetView {
protected TextView label;
protected Repetition newest;
protected int checkmarkValue;
protected int checkmarkState;
@ -123,7 +128,7 @@ public class CheckmarkTimeWidgetView extends HabitWidgetView {
return getResources().getString(R.string.fa_skipped);
case Checkmark.UNCHECKED:
default:
return getResources().getString(R.string.fa_times);
return newest == null ? "0" : String.valueOf(newest.getTimestamp().daysUntil(new Timestamp(System.currentTimeMillis())));
}
}
@ -152,6 +157,10 @@ public class CheckmarkTimeWidgetView extends HabitWidgetView {
this.isNumerical = isNumerical;
}
public void setNewest(Repetition newest) {
this.newest = newest;
}
@Override
@NonNull
protected Integer getInnerLayoutId()

@ -18,7 +18,7 @@
~ with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frame"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
@ -31,13 +31,13 @@
android:id="@+id/scoreRing"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="8dp"
android:layout_marginRight="12dp"
android:layout_weight="1"
habit:thickness="2"
habit:textSize="16"
habit:enableFontAwesome="true"
android:layout_marginTop="8dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"/>
habit:textSize="16"
habit:thickness="2" />
<TextView
android:id="@+id/label"

Loading…
Cancel
Save