Compare commits

...

9 Commits

Author SHA1 Message Date
98abebe099 Merge branch 'hotfix/v1.8.12' 2021-01-30 20:47:36 -06:00
0f86cb4d53 Update list of developers 2021-01-30 20:39:19 -06:00
Kristian Tashkov
4dd77463fb Update widgets at midnight (#634) 2021-01-30 20:36:37 -06:00
Quentin Hibon
2cf3347f8c Set dataOffset when attaching a new CardView
Fixes #713.
2021-01-30 20:15:26 -06:00
5516f40571 Bump version to 1.8.12; update CHANGELOG and release notes 2021-01-30 19:53:57 -06:00
56f91526e6 Update CHANGELOG 2020-12-29 18:51:12 -06:00
dbc6a16a98 Set forceDarkAllowed to false 2020-12-29 18:43:09 -06:00
011abf62a0 Bump version to 1.8.11 2020-12-09 20:01:35 -06:00
Sunxy88
9c96857262 Use dark theme in settings window. (#655) 2020-12-09 19:57:03 -06:00
17 changed files with 84 additions and 31 deletions

View File

@@ -1,5 +1,14 @@
# Changelog
### 1.8.12 (TBD)
* Fix bug that caused incorrect check marks to show after scrolling (#713)
* Fix issue preventing widgets from updating at midnight (#680)
### 1.8.11 (Dev 29, 2020)
* Fix theme issues on Xiaomi phones
### 1.8.10 (Nov 26, 2020)
* Update translations

View File

@@ -1,5 +1,5 @@
VERSION_CODE = 10810
VERSION_NAME = 1.8.10
VERSION_CODE = 10812
VERSION_NAME = 1.8.12
MIN_SDK_VERSION = 21
TARGET_SDK_VERSION = 29

View File

@@ -62,6 +62,7 @@ class HabitsApplication : Application() {
widgetUpdater = component.widgetUpdater
widgetUpdater.startListening()
widgetUpdater.scheduleStartDayWidgetUpdate()
reminderScheduler = component.reminderScheduler
reminderScheduler.startListening()

View File

@@ -206,7 +206,7 @@ public class HabitCardListAdapter
int viewType)
{
if (listView == null) return null;
View view = listView.createHabitCardView();
HabitCardView view = listView.createHabitCardView();
return new HabitCardViewHolder(view);
}

View File

@@ -62,7 +62,7 @@ class HabitCardListView(
super.setAdapter(adapter)
}
fun createHabitCardView(): View {
fun createHabitCardView(): HabitCardView {
return cardViewFactory.create()
}
@@ -91,6 +91,7 @@ class HabitCardListView(
}
fun attachCardView(holder: HabitCardViewHolder) {
(holder.itemView as HabitCardView).dataOffset = dataOffset
attachedHolders.add(holder)
}

View File

@@ -19,8 +19,6 @@
package org.isoron.uhabits.activities.habits.list.views
import androidx.appcompat.widget.*
import android.view.*
import androidx.recyclerview.widget.RecyclerView
class HabitCardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
class HabitCardViewHolder(itemView: HabitCardView) : RecyclerView.ViewHolder(itemView)

View File

@@ -23,17 +23,25 @@ import android.os.*;
import org.isoron.androidbase.activities.*;
import org.isoron.androidbase.utils.*;
import org.isoron.uhabits.R;
import org.isoron.uhabits.*;
import org.isoron.uhabits.activities.*;
/**
* Activity that allows the user to view and modify the app settings.
*/
public class SettingsActivity extends BaseActivity
{
private AndroidThemeSwitcher themeSwitcher;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
HabitsApplicationComponent compoenent = ((HabitsApplication) getApplication()).getComponent();
themeSwitcher = new AndroidThemeSwitcher(this, compoenent.getPreferences());
themeSwitcher.apply();
setContentView(R.layout.settings_activity);
setupActionBarColor();
}

View File

@@ -45,7 +45,7 @@ class IntentScheduler
private val manager =
context.getSystemService(ALARM_SERVICE) as AlarmManager
fun schedule(timestamp: Long, intent: PendingIntent) {
fun schedule(timestamp: Long, intent: PendingIntent, alarmType: Int) {
Log.d("IntentScheduler",
"timestamp=" + timestamp + " current=" + System.currentTimeMillis())
if (timestamp < System.currentTimeMillis()) {
@@ -54,19 +54,24 @@ class IntentScheduler
return;
}
if (SDK_INT >= M)
manager.setExactAndAllowWhileIdle(RTC_WAKEUP, timestamp, intent)
manager.setExactAndAllowWhileIdle(alarmType, timestamp, intent)
else
manager.setExact(RTC_WAKEUP, timestamp, intent)
manager.setExact(alarmType, timestamp, intent)
}
override fun scheduleShowReminder(reminderTime: Long,
habit: Habit,
timestamp: Long) {
val intent = pendingIntents.showReminder(habit, reminderTime, timestamp)
schedule(reminderTime, intent)
schedule(reminderTime, intent, RTC_WAKEUP)
logReminderScheduled(habit, reminderTime)
}
override fun scheduleWidgetUpdate(updateTime: Long) {
val intent = pendingIntents.updateWidgets()
schedule(updateTime, intent, RTC)
}
override fun log(componentName: String, msg: String) {
Log.d(componentName, msg)
}

View File

@@ -103,4 +103,12 @@ class PendingIntentFactory
if (timestamp != null) putExtra("timestamp", timestamp)
},
FLAG_UPDATE_CURRENT)
fun updateWidgets(): PendingIntent =
PendingIntent.getBroadcast(
context, 0,
Intent(context, WidgetReceiver::class.java).apply {
action = WidgetReceiver.ACTION_UPDATE_WIDGETS_VALUE
},
FLAG_UPDATE_CURRENT)
}

View File

@@ -26,6 +26,7 @@ import org.isoron.uhabits.*;
import org.isoron.uhabits.core.preferences.*;
import org.isoron.uhabits.core.ui.widgets.*;
import org.isoron.uhabits.intents.*;
import org.isoron.uhabits.widgets.*;
import dagger.*;
@@ -48,6 +49,9 @@ public class WidgetReceiver extends BroadcastReceiver
public static final String ACTION_TOGGLE_REPETITION =
"org.isoron.uhabits.ACTION_TOGGLE_REPETITION";
public static final String ACTION_UPDATE_WIDGETS_VALUE =
"org.isoron.uhabits.ACTION_UPDATE_WIDGETS_VALUE";
private static final String TAG = "WidgetReceiver";
@Override
@@ -64,13 +68,17 @@ public class WidgetReceiver extends BroadcastReceiver
IntentParser parser = app.getComponent().getIntentParser();
WidgetBehavior controller = component.getWidgetController();
Preferences prefs = app.getComponent().getPreferences();
WidgetUpdater widgetUpdater = app.getComponent().getWidgetUpdater();
Log.i(TAG, String.format("Received intent: %s", intent.toString()));
try
{
IntentParser.CheckmarkIntentData data;
data = parser.parseCheckmarkIntent(intent);
IntentParser.CheckmarkIntentData data = null;
if (intent.getAction() != ACTION_UPDATE_WIDGETS_VALUE)
{
data = parser.parseCheckmarkIntent(intent);
}
switch (intent.getAction())
{
@@ -100,6 +108,11 @@ public class WidgetReceiver extends BroadcastReceiver
controller.onRemoveRepetition(data.getHabit(),
data.getTimestamp());
break;
case ACTION_UPDATE_WIDGETS_VALUE:
widgetUpdater.updateWidgets();
widgetUpdater.scheduleStartDayWidgetUpdate();
break;
}
}
catch (RuntimeException e)

View File

@@ -25,6 +25,8 @@ import org.isoron.androidbase.*
import org.isoron.uhabits.core.commands.*
import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.core.tasks.*
import org.isoron.uhabits.core.utils.*
import org.isoron.uhabits.intents.*
import javax.inject.*
/**
@@ -36,7 +38,8 @@ class WidgetUpdater
@AppContext private val context: Context,
private val commandRunner: CommandRunner,
private val taskRunner: TaskRunner,
private val widgetPrefs: WidgetPreferences
private val widgetPrefs: WidgetPreferences,
private val intentScheduler: IntentScheduler
) : CommandRunner.Listener {
override fun onCommandExecuted(command: Command, refreshKey: Long?) {
@@ -60,6 +63,11 @@ class WidgetUpdater
commandRunner.removeListener(this)
}
fun scheduleStartDayWidgetUpdate() {
val timestamp = DateUtils.getStartOfTomorrow()
intentScheduler.scheduleWidgetUpdate(timestamp);
}
fun updateWidgets(modifiedHabitId: Long?) {
taskRunner.execute {
updateWidgets(modifiedHabitId, CheckmarkWidgetProvider::class.java)

View File

@@ -1,14 +1,3 @@
1.8.10:
* Update translations
1.8.9
* Remove unused permissions
* Notification bundling
1.8:
* New bar chart showing number of repetitions performed each week, month or year
* Performing habits on irregular weekdays will no longer break your streak
* More colors
* Customize how transparent the widgets are
* Customize the first day of the week
* Yes/No buttons on notifications
* Automatic dark theme (Android 10)
* Smaller APK and backup files
1.8.12:
* Fix bug that caused incorrect check marks to show after scrolling
* Fix issue preventing widgets from updating at midnight

View File

@@ -129,6 +129,8 @@
<TextView style="@style/About.Item" android:text="Nikhil (regularcoder)"/>
<TextView style="@style/About.Item" android:text="JanetQC"/>
<TextView style="@style/About.Item" android:text="olegivo"/>
<TextView style="@style/About.Item" android:text="Kristian Tashkov"/>
<TextView style="@style/About.Item" android:text="Quentin Hibon (hiqua)"/>
<TextView
android:id="@+id/tvContributors"
style="@style/About.Item.Clickable"

View File

@@ -17,8 +17,9 @@
~ with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item name="android:dialogTheme">@style/Theme.AppCompat.Light.Dialog</item>
<item name="android:alertDialogTheme">@style/Theme.AppCompat.Light.Dialog</item>
@@ -75,6 +76,7 @@
</style>
<style name="AppBaseThemeDark" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item name="android:dialogTheme">@style/Theme.AppCompat.Dialog</item>
<item name="android:alertDialogTheme">@style/Theme.AppCompat.Dialog</item>
@@ -127,6 +129,7 @@
</style>
<style name="AppBaseThemeDark.PureBlack">
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="selectedBackground">@drawable/selected_box_amoled</item>
<item name="cardBackground">@drawable/card_amoled_background</item>

View File

@@ -164,6 +164,8 @@ public class ReminderScheduler implements CommandRunner.Listener
{
void scheduleShowReminder(long reminderTime, Habit habit, long timestamp);
void scheduleWidgetUpdate(long updateTime);
void log(String componentName, String msg);
}
}

View File

@@ -175,9 +175,14 @@ public abstract class DateUtils
return getStartOfDay(getLocalTime());
}
public static long getStartOfTomorrow()
{
return getUpcomingTimeInMillis(0, 0);
}
public static long millisecondsUntilTomorrow()
{
return getStartOfToday() + DAY_LENGTH - getLocalTime();
return getStartOfTomorrow() - getLocalTime();
}
public static GregorianCalendar getStartOfTodayCalendar()

View File

@@ -164,6 +164,7 @@ public class DateUtilsTest extends BaseUnitTest
@Test
public void testMillisecondsUntilTomorrow() throws Exception
{
DateUtils.setFixedTimeZone(TimeZone.getTimeZone("GMT"));
DateUtils.setFixedLocalTime(unixTime(2017, JANUARY, 1, 23, 59));
assertThat(DateUtils.millisecondsUntilTomorrow(), equalTo(60000L));