implement additional tavern features

This commit is contained in:
Phillip Thelen 2018-01-30 13:41:22 +01:00
parent 0e30b03b0b
commit 31a9e36ad7
26 changed files with 2242 additions and 604 deletions

View file

@ -9,7 +9,7 @@
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="26" />
android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

View file

@ -43,8 +43,8 @@ repositories {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Networking
implementation 'com.squareup.okhttp3:okhttp:3.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
//REST API handling
implementation('com.squareup.retrofit2:retrofit:2.3.0') {
exclude module: 'okhttp'
@ -52,24 +52,24 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.3.0'
//Crash Logging
releaseImplementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
releaseImplementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
transitive = true
}
// View Elements Binding :)
implementation 'com.jakewharton:butterknife:8.8.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
//Dependency Injection
implementation 'com.google.dagger:dagger:2.12'
kapt 'com.google.dagger:dagger-compiler:2.12'
implementation 'com.google.dagger:dagger:2.14.1'
kapt 'com.google.dagger:dagger-compiler:2.14.1'
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
//App Compatibility and Material Design
implementation('com.mikepenz:materialdrawer:5.8.3@aar') {
transitive = true
}
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support:design:27.0.1'
implementation 'com.android.support:recyclerview-v7:27.0.1'
implementation 'com.android.support:preference-v14:27.0.1'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:preference-v14:27.0.2'
//QR Code
implementation 'com.github.kenglxn.QRGen:android:2.2.0'
// Emojis
@ -83,9 +83,9 @@ dependencies {
// a better fab alternative
implementation 'com.github.clans:fab:1.6.4'
//Eventbus
implementation 'org.greenrobot:eventbus:3.0.0'
implementation 'org.greenrobot:eventbus:3.1.1'
// IAP Handling / Verification
implementation 'org.solovyev.android:checkout:1.0.1'
implementation 'org.solovyev.android:checkout:1.2.1'
//Facebook
implementation('com.facebook.android:facebook-android-sdk:4.19.0') {
transitive = true
@ -95,14 +95,14 @@ dependencies {
implementation 'com.github.javadev:underscore:1.23'
//RxJava
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.2'
implementation 'io.reactivex:rxjava:1.3.5'
//Analytics
implementation 'com.amplitude:android-sdk:2.14.1'
implementation 'com.amplitude:android-sdk:2.16.0'
// Fresco Image Management Library
implementation('com.facebook.fresco:fresco:1.5.0') {
implementation('com.facebook.fresco:fresco:1.8.0') {
exclude module: 'bolts-android'
}
implementation('com.facebook.fresco:animated-gif:1.5.0') {
implementation('com.facebook.fresco:animated-gif:1.8.0') {
exclude module: 'bolts-android'
}
//Tests

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- view background color -->
<solid
android:color="@color/yellow_10" >
</solid>
<!-- Here is the corner radius -->
<corners
android:radius="4dp" >
</corners>
</shape>

View file

@ -1,34 +1,88 @@
<?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.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/shop_header" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/days_gray"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_large"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingBottom="?attr/actionBarSize">
<include layout="@layout/shop_header"
android:layout_marginBottom="@dimen/spacing_large"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/check_into_inn">
<Button
android:id="@+id/dailiesButton"
android:id="@+id/innButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/tavern.inn.rest"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
style="@style/Button.Purple.Small"/>
style="@style/Button.Yellow.Small"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/inn_description"
android:layout_margin="@dimen/spacing_large"/>
<View
android:layout_marginTop="@dimen/spacing_large"/>
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/community_guidelines">
<Button
android:id="@+id/guidelinesButton"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/days_gray" />
</LinearLayout>
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/view_community_guidelines"
style="@style/HabiticaButton.Gray"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/guidelines_description"
android:layout_marginTop="@dimen/spacing_large"/>
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/helpful_links">
<Button
android:id="@+id/faqButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/view_faq"
style="@style/HabiticaButton.Gray"/>
<Button
android:id="@+id/reportButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/report_bug"
style="@style/HabiticaButton.Gray"
android:layout_marginTop="@dimen/spacing_large"/>
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
android:id="@+id/moderatorsView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/staff_moderators">
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
<com.habitrpg.android.habitica.ui.views.CollapsibleSectionView
android:id="@+id/playerTiersView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/player_tiers">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/tiers_descriptions"/>
</com.habitrpg.android.habitica.ui.views.CollapsibleSectionView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<merge 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="match_parent">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/days_gray"/>
<LinearLayout
android:id="@+id/title_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/spacing_large"
android:paddingRight="@dimen/spacing_large">
<TextView
android:id="@+id/titleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="@dimen/spacing_large"
android:layout_marginBottom="@dimen/spacing_large"
android:textSize="16sp"
android:textColor="@color/gray_50"
tools:text="Example"/>
<ImageView
android:id="@+id/caretView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp" />
</LinearLayout>
</merge>

View file

@ -1,6 +1,7 @@
<resources>
<attr name="statsColor" format="color" />
<attr name="statsTitle" format="string" />
<attr name="title" format="string" />
<attr name="hasLightBackground" format="boolean" />
<declare-styleable name="AvatarView">
<attr name="showBackground" format="boolean" />
@ -48,7 +49,7 @@
</declare-styleable>
<declare-styleable name="FixValuesEditText">
<attr name="fixIconName" format="string" />
<attr name="title" format="string" />
<attr name="title" />
<attr name="iconBgColor" format="color" />
<attr name="hintStyle" format="reference" />
</declare-styleable>
@ -65,4 +66,7 @@
<attr name="statsTextColor" format="color" />
<attr name="statsTitle" />
</declare-styleable>
<declare-styleable name="CollapsibleSectionView">
<attr name="title" />
</declare-styleable>
</resources>

View file

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="contributor.0">#aaa</color>
<color name="contributor.1">#f57a9d</color>
<color name="contributor.2">#b93030</color>
<color name="contributor.3">#ff3300</color>
<color name="contributor.4">#ff9500</color>
<color name="contributor.5">#fff700</color>
<color name="contributor.6">#5eff00</color>
<color name="contributor.7">#00aaff</color>
<color name="contributor.mod">#130ead</color>
<color name="contributor.staff">#88108f</color>
<color name="contributor.1">#c42871</color>
<color name="contributor.2">#b01515</color>
<color name="contributor.3">#d70e14</color>
<color name="contributor.4">#c24d00</color>
<color name="contributor.5">#9e650f</color>
<color name="contributor.6">#2b8363</color>
<color name="contributor.7">#167e87</color>
<color name="contributor.mod">#277eab</color>
<color name="contributor.staff">#6133b4</color>
<color name="contributor.npc">#000</color>
<color name="contributor.npc.font">#00FF00</color>
</resources>

View file

@ -724,4 +724,14 @@
<string name="available_stats" formatted="false">%d points</string>
<string name="toogle_emojis">Toogle Emojis</string>
<string name="tavern_description">Welcome to the Inn! Pull up a chair to chat, or take a break from your tasks.</string>
<string name="check_into_inn">Check into Inn</string>
<string name="community_guidelines">Community Guidelines</string>
<string name="view_community_guidelines">View Community Guidelines</string>
<string name="guidelines_description">Habitica tries to create a welcoming environment for users of all ages and backgrounds, especially in public spaces like the Tavern. If you have any questions, please consult our guidelines.</string>
<string name="helpful_links">Helpful Links</string>
<string name="view_faq">View FAQ</string>
<string name="report_bug">Report a Bug</string>
<string name="player_tiers">Player Tiers</string>
<string name="staff_moderators">Staff and Moderators</string>
<string name="tiers_descriptions">The colored usernames you see in chat represent a persons contributor tier. The higher the tier, the more the person has contributed to habitica through art, code, the community, or more!</string>
</resources>

View file

@ -304,6 +304,18 @@
<item name="android:paddingBottom">@dimen/button_padding_vertical_small</item>
</style>
<style name="Button.Yellow">
<item name="android:background">@drawable/rounded_yellow_10_square</item>
<item name="android:textColor">@color/white</item>
</style>
<style name="Button.Yellow.Small">
<item name="android:paddingLeft">@dimen/button_padding_small</item>
<item name="android:paddingRight">@dimen/button_padding_small</item>
<item name="android:paddingTop">@dimen/button_padding_vertical_small</item>
<item name="android:paddingBottom">@dimen/button_padding_vertical_small</item>
</style>
<style name="LoginEditTextTheme">
<item name="colorAccent">@color/white_50_alpha</item>
<item name="colorControlNormal">@color/white_15_alpha</item>

View file

@ -67,107 +67,107 @@ public class SetupCustomizationRepositoryImpl implements SetupCustomizationRepos
private List<SetupCustomization> getWheelchairs() {
return Arrays.asList(
SetupCustomization.createWheelchair("none", 0),
SetupCustomization.createWheelchair("black", R.drawable.creator_chair_black),
SetupCustomization.createWheelchair("blue", R.drawable.creator_chair_blue),
SetupCustomization.createWheelchair("green", R.drawable.creator_chair_green),
SetupCustomization.createWheelchair("pink", R.drawable.creator_chair_pink),
SetupCustomization.createWheelchair("red", R.drawable.creator_chair_red),
SetupCustomization.createWheelchair("yellow", R.drawable.creator_chair_yellow)
SetupCustomization.Companion.createWheelchair("none", 0),
SetupCustomization.Companion.createWheelchair("black", R.drawable.creator_chair_black),
SetupCustomization.Companion.createWheelchair("blue", R.drawable.creator_chair_blue),
SetupCustomization.Companion.createWheelchair("green", R.drawable.creator_chair_green),
SetupCustomization.Companion.createWheelchair("pink", R.drawable.creator_chair_pink),
SetupCustomization.Companion.createWheelchair("red", R.drawable.creator_chair_red),
SetupCustomization.Companion.createWheelchair("yellow", R.drawable.creator_chair_yellow)
);
}
private List<SetupCustomization> getGlasses() {
return Arrays.asList(
SetupCustomization.createGlasses("", R.drawable.creator_blank_face),
SetupCustomization.createGlasses("eyewear_special_blackTopFrame", R.drawable.creator_eyewear_special_blacktopframe),
SetupCustomization.createGlasses("eyewear_special_blueTopFrame", R.drawable.creator_eyewear_special_bluetopframe),
SetupCustomization.createGlasses("eyewear_special_greenTopFrame", R.drawable.creator_eyewear_special_greentopframe),
SetupCustomization.createGlasses("eyewear_special_pinkTopFrame", R.drawable.creator_eyewear_special_pinktopframe),
SetupCustomization.createGlasses("eyewear_special_redTopFrame", R.drawable.creator_eyewear_special_redtopframe),
SetupCustomization.createGlasses("eyewear_special_yellowTopFrame", R.drawable.creator_eyewear_special_yellowtopframe),
SetupCustomization.createGlasses("eyewear_special_whiteTopFrame", R.drawable.creator_eyewear_special_whitetopframe)
SetupCustomization.Companion.createGlasses("", R.drawable.creator_blank_face),
SetupCustomization.Companion.createGlasses("eyewear_special_blackTopFrame", R.drawable.creator_eyewear_special_blacktopframe),
SetupCustomization.Companion.createGlasses("eyewear_special_blueTopFrame", R.drawable.creator_eyewear_special_bluetopframe),
SetupCustomization.Companion.createGlasses("eyewear_special_greenTopFrame", R.drawable.creator_eyewear_special_greentopframe),
SetupCustomization.Companion.createGlasses("eyewear_special_pinkTopFrame", R.drawable.creator_eyewear_special_pinktopframe),
SetupCustomization.Companion.createGlasses("eyewear_special_redTopFrame", R.drawable.creator_eyewear_special_redtopframe),
SetupCustomization.Companion.createGlasses("eyewear_special_yellowTopFrame", R.drawable.creator_eyewear_special_yellowtopframe),
SetupCustomization.Companion.createGlasses("eyewear_special_whiteTopFrame", R.drawable.creator_eyewear_special_whitetopframe)
);
}
private List<SetupCustomization> getFlowers() {
return Arrays.asList(
SetupCustomization.createFlower("0", R.drawable.creator_blank_face),
SetupCustomization.createFlower("1", R.drawable.creator_hair_flower_1),
SetupCustomization.createFlower("2", R.drawable.creator_hair_flower_2),
SetupCustomization.createFlower("3", R.drawable.creator_hair_flower_3),
SetupCustomization.createFlower("4", R.drawable.creator_hair_flower_4),
SetupCustomization.createFlower("5", R.drawable.creator_hair_flower_5),
SetupCustomization.createFlower("6", R.drawable.creator_hair_flower_6)
SetupCustomization.Companion.createFlower("0", R.drawable.creator_blank_face),
SetupCustomization.Companion.createFlower("1", R.drawable.creator_hair_flower_1),
SetupCustomization.Companion.createFlower("2", R.drawable.creator_hair_flower_2),
SetupCustomization.Companion.createFlower("3", R.drawable.creator_hair_flower_3),
SetupCustomization.Companion.createFlower("4", R.drawable.creator_hair_flower_4),
SetupCustomization.Companion.createFlower("5", R.drawable.creator_hair_flower_5),
SetupCustomization.Companion.createFlower("6", R.drawable.creator_hair_flower_6)
);
}
private List<SetupCustomization> getHairColors() {
return Arrays.asList(
SetupCustomization.createHairColor("white", R.color.hair_white),
SetupCustomization.createHairColor("brown", R.color.hair_brown),
SetupCustomization.createHairColor("blond", R.color.hair_blond),
SetupCustomization.createHairColor("red", R.color.hair_red),
SetupCustomization.createHairColor("black", R.color.hair_black)
SetupCustomization.Companion.createHairColor("white", R.color.hair_white),
SetupCustomization.Companion.createHairColor("brown", R.color.hair_brown),
SetupCustomization.Companion.createHairColor("blond", R.color.hair_blond),
SetupCustomization.Companion.createHairColor("red", R.color.hair_red),
SetupCustomization.Companion.createHairColor("black", R.color.hair_black)
);
}
private List<SetupCustomization> getHairBases(String color) {
return Arrays.asList(
SetupCustomization.createHairPonytail("0", R.drawable.creator_blank_face),
SetupCustomization.createHairPonytail("1", getResId("creator_hair_base_1_"+color)),
SetupCustomization.createHairPonytail("3", getResId("creator_hair_base_3_"+color))
SetupCustomization.Companion.createHairPonytail("0", R.drawable.creator_blank_face),
SetupCustomization.Companion.createHairPonytail("1", getResId("creator_hair_base_1_"+color)),
SetupCustomization.Companion.createHairPonytail("3", getResId("creator_hair_base_3_"+color))
);
}
private List<SetupCustomization> getBangs(String color) {
return Arrays.asList(
SetupCustomization.createHairBangs("0", R.drawable.creator_blank_face),
SetupCustomization.createHairBangs("1", getResId("creator_hair_bangs_1_"+color)),
SetupCustomization.createHairBangs("2", getResId("creator_hair_bangs_2_"+color)),
SetupCustomization.createHairBangs("3", getResId("creator_hair_bangs_3_"+color))
SetupCustomization.Companion.createHairBangs("0", R.drawable.creator_blank_face),
SetupCustomization.Companion.createHairBangs("1", getResId("creator_hair_bangs_1_"+color)),
SetupCustomization.Companion.createHairBangs("2", getResId("creator_hair_bangs_2_"+color)),
SetupCustomization.Companion.createHairBangs("3", getResId("creator_hair_bangs_3_"+color))
);
}
private List<SetupCustomization> getSizes() {
return Arrays.asList(
SetupCustomization.createSize("slim", R.drawable.creator_slim_shirt_black, context.getString(R.string.avatar_size_slim)),
SetupCustomization.createSize("broad", R.drawable.creator_broad_shirt_black, context.getString(R.string.avatar_size_broad))
SetupCustomization.Companion.createSize("slim", R.drawable.creator_slim_shirt_black, context.getString(R.string.avatar_size_slim)),
SetupCustomization.Companion.createSize("broad", R.drawable.creator_broad_shirt_black, context.getString(R.string.avatar_size_broad))
);
}
private List<SetupCustomization> getShirts(String size) {
if (size.equals("broad")) {
return Arrays.asList(
SetupCustomization.createShirt("black", R.drawable.creator_broad_shirt_black),
SetupCustomization.createShirt("blue", R.drawable.creator_broad_shirt_blue),
SetupCustomization.createShirt("green", R.drawable.creator_broad_shirt_green),
SetupCustomization.createShirt("pink", R.drawable.creator_broad_shirt_pink),
SetupCustomization.createShirt("white", R.drawable.creator_broad_shirt_white),
SetupCustomization.createShirt("yellow", R.drawable.creator_broad_shirt_yellow)
SetupCustomization.Companion.createShirt("black", R.drawable.creator_broad_shirt_black),
SetupCustomization.Companion.createShirt("blue", R.drawable.creator_broad_shirt_blue),
SetupCustomization.Companion.createShirt("green", R.drawable.creator_broad_shirt_green),
SetupCustomization.Companion.createShirt("pink", R.drawable.creator_broad_shirt_pink),
SetupCustomization.Companion.createShirt("white", R.drawable.creator_broad_shirt_white),
SetupCustomization.Companion.createShirt("yellow", R.drawable.creator_broad_shirt_yellow)
);
} else {
return Arrays.asList(
SetupCustomization.createShirt("black", R.drawable.creator_slim_shirt_black),
SetupCustomization.createShirt("blue", R.drawable.creator_slim_shirt_blue),
SetupCustomization.createShirt("green", R.drawable.creator_slim_shirt_green),
SetupCustomization.createShirt("pink", R.drawable.creator_slim_shirt_pink),
SetupCustomization.createShirt("white", R.drawable.creator_slim_shirt_white),
SetupCustomization.createShirt("yellow", R.drawable.creator_slim_shirt_yellow)
SetupCustomization.Companion.createShirt("black", R.drawable.creator_slim_shirt_black),
SetupCustomization.Companion.createShirt("blue", R.drawable.creator_slim_shirt_blue),
SetupCustomization.Companion.createShirt("green", R.drawable.creator_slim_shirt_green),
SetupCustomization.Companion.createShirt("pink", R.drawable.creator_slim_shirt_pink),
SetupCustomization.Companion.createShirt("white", R.drawable.creator_slim_shirt_white),
SetupCustomization.Companion.createShirt("yellow", R.drawable.creator_slim_shirt_yellow)
);
}
}
private List<SetupCustomization> getSkins() {
return Arrays.asList(
SetupCustomization.createSkin("ddc994", R.color.skin_ddc994),
SetupCustomization.createSkin("f5a76e", R.color.skin_f5a76e),
SetupCustomization.createSkin("ea8349", R.color.skin_ea8349),
SetupCustomization.createSkin("c06534", R.color.skin_c06534),
SetupCustomization.createSkin("98461a", R.color.skin_98461a),
SetupCustomization.createSkin("915533", R.color.skin_915533),
SetupCustomization.createSkin("c3e1dc", R.color.skin_c3e1dc),
SetupCustomization.createSkin("6bd049", R.color.skin_6bd049)
SetupCustomization.Companion.createSkin("ddc994", R.color.skin_ddc994),
SetupCustomization.Companion.createSkin("f5a76e", R.color.skin_f5a76e),
SetupCustomization.Companion.createSkin("ea8349", R.color.skin_ea8349),
SetupCustomization.Companion.createSkin("c06534", R.color.skin_c06534),
SetupCustomization.Companion.createSkin("98461a", R.color.skin_98461a),
SetupCustomization.Companion.createSkin("915533", R.color.skin_915533),
SetupCustomization.Companion.createSkin("c3e1dc", R.color.skin_c3e1dc),
SetupCustomization.Companion.createSkin("6bd049", R.color.skin_6bd049)
);
}

View file

@ -5,4 +5,11 @@ package com.habitrpg.android.habitica.events.commands;
*/
public class OpenMenuItemCommand {
public int identifier;
public OpenMenuItemCommand(int identifier) {
this.identifier = identifier;
}
public OpenMenuItemCommand() {
}
}

View file

@ -1,111 +0,0 @@
package com.habitrpg.android.habitica.models;
public class SetupCustomization {
public String key;
public Integer drawableId;
public Integer colorId;
public String text;
public String path;
public String category;
public String subcategory;
public SetupCustomization() {
super();
}
public String getPath() {
return path;
}
public static SetupCustomization createSize(String key, int drawableId, String text) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.text = text;
customization.path = "size";
customization.category = "body";
customization.subcategory = "size";
return customization;
}
public static SetupCustomization createShirt(String key, int drawableId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.path = "shirt";
customization.category = "body";
customization.subcategory = "shirt";
return customization;
}
public static SetupCustomization createSkin(String key, Integer colorId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.colorId = colorId;
customization.path = "skin";
customization.category = "skin";
return customization;
}
public static SetupCustomization createHairColor(String key, Integer colorId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.colorId = colorId;
customization.path = "hair.color";
customization.category = "hair";
customization.subcategory = "color";
return customization;
}
public static SetupCustomization createHairBangs(String key, Integer drawableId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.path = "hair.bangs";
customization.category = "hair";
customization.subcategory = "bangs";
return customization;
}
public static SetupCustomization createHairPonytail(String key, Integer drawableId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.path = "hair.base";
customization.category = "hair";
customization.subcategory = "base";
return customization;
}
public static SetupCustomization createGlasses(String key, Integer drawableId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.path = "glasses";
customization.category = "extras";
customization.subcategory = "glasses";
return customization;
}
public static SetupCustomization createFlower(String key, Integer drawableId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.path = "hair.flower";
customization.category = "extras";
customization.subcategory = "flower";
return customization;
}
public static SetupCustomization createWheelchair(String key, Integer drawableId) {
SetupCustomization customization = new SetupCustomization();
customization.key = key;
customization.drawableId = drawableId;
customization.path = "chair";
customization.category = "extras";
customization.subcategory = "wheelchair";
return customization;
}
}

View file

@ -0,0 +1,106 @@
package com.habitrpg.android.habitica.models
class SetupCustomization {
lateinit var key: String
var drawableId: Int? = null
var colorId: Int? = null
lateinit var text: String
lateinit var path: String
lateinit var category: String
lateinit var subcategory: String
companion object {
fun createSize(key: String, drawableId: Int, text: String): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.text = text
customization.path = "size"
customization.category = "body"
customization.subcategory = "size"
return customization
}
fun createShirt(key: String, drawableId: Int): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.path = "shirt"
customization.category = "body"
customization.subcategory = "shirt"
return customization
}
fun createSkin(key: String, colorId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.colorId = colorId
customization.path = "skin"
customization.category = "skin"
return customization
}
fun createHairColor(key: String, colorId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.colorId = colorId
customization.path = "hair.color"
customization.category = "hair"
customization.subcategory = "color"
return customization
}
fun createHairBangs(key: String, drawableId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.path = "hair.bangs"
customization.category = "hair"
customization.subcategory = "bangs"
return customization
}
fun createHairPonytail(key: String, drawableId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.path = "hair.base"
customization.category = "hair"
customization.subcategory = "base"
return customization
}
fun createGlasses(key: String, drawableId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.path = "glasses"
customization.category = "extras"
customization.subcategory = "glasses"
return customization
}
fun createFlower(key: String, drawableId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.path = "hair.flower"
customization.category = "extras"
customization.subcategory = "flower"
return customization
}
fun createWheelchair(key: String, drawableId: Int?): SetupCustomization {
val customization = SetupCustomization()
customization.key = key
customization.drawableId = drawableId
customization.path = "chair"
customization.category = "extras"
customization.subcategory = "wheelchair"
return customization
}
}
}

View file

@ -0,0 +1,39 @@
package com.habitrpg.android.habitica.models.members
import android.content.Context
import android.support.v4.content.ContextCompat
import com.habitrpg.android.habitica.R
class PlayerTier(val title: String, val id: Int) {
companion object {
fun getTiers(): List<PlayerTier> {
return arrayListOf(
PlayerTier("Tier 1 (Friend)", 1),
PlayerTier("Tier 2 (Friend)", 2),
PlayerTier("Tier 3 (Elite)", 3),
PlayerTier("Tier 4 (Elite)", 4),
PlayerTier("Tier 5 (Champion)", 5),
PlayerTier("Tier 6 (Champion)", 6),
PlayerTier("Tier 7 (Legendary)", 7),
PlayerTier("Moderator (Guardian)", 8),
PlayerTier("Staff (Heroic)", 9)
)
}
fun getColorForTier(context: Context, value: Int): Int {
return when (value) {
1 -> ContextCompat.getColor(context, R.color.contributor_1)
2 -> ContextCompat.getColor(context, R.color.contributor_2)
3 -> ContextCompat.getColor(context, R.color.contributor_3)
4 -> ContextCompat.getColor(context, R.color.contributor_4)
5 -> ContextCompat.getColor(context, R.color.contributor_5)
6 -> ContextCompat.getColor(context, R.color.contributor_6)
7 -> ContextCompat.getColor(context, R.color.contributor_7)
8 -> ContextCompat.getColor(context, R.color.contributor_mod)
9 -> ContextCompat.getColor(context, R.color.contributor_staff)
else -> ContextCompat.getColor(context, R.color.contributor_0)
}
}
}
}

View file

@ -63,42 +63,42 @@ public class CustomizationSetupAdapter extends RecyclerView.Adapter<RecyclerView
return false;
}
Preferences prefs = this.user.getPreferences();
switch (customization.category) {
switch (customization.getCategory()) {
case "body": {
switch (customization.subcategory) {
switch (customization.getSubcategory()) {
case "size":
return customization.key.equals(prefs.getSize());
return customization.getKey().equals(prefs.getSize());
case "shirt":
return customization.key.equals(prefs.getShirt());
return customization.getKey().equals(prefs.getShirt());
}
}
case "skin":
return customization.key.equals(prefs.getSkin());
return customization.getKey().equals(prefs.getSkin());
case "background":
return customization.key.equals(prefs.getBackground());
return customization.getKey().equals(prefs.getBackground());
case "hair":
switch (customization.subcategory) {
switch (customization.getSubcategory()) {
case "bangs":
return Integer.parseInt(customization.key) == prefs.getHair().getBangs();
return Integer.parseInt(customization.getKey()) == prefs.getHair().getBangs();
case "base":
return Integer.parseInt(customization.key) == prefs.getHair().getBase();
return Integer.parseInt(customization.getKey()) == prefs.getHair().getBase();
case "color":
return customization.key.equals(prefs.getHair().getColor());
return customization.getKey().equals(prefs.getHair().getColor());
case "flower":
return Integer.parseInt(customization.key) == prefs.getHair().getFlower();
return Integer.parseInt(customization.getKey()) == prefs.getHair().getFlower();
case "beard":
return Integer.parseInt(customization.key) == prefs.getHair().getBeard();
return Integer.parseInt(customization.getKey()) == prefs.getHair().getBeard();
case "mustache":
return Integer.parseInt(customization.key) == prefs.getHair().getMustache();
return Integer.parseInt(customization.getKey()) == prefs.getHair().getMustache();
}
case "extras": {
switch (customization.subcategory) {
switch (customization.getSubcategory()) {
case "glasses":
return customization.key.equals(this.user.getItems().getGear().getEquipped().getEyeWear()) || ("eyewear_base_0".equals(this.user.getItems().getGear().getEquipped().getEyeWear()) && customization.key.length() == 0);
return customization.getKey().equals(this.user.getItems().getGear().getEquipped().getEyeWear()) || ("eyewear_base_0".equals(this.user.getItems().getGear().getEquipped().getEyeWear()) && customization.getKey().length() == 0);
case "flower":
return Integer.parseInt(customization.key) == prefs.getHair().getFlower();
return Integer.parseInt(customization.getKey()) == prefs.getHair().getFlower();
case "wheelchair":
return ("chair_"+customization.key).equals(prefs.getChair()) || customization.key.equals(prefs.getChair()) || (customization.key.equals("none") && prefs.getChair() == null);
return ("chair_"+ customization.getKey()).equals(prefs.getChair()) || customization.getKey().equals(prefs.getChair()) || (customization.getKey().equals("none") && prefs.getChair() == null);
}
}
}
@ -129,19 +129,19 @@ public class CustomizationSetupAdapter extends RecyclerView.Adapter<RecyclerView
public void bind(SetupCustomization customization) {
this.customization = customization;
if (customization.drawableId != null) {
imageView.setImageResource(customization.drawableId);
} else if (customization.colorId != null) {
if (customization.getDrawableId() != null) {
imageView.setImageResource(customization.getDrawableId());
} else if (customization.getColorId() != null) {
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.setup_customization_circle);
if (drawable != null) {
drawable.setColorFilter(ContextCompat.getColor(context, customization.colorId), PorterDuff.Mode.MULTIPLY);
drawable.setColorFilter(ContextCompat.getColor(context, customization.getColorId()), PorterDuff.Mode.MULTIPLY);
}
imageView.setImageDrawable(drawable);
} else {
imageView.setImageDrawable(null);
}
textView.setText(customization.text);
if (!"0".equals(customization.key) && "flower".equals(customization.subcategory)) {
textView.setText(customization.getText());
if (!"0".equals(customization.getKey()) && "flower".equals(customization.getSubcategory())) {
if (isCustomizationActive(customization)) {
imageView.setBackgroundResource(R.drawable.setup_customization_flower_bg_selected);
} else {
@ -160,12 +160,12 @@ public class CustomizationSetupAdapter extends RecyclerView.Adapter<RecyclerView
@Override
public void onClick(View v) {
if (customization.path.equals("glasses")) {
if (customization.getPath().equals("glasses")) {
EquipCommand command = new EquipCommand();
if (customization.key.length() == 0) {
if (customization.getKey().length() == 0) {
command.key = user.getItems().getGear().getEquipped().getEyeWear();
} else {
command.key = customization.key;
command.key = customization.getKey();
}
command.type = "equipped";
EventBus.getDefault().post(command);
@ -173,7 +173,7 @@ public class CustomizationSetupAdapter extends RecyclerView.Adapter<RecyclerView
UpdateUserCommand command = new UpdateUserCommand();
Map<String, Object> updateData = new HashMap<>();
String updatePath = "preferences." + customization.getPath();
updateData.put(updatePath, customization.key);
updateData.put(updatePath, customization.getKey());
command.updateData = updateData;

View file

@ -243,10 +243,10 @@ public class AvatarSetupFragment extends BaseFragment {
}
if (weighFirstOption) {
if (random.nextInt(10) > 3) {
return customizations.get(0).key;
return customizations.get(0).getKey();
}
}
return customizations.get(random.nextInt(customizations.size())).key;
return customizations.get(random.nextInt(customizations.size())).getKey();
}
private void activateButton(AvatarCategoryView button) {

View file

@ -1,13 +1,17 @@
package com.habitrpg.android.habitica.ui.fragments.social
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Shader
import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import com.habitrpg.android.habitica.R
@ -29,11 +33,16 @@ import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
import com.facebook.imagepipeline.image.CloseableImage
import com.facebook.imagepipeline.request.ImageRequestBuilder
import com.habitrpg.android.habitica.events.commands.OpenMenuItemCommand
import com.habitrpg.android.habitica.helpers.RemoteConfigManager
import com.habitrpg.android.habitica.models.members.PlayerTier
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
import com.habitrpg.android.habitica.ui.menu.MainDrawerBuilder
import com.habitrpg.android.habitica.ui.views.social.UsernameLabel
import kotlinx.android.synthetic.main.shop_header.*
import kotlinx.android.synthetic.main.fragment_tavern_detail.*
import kotlinx.android.synthetic.main.stats_view.view.*
import org.greenrobot.eventbus.EventBus
import rx.Observable
import rx.android.schedulers.AndroidSchedulers
import rx.functions.Action1
@ -92,35 +101,67 @@ class TavernDetailFragment : BaseFragment() {
drawable.tileModeX = Shader.TileMode.REPEAT
Observable.just(drawable)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Action1 {
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
backgroundView?.setBackgroundDrawable(it)
} else {
backgroundView?.background = it
}}, RxErrorHandler.handleEmptyError())
.subscribe(Action1 { backgroundView.background = it }, RxErrorHandler.handleEmptyError())
dataSource.close()
}
}
}, CallerThreadExecutor.getInstance())
addPlayerTiers()
bindButtons()
}
private fun bindButtons() {
innButton.setOnClickListener {
user?.let { userRepository.sleep(it).subscribe(Action1 { }, RxErrorHandler.handleEmptyError()) }
}
guidelinesButton.setOnClickListener {
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse("https://habitica.com/static/community-guidelines")
context?.startActivity(i)
}
faqButton.setOnClickListener {
EventBus.getDefault().post(OpenMenuItemCommand(MainDrawerBuilder.SIDEBAR_HELP))
}
reportButton.setOnClickListener {
EventBus.getDefault().post(OpenMenuItemCommand(MainDrawerBuilder.SIDEBAR_ABOUT))
}
}
private fun updatePausedState() {
if (dailiesButton == null) {
if (innButton == null) {
return
}
if (user?.preferences?.sleep == true) {
dailiesButton .setText(R.string.tavern_inn_checkOut)
innButton .setText(R.string.tavern_inn_checkOut)
} else {
dailiesButton.setText(R.string.tavern_inn_rest)
innButton.setText(R.string.tavern_inn_rest)
}
}
private fun addPlayerTiers() {
for (tier in PlayerTier.getTiers()) {
val container = FrameLayout(context)
val context = this.context
if (context != null) {
container.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.layout_rounded_bg_gray_700))
}
val label = UsernameLabel(context, null)
label.tier = tier.id
label.username = tier.title
val params = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT,
Gravity.CENTER)
container.addView(label, params)
playerTiersView.addView(container)
val padding = context?.resources?.getDimension(R.dimen.spacing_medium)?.toInt() ?: 0
container.setPadding(0, padding, 0, padding)
}
}
override fun injectFragment(component: AppComponent) {
component.inject(this)
}
@OnClick(R.id.dailiesButton)
fun dailiesButtonClicked() {
user?.let { userRepository.sleep(it).subscribe(Action1 { }, RxErrorHandler.handleEmptyError()) }
}
}

View file

@ -1,161 +0,0 @@
package com.habitrpg.android.habitica.ui.fragments.social;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
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.data.SocialRepository;
import com.habitrpg.android.habitica.helpers.RxErrorHandler;
import com.habitrpg.android.habitica.models.social.Group;
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
import javax.inject.Inject;
public class TavernFragment extends BaseMainFragment {
@Inject
SocialRepository socialRepository;
public ViewPager viewPager;
Group tavern;
ChatListFragment chatListFragment;
GroupInformationFragment questInfoFragment;
@Inject
InventoryRepository inventoryRepository;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
this.usesTabLayout = true;
hideToolbar();
disableToolbarScrolling();
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(R.layout.fragment_viewpager, container, false);
viewPager = (ViewPager) v.findViewById(R.id.viewPager);
viewPager.setCurrentItem(0);
setViewPagerAdapter();
this.setTutorialStepIdentifier("tavern");
this.setTutorialText(getString(R.string.tutorial_tavern));
return v;
}
@Override
public void onDestroyView() {
showToolbar();
enableToolbarScrolling();
super.onDestroyView();
}
@Override
public void onDestroy() {
socialRepository.close();
super.onDestroy();
}
@Override
public void injectFragment(AppComponent component) {
component.inject(this);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (this.socialRepository != null) {
getCompositeSubscription().add(socialRepository.getGroup("habitrpg")
.subscribe(group -> {
TavernFragment.this.tavern = group;
if (group.quest != null && group.quest.key != null && TavernFragment.this.isAdded()) {
TavernFragment.this.viewPager.getAdapter().notifyDataSetChanged();
if (TavernFragment.this.tabLayout != null) {
TavernFragment.this.tabLayout.setVisibility(View.VISIBLE);
TavernFragment.this.tabLayout.setupWithViewPager(TavernFragment.this.viewPager);
}
}
}, RxErrorHandler.handleEmptyError()));
}
}
public void setViewPagerAdapter() {
android.support.v4.app.FragmentManager fragmentManager = getChildFragmentManager();
if (this.user == null) {
return;
}
this.viewPager.setAdapter(new FragmentPagerAdapter(fragmentManager) {
@Override
public Fragment getItem(int position) {
Fragment fragment;
switch (position) {
case 0: {
fragment = new TavernDetailFragment();
break;
}
case 1: {
chatListFragment = new ChatListFragment();
chatListFragment.configure("habitrpg", user, true);
fragment = chatListFragment;
break;
}
case 2: {
fragment = questInfoFragment = GroupInformationFragment.Companion.newInstance(tavern, user);
break;
}
default:
fragment = new Fragment();
}
return fragment;
}
@Override
public int getCount() {
if (tavern != null && tavern.quest != null && tavern.quest.key != null) {
return 3;
}
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return getContext().getString(R.string.inn);
case 1:
return getContext().getString(R.string.chat);
case 2:
return getContext().getString(R.string.world_quest);
}
return "";
}
});
if (tabLayout != null) {
tabLayout.setupWithViewPager(viewPager);
}
}
@Override
public String customTitle() {
if (!isAdded()) {
return "";
}
return getString(R.string.sidebar_tavern);
}
}

View file

@ -0,0 +1,114 @@
package com.habitrpg.android.habitica.ui.fragments.social
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
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.SocialRepository
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.models.social.Group
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
import kotlinx.android.synthetic.main.fragment_viewpager.*
import rx.functions.Action1
import javax.inject.Inject
class TavernFragment : BaseMainFragment() {
@Inject
lateinit var socialRepository: SocialRepository
internal var tavern: Group? = null
internal var tavernDetailFragment = TavernDetailFragment()
internal var chatListFragment = ChatListFragment()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
this.usesTabLayout = true
hideToolbar()
disableToolbarScrolling()
super.onCreateView(inflater, container, savedInstanceState)
val v = inflater.inflate(R.layout.fragment_viewpager, container, false)
this.tutorialStepIdentifier = "tavern"
this.tutorialText = getString(R.string.tutorial_tavern)
return v
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setViewPagerAdapter()
viewPager.currentItem = 0
compositeSubscription.add(socialRepository.getGroup("habitrpg")?.subscribe(Action1 { group ->
this@TavernFragment.tavern = group
if (group.quest != null && group.quest.key != null && this@TavernFragment.isAdded) {
this@TavernFragment.viewPager.adapter?.notifyDataSetChanged()
this@TavernFragment.tabLayout?.visibility = View.VISIBLE
this@TavernFragment.tabLayout?.setupWithViewPager(this@TavernFragment.viewPager)
}
}, RxErrorHandler.handleEmptyError()))
}
override fun onDestroyView() {
showToolbar()
enableToolbarScrolling()
super.onDestroyView()
}
override fun onDestroy() {
socialRepository.close()
super.onDestroy()
}
override fun injectFragment(component: AppComponent) {
component.inject(this)
}
private fun setViewPagerAdapter() {
val fragmentManager = childFragmentManager
if (this.user == null) {
return
}
viewPager.adapter = object : FragmentPagerAdapter(fragmentManager) {
override fun getItem(position: Int): Fragment {
return when (position) {
0 -> {
tavernDetailFragment
}
1 -> {
chatListFragment.configure("habitrpg", user, true)
chatListFragment
}
else -> Fragment()
}
}
override fun getCount(): Int {
return if (tavern != null && tavern?.quest != null && tavern?.quest?.key != null) {
3
} else 2
}
override fun getPageTitle(position: Int): CharSequence? {
when (position) {
0 -> return context?.getString(R.string.inn)
1 -> return context?.getString(R.string.chat)
2 -> return context?.getString(R.string.world_quest)
}
return ""
}
}
tabLayout?.setupWithViewPager(viewPager)
}
override fun customTitle(): String {
return if (!isAdded) {
""
} else getString(R.string.sidebar_tavern)
}
}

View file

@ -83,14 +83,14 @@ object MainDrawerBuilder {
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())),
//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())),
//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()),
@ -98,7 +98,7 @@ object MainDrawerBuilder {
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())),
//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()),

