mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 21:29:00 +00:00
Fix task based allocation display. Fixes #893
This commit is contained in:
parent
0b020bb198
commit
b4036d6902
3 changed files with 128 additions and 241 deletions
|
|
@ -90,7 +90,7 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
|
|||
}
|
||||
|
||||
override fun sleep(user: User): Observable<User> {
|
||||
localRepository.executeTransaction { user.preferences.sleep = !user.preferences.sleep }
|
||||
localRepository.executeTransaction { user.preferences.isSleep = !user.preferences.sleep }
|
||||
return apiClient.sleep().map { user }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,240 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models.user;
|
||||
|
||||
|
||||
import com.habitrpg.android.habitica.models.AvatarPreferences;
|
||||
|
||||
import io.realm.RealmObject;
|
||||
import io.realm.annotations.PrimaryKey;
|
||||
|
||||
public class Preferences extends RealmObject implements AvatarPreferences {
|
||||
|
||||
@PrimaryKey
|
||||
private String userId;
|
||||
|
||||
private Hair hair;
|
||||
SuppressedModals suppressModals;
|
||||
User user;
|
||||
private boolean costume, toolbarCollapsed, advancedCollapsed, tagsCollapsed, newTaskEdit, disableClasses, stickyHeader, sleep, hideHeader, dailyDueDefaultView, automaticAllocation;
|
||||
private String allocationMode, shirt, skin, size, background, chair, language, sound;
|
||||
private int dayStart, timezoneOffset;
|
||||
|
||||
public Preferences() {
|
||||
}
|
||||
|
||||
public String getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
public void setBackground(String background) {
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
public int getDayStart() {
|
||||
return dayStart;
|
||||
}
|
||||
|
||||
public void setDayStart(int dayStart) {
|
||||
this.dayStart = dayStart;
|
||||
}
|
||||
|
||||
public boolean getCostume() {
|
||||
return costume;
|
||||
}
|
||||
|
||||
public void setCostume(boolean costume) {
|
||||
this.costume = costume;
|
||||
}
|
||||
|
||||
public boolean getToolbarCollapsed() {
|
||||
return toolbarCollapsed;
|
||||
}
|
||||
|
||||
public void setToolbarCollapsed(boolean toolbarCollapsed) {
|
||||
this.toolbarCollapsed = toolbarCollapsed;
|
||||
}
|
||||
|
||||
public boolean getAdvancedCollapsed() {
|
||||
return advancedCollapsed;
|
||||
}
|
||||
|
||||
public void setAdvancedCollapsed(boolean advancedCollapsed) {
|
||||
this.advancedCollapsed = advancedCollapsed;
|
||||
}
|
||||
|
||||
public boolean getTagsCollapsed() {
|
||||
return tagsCollapsed;
|
||||
}
|
||||
|
||||
public void setTagsCollapsed(boolean tagsCollapsed) {
|
||||
this.tagsCollapsed = tagsCollapsed;
|
||||
}
|
||||
|
||||
public boolean getNewTaskEdit() {
|
||||
return newTaskEdit;
|
||||
}
|
||||
|
||||
public void setNewTaskEdit(boolean newTaskEdit) {
|
||||
this.newTaskEdit = newTaskEdit;
|
||||
}
|
||||
|
||||
public boolean getDisableClasses() {
|
||||
return disableClasses;
|
||||
}
|
||||
|
||||
public boolean getStickyHeader() {
|
||||
return stickyHeader;
|
||||
}
|
||||
|
||||
public void setStickyHeader(boolean stickyHeader) {
|
||||
this.stickyHeader = stickyHeader;
|
||||
}
|
||||
|
||||
public boolean getSleep() {
|
||||
return sleep;
|
||||
}
|
||||
|
||||
public boolean getHideHeader() {
|
||||
return hideHeader;
|
||||
}
|
||||
|
||||
public void setHideHeader(boolean hideHeader) {
|
||||
this.hideHeader = hideHeader;
|
||||
}
|
||||
|
||||
public String getAllocationMode() {
|
||||
return allocationMode;
|
||||
}
|
||||
|
||||
public void setAllocationMode(String allocationMode) {
|
||||
this.allocationMode = allocationMode;
|
||||
}
|
||||
|
||||
public String getShirt() {
|
||||
return shirt;
|
||||
}
|
||||
|
||||
public void setShirt(String shirt) {
|
||||
this.shirt = shirt;
|
||||
}
|
||||
|
||||
public String getSkin() {
|
||||
return skin;
|
||||
}
|
||||
|
||||
public void setSkin(String skin) {
|
||||
this.skin = skin;
|
||||
}
|
||||
|
||||
public String getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(String size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public void setSound(String sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
public int getTimezoneOffset() {
|
||||
return timezoneOffset;
|
||||
}
|
||||
|
||||
public void setTimezoneOffset(int timezoneOffset) {
|
||||
this.timezoneOffset = timezoneOffset;
|
||||
}
|
||||
|
||||
public Hair getHair() {
|
||||
return hair;
|
||||
}
|
||||
|
||||
public void setHair(Hair hair) {
|
||||
this.hair = hair;
|
||||
}
|
||||
|
||||
public SuppressedModals getSuppressModals() {
|
||||
return suppressModals;
|
||||
}
|
||||
|
||||
public void setSuppressModals(SuppressedModals suppressModals) {
|
||||
this.suppressModals = suppressModals;
|
||||
}
|
||||
|
||||
public String getChair() {
|
||||
if (chair != null && !chair.equals("none")) {
|
||||
if (chair.length() > 5 && !chair.substring(0, 6).equals("chair_")) {
|
||||
return chair;
|
||||
} else {
|
||||
return "chair_" +chair;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setChair(String chair) {
|
||||
this.chair = chair;
|
||||
}
|
||||
|
||||
public boolean isSleep() {
|
||||
return sleep;
|
||||
}
|
||||
|
||||
public void setSleep(boolean sleep) {
|
||||
this.sleep = sleep;
|
||||
}
|
||||
|
||||
public boolean isDisableClasses() {
|
||||
return disableClasses;
|
||||
}
|
||||
|
||||
public void setDisableClasses(boolean disableClasses) {
|
||||
this.disableClasses = disableClasses;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public boolean getDailyDueDefaultView() {
|
||||
return dailyDueDefaultView;
|
||||
}
|
||||
|
||||
public void setDailyDueDefaultView(boolean dailyDueDefaultView) {
|
||||
this.dailyDueDefaultView = dailyDueDefaultView;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
if (hair != null && !hair.isManaged()) {
|
||||
hair.setUserId(userId);
|
||||
}
|
||||
if (suppressModals != null && !suppressModals.isManaged()) {
|
||||
suppressModals.setUserId(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasTaskBasedAllocation() {
|
||||
return allocationMode.equals("taskBased") && !automaticAllocation;
|
||||
}
|
||||
|
||||
public boolean getAutomaticAllocation() {
|
||||
return this.automaticAllocation;
|
||||
}
|
||||
|
||||
public void setAutomaticAllocation(boolean automaticAllocation) {
|
||||
this.automaticAllocation = automaticAllocation;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
package com.habitrpg.android.habitica.models.user
|
||||
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.habitrpg.android.habitica.models.AvatarPreferences
|
||||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
|
||||
open class Preferences : RealmObject(), AvatarPreferences {
|
||||
|
||||
@PrimaryKey
|
||||
private var userId: String? = null
|
||||
|
||||
private var hair: Hair? = null
|
||||
var suppressModals: SuppressedModals? = null
|
||||
private var costume: Boolean = false
|
||||
var toolbarCollapsed: Boolean = false
|
||||
var advancedCollapsed: Boolean = false
|
||||
var tagsCollapsed: Boolean = false
|
||||
var newTaskEdit: Boolean = false
|
||||
var isDisableClasses: Boolean = false
|
||||
var stickyHeader: Boolean = false
|
||||
@SerializedName("sleep")
|
||||
var isSleep: Boolean = false
|
||||
var hideHeader: Boolean = false
|
||||
var dailyDueDefaultView: Boolean = false
|
||||
var automaticAllocation: Boolean = false
|
||||
var allocationMode: String? = null
|
||||
private var shirt: String? = null
|
||||
private var skin: String? = null
|
||||
private var size: String? = null
|
||||
private var background: String? = null
|
||||
private var chair: String? = null
|
||||
var language: String? = null
|
||||
var sound: String? = null
|
||||
var dayStart: Int = 0
|
||||
var timezoneOffset: Int = 0
|
||||
|
||||
override fun getBackground(): String? {
|
||||
return background
|
||||
}
|
||||
|
||||
fun setBackground(background: String) {
|
||||
this.background = background
|
||||
}
|
||||
|
||||
override fun getCostume(): Boolean {
|
||||
return costume
|
||||
}
|
||||
|
||||
fun setCostume(costume: Boolean) {
|
||||
this.costume = costume
|
||||
}
|
||||
|
||||
override fun getDisableClasses(): Boolean {
|
||||
return isDisableClasses
|
||||
}
|
||||
|
||||
override fun getSleep(): Boolean {
|
||||
return isSleep
|
||||
}
|
||||
|
||||
override fun getShirt(): String? {
|
||||
return shirt
|
||||
}
|
||||
|
||||
fun setShirt(shirt: String) {
|
||||
this.shirt = shirt
|
||||
}
|
||||
|
||||
override fun getSkin(): String? {
|
||||
return skin
|
||||
}
|
||||
|
||||
fun setSkin(skin: String) {
|
||||
this.skin = skin
|
||||
}
|
||||
|
||||
override fun getSize(): String? {
|
||||
return size
|
||||
}
|
||||
|
||||
fun setSize(size: String) {
|
||||
this.size = size
|
||||
}
|
||||
|
||||
override fun getHair(): Hair? {
|
||||
return hair
|
||||
}
|
||||
|
||||
fun setHair(hair: Hair) {
|
||||
this.hair = hair
|
||||
}
|
||||
|
||||
override fun getChair(): String? {
|
||||
return if (chair != null && chair != "none") {
|
||||
if (chair!!.length > 5 && chair!!.substring(0, 6) != "chair_") {
|
||||
chair
|
||||
} else {
|
||||
"chair_" + chair!!
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
fun setChair(chair: String) {
|
||||
this.chair = chair
|
||||
}
|
||||
|
||||
override fun getUserId(): String? {
|
||||
return userId
|
||||
}
|
||||
|
||||
fun setUserId(userId: String) {
|
||||
this.userId = userId
|
||||
if (hair != null && !hair!!.isManaged) {
|
||||
hair!!.userId = userId
|
||||
}
|
||||
if (suppressModals != null && !suppressModals!!.isManaged) {
|
||||
suppressModals!!.userId = userId
|
||||
}
|
||||
}
|
||||
|
||||
fun hasTaskBasedAllocation(): Boolean {
|
||||
return allocationMode?.toLowerCase() == "taskbased" && automaticAllocation
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue