add stats tutorial step. Fixes #824

This commit is contained in:
Phillip Thelen 2017-11-02 18:46:04 +01:00
parent 4c713e8c92
commit 5bf4b4bb9a
4 changed files with 34 additions and 64 deletions

View file

@ -20,4 +20,5 @@
<string name="tutorial_party">This is where you and your friends can hold each other accountable to your goals and fight monsters with your tasks!</string>
<string name="tutorial_tavern">Welcome to the Tavern, a public, all-ages chatroom! Here you can chat about productivity and ask questions. Have fun!</string>
<string name="tutorial_classes">Choose to become a Warrior, Mage, Healer, or Rogue! Each class has unique equipment and skills. Tap the (?) to learn more!</string>
<string name="tutorial_stats">Tap the gray button to allocate lots of your stats at once, or tap the arrows to add them one point at a time.</string>
</resources>

View file

@ -1,64 +0,0 @@
package com.habitrpg.android.habitica.models;
import com.habitrpg.android.habitica.models.user.Flags;
import java.util.Date;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
public class TutorialStep extends RealmObject {
public Flags flags;
@PrimaryKey
private String key;
private String tutorialGroup, identifier;
private boolean wasCompleted;
private Date displayedOn;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getTutorialGroup() {
return tutorialGroup;
}
public void setTutorialGroup(String group) {
this.tutorialGroup = group;
this.key = group + "_" + this.identifier;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
this.key = this.tutorialGroup + "_" + identifier;
}
public boolean getWasCompleted() {
return wasCompleted;
}
public void setWasCompleted(boolean wasCompleted) {
this.wasCompleted = wasCompleted;
}
public Date getDisplayedOn() {
return displayedOn;
}
public void setDisplayedOn(Date displayedOn) {
this.displayedOn = displayedOn;
}
public boolean shouldDisplay() {
return !this.getWasCompleted() && (this.getDisplayedOn() == null || (new Date().getTime() - this.getDisplayedOn().getTime()) > 86400000);
}
}

View file

@ -0,0 +1,29 @@
package com.habitrpg.android.habitica.models
import com.habitrpg.android.habitica.models.user.Flags
import java.util.Date
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class TutorialStep : RealmObject() {
@PrimaryKey
var key: String? = null
var tutorialGroup: String? = null
set(group) {
field = group
this.key = group + "_" + this.identifier
}
var identifier: String? = null
set(identifier) {
field = identifier
this.key = this.tutorialGroup + "_" + identifier
}
var wasCompleted: Boolean = false
var displayedOn: Date? = null
fun shouldDisplay(): Boolean =
!this.wasCompleted && (this.displayedOn == null || Date().time - this.displayedOn!!.time > 86400000)
}

View file

@ -57,6 +57,10 @@ class StatsFragment: BaseMainFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
hideToolbar()
tutorialStepIdentifier = "stats"
tutorialText = getString(R.string.tutorial_stats)
return container?.inflate(R.layout.fragment_stats)
}