View file

@ -1,127 +0,0 @@
package com.habitrpg.android.habitica.ui.menu;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.habitrpg.android.habitica.R;
import com.mikepenz.fastadapter.utils.ViewHolderFactory;
import com.mikepenz.materialdrawer.holder.StringHolder;
import com.mikepenz.materialdrawer.model.AbstractDrawerItem;
import com.mikepenz.materialdrawer.model.interfaces.Nameable;
import com.mikepenz.materialdrawer.model.interfaces.Typefaceable;
import java.util.List;
/**
* Created by mikepenz on 03.02.15.
*/
public class SectionIconDrawerItem extends AbstractDrawerItem<SectionIconDrawerItem, SectionIconDrawerItem.ViewHolder> implements Nameable<SectionIconDrawerItem>, Typefaceable<SectionIconDrawerItem> {
private StringHolder name;
private Typeface typeface = null;
public SectionIconDrawerItem withName(StringHolder name) {
this.name = name;
return this;
}
public SectionIconDrawerItem withName(String name) {
this.name = new StringHolder(name);
return this;
}
public SectionIconDrawerItem withName(@StringRes int nameRes) {
this.name = new StringHolder(nameRes);
return this;
}
public SectionIconDrawerItem withTypeface(Typeface typeface) {
this.typeface = typeface;
return this;
}
public StringHolder getName() {
return name;
}
@Override
public boolean isEnabled() {
return false;
}
@Override
public boolean isSelected() {
return false;
}
@Override
public int getType() {
return R.id.material_drawer_item_section;
}
@Override
@LayoutRes
public int getLayoutRes() {
return R.layout.material_drawer_item_section_icon;
}
@Override
public Typeface getTypeface() {
return typeface;
}
@Override
public void bindView(ViewHolder holder, List<Object> payloads) {
super.bindView(holder, payloads);
Context ctx = holder.itemView.getContext();
//set the identifier from the drawerItem here. It can be used to run tests
holder.itemView.setId(hashCode());
//define this item to be not clickable nor enabled
holder.view.setClickable(false);
holder.view.setEnabled(false);
//define the text color
holder.name.setTextColor(ContextCompat.getColor(ctx, R.color.white));
//set the text for the name
StringHolder.applyTo(this.getName(), holder.name);
//define the typeface for our textViews
if (getTypeface() != null) {
holder.name.setTypeface(getTypeface());
}
//call the onPostBindView method to trigger post bind view actions (like the listener to modify the item if required)
onPostBindView(this, holder.itemView);
}
@Override
public ViewHolderFactory<ViewHolder> getFactory() {
return new ItemFactory();
}
public static class ItemFactory implements ViewHolderFactory<ViewHolder> {
public ViewHolder create(View v) {
return new ViewHolder(v);
}
}
protected static class ViewHolder extends RecyclerView.ViewHolder {
private View view;
private TextView name;
private ViewHolder(View view) {
super(view);
this.view = view;
this.name = (TextView) view.findViewById(R.id.material_drawer_name);
}
}
}

