mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
display stats
This commit is contained in:
parent
120da990b0
commit
afb173c61f
22 changed files with 760 additions and 300 deletions
6
Habitica/res/drawable/layout_top_rounded_bg.xml
Normal file
6
Habitica/res/drawable/layout_top_rounded_bg.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white" />
|
||||
<corners android:topLeftRadius="@dimen/rounded_button_radius" android:topRightRadius="@dimen/rounded_button_radius" />
|
||||
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||
</shape>
|
||||
|
|
@ -1,16 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
<WebView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/newsWebview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarThumbVertical="@color/md_grey_500"
|
||||
|
||||
android:scrollbars="vertical">
|
||||
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/news_webview"/>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
</WebView>
|
||||
137
Habitica/res/layout/fragment_stats.xml
Normal file
137
Habitica/res/layout/fragment_stats.xml
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:scrollbarSize="3dp"
|
||||
android:scrollbarThumbVertical="@color/md_grey_500"
|
||||
android:scrollbars="vertical"
|
||||
android:background="@color/white">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="20dp">
|
||||
<com.habitrpg.android.habitica.ui.views.StatsView
|
||||
android:id="@+id/strengthStatsView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:statsTitle="@string/strength"
|
||||
app:titleBackgroundColor="@color/red_50"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
<com.habitrpg.android.habitica.ui.views.StatsView
|
||||
android:id="@+id/intelligenceStatsView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:statsTitle="@string/intelligence"
|
||||
app:titleBackgroundColor="@color/blue_50"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
<com.habitrpg.android.habitica.ui.views.StatsView
|
||||
android:id="@+id/constitutionStatsView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:statsTitle="@string/constitution"
|
||||
app:titleBackgroundColor="@color/yellow_10"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
<com.habitrpg.android.habitica.ui.views.StatsView
|
||||
android:id="@+id/perceptionStatsView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:statsTitle="@string/perception"
|
||||
app:titleBackgroundColor="@color/brand_300"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
<Switch
|
||||
android:id="@+id/switch1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/auto_allocate_points"
|
||||
android:layout_marginLeft="@dimen/content_border"
|
||||
android:layout_marginRight="@dimen/content_border"/>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/gray_600"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_border"
|
||||
android:layout_marginRight="@dimen/content_border"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stat_guide"
|
||||
style="@style/Subheader2"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/character_build"
|
||||
style="@style/Subheader3"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:textColor="@color/gray_10"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/character_build_description"
|
||||
android:textColor="@color/gray_100"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/strength"
|
||||
style="@style/Subheader3"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:textColor="@color/red_10"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/strength_description"
|
||||
android:textColor="@color/gray_100"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/intelligence"
|
||||
style="@style/Subheader3"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:textColor="@color/blue_10"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/intelligence_description"
|
||||
android:textColor="@color/gray_100"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/constitution"
|
||||
style="@style/Subheader3"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:textColor="@color/yellow_10"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/constitution_description"
|
||||
android:textColor="@color/gray_100"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/perception"
|
||||
style="@style/Subheader3"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:textColor="@color/brand_300"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/perception_description"
|
||||
android:textColor="@color/gray_100"
|
||||
android:layout_marginBottom="28dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
129
Habitica/res/layout/stats_view.xml
Normal file
129
Habitica/res/layout/stats_view.xml
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/layout_rounded_bg_gray_700"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp">
|
||||
<LinearLayout
|
||||
android:id="@+id/titleWrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="43dp">
|
||||
<TextView
|
||||
android:id="@id/titleTextView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
tools:text="Strength"
|
||||
android:gravity="center_vertical"
|
||||
style="@style/Headline"
|
||||
android:textColor="@color/white"
|
||||
android:layout_marginLeft="12dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/totalValueTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
tools:text="130"
|
||||
android:gravity="center_vertical"
|
||||
style="@style/Headline"
|
||||
android:textColor="@color/white"
|
||||
android:layout_marginRight="12dp"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="61dp">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/levelValueTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Title1"
|
||||
tools:text="20"
|
||||
android:gravity="center_horizontal"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/level"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_300"
|
||||
android:gravity="center_horizontal"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/equipmentValueTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Title1"
|
||||
tools:text="20"
|
||||
android:gravity="center_horizontal"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sidebar.equipment"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_300"
|
||||
android:gravity="center_horizontal"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/buffValueTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Title1"
|
||||
tools:text="20"
|
||||
android:gravity="center_horizontal"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/buffs"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_300"
|
||||
android:gravity="center_horizontal"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/allocatedWrapper"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/allocatedValueTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Title1"
|
||||
tools:text="20"
|
||||
android:gravity="center_horizontal"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/allocated"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_300"
|
||||
android:gravity="center_horizontal"/>
|
||||
</LinearLayout>
|
||||
<ImageButton
|
||||
android:id="@+id/allocateButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
@ -48,4 +48,8 @@
|
|||
<attr name="iconBgColor" format="color" />
|
||||
<attr name="hintStyle" format="reference" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="StatsView">
|
||||
<attr name="titleBackgroundColor" format="color" />
|
||||
<attr name="statsTitle" format="string" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@
|
|||
<dimen name="setup_customization_size">56dp</dimen>
|
||||
<dimen name="outer_inset">16dp</dimen>
|
||||
<dimen name="rounded_button_radius">6dp</dimen>
|
||||
<dimen name="content_border">21dp</dimen>
|
||||
<dimen name="content_border">18dp</dimen>
|
||||
<dimen name="content_section_spacing">21dp</dimen>
|
||||
<dimen name="header_spacing">6dp</dimen>
|
||||
<dimen name="shopitem_width">84dp</dimen>
|
||||
|
|
|
|||
|
|
@ -17,4 +17,5 @@
|
|||
<string name="sidebar.settings">Settings</string>
|
||||
<string name="sidebar.about">About</string>
|
||||
<string name="sidebar_shops">Shops</string>
|
||||
<string name="sidebar_stats">Stats</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -687,4 +687,18 @@
|
|||
<string name="change_login_name">Change Login Name</string>
|
||||
<string name="change">Change</string>
|
||||
<string name="character_level">Character Level</string>
|
||||
<string name="auto_allocate_points">Auto Allocate Points</string>
|
||||
<string name="stat_guide">Stat Guide</string>
|
||||
<string name="character_build">Character Build</string>
|
||||
<string name="character_build_description">Each level earns you one point to assign to an attribute of your choice. You can do so manually, or let the game decide for you using one of the Automatic Allocation options.</string>
|
||||
<string name="strength">Strength</string>
|
||||
<string name="strength_description">Increases the bonus of critical hits and makes them more likely when scoring a task. Also increases damage dealt to bosses.</string>
|
||||
<string name="intelligence">Intelligence</string>
|
||||
<string name="intelligence_description">Increases EXP earned from completing tasks. Also increases your mana cap and how fast mana regenerates over time.</string>
|
||||
<string name="constitution">Constitution</string>
|
||||
<string name="constitution_description">Decreases the amount of damage taken from your tasks. Does not decrease the damage received from bosses.</string>
|
||||
<string name="perception">Perception</string>
|
||||
<string name="perception_description">Increases the likelihood of finding drops when completing Tasks, the daily drop-cap, Streak Bonuses, and the amount of gold awarded for Tasks.</string>
|
||||
<string name="buffs">Buffs</string>
|
||||
<string name="allocated">Allocated</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import com.habitrpg.android.habitica.ui.adapter.tasks.RewardsRecyclerViewAdapter
|
|||
import com.habitrpg.android.habitica.ui.adapter.tasks.TodosRecyclerViewAdapter;
|
||||
import com.habitrpg.android.habitica.ui.fragments.GemsPurchaseFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.NewsFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.StatsFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.SubscriptionFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.faq.FAQDetailFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.faq.FAQOverviewFragment;
|
||||
|
|
@ -287,4 +288,6 @@ public interface AppComponent {
|
|||
void inject(@NotNull ProfilePreferencesFragment profilePreferencesFragment);
|
||||
|
||||
void inject(@NotNull APIPreferenceFragment apiPreferenceFragment);
|
||||
|
||||
void inject(@NotNull StatsFragment statsFragment);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.models.Avatar;
|
||||
import com.habitrpg.android.habitica.models.inventory.Equipment;
|
||||
import com.habitrpg.android.habitica.models.members.Member;
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ public class UserStatComputer {
|
|||
public String stats;
|
||||
}
|
||||
|
||||
public List<StatsRow> computeClassBonus (List<Equipment> equipmentList, Member user) {
|
||||
public List<StatsRow> computeClassBonus (List<Equipment> equipmentList, Avatar user) {
|
||||
List<StatsRow> skillRows = new ArrayList<>();
|
||||
|
||||
float strAttributes = 0;
|
||||
|
|
@ -45,10 +46,10 @@ public class UserStatComputer {
|
|||
|
||||
// Summarize stats and fill equipment table
|
||||
for (Equipment i : equipmentList) {
|
||||
int str_ = (int) i.getStr();
|
||||
int int_ = (int) i.get_int();
|
||||
int con_ = (int) i.getCon();
|
||||
int per_ = (int) i.getPer();
|
||||
int str_ = i.getStr();
|
||||
int int_ = i.get_int();
|
||||
int con_ = i.getCon();
|
||||
int per_ = i.getPer();
|
||||
|
||||
strAttributes += str_;
|
||||
intAttributes += int_;
|
||||
|
|
@ -98,27 +99,27 @@ public class UserStatComputer {
|
|||
|
||||
if (!userClassMatchesGearClass && !userClassMatchesGearSpecialClass) classBonus = 0;
|
||||
|
||||
if (itemClass == null || itemClass.isEmpty()) {
|
||||
if (itemClass == null || itemClass.isEmpty() || itemClass.equals("special")) {
|
||||
itemClass = itemSpecialClass;
|
||||
}
|
||||
|
||||
if (itemClass != null) {
|
||||
switch (itemClass) {
|
||||
case "rogue":
|
||||
strClassBonus = str_ * classBonus;
|
||||
perClassBonus = per_ * classBonus;
|
||||
strClassBonus += str_ * classBonus;
|
||||
perClassBonus += per_ * classBonus;
|
||||
break;
|
||||
case "healer":
|
||||
conClassBonus = con_ * classBonus;
|
||||
intClassBonus = int_ * classBonus;
|
||||
conClassBonus += con_ * classBonus;
|
||||
intClassBonus += int_ * classBonus;
|
||||
break;
|
||||
case "warrior":
|
||||
strClassBonus = str_ * classBonus;
|
||||
conClassBonus = con_ * classBonus;
|
||||
strClassBonus += str_ * classBonus;
|
||||
conClassBonus += con_ * classBonus;
|
||||
break;
|
||||
case "wizard":
|
||||
intClassBonus = int_ * classBonus;
|
||||
perClassBonus = per_ * classBonus;
|
||||
intClassBonus += int_ * classBonus;
|
||||
perClassBonus += per_ * classBonus;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class AvatarWithBarsViewModel {
|
|||
@OnClick(R.id.avatarView)
|
||||
public void avatarViewClicked() {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_AVATAR;
|
||||
event.identifier = MainDrawerBuilder.INSTANCE.getSIDEBAR_AVATAR();
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import javax.inject.Named
|
|||
class FixCharacterValuesActivity: BaseActivity() {
|
||||
|
||||
@Inject
|
||||
public lateinit var repository: UserRepository
|
||||
lateinit var repository: UserRepository
|
||||
|
||||
@field:[Inject Named(AppModule.NAMED_USER_ID)]
|
||||
lateinit var userId: String
|
||||
|
|
|
|||
|
|
@ -258,8 +258,8 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
setupToolbar(toolbar);
|
||||
|
||||
avatarInHeader = new AvatarWithBarsViewModel(this, avatar_with_bars);
|
||||
accountHeader = MainDrawerBuilder.CreateDefaultAccountHeader(this).build();
|
||||
drawer = MainDrawerBuilder.CreateDefaultBuilderSettings(this, sharedPreferences, toolbar, accountHeader)
|
||||
accountHeader = MainDrawerBuilder.INSTANCE.CreateDefaultAccountHeader(this).build();
|
||||
drawer = MainDrawerBuilder.INSTANCE.CreateDefaultBuilderSettings(this, sharedPreferences, toolbar, accountHeader)
|
||||
.build();
|
||||
drawer.setSelectionAtPosition(1, false);
|
||||
sideAvatarView = new AvatarView(this, true, false, false);
|
||||
|
|
@ -404,7 +404,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
if (numberOfUnreadPms <= 0) {
|
||||
newInboxItem = new PrimaryDrawerItem()
|
||||
.withName(this.getString(R.string.sidebar_inbox))
|
||||
.withIdentifier(MainDrawerBuilder.SIDEBAR_INBOX);
|
||||
.withIdentifier(MainDrawerBuilder.INSTANCE.getSIDEBAR_INBOX());
|
||||
} else {
|
||||
String numberOfUnreadPmsLabel = String.valueOf(numberOfUnreadPms);
|
||||
BadgeStyle badgeStyle = new BadgeStyle()
|
||||
|
|
@ -413,13 +413,13 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
|
||||
newInboxItem = new PrimaryDrawerItem()
|
||||
.withName(this.getString(R.string.sidebar_inbox))
|
||||
.withIdentifier(MainDrawerBuilder.SIDEBAR_INBOX)
|
||||
.withIdentifier(MainDrawerBuilder.INSTANCE.getSIDEBAR_INBOX())
|
||||
.withBadge(numberOfUnreadPmsLabel)
|
||||
.withBadgeStyle(badgeStyle);
|
||||
}
|
||||
|
||||
if (this.drawer != null) {
|
||||
this.drawer.updateItemAtPosition(newInboxItem, this.drawer.getPosition(MainDrawerBuilder.SIDEBAR_INBOX));
|
||||
this.drawer.updateItemAtPosition(newInboxItem, this.drawer.getPosition(MainDrawerBuilder.INSTANCE.getSIDEBAR_INBOX()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,10 +467,10 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
}
|
||||
|
||||
if (drawer != null) {
|
||||
IDrawerItem item = drawer.getDrawerItem(MainDrawerBuilder.SIDEBAR_SKILLS);
|
||||
IDrawerItem item = drawer.getDrawerItem(MainDrawerBuilder.INSTANCE.getSIDEBAR_SKILLS());
|
||||
if (!user.hasClass() && !hasSpecialItems) {
|
||||
if (item != null) {
|
||||
drawer.removeItem(MainDrawerBuilder.SIDEBAR_SKILLS);
|
||||
drawer.removeItem(MainDrawerBuilder.INSTANCE.getSIDEBAR_SKILLS());
|
||||
}
|
||||
} else {
|
||||
IDrawerItem newItem;
|
||||
|
|
@ -479,11 +479,11 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
.withName(this.getString(R.string.sidebar_skills))
|
||||
.withEnabled(false)
|
||||
.withBadge(this.getString(R.string.unlock_lvl_11))
|
||||
.withIdentifier(MainDrawerBuilder.SIDEBAR_SKILLS);
|
||||
.withIdentifier(MainDrawerBuilder.INSTANCE.getSIDEBAR_SKILLS());
|
||||
} else {
|
||||
newItem = new PrimaryDrawerItem()
|
||||
.withName(this.getString(R.string.sidebar_skills))
|
||||
.withIdentifier(MainDrawerBuilder.SIDEBAR_SKILLS);
|
||||
.withIdentifier(MainDrawerBuilder.INSTANCE.getSIDEBAR_SKILLS());
|
||||
}
|
||||
if (item == null) {
|
||||
drawer.addItemAtPosition(newItem, 1);
|
||||
|
|
@ -610,7 +610,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
@Subscribe
|
||||
public void openGemPurchaseFragment(@Nullable OpenGemPurchaseFragmentCommand cmd) {
|
||||
if (drawer != null) {
|
||||
drawer.setSelection(MainDrawerBuilder.SIDEBAR_PURCHASE);
|
||||
drawer.setSelection(MainDrawerBuilder.INSTANCE.getSIDEBAR_PURCHASE());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
.setPositiveButton(R.string.purchase_button, (dialog1, which) -> {
|
||||
if (customization.getPrice() > gemBalance) {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_PURCHASE;
|
||||
event.identifier = MainDrawerBuilder.INSTANCE.getSIDEBAR_PURCHASE();
|
||||
EventBus.getDefault().post(event);
|
||||
return;
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ public class CustomizationRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||
.setPositiveButton(R.string.purchase_button, (dialog1, which) -> {
|
||||
if (set.price > gemBalance) {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_PURCHASE;
|
||||
event.identifier = MainDrawerBuilder.INSTANCE.getSIDEBAR_PURCHASE();
|
||||
EventBus.getDefault().post(event);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ public abstract class BaseMainFragment extends BaseFragment {
|
|||
@Inject
|
||||
public ApiClient apiClient;
|
||||
@Inject
|
||||
protected
|
||||
UserRepository userRepository;
|
||||
protected UserRepository userRepository;
|
||||
@Nullable
|
||||
public MainActivity activity;
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class NewsFragment extends BaseMainFragment {
|
||||
|
||||
@BindView(R.id.news_webview)
|
||||
WebView newsWebview;
|
||||
private View view;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view == null)
|
||||
view = inflater.inflate(R.layout.fragment_news, container, false);
|
||||
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
String address = BuildConfig.DEBUG ? BuildConfig.BASE_URL : getContext().getString(R.string.base_url);
|
||||
|
||||
newsWebview.loadUrl(address + "/static/new-stuff");
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectFragment(AppComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String customTitle() {
|
||||
if (!isAdded()) {
|
||||
return "";
|
||||
}
|
||||
return getString(R.string.sidebar_news);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
|
||||
import kotlinx.android.synthetic.main.fragment_news.*
|
||||
|
||||
class NewsFragment : BaseMainFragment() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
return inflater?.inflate(R.layout.fragment_news, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val address = if (BuildConfig.DEBUG) BuildConfig.BASE_URL else context.getString(R.string.base_url)
|
||||
newsWebview.loadUrl(address + "/static/new-stuff")
|
||||
}
|
||||
|
||||
override fun injectFragment(component: AppComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
||||
|
||||
override fun customTitle(): String {
|
||||
return if (!isAdded) {
|
||||
""
|
||||
} else getString(R.string.sidebar_news)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.data.InventoryRepository
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.UserStatComputer
|
||||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import kotlinx.android.synthetic.main.fragment_stats.*
|
||||
import rx.functions.Action1
|
||||
import java.util.ArrayList
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
class StatsFragment: BaseMainFragment() {
|
||||
|
||||
@field:[Inject Named(AppModule.NAMED_USER_ID)]
|
||||
lateinit var userId: String
|
||||
|
||||
@Inject
|
||||
lateinit var inventoryRepository: InventoryRepository
|
||||
|
||||
private var totalStrength = 0
|
||||
set(value) {
|
||||
field = value
|
||||
strengthStatsView.totalValue = value
|
||||
}
|
||||
private var totalIntelligence = 0
|
||||
set(value) {
|
||||
field = value
|
||||
intelligenceStatsView.totalValue = value
|
||||
}
|
||||
private var totalConstitution = 0
|
||||
set(value) {
|
||||
field = value
|
||||
constitutionStatsView.totalValue = value
|
||||
}
|
||||
private var totalPerception = 0
|
||||
set(value) {
|
||||
field = value
|
||||
perceptionStatsView.totalValue = value
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
return inflater?.inflate(R.layout.fragment_stats, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
compositeSubscription.add(userRepository.getUser(userId).subscribe(Action1 {
|
||||
user = it
|
||||
updateStats()
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
override fun injectFragment(component: AppComponent) {
|
||||
component.inject(this)
|
||||
}
|
||||
|
||||
private fun updateStats() {
|
||||
val currentUser = user ?: return
|
||||
val levelStat = Math.min(currentUser.stats.getLvl()!! / 2.0f, 50f).toInt()
|
||||
|
||||
totalStrength = levelStat
|
||||
totalIntelligence = levelStat
|
||||
totalConstitution = levelStat
|
||||
totalPerception = levelStat
|
||||
|
||||
strengthStatsView.levelValue = levelStat
|
||||
intelligenceStatsView.levelValue = levelStat
|
||||
constitutionStatsView.levelValue = levelStat
|
||||
perceptionStatsView.levelValue = levelStat
|
||||
|
||||
totalStrength += currentUser.stats?.buffs?.str?.toInt() ?: 0
|
||||
totalIntelligence += currentUser.stats?.buffs?._int?.toInt() ?: 0
|
||||
totalConstitution += currentUser.stats?.buffs?.con?.toInt() ?: 0
|
||||
totalPerception += currentUser.stats?.buffs?.per?.toInt() ?: 0
|
||||
strengthStatsView.buffValue = currentUser.stats?.buffs?.str?.toInt() ?: 0
|
||||
intelligenceStatsView.buffValue = currentUser.stats?.buffs?._int?.toInt() ?: 0
|
||||
constitutionStatsView.buffValue = currentUser.stats?.buffs?.con?.toInt() ?: 0
|
||||
perceptionStatsView.buffValue = currentUser.stats?.buffs?.per?.toInt() ?: 0
|
||||
|
||||
totalStrength += currentUser.stats?.str?.toInt() ?: 0
|
||||
totalIntelligence += currentUser.stats?._int?.toInt() ?: 0
|
||||
totalConstitution += currentUser.stats?.con?.toInt() ?: 0
|
||||
totalPerception += currentUser.stats?.per?.toInt() ?: 0
|
||||
strengthStatsView.allocatedValue = currentUser.stats?.str?.toInt() ?: 0
|
||||
intelligenceStatsView.allocatedValue = currentUser.stats?._int?.toInt() ?: 0
|
||||
constitutionStatsView.allocatedValue = currentUser.stats?.con?.toInt() ?: 0
|
||||
perceptionStatsView.allocatedValue = currentUser.stats?.per?.toInt() ?: 0
|
||||
|
||||
val outfit = currentUser.items.gear.equipped
|
||||
val outfitList = ArrayList<String>()
|
||||
outfitList.add(outfit.armor)
|
||||
outfitList.add(outfit.back)
|
||||
outfitList.add(outfit.body)
|
||||
outfitList.add(outfit.eyeWear)
|
||||
outfitList.add(outfit.head)
|
||||
outfitList.add(outfit.headAccessory)
|
||||
outfitList.add(outfit.shield)
|
||||
outfitList.add(outfit.weapon)
|
||||
|
||||
inventoryRepository.getItems(outfitList).subscribe(Action1 {
|
||||
val userStatComputer = UserStatComputer()
|
||||
val statsRows = userStatComputer.computeClassBonus(it, user)
|
||||
|
||||
var strength = 0
|
||||
var intelligence = 0
|
||||
var constitution = 0
|
||||
var perception = 0
|
||||
|
||||
for (row in statsRows) {
|
||||
if (row.javaClass == UserStatComputer.AttributeRow::class.java) {
|
||||
val attributeRow = row as UserStatComputer.AttributeRow
|
||||
strength += attributeRow.strVal.toInt()
|
||||
intelligence += attributeRow.intVal.toInt()
|
||||
constitution += attributeRow.conVal.toInt()
|
||||
perception += attributeRow.perVal.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
totalStrength += strength
|
||||
totalIntelligence += intelligence
|
||||
totalConstitution += constitution
|
||||
totalPerception += perception
|
||||
strengthStatsView.equipmentValue += strength
|
||||
intelligenceStatsView.equipmentValue += intelligence
|
||||
constitutionStatsView.equipmentValue += constitution
|
||||
perceptionStatsView.equipmentValue += perception
|
||||
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
|
||||
override fun customTitle(): String {
|
||||
return if (!isAdded) {
|
||||
""
|
||||
} else getString(R.string.sidebar_stats)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ public class ItemRecyclerFragment extends BaseFragment {
|
|||
.flatMap(quest -> inventoryRepository.inviteToQuest(quest))
|
||||
.subscribe(group -> {
|
||||
OpenMenuItemCommand event1 = new OpenMenuItemCommand();
|
||||
event1.identifier = MainDrawerBuilder.SIDEBAR_PARTY;
|
||||
event1.identifier = MainDrawerBuilder.INSTANCE.getSIDEBAR_PARTY();
|
||||
EventBus.getDefault().post(event1);
|
||||
}, RxErrorHandler.handleEmptyError()));
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ public class ItemRecyclerFragment extends BaseFragment {
|
|||
|
||||
private void openMarket() {
|
||||
OpenMenuItemCommand command = new OpenMenuItemCommand();
|
||||
command.identifier = MainDrawerBuilder.SIDEBAR_SHOPS;
|
||||
command.identifier = MainDrawerBuilder.INSTANCE.getSIDEBAR_SHOPS();
|
||||
EventBus.getDefault().post(command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,210 +0,0 @@
|
|||
package com.habitrpg.android.habitica.ui.menu;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.ui.activities.AboutActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.GemPurchaseActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.PrefsActivity;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.NewsFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.faq.FAQOverviewFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarOverviewFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.equipment.EquipmentOverviewFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemsFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.shops.ShopsFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.stable.StableFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.skills.SkillsFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.GuildsOverviewFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.InboxFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.TavernFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengesOverviewFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.party.PartyFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.tasks.TasksFragment;
|
||||
import com.mikepenz.materialdrawer.AccountHeader;
|
||||
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
|
||||
import com.mikepenz.materialdrawer.DrawerBuilder;
|
||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.habitrpg.android.habitica.ui.activities.MainActivity.GEM_PURCHASE_REQUEST;
|
||||
|
||||
public class MainDrawerBuilder {
|
||||
|
||||
// Change the identificationIDs to the position IDs so that its easier to set the selected entry
|
||||
public static final int SIDEBAR_TASKS = 0;
|
||||
public static final int SIDEBAR_SKILLS = 1;
|
||||
public static final int SIDEBAR_INBOX = 2;
|
||||
public static final int SIDEBAR_TAVERN = 3;
|
||||
public static final int SIDEBAR_PARTY = 4;
|
||||
public static final int SIDEBAR_GUILDS = 5;
|
||||
public static final int SIDEBAR_CHALLENGES = 6;
|
||||
public static final int SIDEBAR_SHOPS = 7;
|
||||
public static final int SIDEBAR_AVATAR = 8;
|
||||
public static final int SIDEBAR_EQUIPMENT = 9;
|
||||
public static final int SIDEBAR_ITEMS = 10;
|
||||
public static final int SIDEBAR_STABLE = 11;
|
||||
public static final int SIDEBAR_PURCHASE = 12;
|
||||
public static final int SIDEBAR_NEWS = 13;
|
||||
public static final int SIDEBAR_SETTINGS = 14;
|
||||
public static final int SIDEBAR_HELP = 15;
|
||||
public static final int SIDEBAR_ABOUT = 16;
|
||||
|
||||
public static AccountHeaderBuilder CreateDefaultAccountHeader(final Activity activity) {
|
||||
return new AccountHeaderBuilder()
|
||||
.withActivity(activity)
|
||||
.withHeaderBackground(R.drawable.sidebar_background)
|
||||
.addProfiles(
|
||||
new ProfileDrawerItem()
|
||||
)
|
||||
.withOnAccountHeaderListener((view, profile, currentProfile) -> false)
|
||||
.withSelectionListEnabledForSingleProfile(false);
|
||||
}
|
||||
|
||||
|
||||
public static DrawerBuilder CreateDefaultBuilderSettings(final MainActivity activity, SharedPreferences sharedPreferences, Toolbar toolbar, final AccountHeader accountHeader) {
|
||||
DrawerBuilder builder = new DrawerBuilder()
|
||||
.withActivity(activity)
|
||||
.withFullscreen(true);
|
||||
|
||||
if (toolbar != null) {
|
||||
builder.withToolbar(toolbar);
|
||||
}
|
||||
|
||||
builder.withHeaderDivider(false)
|
||||
.withAccountHeader(accountHeader)
|
||||
.addDrawerItems(
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tasks)).withIdentifier(SIDEBAR_TASKS),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_skills)).withIdentifier(SIDEBAR_SKILLS),
|
||||
|
||||
new SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_social).toUpperCase(Locale.getDefault())),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_inbox)).withIdentifier(SIDEBAR_INBOX),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tavern)).withIdentifier(SIDEBAR_TAVERN),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_party)).withIdentifier(SIDEBAR_PARTY),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_guilds)).withIdentifier(SIDEBAR_GUILDS),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_challenges)).withIdentifier(SIDEBAR_CHALLENGES),
|
||||
|
||||
new SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_inventory).toUpperCase(Locale.getDefault())),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_shops)).withIdentifier(SIDEBAR_SHOPS),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_avatar)).withIdentifier(SIDEBAR_AVATAR),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_equipment)).withIdentifier(SIDEBAR_EQUIPMENT),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_items)).withIdentifier(SIDEBAR_ITEMS),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_stable)).withIdentifier(SIDEBAR_STABLE),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_purchaseGems)).withIdentifier(SIDEBAR_PURCHASE),
|
||||
|
||||
new SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_about).toUpperCase(Locale.getDefault())),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_news)).withIdentifier(SIDEBAR_NEWS).withSelectable(false),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_settings)).withIdentifier(SIDEBAR_SETTINGS).withSelectable(false),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_help)).withIdentifier(SIDEBAR_HELP),
|
||||
new PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_about)).withIdentifier(SIDEBAR_ABOUT).withSelectable(false)
|
||||
|
||||
)
|
||||
.withStickyFooterDivider(false)
|
||||
.withOnDrawerItemClickListener((view, position, drawerItem) -> {
|
||||
BaseMainFragment fragment = null;
|
||||
Class newActivityClass = null;
|
||||
|
||||
int identifier = (int) drawerItem.getIdentifier();
|
||||
switch (identifier) {
|
||||
case SIDEBAR_TASKS: {
|
||||
fragment = new TasksFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_SKILLS: {
|
||||
fragment = new SkillsFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_INBOX: {
|
||||
fragment = new InboxFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_PARTY: {
|
||||
fragment = new PartyFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_GUILDS: {
|
||||
fragment = new GuildsOverviewFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_TAVERN: {
|
||||
fragment = new TavernFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_CHALLENGES: {
|
||||
fragment = new ChallengesOverviewFragment();
|
||||
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_SHOPS: {
|
||||
fragment = new ShopsFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_AVATAR: {
|
||||
fragment = new AvatarOverviewFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_EQUIPMENT: {
|
||||
fragment = new EquipmentOverviewFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_ITEMS: {
|
||||
fragment = new ItemsFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_STABLE: {
|
||||
fragment = new StableFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_PURCHASE: {
|
||||
newActivityClass = GemPurchaseActivity.class;
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_NEWS: {
|
||||
fragment = new NewsFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_SETTINGS: {
|
||||
newActivityClass = PrefsActivity.class;
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_HELP: {
|
||||
fragment = new FAQOverviewFragment();
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_ABOUT: {
|
||||
newActivityClass = AboutActivity.class;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sharedPreferences.edit().putInt("lastActivePosition", position).apply();
|
||||
|
||||
if (fragment != null) {
|
||||
fragment.fragmentSidebarPosition = position;
|
||||
activity.displayFragment(fragment);
|
||||
return false;
|
||||
}
|
||||
if (newActivityClass != null) {
|
||||
Intent passUserId = new Intent(activity, newActivityClass);
|
||||
passUserId.putExtra("userId", activity.getUserID());
|
||||
if (identifier == SIDEBAR_PURCHASE) {
|
||||
activity.startActivityForResult(passUserId, GEM_PURCHASE_REQUEST);
|
||||
} else {
|
||||
activity.startActivity(passUserId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
package com.habitrpg.android.habitica.ui.menu
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.support.v7.widget.Toolbar
|
||||
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.ui.activities.AboutActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.BaseActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.GemPurchaseActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.PrefsActivity
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.NewsFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.faq.FAQOverviewFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.customization.AvatarOverviewFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.equipment.EquipmentOverviewFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.items.ItemsFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.shops.ShopsFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.inventory.stable.StableFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.skills.SkillsFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.GuildsOverviewFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.InboxFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.TavernFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengesOverviewFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.party.PartyFragment
|
||||
import com.habitrpg.android.habitica.ui.fragments.tasks.TasksFragment
|
||||
import com.mikepenz.materialdrawer.AccountHeader
|
||||
import com.mikepenz.materialdrawer.AccountHeaderBuilder
|
||||
import com.mikepenz.materialdrawer.DrawerBuilder
|
||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
|
||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity.GEM_PURCHASE_REQUEST
|
||||
import com.habitrpg.android.habitica.ui.fragments.StatsFragment
|
||||
|
||||
object MainDrawerBuilder {
|
||||
|
||||
// Change the identificationIDs to the position IDs so that its easier to set the selected entry
|
||||
val SIDEBAR_TASKS = 0
|
||||
val SIDEBAR_SKILLS = 1
|
||||
val SIDEBAR_STATS = 2
|
||||
val SIDEBAR_INBOX = 3
|
||||
val SIDEBAR_TAVERN = 4
|
||||
val SIDEBAR_PARTY = 5
|
||||
val SIDEBAR_GUILDS = 6
|
||||
val SIDEBAR_CHALLENGES = 7
|
||||
val SIDEBAR_SHOPS = 8
|
||||
val SIDEBAR_AVATAR = 9
|
||||
val SIDEBAR_EQUIPMENT = 10
|
||||
val SIDEBAR_ITEMS = 11
|
||||
val SIDEBAR_STABLE = 12
|
||||
val SIDEBAR_PURCHASE = 13
|
||||
val SIDEBAR_NEWS = 14
|
||||
val SIDEBAR_SETTINGS = 15
|
||||
val SIDEBAR_HELP = 16
|
||||
val SIDEBAR_ABOUT = 17
|
||||
|
||||
fun CreateDefaultAccountHeader(activity: Activity): AccountHeaderBuilder {
|
||||
return AccountHeaderBuilder()
|
||||
.withActivity(activity)
|
||||
.withHeaderBackground(R.drawable.sidebar_background)
|
||||
.addProfiles(
|
||||
ProfileDrawerItem()
|
||||
)
|
||||
.withOnAccountHeaderListener { view, profile, currentProfile -> false }
|
||||
.withSelectionListEnabledForSingleProfile(false)
|
||||
}
|
||||
|
||||
|
||||
fun CreateDefaultBuilderSettings(activity: MainActivity, sharedPreferences: SharedPreferences, toolbar: Toolbar?, accountHeader: AccountHeader): DrawerBuilder {
|
||||
val builder = DrawerBuilder()
|
||||
.withActivity(activity)
|
||||
.withFullscreen(true)
|
||||
|
||||
if (toolbar != null) {
|
||||
builder.withToolbar(toolbar)
|
||||
}
|
||||
|
||||
builder.withHeaderDivider(false)
|
||||
.withAccountHeader(accountHeader)
|
||||
.addDrawerItems(
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tasks)).withIdentifier(SIDEBAR_TASKS.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_skills)).withIdentifier(SIDEBAR_SKILLS.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_stats)).withIdentifier(SIDEBAR_STATS.toLong()),
|
||||
|
||||
SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_social).toUpperCase(Locale.getDefault())),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_inbox)).withIdentifier(SIDEBAR_INBOX.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_tavern)).withIdentifier(SIDEBAR_TAVERN.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_party)).withIdentifier(SIDEBAR_PARTY.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_guilds)).withIdentifier(SIDEBAR_GUILDS.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_challenges)).withIdentifier(SIDEBAR_CHALLENGES.toLong()),
|
||||
|
||||
SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_section_inventory).toUpperCase(Locale.getDefault())),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_shops)).withIdentifier(SIDEBAR_SHOPS.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_avatar)).withIdentifier(SIDEBAR_AVATAR.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_equipment)).withIdentifier(SIDEBAR_EQUIPMENT.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_items)).withIdentifier(SIDEBAR_ITEMS.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_stable)).withIdentifier(SIDEBAR_STABLE.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_purchaseGems)).withIdentifier(SIDEBAR_PURCHASE.toLong()),
|
||||
|
||||
SectionIconDrawerItem().withName(activity.getString(R.string.sidebar_about).toUpperCase(Locale.getDefault())),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_news)).withIdentifier(SIDEBAR_NEWS.toLong()).withSelectable(false),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_settings)).withIdentifier(SIDEBAR_SETTINGS.toLong()).withSelectable(false),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_help)).withIdentifier(SIDEBAR_HELP.toLong()),
|
||||
PrimaryDrawerItem().withName(activity.getString(R.string.sidebar_about)).withIdentifier(SIDEBAR_ABOUT.toLong()).withSelectable(false)
|
||||
)
|
||||
.withStickyFooterDivider(false)
|
||||
.withOnDrawerItemClickListener { view, position, drawerItem ->
|
||||
var fragment: BaseMainFragment? = null
|
||||
var newActivityClass: Class<*>? = null
|
||||
|
||||
val identifier = drawerItem.identifier.toInt()
|
||||
when (identifier) {
|
||||
SIDEBAR_TASKS -> {
|
||||
fragment = TasksFragment()
|
||||
}
|
||||
SIDEBAR_SKILLS -> {
|
||||
fragment = SkillsFragment()
|
||||
}
|
||||
SIDEBAR_STATS -> {
|
||||
fragment = StatsFragment()
|
||||
}
|
||||
SIDEBAR_INBOX -> {
|
||||
fragment = InboxFragment()
|
||||
}
|
||||
SIDEBAR_PARTY -> {
|
||||
fragment = PartyFragment()
|
||||
}
|
||||
SIDEBAR_GUILDS -> {
|
||||
fragment = GuildsOverviewFragment()
|
||||
}
|
||||
SIDEBAR_TAVERN -> {
|
||||
fragment = TavernFragment()
|
||||
}
|
||||
SIDEBAR_CHALLENGES -> {
|
||||
fragment = ChallengesOverviewFragment()
|
||||
}
|
||||
SIDEBAR_SHOPS -> {
|
||||
fragment = ShopsFragment()
|
||||
}
|
||||
SIDEBAR_AVATAR -> {
|
||||
fragment = AvatarOverviewFragment()
|
||||
}
|
||||
SIDEBAR_EQUIPMENT -> {
|
||||
fragment = EquipmentOverviewFragment()
|
||||
}
|
||||
SIDEBAR_ITEMS -> {
|
||||
fragment = ItemsFragment()
|
||||
}
|
||||
SIDEBAR_STABLE -> {
|
||||
fragment = StableFragment()
|
||||
}
|
||||
SIDEBAR_PURCHASE -> {
|
||||
newActivityClass = GemPurchaseActivity::class.java
|
||||
}
|
||||
SIDEBAR_NEWS -> {
|
||||
fragment = NewsFragment()
|
||||
}
|
||||
SIDEBAR_SETTINGS -> {
|
||||
newActivityClass = PrefsActivity::class.java
|
||||
}
|
||||
SIDEBAR_HELP -> {
|
||||
fragment = FAQOverviewFragment()
|
||||
}
|
||||
SIDEBAR_ABOUT -> {
|
||||
newActivityClass = AboutActivity::class.java
|
||||
}
|
||||
}
|
||||
|
||||
sharedPreferences.edit().putInt("lastActivePosition", position).apply()
|
||||
|
||||
if (fragment != null) {
|
||||
fragment.fragmentSidebarPosition = position
|
||||
activity.displayFragment(fragment)
|
||||
return@withOnDrawerItemClickListener false
|
||||
}
|
||||
if (newActivityClass != null) {
|
||||
val passUserId = Intent(activity, newActivityClass)
|
||||
passUserId.putExtra("userId", activity.userID)
|
||||
if (identifier == SIDEBAR_PURCHASE) {
|
||||
activity.startActivityForResult(passUserId, GEM_PURCHASE_REQUEST)
|
||||
} else {
|
||||
activity.startActivity(passUserId)
|
||||
}
|
||||
return@withOnDrawerItemClickListener false
|
||||
}
|
||||
return@withOnDrawerItemClickListener true
|
||||
}
|
||||
|
||||
return builder
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.habitrpg.android.habitica.ui.views
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.PorterDuff
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import kotlinx.android.synthetic.main.stats_view.view.*
|
||||
|
||||
class StatsView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {
|
||||
|
||||
var levelValue: Int = 0
|
||||
set(value) {
|
||||
levelValueTextView.text = value.toString()
|
||||
}
|
||||
var equipmentValue: Int = 0
|
||||
set(value) {
|
||||
equipmentValueTextView.text = value.toString()
|
||||
}
|
||||
var buffValue: Int = 0
|
||||
set(value) {
|
||||
buffValueTextView.text = value.toString()
|
||||
}
|
||||
var allocatedValue: Int = 0
|
||||
set(value) {
|
||||
allocatedValueTextView.text = value.toString()
|
||||
}
|
||||
|
||||
var totalValue: Int = 0
|
||||
set(value) {
|
||||
totalValueTextView.text = value.toString()
|
||||
}
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.stats_view, this)
|
||||
|
||||
val attributes = context?.theme?.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.StatsView,
|
||||
0, 0)
|
||||
|
||||
val backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.layout_top_rounded_bg)
|
||||
if (attributes != null) {
|
||||
backgroundDrawable.setColorFilter(attributes.getColor(R.styleable.StatsView_titleBackgroundColor, 0), PorterDuff.Mode.MULTIPLY)
|
||||
titleTextView.text = attributes.getString(R.styleable.StatsView_statsTitle)
|
||||
}
|
||||
titleWrapper.background = backgroundDrawable
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue