Improve currency display
BIN
Habitica/res/drawable-hdpi/currency_gem.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Habitica/res/drawable-hdpi/currency_gold.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Habitica/res/drawable-hdpi/currency_hourglass.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 992 B |
BIN
Habitica/res/drawable-hdpi/item_count_bubble.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Habitica/res/drawable-hdpi/item_limited_bubble.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
Habitica/res/drawable-hdpi/item_locked_bubble.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
Habitica/res/drawable-hdpi/item_pinned.png
Normal file
|
After Width: | Height: | Size: 784 B |
BIN
Habitica/res/drawable-hdpi/shop_gem.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Habitica/res/drawable-mdpi/currency_gem.png
Normal file
|
After Width: | Height: | Size: 743 B |
BIN
Habitica/res/drawable-mdpi/currency_gold.png
Normal file
|
After Width: | Height: | Size: 766 B |
BIN
Habitica/res/drawable-mdpi/currency_hourglass.png
Normal file
|
After Width: | Height: | Size: 850 B |
|
Before Width: | Height: | Size: 701 B |
|
Before Width: | Height: | Size: 716 B |
|
Before Width: | Height: | Size: 620 B |
BIN
Habitica/res/drawable-mdpi/item_count_bubble.png
Normal file
|
After Width: | Height: | Size: 862 B |
BIN
Habitica/res/drawable-mdpi/item_limited_bubble.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Habitica/res/drawable-mdpi/item_locked_bubble.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
Habitica/res/drawable-mdpi/item_pinned.png
Normal file
|
After Width: | Height: | Size: 537 B |
BIN
Habitica/res/drawable-mdpi/shop_empty_hourglass.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
Habitica/res/drawable-mdpi/shop_empty_seasonal.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Habitica/res/drawable-mdpi/shop_gem.png
Normal file
|
After Width: | Height: | Size: 527 B |
BIN
Habitica/res/drawable-xhdpi/currency_gem.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Habitica/res/drawable-xhdpi/currency_gold.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
Habitica/res/drawable-xhdpi/currency_hourglass.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
BIN
Habitica/res/drawable-xhdpi/item_count_bubble.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
Habitica/res/drawable-xhdpi/item_limited_bubble.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
Habitica/res/drawable-xhdpi/item_locked_bubble.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
Habitica/res/drawable-xhdpi/item_pinned.png
Normal file
|
After Width: | Height: | Size: 1,003 B |
BIN
Habitica/res/drawable-xhdpi/shop_empty_hourglass.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
Habitica/res/drawable-xhdpi/shop_empty_seasonal.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
Habitica/res/drawable-xhdpi/shop_gem.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Habitica/res/drawable-xxhdpi/currency_gem.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Habitica/res/drawable-xxhdpi/currency_gold.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
Habitica/res/drawable-xxhdpi/currency_hourglass.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2 KiB |
BIN
Habitica/res/drawable-xxhdpi/item_count_bubble.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
Habitica/res/drawable-xxhdpi/item_limited_bubble.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
Habitica/res/drawable-xxhdpi/item_locked_bubble.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
Habitica/res/drawable-xxhdpi/item_pinned.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
Habitica/res/drawable-xxhdpi/shop_gem.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/gray_600" />
|
||||
<solid android:color="@color/gray_600_30" />
|
||||
<corners android:bottomLeftRadius="6dp" android:bottomRightRadius="6dp"/>
|
||||
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
|
||||
</shape>
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:src="@drawable/ic_header_gem"
|
||||
android:src="@drawable/currency_gem"
|
||||
android:layout_marginRight="5dp"/>
|
||||
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@
|
|||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_header_gem" />
|
||||
android:src="@drawable/currency_gem" />
|
||||
|
||||
<EditText
|
||||
style="@style/Subheader2"
|
||||
|
|
|
|||
|
|
@ -107,47 +107,10 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<LinearLayout
|
||||
<com.habitrpg.android.habitica.ui.views.CurrencyView
|
||||
android:id="@+id/currencyView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gems_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:drawableLeft="@drawable/ic_header_gem"
|
||||
android:drawablePadding="8dp"
|
||||
android:drawableStart="@drawable/ic_header_gem"
|
||||
android:gravity="center"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gold_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:drawableLeft="@drawable/ic_header_gold"
|
||||
android:drawablePadding="6dp"
|
||||
android:drawableStart="@drawable/ic_header_gold"
|
||||
android:gravity="center"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/silver_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:drawableLeft="@drawable/ic_header_silver"
|
||||
android:drawablePadding="6dp"
|
||||
android:drawableStart="@drawable/ic_header_silver"
|
||||
android:gravity="center"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,33 @@
|
|||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/Theme.AppCompat.Light" />
|
||||
app:popupTheme="@style/Theme.AppCompat.Light">
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
|
||||
tools:text="Habitica"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar_accessory_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
|
|
|
|||
|
|
@ -87,51 +87,9 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
<LinearLayout
|
||||
<com.habitrpg.android.habitica.ui.views.CurrencyView
|
||||
android:id="@+id/currencyView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gems_tv"
|
||||
android:drawableLeft="@drawable/ic_header_gem"
|
||||
android:drawableStart="@drawable/ic_header_gem"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gold_tv"
|
||||
android:drawableLeft="@drawable/ic_header_gold"
|
||||
android:drawableStart="@drawable/ic_header_gold"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/silver_tv"
|
||||
android:drawableLeft="@drawable/ic_header_silver"
|
||||
android:drawableStart="@drawable/ic_header_silver"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<ImageView
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:src="@drawable/ic_header_gem" />
|
||||
android:src="@drawable/currency_gem" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
|||
36
Habitica/res/layout/currency_view.xml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/hourglassTextView"
|
||||
android:drawableLeft="@drawable/currency_hourglass"
|
||||
android:drawableStart="@drawable/currency_hourglass"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
style="@style/CurrencyTextView"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/gemTextView"
|
||||
android:drawableLeft="@drawable/currency_gem"
|
||||
android:drawableStart="@drawable/currency_gem"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
style="@style/CurrencyTextView"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/goldTextView"
|
||||
android:drawableLeft="@drawable/currency_gold"
|
||||
android:drawableStart="@drawable/currency_gold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
style="@style/CurrencyTextView"
|
||||
/>
|
||||
</merge>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
android:layout_marginRight="15.5dp"
|
||||
android:layout_marginStart="14.5dp"
|
||||
android:layout_marginTop="18dp"
|
||||
android:src="@drawable/ic_header_gold"
|
||||
android:src="@drawable/currency_gold"
|
||||
/>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/imageButton"
|
||||
android:src="@drawable/ic_header_gem"
|
||||
android:src="@drawable/currency_gem"
|
||||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
android:layout_marginLeft="8dp"/>
|
||||
<ImageView
|
||||
style="@style/welcome_floating_icon"
|
||||
android:src="@drawable/ic_header_gold"
|
||||
android:src="@drawable/currency_gold"
|
||||
android:layout_below="@id/heart_icon"
|
||||
android:layout_toLeftOf="@id/exp_icon"
|
||||
android:layout_marginRight="33dp"
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
/>
|
||||
<ImageView
|
||||
style="@style/welcome_floating_icon"
|
||||
android:src="@drawable/ic_header_gem"
|
||||
android:src="@drawable/currency_gem"
|
||||
android:layout_below="@id/magic_icon"
|
||||
android:layout_toRightOf="@id/exp_icon"
|
||||
android:layout_marginLeft="33dp"
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@
|
|||
android:gravity="left|center_vertical"
|
||||
android:drawablePadding="5dp"
|
||||
android:background="@drawable/rounded_purple_square"
|
||||
android:drawableLeft="@drawable/ic_header_gold"
|
||||
android:drawableStart="@drawable/ic_header_gold"
|
||||
android:drawableLeft="@drawable/currency_gold"
|
||||
android:drawableStart="@drawable/currency_gold"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingRight="12dp"
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:background="@color/white">
|
||||
<ImageView
|
||||
android:layout_width="@dimen/shopitem_status_size"
|
||||
android:layout_height="@dimen/shopitem_status_size"
|
||||
android:layout_gravity="right"/>
|
||||
<LinearLayout
|
||||
android:layout_margin="4dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/layout_rounded_bg_shopitem">
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/imageView"
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
android:id="@+id/currency_icon_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
tools:src="@drawable/ic_header_gold"/>
|
||||
tools:src="@drawable/currency_gold"/>
|
||||
<TextView
|
||||
android:id="@+id/priceLabel"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -41,9 +41,31 @@
|
|||
android:textColor="@color/gray_300"
|
||||
tools:text="150"
|
||||
android:layout_marginLeft="6dp"
|
||||
style="@style/Body1"
|
||||
android:textSize="15sp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/item_limited_icon"
|
||||
android:layout_width="@dimen/shopitem_status_size"
|
||||
android:layout_height="@dimen/shopitem_status_size"
|
||||
android:src="@drawable/item_limited_bubble"
|
||||
android:layout_gravity="right"
|
||||
android:visibility="gone"/>
|
||||
<ImageView
|
||||
android:id="@+id/item_locked_icon"
|
||||
android:layout_width="@dimen/shopitem_status_size"
|
||||
android:layout_height="@dimen/shopitem_status_size"
|
||||
android:src="@drawable/item_locked_bubble"
|
||||
android:layout_gravity="right"
|
||||
android:visibility="gone"/>
|
||||
<TextView
|
||||
android:id="@+id/item_count_icon"
|
||||
android:layout_width="@dimen/shopitem_status_size"
|
||||
android:layout_height="@dimen/shopitem_status_size"
|
||||
android:background="@drawable/item_count_bubble"
|
||||
android:layout_gravity="right"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -217,46 +217,33 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hourglasses_tv"
|
||||
android:drawableLeft="@drawable/currency_hourglass"
|
||||
android:drawableStart="@drawable/currency_hourglass"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
style="@style/CurrencyTextView"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/gems_tv"
|
||||
android:drawableLeft="@drawable/ic_header_gem"
|
||||
android:drawableStart="@drawable/ic_header_gem"
|
||||
android:drawableLeft="@drawable/currency_gem"
|
||||
android:drawableStart="@drawable/currency_gem"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
style="@style/CurrencyTextView"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gold_tv"
|
||||
android:drawableLeft="@drawable/ic_header_gold"
|
||||
android:drawableStart="@drawable/ic_header_gold"
|
||||
android:drawableLeft="@drawable/currency_gold"
|
||||
android:drawableStart="@drawable/currency_gold"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/silver_tv"
|
||||
android:drawableLeft="@drawable/ic_header_silver"
|
||||
android:drawableStart="@drawable/ic_header_silver"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center"
|
||||
android:drawablePadding="6dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/textColorSecondaryDark"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
style="@style/CurrencyTextView"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
<color name="gray_600">#edecee</color>
|
||||
<color name="gray_700">#f9f9f9</color>
|
||||
|
||||
<color name="gray_600_30">#4cedecee</color>
|
||||
|
||||
<color name="completed">#D9D9D9</color>
|
||||
<color name="completed_btn">#989898</color>
|
||||
|
||||
|
|
|
|||
|
|
@ -624,4 +624,7 @@
|
|||
<string name="quest_abort_message">Are you sure you want to abort this mission? It will abort it for everyone in your party and all progress will be lost. The quest scroll will be returned to the quest owner.</string>
|
||||
<string name="loading">Loading...</string>
|
||||
<string name="reloading_content">Reloading Content</string>
|
||||
<string name="thousand_abbrev">k</string>
|
||||
<string name="million_abbrev">m</string>
|
||||
<string name="billion_abbrev">b</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -392,4 +392,11 @@
|
|||
<style name="HabiticaButton.Yellow" parent="HabiticaButton">
|
||||
<item name="android:background">@drawable/layout_rounded_bg_yellow</item>
|
||||
</style>
|
||||
|
||||
<style name="CurrencyTextView">
|
||||
<item name="android:textSize">14sp</item>
|
||||
<item name="android:layout_marginLeft">16dp</item>
|
||||
<item name="android:drawablePadding">4dp</item>
|
||||
<item name="android:gravity">center</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class NumberAbbreviator {
|
||||
|
||||
public static String abbreviate(Context context, double number) {
|
||||
int counter = 0;
|
||||
while (number >= 1000) {
|
||||
counter++;
|
||||
number = number / 1000;
|
||||
}
|
||||
|
||||
DecimalFormat formatter = new DecimalFormat("###.##"+abbreviationForCounter(context, counter));
|
||||
return formatter.format(number);
|
||||
}
|
||||
|
||||
|
||||
private static String abbreviationForCounter(Context context, int counter) {
|
||||
switch (counter) {
|
||||
case 0:
|
||||
return "";
|
||||
case 1:
|
||||
return context.getString(R.string.thousand_abbrev);
|
||||
case 2:
|
||||
return context.getString(R.string.million_abbrev);
|
||||
case 3:
|
||||
return context.getString(R.string.billion_abbrev);
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,4 +30,6 @@ public interface Avatar {
|
|||
Flags getFlags();
|
||||
|
||||
Integer getGemCount();
|
||||
|
||||
Integer getHourglassCount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,6 +148,11 @@ public class Member extends RealmObject implements Avatar {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getHourglassCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setFlags(Flags flags) {
|
||||
this.flags = flags;
|
||||
if (flags != null && id != null) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ public class ShopItem {
|
|||
@SerializedName("class")
|
||||
public String imageName;
|
||||
public Integer value;
|
||||
public Boolean locked;
|
||||
public boolean locked;
|
||||
public boolean limited;
|
||||
public String currency;
|
||||
public String purchaseType;
|
||||
public String categoryIdentifier;
|
||||
|
|
@ -79,9 +80,6 @@ public class ShopItem {
|
|||
}
|
||||
|
||||
public Boolean getLocked() {
|
||||
if (locked == null) {
|
||||
return false;
|
||||
}
|
||||
return locked;
|
||||
}
|
||||
|
||||
|
|
@ -138,4 +136,8 @@ public class ShopItem {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLimited() {
|
||||
return limited;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,6 +191,14 @@ public class User extends RealmObject implements Avatar {
|
|||
return (int)(this.balance * 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getHourglassCount() {
|
||||
if (getPurchased() != null) {
|
||||
return getPurchased().getPlan().consecutive.getTrinkets();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setBalance(double balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.habitrpg.android.habitica.events.commands.OpenMenuItemCommand;
|
|||
import com.habitrpg.android.habitica.models.Avatar;
|
||||
import com.habitrpg.android.habitica.models.user.Stats;
|
||||
import com.habitrpg.android.habitica.ui.menu.MainDrawerBuilder;
|
||||
import com.habitrpg.android.habitica.ui.views.CurrencyView;
|
||||
import com.habitrpg.android.habitica.ui.views.ValueBar;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
|
@ -25,8 +26,9 @@ import java.util.Locale;
|
|||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class AvatarWithBarsViewModel implements View.OnClickListener {
|
||||
public class AvatarWithBarsViewModel {
|
||||
@BindView(R.id.hpBar)
|
||||
ValueBar hpBar;
|
||||
@BindView(R.id.xpBar)
|
||||
|
|
@ -42,12 +44,8 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
|
||||
@BindView(R.id.lvl_tv)
|
||||
TextView lvlText;
|
||||
@BindView(R.id.gold_tv)
|
||||
TextView goldText;
|
||||
@BindView(R.id.silver_tv)
|
||||
TextView silverText;
|
||||
@BindView(R.id.gems_tv)
|
||||
TextView gemsText;
|
||||
@BindView(R.id.currencyView)
|
||||
CurrencyView currencyView;
|
||||
|
||||
private Avatar userObject;
|
||||
|
||||
|
|
@ -68,12 +66,6 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
setHpBarData(0, 50);
|
||||
setXpBarData(0, 1);
|
||||
setMpBarData(0, 1);
|
||||
|
||||
gemsText.setClickable(true);
|
||||
gemsText.setOnClickListener(this);
|
||||
|
||||
avatarView.setClickable(true);
|
||||
avatarView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
|
|
@ -83,8 +75,6 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
Stats stats = user.getStats();
|
||||
|
||||
String userClass = "";
|
||||
int gp = (stats.getGp().intValue());
|
||||
int sp = (int) ((stats.getGp() - gp) * 100);
|
||||
|
||||
avatarView.setAvatar(user);
|
||||
|
||||
|
|
@ -128,11 +118,9 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
setXpBarData(stats.getExp().floatValue(), stats.getToNextLevel());
|
||||
setMpBarData(stats.getMp().floatValue(), stats.getMaxMP());
|
||||
|
||||
goldText.setText(String.valueOf(gp));
|
||||
silverText.setText(String.valueOf(sp));
|
||||
|
||||
Integer gems = user.getGemCount();
|
||||
gemsText.setText(String.valueOf(gems));
|
||||
currencyView.setHourglasses(user.getHourglassCount());
|
||||
currencyView.setGold(stats.getGp());
|
||||
currencyView.setGems(user.getGemCount());
|
||||
}
|
||||
|
||||
private void setHpBarData(float value, int valueMax) {
|
||||
|
|
@ -166,25 +154,19 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
public void onEvent(BoughtGemsEvent gemsEvent) {
|
||||
Integer gems = userObject.getGemCount();
|
||||
gems += gemsEvent.NewGemsToAdd;
|
||||
gemsText.setText(String.valueOf(gems));
|
||||
currencyView.setGems(gems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view == gemsText) {
|
||||
// Gems Clicked
|
||||
|
||||
EventBus.getDefault().post(new OpenGemPurchaseFragmentCommand());
|
||||
} else {
|
||||
// Avatar overview
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_AVATAR;
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
@OnClick(R.id.gemTextView)
|
||||
public void gemTextClicked() {
|
||||
EventBus.getDefault().post(new OpenGemPurchaseFragmentCommand());
|
||||
}
|
||||
|
||||
public void hideGems() {
|
||||
gemsText.setVisibility(View.GONE);
|
||||
@OnClick(R.id.avatarView)
|
||||
public void avatarViewClicked() {
|
||||
OpenMenuItemCommand event = new OpenMenuItemCommand();
|
||||
event.identifier = MainDrawerBuilder.SIDEBAR_AVATAR;
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
|
||||
public void valueBarLabelsToBlack() {
|
||||
|
|
|
|||
|
|
@ -92,10 +92,10 @@ public class ItemDetailDialog extends AlertDialog {
|
|||
public void setCurrency(String currency) {
|
||||
switch (currency) {
|
||||
case "gold":
|
||||
currencyImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_header_gold));
|
||||
currencyImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.currency_gold));
|
||||
break;
|
||||
case "gems":
|
||||
currencyImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_header_gem));
|
||||
currencyImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.currency_gem));
|
||||
break;
|
||||
default:
|
||||
currencyImageView.setImageDrawable(null);
|
||||
|
|
|
|||
|
|
@ -142,7 +142,6 @@ public class FullProfileActivity extends BaseActivity {
|
|||
socialRepository.getMember(this.userId).subscribe(this::updateView, RxErrorHandler.handleEmptyError());
|
||||
|
||||
avatarWithBars = new AvatarWithBarsViewModel(this, avatar_with_bars);
|
||||
avatarWithBars.hideGems();
|
||||
avatarWithBars.valueBarLabelsToBlack();
|
||||
|
||||
avatar_with_bars.setBackgroundColor(ContextCompat.getColor(this, R.color.transparent));
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import android.view.ViewGroup;
|
|||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
|
|
@ -153,6 +154,10 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
AppBarLayout appBar;
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.toolbar_accessory_container)
|
||||
FrameLayout toolbarAccessoryContainer;
|
||||
@BindView(R.id.toolbar_title)
|
||||
TextView toolbarTitleTextView;
|
||||
@BindView(R.id.collapsing_toolbar)
|
||||
CollapsingToolbarLayout collapsingToolbar;
|
||||
@BindView(R.id.detail_tabs)
|
||||
|
|
@ -346,6 +351,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
fragment.setUser(user);
|
||||
fragment.setActivity(this);
|
||||
fragment.setTabLayout(detail_tabs);
|
||||
fragment.setToolbarAccessoryContainer(toolbarAccessoryContainer);
|
||||
fragment.setCollapsingToolbar(collapsingToolbar);
|
||||
fragment.setBottomNavigation(bottomNavigation);
|
||||
fragment.setFloatingMenuWrapper(floatingMenuWrapper);
|
||||
|
|
@ -505,9 +511,9 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
return;
|
||||
}
|
||||
if (fragment != null && fragment.customTitle() != null) {
|
||||
getSupportActionBar().setTitle(fragment.customTitle());
|
||||
toolbarTitleTextView.setText(fragment.customTitle());
|
||||
} else if (user != null && user.getProfile() != null) {
|
||||
getSupportActionBar().setTitle(user.getProfile().getName());
|
||||
toolbarTitleTextView.setText(user.getProfile().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
@BindView(R.id.priceLabel)
|
||||
TextView priceLabel;
|
||||
|
||||
@BindView(R.id.item_limited_icon)
|
||||
ImageView itemLimitedIcon;
|
||||
@BindView(R.id.item_locked_icon)
|
||||
ImageView itemLockedIcon;
|
||||
@BindView(R.id.item_count_icon)
|
||||
TextView itemCountView;
|
||||
|
||||
String shopIdentifier;
|
||||
ShopItem item;
|
||||
|
|
@ -160,21 +166,33 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
if (item.getUnlockCondition() == null) {
|
||||
priceLabel.setText(item.getValue().toString());
|
||||
if (item.getCurrency().equals("gold")) {
|
||||
currencyIconView.setImageResource(R.drawable.ic_header_gold);
|
||||
currencyIconView.setImageResource(R.drawable.currency_gold);
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.gold));
|
||||
} else if (item.getCurrency().equals("gems")) {
|
||||
currencyIconView.setImageResource(R.drawable.ic_header_gem);
|
||||
currencyIconView.setImageResource(R.drawable.currency_gem);
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.good_10));
|
||||
} else {
|
||||
buyButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.isLimited()) {
|
||||
itemLimitedIcon.setVisibility(View.VISIBLE);
|
||||
itemCountView.setVisibility(View.GONE);
|
||||
itemLockedIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
itemLimitedIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (item.getLocked()) {
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.gray_300));
|
||||
currencyIconView.setAlpha(0.5f);
|
||||
itemLockedIcon.setVisibility(View.VISIBLE);
|
||||
itemCountView.setVisibility(View.GONE);
|
||||
itemLimitedIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
currencyIconView.setAlpha(1.0f);
|
||||
itemLockedIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -204,6 +222,7 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
@BindView(R.id.descriptionView)
|
||||
public TextView descriptionView;
|
||||
|
||||
|
||||
ShopHeaderViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.habitrpg.android.habitica.data.ApiClient;
|
||||
import com.habitrpg.android.habitica.data.UserRepository;
|
||||
|
|
@ -35,6 +36,8 @@ public abstract class BaseMainFragment extends BaseFragment {
|
|||
@Nullable
|
||||
private CollapsingToolbarLayout collapsingToolbar;
|
||||
@Nullable
|
||||
protected FrameLayout toolbarAccessoryContainer;
|
||||
@Nullable
|
||||
public BottomBar bottomNavigation;
|
||||
public ViewGroup floatingMenuWrapper;
|
||||
public boolean usesTabLayout;
|
||||
|
|
@ -174,4 +177,8 @@ public abstract class BaseMainFragment extends BaseFragment {
|
|||
public void setCollapsingToolbar(@Nullable CollapsingToolbarLayout collapsingToolbar) {
|
||||
this.collapsingToolbar = collapsingToolbar;
|
||||
}
|
||||
|
||||
public void setToolbarAccessoryContainer(FrameLayout toolbarAccessoryContainer) {
|
||||
this.toolbarAccessoryContainer = toolbarAccessoryContainer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,35 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.inventory.shops;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
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.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
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.models.shops.Shop;
|
||||
import com.habitrpg.android.habitica.models.user.User;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
|
||||
import com.habitrpg.android.habitica.ui.views.CurrencyView;
|
||||
|
||||
public class ShopsFragment extends BaseMainFragment {
|
||||
|
||||
public ViewPager viewPager;
|
||||
private CurrencyView currencyView;
|
||||
|
||||
@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);
|
||||
|
||||
|
|
@ -33,6 +42,26 @@ public class ShopsFragment extends BaseMainFragment {
|
|||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
currencyView = new CurrencyView(getContext());
|
||||
if (toolbarAccessoryContainer != null) {
|
||||
toolbarAccessoryContainer.addView(currencyView);
|
||||
}
|
||||
updateCurrencyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
if (toolbarAccessoryContainer != null) {
|
||||
toolbarAccessoryContainer.removeView(currencyView);
|
||||
}
|
||||
showToolbar();
|
||||
enableToolbarScrolling();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectFragment(AppComponent component) {
|
||||
component.inject(this);
|
||||
|
|
@ -107,4 +136,18 @@ public class ShopsFragment extends BaseMainFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserData(User user) {
|
||||
super.updateUserData(user);
|
||||
updateCurrencyView();
|
||||
}
|
||||
|
||||
private void updateCurrencyView() {
|
||||
if (user == null || currencyView == null) {
|
||||
return;
|
||||
}
|
||||
currencyView.setGold(user.getStats().getGp());
|
||||
currencyView.setGems(user.getGemCount());
|
||||
currencyView.setHourglasses(user.getHourglassCount());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package com.habitrpg.android.habitica.ui.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.helpers.NumberAbbreviator;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class CurrencyView extends LinearLayout {
|
||||
|
||||
@BindView(R.id.hourglassTextView)
|
||||
TextView hourglassTextView;
|
||||
@BindView(R.id.gemTextView)
|
||||
TextView gemTextView;
|
||||
@BindView(R.id.goldTextView)
|
||||
TextView goldTextView;
|
||||
|
||||
public CurrencyView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setupView();
|
||||
}
|
||||
|
||||
public CurrencyView(Context context) {
|
||||
super(context);
|
||||
setupView();
|
||||
}
|
||||
|
||||
private void setupView() {
|
||||
inflate(getContext(), R.layout.currency_view, this);
|
||||
|
||||
ButterKnife.bind(this, this);
|
||||
}
|
||||
|
||||
public void setGold(Double gold) {
|
||||
goldTextView.setText(NumberAbbreviator.abbreviate(getContext(), gold));
|
||||
}
|
||||
|
||||
public void setGems(Integer gemCount) {
|
||||
gemTextView.setText(String.valueOf(gemCount));
|
||||
gemTextView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void setHourglasses(Integer hourglassCount) {
|
||||
hourglassTextView.setText(String.valueOf(hourglassCount));
|
||||
if (hourglassCount > 0) {
|
||||
hourglassTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
hourglassTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import android.widget.RemoteViews;
|
|||
import com.habitrpg.android.habitica.HabiticaBaseApplication;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.data.UserRepository;
|
||||
import com.habitrpg.android.habitica.helpers.NumberAbbreviator;
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler;
|
||||
import com.habitrpg.android.habitica.models.user.User;
|
||||
import com.habitrpg.android.habitica.models.user.Stats;
|
||||
|
|
@ -95,11 +96,15 @@ public class AvatarStatsWidgetProvider extends BaseWidgetProvider {
|
|||
remoteViews.setProgressBar(R.id.mp_bar, stats.getMaxMP(), stats.getMp().intValue(), false);
|
||||
remoteViews.setViewVisibility(R.id.mp_wrapper, (stats.getHabitClass() == null || stats.getLvl() < 10 || user.getPreferences().getDisableClasses()) ? View.GONE : View.VISIBLE);
|
||||
|
||||
int gp = (stats.getGp().intValue());
|
||||
int sp = (int) ((stats.getGp() - gp) * 100);
|
||||
remoteViews.setTextViewText(R.id.gold_tv, String.valueOf(gp));
|
||||
remoteViews.setTextViewText(R.id.silver_tv, String.valueOf(sp));
|
||||
remoteViews.setTextViewText(R.id.gold_tv, NumberAbbreviator.abbreviate(context, stats.getGp()));
|
||||
remoteViews.setTextViewText(R.id.gems_tv, String.valueOf((int) (user.getBalance() * 4)));
|
||||
int hourGlassCount = user.getHourglassCount();
|
||||
if (hourGlassCount == 0) {
|
||||
remoteViews.setViewVisibility(R.id.hourglasses_tv, View.GONE);
|
||||
} else {
|
||||
remoteViews.setTextViewText(R.id.hourglasses_tv, String.valueOf(hourGlassCount));
|
||||
remoteViews.setViewVisibility(R.id.hourglasses_tv, View.VISIBLE);
|
||||
}
|
||||
remoteViews.setTextViewText(R.id.lvl_tv, context.getString(R.string.user_level, user.getStats().getLvl()));
|
||||
|
||||
AvatarView avatarView = new AvatarView(context, true, true, true);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
@Config(constants = BuildConfig.class)
|
||||
@RunWith(value = RobolectricTestRunner.class)
|
||||
public class NumberAbbreviatorTest {
|
||||
|
||||
private Context context;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
context = RuntimeEnvironment.application;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatItDoesntAbbreviatesSmallNumbers() {
|
||||
assertEquals("215", NumberAbbreviator.abbreviate(context, 215));
|
||||
assertEquals("2.05", NumberAbbreviator.abbreviate(context, 2.05));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatItAbbreviatesThousand() {
|
||||
assertEquals("1.55k", NumberAbbreviator.abbreviate(context, 1550));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatItAbbreviatesMillion() {
|
||||
assertEquals("9.99m", NumberAbbreviator.abbreviate(context, 9990000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatItAbbreviatesBillion() {
|
||||
assertEquals("1.99b", NumberAbbreviator.abbreviate(context, 1990000000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatItAbbreviatesThousandWithoutAdditionalDecimals() {
|
||||
assertEquals("1k", NumberAbbreviator.abbreviate(context, 1000));
|
||||
assertEquals("1.5k", NumberAbbreviator.abbreviate(context, 1500));
|
||||
}
|
||||
|
||||
}
|
||||