View file

@ -0,0 +1,102 @@
package com.habitrpg.android.habitica.ui.views
import android.content.Context
import android.support.v4.content.ContextCompat
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.extensions.bindView
/**
* Created by phillip on 29.01.18.
*/
class CollapsibleSectionView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {
private val titleView: LinearLayout by bindView(R.id.title_view)
private val titleLabel: TextView by bindView(R.id.titleTextView)
private val caretView: ImageView by bindView(R.id.caretView)
private val padding = context?.resources?.getDimension(R.dimen.spacing_large)?.toInt() ?: 0
var title: CharSequence
get() {
return titleLabel.text
}
set(value) {
titleLabel.text = value
}
var isCollapsed = false
set(value) {
field = value
if (value) {
hideViews()
} else {
showViews()
}
}
var caretColor: Int = 0
private fun showViews() {
setCaretImage()
setPadding(0, 0, 0, padding)
(2 until childCount)
.filter { getChildAt(it) != titleView }
.forEach { getChildAt(it).visibility = View.VISIBLE }
}
private fun hideViews() {
setCaretImage()
setPadding(0, 0, 0, 0)
(2 until childCount)
.map { getChildAt(it) }
.forEach {
it.visibility = View.GONE
}
}
private fun setCaretImage() {
caretView.setImageBitmap(HabiticaIconsHelper.imageOfCaret(caretColor, isCollapsed))
}
private fun setChildMargins() {
(2 until childCount)
.map { getChildAt(it) }
.forEach {
val lp = it.layoutParams as LayoutParams
lp.setMargins(padding, 0, padding, padding)
it.layoutParams = lp
}
}
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
super.onLayout(changed, l, t, r, b)
setChildMargins()
}
init {
val thisContext = this.context
if (thisContext != null) {
caretColor = ContextCompat.getColor(thisContext, R.color.black_50_alpha)
}
View.inflate(context, R.layout.view_collapsible_section, this)
orientation = LinearLayout.VERTICAL
titleView.setOnClickListener {
isCollapsed = !isCollapsed
}
val attributes = context?.theme?.obtainStyledAttributes(
attrs,
R.styleable.CollapsibleSectionView,
0, 0)
title = attributes?.getString(R.styleable.CollapsibleSectionView_title) ?: ""
setCaretImage()
setChildMargins()
}
}

