mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Merge tag 'v1.3.1' into dev
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# 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)
|
### 1.3.0 (March 12, 2016)
|
||||||
|
|
||||||
* New frequency plot: view total repetitions per day of week
|
* New frequency plot: view total repetitions per day of week
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
<manifest
|
<manifest
|
||||||
package="org.isoron.uhabits"
|
package="org.isoron.uhabits"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:versionCode="10"
|
android:versionCode="11"
|
||||||
android:versionName="1.3.0">
|
android:versionName="1.3.1">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.TimeZone;
|
|||||||
|
|
||||||
public class DateHelper
|
public class DateHelper
|
||||||
{
|
{
|
||||||
public static int millisecondsInOneDay = 24 * 60 * 60 * 1000;
|
public static long millisecondsInOneDay = 24 * 60 * 60 * 1000;
|
||||||
private static Long fixedLocalTime = null;
|
private static Long fixedLocalTime = null;
|
||||||
|
|
||||||
public static long getLocalTime()
|
public static long getLocalTime()
|
||||||
|
|||||||
@@ -92,10 +92,12 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
long delayMinutes = Long.parseLong(prefs.getString("pref_snooze_interval", "15"));
|
long delayMinutes = Long.parseLong(prefs.getString("pref_snooze_interval", "15"));
|
||||||
|
|
||||||
Habit habit = Habit.get(ContentUris.parseId(data));
|
long habitId = ContentUris.parseId(data);
|
||||||
|
Habit habit = Habit.get(habitId);
|
||||||
|
if(habit != null)
|
||||||
ReminderHelper.createReminderAlarm(context, habit,
|
ReminderHelper.createReminderAlarm(context, habit,
|
||||||
new Date().getTime() + delayMinutes * 60 * 1000);
|
new Date().getTime() + delayMinutes * 60 * 1000);
|
||||||
dismissNotification(context, habit);
|
dismissNotification(context, habitId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkHabit(Context context, Intent intent)
|
private void checkHabit(Context context, Intent intent)
|
||||||
@@ -103,10 +105,11 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
||||||
|
|
||||||
Habit habit = Habit.get(ContentUris.parseId(data));
|
long habitId = ContentUris.parseId(data);
|
||||||
|
Habit habit = Habit.get(habitId);
|
||||||
|
if(habit != null)
|
||||||
habit.repetitions.toggle(timestamp);
|
habit.repetitions.toggle(timestamp);
|
||||||
habit.save();
|
dismissNotification(context, habitId);
|
||||||
dismissNotification(context, habit);
|
|
||||||
|
|
||||||
sendRefreshBroadcast(context);
|
sendRefreshBroadcast(context);
|
||||||
}
|
}
|
||||||
@@ -129,12 +132,12 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dismissNotification(Context context, Habit habit)
|
private void dismissNotification(Context context, Long habitId)
|
||||||
{
|
{
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Activity.NOTIFICATION_SERVICE);
|
(NotificationManager) context.getSystemService(Activity.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
int notificationId = (int) (habit.getId() % Integer.MAX_VALUE);
|
int notificationId = (int) (habitId % Integer.MAX_VALUE);
|
||||||
notificationManager.cancel(notificationId);
|
notificationManager.cancel(notificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +149,7 @@ public class HabitBroadcastReceiver extends BroadcastReceiver
|
|||||||
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
|
||||||
Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());
|
Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());
|
||||||
|
|
||||||
|
if (habit == null) return;
|
||||||
if (habit.checkmarks.getTodayValue() != Checkmark.UNCHECKED) return;
|
if (habit.checkmarks.getTodayValue() != Checkmark.UNCHECKED) return;
|
||||||
|
|
||||||
habit.highlight = 1;
|
habit.highlight = 1;
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class ScoreList
|
|||||||
return lastScore;
|
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
|
// Force rebuild of the score table
|
||||||
getNewestValue();
|
getNewestValue();
|
||||||
@@ -157,7 +157,7 @@ public class ScoreList
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getAllValues(int divisor)
|
public int[] getAllValues(long divisor)
|
||||||
{
|
{
|
||||||
Repetition oldestRep = habit.repetitions.getOldest();
|
Repetition oldestRep = habit.repetitions.getOldest();
|
||||||
if(oldestRep == null) return new int[0];
|
if(oldestRep == null) return new int[0];
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class RingView extends View
|
|||||||
private float maxDiameter;
|
private float maxDiameter;
|
||||||
private float textSize;
|
private float textSize;
|
||||||
|
|
||||||
|
|
||||||
public RingView(Context context, AttributeSet attrs)
|
public RingView(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -133,7 +134,6 @@ public class RingView extends View
|
|||||||
float lineHeight = pRing.getFontSpacing();
|
float lineHeight = pRing.getFontSpacing();
|
||||||
canvas.drawText(String.format("%.0f%%", percentage * 100), rect.centerX(),
|
canvas.drawText(String.format("%.0f%%", percentage * 100), rect.centerX(),
|
||||||
rect.centerY() + lineHeight / 3, pRing);
|
rect.centerY() + lineHeight / 3, pRing);
|
||||||
|
|
||||||
pRing.setTextSize(textSize);
|
pRing.setTextSize(textSize);
|
||||||
canvas.translate(width / 2, diameter + labelMarginTop);
|
canvas.translate(width / 2, diameter + labelMarginTop);
|
||||||
labelLayout.draw(canvas);
|
labelLayout.draw(canvas);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.appwidget.AppWidgetProvider;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.media.Image;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
@@ -33,7 +32,6 @@ import android.util.Log;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
import org.isoron.helpers.DialogHelper;
|
import org.isoron.helpers.DialogHelper;
|
||||||
@@ -106,7 +104,13 @@ public abstract class BaseWidgetProvider extends AppWidgetProvider
|
|||||||
if(habitId < 0) return;
|
if(habitId < 0) return;
|
||||||
|
|
||||||
Habit habit = Habit.get(habitId);
|
Habit habit = Habit.get(habitId);
|
||||||
if(habit == null) return;
|
if(habit == null)
|
||||||
|
{
|
||||||
|
RemoteViews errorView = new RemoteViews(context.getPackageName(),
|
||||||
|
R.layout.widget_error);
|
||||||
|
manager.updateAppWidget(widgetId, errorView);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
View widgetView = buildCustomView(context, habit);
|
View widgetView = buildCustomView(context, habit);
|
||||||
measureCustomView(context, width, height, widgetView);
|
measureCustomView(context, width, height, widgetView);
|
||||||
|
|||||||
41
app/src/main/res/layout/widget_error.xml
Normal file
41
app/src/main/res/layout/widget_error.xml
Normal file
@@ -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>
|
||||||
Reference in New Issue
Block a user