mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 13:48:55 +00:00
Display levelup popup
This commit is contained in:
parent
e181c51fdc
commit
75ad7523cc
6 changed files with 117 additions and 9 deletions
|
|
@ -74,7 +74,7 @@
|
|||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/gridlayout-v7/23.0.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/answers/1.2.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.2/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.0/jars" />
|
||||
|
|
@ -128,15 +128,15 @@
|
|||
<orderEntry type="library" exported="" name="org.abego.treelayout.core-1.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-1.1.5" level="project" />
|
||||
<orderEntry type="library" exported="" name="DBFlow-2.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="bolts-android-1.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="materialdrawer-4.3.8" level="project" />
|
||||
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="checkout-0.7.4" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="compilerCommon-1.0-rc1" level="project" />
|
||||
<orderEntry type="library" exported="" name="compiler-1.0-rc1" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="mimecraft-1.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="guava-18.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="materialize-0.2.7" level="project" />
|
||||
<orderEntry type="library" exported="" name="gridlayout-v7-23.0.1" level="project" />
|
||||
|
|
@ -148,25 +148,25 @@
|
|||
<orderEntry type="library" exported="" name="facebook-android-sdk-4.7.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="iconics-core-1.7.9" level="project" />
|
||||
<orderEntry type="library" exported="" name="paperboy-2.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
|
||||
<orderEntry type="library" exported="" name="javawriter-2.5.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-codec-1.10" level="project" />
|
||||
<orderEntry type="library" exported="" name="kotlin-stdlib-0.12.613" level="project" />
|
||||
<orderEntry type="library" exported="" name="commons-lang3-3.3.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="fab-1.6.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="instabugcore-1.8-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="cardview-v7-22.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="DBFlow-Compiler-2.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="kotlin-runtime-0.12.613" level="project" />
|
||||
<orderEntry type="library" exported="" name="DBFlow-Compiler-2.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="answers-1.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="retrofit-1.9.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="DBFlow-Core-2.2.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="auto-common-0.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="antlr-runtime-3.5.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="butterknife-6.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="instabugsupport-1.8-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" exported="" name="fontawesome-typeface-4.4.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="adapters-1.0-rc1" level="project" />
|
||||
<orderEntry type="library" exported="" name="okhttp-urlconnection-2.3.0" level="project" />
|
||||
|
|
|
|||
22
Habitica/res/layout/levelup_dialog.xml
Normal file
22
Habitica/res/layout/levelup_dialog.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/levelupDetail"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/levelup_health"
|
||||
android:id="@+id/textView11" />
|
||||
</LinearLayout>
|
||||
|
|
@ -157,4 +157,9 @@
|
|||
<string name="gryphon">Gryphon</string>
|
||||
|
||||
<string name="facebook_app_id">128307497299777</string>
|
||||
<string name="levelup_header">You gained a level!</string>
|
||||
<string name="levelup_detail">By accomplishing your real-life goals, you\'ve grown to Level %1$d!</string>
|
||||
<string name="levelup_health">You have been fully healed!</string>
|
||||
<string name="levelup_button">Huzzah!</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
|
|
@ -13,13 +15,16 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.github.clans.fab.FloatingActionMenu;
|
||||
import com.habitrpg.android.habitica.callbacks.HabitRPGUserCallback;
|
||||
import com.habitrpg.android.habitica.callbacks.TaskCreationCallback;
|
||||
import com.habitrpg.android.habitica.callbacks.TaskScoringCallback;
|
||||
import com.habitrpg.android.habitica.callbacks.TaskUpdateCallback;
|
||||
import com.habitrpg.android.habitica.databinding.ValueBarBinding;
|
||||
import com.habitrpg.android.habitica.events.BuyRewardTappedEvent;
|
||||
import com.habitrpg.android.habitica.events.HabitScoreEvent;
|
||||
import com.habitrpg.android.habitica.events.TaskCheckedEvent;
|
||||
|
|
@ -32,12 +37,14 @@ import com.habitrpg.android.habitica.events.commands.CreateTagCommand;
|
|||
import com.habitrpg.android.habitica.events.commands.FilterTasksByTagsCommand;
|
||||
import com.habitrpg.android.habitica.helpers.TagsHelper;
|
||||
import com.habitrpg.android.habitica.prefs.PrefsActivity;
|
||||
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
|
||||
import com.habitrpg.android.habitica.ui.EditTextDrawer;
|
||||
import com.habitrpg.android.habitica.ui.MainDrawerBuilder;
|
||||
import com.habitrpg.android.habitica.ui.adapter.HabitItemRecyclerViewAdapter;
|
||||
import com.habitrpg.android.habitica.ui.adapter.IReceiveNewEntries;
|
||||
import com.habitrpg.android.habitica.ui.fragments.TaskRecyclerViewFragment;
|
||||
import com.habitrpg.android.habitica.ui.helpers.Debounce;
|
||||
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Tag;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirection;
|
||||
|
|
@ -59,6 +66,8 @@ import com.raizlabs.android.dbflow.sql.language.Select;
|
|||
import com.raizlabs.android.dbflow.structure.BaseModel;
|
||||
import com.raizlabs.android.dbflow.structure.Model;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -337,12 +346,12 @@ public class MainActivity extends AvatarActivityBase implements HabitRPGUserCall
|
|||
//endregion Events
|
||||
|
||||
private void notifyUser(double xp, double hp, double gold,
|
||||
double lvl, double delta) {
|
||||
int lvl, double delta) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
SnackbarDisplayType displayType = SnackbarDisplayType.NORMAL;
|
||||
if (lvl > User.getStats().getLvl()) {
|
||||
message.append(getString(R.string.lvlup));
|
||||
//If user lvl up, we need to fetch again the data from the server...
|
||||
displayLevelUpDialog(lvl);
|
||||
|
||||
this.mAPIHelper.retrieveUser(new HabitRPGUserCallback(this));
|
||||
User.getStats().setLvl((int) lvl);
|
||||
showSnackbar(message.toString());
|
||||
|
|
@ -562,6 +571,7 @@ public class MainActivity extends AvatarActivityBase implements HabitRPGUserCall
|
|||
showSnackbar(data.get_tmp().getDrop().getDialog(), SnackbarDisplayType.DROP);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -695,4 +705,28 @@ public class MainActivity extends AvatarActivityBase implements HabitRPGUserCall
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
private void displayLevelUpDialog(int level) {
|
||||
if (User.getPreferences().getSuppressModals().getLevelUp()) {
|
||||
return;
|
||||
}
|
||||
MaterialDialog dialog = new MaterialDialog.Builder(this)
|
||||
.title(R.string.levelup_header)
|
||||
.customView(R.layout.levelup_dialog, true)
|
||||
.positiveText(R.string.levelup_button)
|
||||
.positiveColorRes(R.color.brand_100)
|
||||
.build();
|
||||
|
||||
View customView = dialog.getCustomView();
|
||||
if (customView != null) {
|
||||
TextView detailView = (TextView)customView.findViewById(R.id.levelupDetail);
|
||||
detailView.setText(this.getString(R.string.levelup_detail, level));
|
||||
|
||||
ImageView avatarView = (ImageView)customView.findViewById(R.id.avatarView);
|
||||
UserPicture userPicture = new UserPicture(User, this, false, false, false);
|
||||
userPicture.setPictureOn(avatarView);
|
||||
}
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,12 @@ public class Preferences extends BaseModel {
|
|||
foreignColumnName = "userId")})
|
||||
public Hair hair;
|
||||
|
||||
@Column
|
||||
@ForeignKey(references = {@ForeignKeyReference(columnName = "suppressedModals_user_id",
|
||||
columnType = String.class,
|
||||
foreignColumnName = "userId")})
|
||||
public SuppressedModals suppressModals;
|
||||
|
||||
public Preferences() {
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +195,14 @@ public class Preferences extends BaseModel {
|
|||
this.hair = hair;
|
||||
}
|
||||
|
||||
public SuppressedModals getSuppressModals() {
|
||||
return suppressModals;
|
||||
}
|
||||
|
||||
public void setSuppressModals(SuppressedModals suppressModals) {
|
||||
this.suppressModals = suppressModals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
hair.userId = userId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.magicmicky.habitrpgwrapper.lib.models;
|
||||
|
||||
import com.habitrpg.android.habitica.HabitDatabase;
|
||||
import com.raizlabs.android.dbflow.annotation.Column;
|
||||
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
|
||||
import com.raizlabs.android.dbflow.annotation.Table;
|
||||
import com.raizlabs.android.dbflow.structure.BaseModel;
|
||||
|
||||
/**
|
||||
* Created by viirus on 15/11/15.
|
||||
*/
|
||||
@Table(databaseName = HabitDatabase.NAME)
|
||||
public class SuppressedModals extends BaseModel {
|
||||
|
||||
@Column
|
||||
@PrimaryKey
|
||||
public String userId;
|
||||
|
||||
private Boolean streak;
|
||||
private Boolean raisePet;
|
||||
private Boolean hatchPet;
|
||||
private Boolean levelUp;
|
||||
|
||||
public Boolean getStreak() {return streak; }
|
||||
public Boolean getRaisePet() {return raisePet; }
|
||||
public Boolean getHatchPet() {return hatchPet; }
|
||||
public Boolean getLevelUp() {return levelUp; }
|
||||
|
||||
public void setStreak(Boolean streak) {this.streak = streak; }
|
||||
public void setRaisePet(Boolean raisePet) {this.raisePet = raisePet; }
|
||||
public void setHatchPet(Boolean hatchPet) {this.hatchPet = hatchPet; }
|
||||
public void setLevelUp(Boolean levelUp) {this.levelUp = levelUp; }
|
||||
}
|
||||
Loading…
Reference in a new issue