View file

@ -486,4 +486,59 @@ public class HabiticaIconsHelper {
return imageOfInfoIcon;
}
public static Bitmap imageOfContributorBadge(float contributorTier, boolean isNPC) {
int size = scaleSize(16);
Bitmap imageOfContributorBadge = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfContributorBadge);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawContributorBadge(canvas, contributorTier, isNPC);
return imageOfContributorBadge;
}
public static Bitmap imageOfChatLikeIcon(boolean wasLiked) {
int size = scaleSize(12);
Bitmap imageOfChatLikeIcon = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfChatLikeIcon);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawChatLikeIcon(canvas, wasLiked);
return imageOfChatLikeIcon;
}
public static Bitmap imageOfQuestBackground(int bossColorDark, int bossColorMedium, int bossColorLight) {
int size = scaleSize(21);
Bitmap imageOfQuestBackground = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfQuestBackground);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawQuestBackground(canvas, bossColorDark, bossColorMedium, bossColorLight);
return imageOfQuestBackground;
}
private static Bitmap imageOfDamage = null;
public static Bitmap imageOfDamage() {
if (imageOfDamage != null)
return imageOfDamage;
int size = scaleSize(18);
imageOfDamage = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfDamage);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawDamage(canvas);
return imageOfDamage;
}
public static Bitmap imageOfCaret(int caretColor, boolean pointsUp) {
int size = scaleSize(16);
Bitmap imageOfCaret = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfCaret);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawCaret(canvas, caretColor, pointsUp);
return imageOfCaret;
}
}

View file

@ -0,0 +1,48 @@
package com.habitrpg.android.habitica.ui.views.social
import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.models.members.PlayerTier
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
class UsernameLabel(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {
private val textView = TextView(context)
private val tierIconView = ImageView(context)
var username: String = ""
set(value) {
textView.text = value
}
var tier: Int = 0
set(value) {
field = value
textView.setTextColor(PlayerTier.getColorForTier(context, value))
when (value) {
0 -> tierIconView.visibility = View.GONE
else -> {
tierIconView.visibility = View.VISIBLE
tierIconView.setImageBitmap(HabiticaIconsHelper.imageOfContributorBadge(value.toFloat(), false))
}
}
}
init {
val params = LinearLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT)
params.gravity = Gravity.CENTER_VERTICAL
addView(textView, params)
val padding = context?.resources?.getDimension(R.dimen.spacing_small)?.toInt() ?: 0
textView.setPadding(0, 0, padding, 0)
addView(tierIconView, params)
}
}

View file

@ -3,7 +3,7 @@
buildscript {
ext.kotlin_version = '1.1.61'
ext.build_tools_version = '26.0.2'
ext.sdk_version = 26
ext.sdk_version = 27
repositories {
jcenter()