Merge branch 'hotfix/1.3.1'

pull/69/head v1.3.1
Alinson S. Xavier 10 years ago
commit 824f98dd96

@ -1,5 +1,11 @@
# Changelog
### 1.3.1 (March 15, 2016)
* Fixes crash on devices with large screen, such as the Nexus 10
* Fixes crash when clicking widgets and reminders of deleted habits
* Other minor bug fixes
### 1.3.0 (March 12, 2016)
* New frequency plot: view total repetitions per day of week

@ -21,8 +21,8 @@
<manifest
package="org.isoron.uhabits"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="10"
android:versionName="1.3.0">
android:versionCode="11"
android:versionName="1.3.1">
<uses-permission android:name="android.permission.VIBRATE"/>

@ -31,7 +31,7 @@ import java.util.TimeZone;
public class DateHelper
{
public static int millisecondsInOneDay = 24 * 60 * 60 * 1000;
public static long millisecondsInOneDay = 24 * 60 * 60 * 1000;
public static long getLocalTime()
{

@ -91,10 +91,12 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
long delayMinutes = Long.parseLong(prefs.getString("pref_snooze_interval", "15"));
Habit habit = Habit.get(ContentUris.parseId(data));
ReminderHelper.createReminderAlarm(context, habit,
new Date().getTime() + delayMinutes * 60 * 1000);
dismissNotification(context, habit);
long habitId = ContentUris.parseId(data);
Habit habit = Habit.get(habitId);
if(habit != null)
ReminderHelper.createReminderAlarm(context, habit,
new Date().getTime() + delayMinutes * 60 * 1000);
dismissNotification(context, habitId);
}
private void checkHabit(Context context, Intent intent)
@ -102,10 +104,11 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
Uri data = intent.getData();
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
Habit habit = Habit.get(ContentUris.parseId(data));
habit.repetitions.toggle(timestamp);
habit.save();
dismissNotification(context, habit);
long habitId = ContentUris.parseId(data);
Habit habit = Habit.get(habitId);
if(habit != null)
habit.repetitions.toggle(timestamp);
dismissNotification(context, habitId);
sendRefreshBroadcast(context);
}
@ -128,12 +131,12 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
}
}
private void dismissNotification(Context context, Habit habit)
private void dismissNotification(Context context, Long habitId)
{
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Activity.NOTIFICATION_SERVICE);
int notificationId = (int) (habit.getId() % Integer.MAX_VALUE);
int notificationId = (int) (habitId % Integer.MAX_VALUE);
notificationManager.cancel(notificationId);
}
@ -145,6 +148,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());
if (habit == null) return;
if (habit.repetitions.hasImplicitRepToday()) return;
habit.highlight = 1;

@ -124,7 +124,7 @@ public class ScoreList
return lastScore;
}
public int[] getAllValues(Long fromTimestamp, Long toTimestamp, Integer divisor)
public int[] getAllValues(Long fromTimestamp, Long toTimestamp, Long divisor)
{
// Force rebuild of the score table
getNewestValue();
@ -157,7 +157,7 @@ public class ScoreList
}
public int[] getAllValues(int divisor)
public int[] getAllValues(long divisor)
{
Repetition oldestRep = habit.repetitions.getOldest();
if(oldestRep == null) return new int[0];

@ -24,6 +24,9 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.View;
@ -37,10 +40,11 @@ public class RingView extends View
private int size;
private int color;
private float percentage;
private Paint pRing;
private float lineHeight;
private float labelMarginTop;
private TextPaint pRing;
private String label;
private RectF rect;
private StaticLayout labelLayout;
public RingView(Context context, AttributeSet attrs)
{
@ -68,12 +72,16 @@ public class RingView extends View
private void init()
{
pRing = new Paint();
pRing = new TextPaint();
pRing.setAntiAlias(true);
pRing.setColor(color);
pRing.setTextAlign(Paint.Align.CENTER);
pRing.setTextSize(size * 0.2f);
lineHeight = pRing.getFontSpacing();
pRing.setTextSize(size * 0.15f);
labelMarginTop = size * 0.10f;
labelLayout = new StaticLayout(label, pRing, size, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0f,
false);
rect = new RectF();
}
@ -81,7 +89,11 @@ public class RingView extends View
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(size, size + (int) (2 * lineHeight));
int width = Math.max(size, labelLayout.getWidth());
int height = (int) (size + labelLayout.getHeight() + labelMarginTop);
setMeasuredDimension(width, height);
}
@Override
@ -101,12 +113,14 @@ public class RingView extends View
rect.inset(thickness, thickness);
canvas.drawArc(rect, -90, 360, true, pRing);
float lineHeight = pRing.getFontSpacing();
pRing.setColor(Color.GRAY);
pRing.setTextSize(size * 0.2f);
canvas.drawText(String.format("%.0f%%", percentage * 100), rect.centerX(),
rect.centerY() + lineHeight / 3, pRing);
pRing.setTextSize(size * 0.15f);
canvas.drawText(label, size / 2, size + lineHeight * 1.2f, pRing);
canvas.translate(size / 2, size + labelMarginTop);
labelLayout.draw(canvas);
}
}

@ -25,7 +25,6 @@ import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.media.Image;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
@ -33,7 +32,6 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import org.isoron.helpers.DialogHelper;
@ -106,6 +104,14 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
if(habitId < 0) return;
Habit habit = Habit.get(habitId);
if(habit == null)
{
RemoteViews errorView = new RemoteViews(context.getPackageName(),
R.layout.widget_error);
manager.updateAppWidget(widgetId, errorView);
return;
}
View widgetView = buildCustomView(context, habit);
measureCustomView(context, width, height, widgetView);

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
~
~ This file is part of Loop Habit Tracker.
~
~ Loop Habit Tracker is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by the
~ Free Software Foundation, either version 3 of the License, or (at your
~ option) any later version.
~
~ Loop Habit Tracker is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
~ more details.
~
~ You should have received a copy of the GNU General Public License along
~ with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/widget_background"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="4dp"
android:paddingBottom="0dp"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<TextView
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Habit not found"
android:textColor="#ffffff"/>
</LinearLayout>
Loading…
Cancel
Save