mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-16 11:11:41 +00:00
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # Habitica/res/values/strings.xml
This commit is contained in:
commit
33f1e4c22d
4 changed files with 38 additions and 8 deletions
|
|
@ -519,4 +519,6 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="myster_item_notes">Each month, subscribers will receive a mystery item. This is usually released about one week before the end of the month.</string>
|
||||
<string name="open">Open</string>
|
||||
<string name="notification_mystery_item">You open the box and find %s!</string>
|
||||
<string name="checkInRewardEarned">You earned a %1$s as a reward for your devotion to improving your life.</string>
|
||||
<string name="nextPrizeUnlocks">Your next prize unlocks at %1$d Check-Ins</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ import com.habitrpg.android.habitica.widget.AvatarStatsWidgetProvider;
|
|||
import com.habitrpg.android.habitica.widget.DailiesWidgetProvider;
|
||||
import com.habitrpg.android.habitica.widget.HabitButtonWidgetProvider;
|
||||
import com.habitrpg.android.habitica.widget.HabitButtonWidgetService;
|
||||
import com.habitrpg.android.habitica.widget.TaskListFactory;
|
||||
import com.habitrpg.android.habitica.widget.TaskListWidgetProvider;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
|
@ -225,4 +226,6 @@ public interface AppComponent {
|
|||
void inject(ChallengeTasksRecyclerViewFragment.ChallengeTasksRecyclerViewAdapter challengeTasksRecyclerViewAdapter);
|
||||
|
||||
void inject(ChallengeTasksRecyclerViewFragment challengeTasksRecyclerViewFragment);
|
||||
|
||||
void inject(TaskListFactory taskListFactory);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -28,12 +29,14 @@ public class PopupNotificationsManager {
|
|||
private Map<String, Boolean> seenNotifications;
|
||||
private APIHelper apiHelper;
|
||||
private static PopupNotificationsManager instance;
|
||||
private Context context;
|
||||
|
||||
// @TODO: A queue for displaying alert dialogues
|
||||
|
||||
private PopupNotificationsManager(APIHelper apiHelper) {
|
||||
this.apiHelper = apiHelper;
|
||||
this.seenNotifications = new HashMap<>();
|
||||
context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static PopupNotificationsManager getInstance(APIHelper apiHelper) {
|
||||
|
|
@ -65,17 +68,17 @@ public class PopupNotificationsManager {
|
|||
earnedString += ", ";
|
||||
}
|
||||
}
|
||||
youEarnedMessage = "You earned a " + earnedString + " as a reward for your devotion to improving your life.";
|
||||
youEarnedMessage = context.getString(R.string.checkInRewardEarned,earnedString);
|
||||
}
|
||||
}
|
||||
DataBindingUtils.loadImage(imageView, imageKey);
|
||||
|
||||
String message = "Your next prize unlocks at " + notification.data.nextRewardAt + " Check-Ins";
|
||||
TextView nextUnlockTextView = (TextView) view.findViewById(R.id.next_unlock_message);
|
||||
nextUnlockTextView.setText(message);
|
||||
TextView youEarnedTexView = (TextView) view.findViewById(R.id.you_earned_message);
|
||||
youEarnedTexView.setText(youEarnedMessage);
|
||||
|
||||
TextView youEarnedTexView = (TextView) view.findViewById(R.id.you_earned_message);
|
||||
youEarnedTexView.setText(youEarnedMessage);
|
||||
String message = context.getString(R.string.nextPrizeUnlocks,notification.data.nextRewardAt);
|
||||
TextView nextUnlockTextView = (TextView) view.findViewById(R.id.next_unlock_message);
|
||||
nextUnlockTextView.setText(message);
|
||||
|
||||
Button confirmButton = (Button) view.findViewById(R.id.confirm_button);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import android.text.style.DynamicDrawableSpan;
|
|||
import android.widget.RemoteViews;
|
||||
import android.widget.RemoteViewsService;
|
||||
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
import com.raizlabs.android.dbflow.sql.builder.Condition;
|
||||
import com.raizlabs.android.dbflow.sql.language.OrderBy;
|
||||
|
|
@ -20,12 +22,16 @@ import net.pherth.android.emoji_library.EmojiHandler;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
public abstract class TaskListFactory implements RemoteViewsService.RemoteViewsFactory {
|
||||
private final int widgetId;
|
||||
private Integer customDayStart;
|
||||
private int listItemResId;
|
||||
private int listItemTextResId;
|
||||
private String taskType;
|
||||
|
|
@ -33,6 +39,10 @@ public abstract class TaskListFactory implements RemoteViewsService.RemoteViewsF
|
|||
private Context context = null;
|
||||
private boolean reloadData;
|
||||
|
||||
@Inject
|
||||
@Named("UserID")
|
||||
public String userID;
|
||||
|
||||
public TaskListFactory(Context context, Intent intent, String taskType, int listItemResId, int listItemTextResId) {
|
||||
this.context = context;
|
||||
this.widgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0);
|
||||
|
|
@ -41,7 +51,19 @@ public abstract class TaskListFactory implements RemoteViewsService.RemoteViewsF
|
|||
this.reloadData = false;
|
||||
this.taskType = taskType;
|
||||
|
||||
this.loadData();
|
||||
if (userID == null) {
|
||||
HabiticaApplication.getComponent().inject(this);
|
||||
}
|
||||
|
||||
if (customDayStart == null) {
|
||||
Observable.defer(() -> Observable.just(new Select().from(HabitRPGUser.class).where(Condition.column("id").eq(userID)).querySingle()))
|
||||
.subscribe(habitRPGUser -> {
|
||||
customDayStart = habitRPGUser.getPreferences().getDayStart();
|
||||
this.loadData();
|
||||
}, throwable -> {});
|
||||
} else {
|
||||
this.loadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
|
|
@ -51,7 +73,7 @@ public abstract class TaskListFactory implements RemoteViewsService.RemoteViewsF
|
|||
.and(Condition.column("completed").eq(false))
|
||||
.orderBy(OrderBy.columns("position", "dateCreated").descending())
|
||||
.queryList()))
|
||||
.filter(task -> task.type.equals(Task.TYPE_TODO) || task.isDisplayedActive(0))
|
||||
.filter(task -> task.type.equals(Task.TYPE_TODO) || task.isDisplayedActive(customDayStart))
|
||||
.toList()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
|
|||
Loading…
Reference in a new issue