mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
Avatar Control, Value Bar Control (HP, MP, XP), new colors
This commit is contained in:
parent
dc1d44dd53
commit
dc6b066b46
9 changed files with 276 additions and 23 deletions
|
|
@ -1,9 +1,10 @@
|
|||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<!-- <solid android:color="#FF0000" /> -->
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="@color/transparent" />
|
||||
|
||||
<stroke android:width="1dip" android:color="#000000"/>
|
||||
<stroke
|
||||
android:width="1dip"
|
||||
android:color="#000000"/>
|
||||
|
||||
</shape>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<shape>
|
||||
|
||||
<solid
|
||||
android:color="@color/habitrpg_red"
|
||||
android:color="@color/hpColor"
|
||||
/>
|
||||
</shape>
|
||||
</clip>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<shape>
|
||||
|
||||
<solid
|
||||
android:color="@color/habitrpg_yellow"
|
||||
android:color="@color/xpColor"
|
||||
/>
|
||||
</shape>
|
||||
</clip>
|
||||
|
|
|
|||
44
Habitica/res/layout/avatar_with_bars.xml
Normal file
44
Habitica/res/layout/avatar_with_bars.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/avatar_with_bars_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="horizontal"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/IMG_ProfilePicture"
|
||||
android:layout_width="@dimen/avatar_width"
|
||||
android:layout_height="@dimen/avatar_height"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:scaleType="fitStart"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/LL_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bar_padding"
|
||||
android:paddingTop="@dimen/bar_padding">
|
||||
|
||||
<include
|
||||
android:id="@+id/hpBar"
|
||||
layout="@layout/value_bar" />
|
||||
|
||||
<include
|
||||
android:id="@+id/xpBar"
|
||||
layout="@layout/value_bar" />
|
||||
|
||||
<include
|
||||
android:id="@+id/mpBar"
|
||||
layout="@layout/value_bar" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
73
Habitica/res/layout/value_bar.xml
Normal file
73
Habitica/res/layout/value_bar.xml
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="text"
|
||||
type="String" />
|
||||
|
||||
<variable
|
||||
name="textColor"
|
||||
type="int" />
|
||||
|
||||
<variable
|
||||
name="weightToShow"
|
||||
type="float" />
|
||||
|
||||
<variable
|
||||
name="weightToHide"
|
||||
type="float" />
|
||||
|
||||
<variable
|
||||
name="barBackgroundColor"
|
||||
type="int" />
|
||||
|
||||
<variable
|
||||
name="barForegroundColor"
|
||||
type="int" />
|
||||
</data>
|
||||
|
||||
<FrameLayout 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="@dimen/bar_size"
|
||||
android:layout_marginBottom="@dimen/bar_padding"
|
||||
android:background="@{barBackgroundColor}">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/border"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="1">
|
||||
|
||||
<View
|
||||
android:id="@+id/V_HPBar"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="@dimen/bar_inner_size"
|
||||
android:layout_margin="2dip"
|
||||
android:layout_weight="1"
|
||||
android:background="@{barForegroundColor}"
|
||||
app:layout_weight="@{weightToShow}" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:padding="2dip"
|
||||
app:layout_weight="@{weightToHide}" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TV_HP"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bar_size"
|
||||
android:background="@drawable/border"
|
||||
android:gravity="center|right"
|
||||
android:paddingRight="5dp"
|
||||
android:textColor="@{textColor}"
|
||||
android:text="@{text}" />
|
||||
</FrameLayout>
|
||||
</layout>
|
||||
|
|
@ -1,29 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="habitrpg_red">#D64040</color>
|
||||
<color name="habitrpg_yellow">#FFCF42</color>
|
||||
<color name="hpColor">#da5353</color>
|
||||
<color name="hpColorBackground">#fcf0f0</color>
|
||||
<color name="hpColorForeground">#250808</color>
|
||||
<color name="xpColor">#ffcc35</color>
|
||||
<color name="xpColorBackground">#fffbf0</color>
|
||||
<color name="xpColorForeground">#2e2200</color>
|
||||
<color name="mpColor">#4781e7</color>
|
||||
<color name="mpColorBackground">#eff4fd</color>
|
||||
<color name="mpColorForeground">#051228</color>
|
||||
|
||||
<!-- HabitRPG task color -->
|
||||
<color name="worst">#E6B8AF</color>
|
||||
<color name="worst_btn">#c96652</color>
|
||||
<color name="worse">#F4CCCC</color>
|
||||
<color name="worse">#F4CCCC</color>
|
||||
<color name="worse_btn">#dc5d5d</color>
|
||||
|
||||
<color name="bad">#FCE5CD</color>
|
||||
<color name="bad">#FCE5CD</color>
|
||||
<color name="bad_btn">#f4a24c</color>
|
||||
|
||||
<color name="neutral">#FFF2CC</color>
|
||||
<color name="neutral">#FFF2CC</color>
|
||||
<color name="neutral_btn">#ffcf42</color>
|
||||
|
||||
<color name="good">#D9EAD3</color>
|
||||
<color name="good">#D9EAD3</color>
|
||||
<color name="good_btn">#8bbf79</color>
|
||||
|
||||
<color name="better">#D0E0E3</color>
|
||||
<color name="better">#D0E0E3</color>
|
||||
<color name="better_btn">#7eaab2</color>
|
||||
|
||||
<color name="best">#C9DAF8</color>
|
||||
<color name="best">#C9DAF8</color>
|
||||
<color name="best_btn">#5288e9</color>
|
||||
|
||||
<color name="completed">#D9D9D9</color>
|
||||
<color name="completed">#D9D9D9</color>
|
||||
<color name="completed_btn">#989898</color>
|
||||
|
||||
<!-- Cards -->
|
||||
|
|
@ -35,17 +43,33 @@
|
|||
<color name="card_grid_text">#ff707070</color>
|
||||
<color name="card_separator">#ffe5e5e5</color>
|
||||
<color name="card_border">#ffdedede</color>
|
||||
|
||||
|
||||
<!-- dialog -->
|
||||
<color name="primary_text_light">#000000</color>
|
||||
<color name="transparent">#00000000</color>
|
||||
|
||||
|
||||
<!-- clock styled weekdays -->
|
||||
<color name="days_gray">#ffb5b5b5</color>
|
||||
<color name="days_black">#FF000000</color>
|
||||
<color name="holo_blue_light">#ff33b5e5</color>
|
||||
<color name="holo_blue_light">#ff33b5e5</color>
|
||||
|
||||
<color name="btn_separator">#aaa</color>
|
||||
<color name="new_task_bar_color">#555555</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="btn_separator">#aaa</color>
|
||||
<color name="new_task_bar_color">#555555</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
|
||||
<!-- MaterialDrawer DEFAULT DARK colors -->
|
||||
<color name="material_drawer_dark_background">#303030</color>
|
||||
<!-- MaterialDrawer DEFAULT DARK text / items colors -->
|
||||
<color name="material_drawer_dark_icons">#000</color>
|
||||
<color name="material_drawer_dark_primary_text">#de9a9a9a</color>
|
||||
<color name="material_drawer_dark_primary_icon">#8AFFFFFF</color>
|
||||
<color name="material_drawer_dark_secondary_text">#de9a9a9a</color>
|
||||
<color name="material_drawer_dark_hint_text">#42FFFFFF</color>
|
||||
<color name="material_drawer_dark_divider">#1FFFFFFF</color>
|
||||
<!-- MaterialDrawer DEFAULT DARK drawer colors -->
|
||||
<color name="material_drawer_dark_selected">#202020</color>
|
||||
<color name="material_drawer_dark_selected_text">@color/material_drawer_primary</color>
|
||||
<color name="material_drawer_dark_header_selection_text">#FFF</color>
|
||||
|
||||
<color name="checkbox_tint_color">#ffd8dcdd</color>
|
||||
</resources>
|
||||
|
|
@ -11,7 +11,8 @@
|
|||
<dimen name="card_small_text">14.0sp</dimen>
|
||||
<dimen name="card_padding">16.0dip</dimen>
|
||||
|
||||
<dimen name="bar_size">25dp</dimen>
|
||||
<dimen name="bar_size">29dp</dimen>
|
||||
<dimen name="bar_inner_size">25dp</dimen>
|
||||
<dimen name="bar_padding">5dp</dimen>
|
||||
<dimen name="avatar_width">90dp</dimen>
|
||||
<dimen name="avatar_height">70dp</dimen>
|
||||
|
|
|
|||
|
|
@ -112,8 +112,9 @@
|
|||
<string name="changelog_close">Close</string>
|
||||
<string name="SP_last_seen_version">SP_last_version</string>
|
||||
<string name="SP_see_changelog">See the changelog</string>
|
||||
<string name="MP_default">MP</string>
|
||||
|
||||
<!-- Premium - ->
|
||||
<!-- Premium - ->
|
||||
<string name="premium_sku">premium</string>
|
||||
<string name="appPublicKey">MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqxsCCpTSRrjW/vQoc1oSjFyaDqVqQIreY1+i5npLKbWbcwovdF4MbyFjIQzRBiGvbxPRYNlApmoDNIeHjr7qJrprsuPwSMThFLRv3unsGJws7/vxdbcp6YTpmyJODk2zSmRvI5OTu+hfB+SESzrfE1K960+mawCI+N7ee5xIg1sEZmV6e8mQ33f+gE3yaivPw6FYBnqSO6V0bq+k6nUyuN5Hk7wQKOXlZ4quJy1IsI/LhGl7ZSxx0fPoMe0QdjZpvW0leEpdXLU0LUpGR0fm2Ui2qj0gJP5OyDwo2EbF7PLDIz0zmisHWpV/vHKljGHCKzBZu46YgQZRn+zueqVjywIDAQAB</string>
|
||||
<string name="adKey">ca-app-pub-3124440915077289/1083610578</string>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
package com.habitrpg.android.habitica.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.databinding.DataBindingUtil;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.databinding.ValueBarBinding;
|
||||
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Stats;
|
||||
|
||||
/**
|
||||
* Created by Negue on 14.06.2015.
|
||||
*/
|
||||
public class AvatarWithBarsViewModel {
|
||||
ValueBarBinding hpBar;
|
||||
ValueBarBinding xpBar;
|
||||
ValueBarBinding mpBar;
|
||||
|
||||
ImageView image;
|
||||
|
||||
android.content.res.Resources res;
|
||||
|
||||
private Context context;
|
||||
|
||||
public AvatarWithBarsViewModel(Context context, View v){
|
||||
this.context = context;
|
||||
|
||||
res = context.getResources();
|
||||
|
||||
if(v == null)
|
||||
{
|
||||
Log.w("AvatarWithBarsViewModel", "View is null");
|
||||
return;
|
||||
}
|
||||
|
||||
//binding = DataBindingUtil.bind(v);
|
||||
|
||||
View hpBarView = v.findViewById(R.id.hpBar);
|
||||
|
||||
image = (ImageView) v.findViewById(R.id.IMG_ProfilePicture);
|
||||
|
||||
hpBar = DataBindingUtil.bind(hpBarView);
|
||||
xpBar = DataBindingUtil.bind(v.findViewById(R.id.xpBar));
|
||||
mpBar = DataBindingUtil.bind(v.findViewById(R.id.mpBar));
|
||||
|
||||
|
||||
SetValueBar(hpBar, 50, 50, context.getString(R.string.HP_default),
|
||||
res.getColor(R.color.hpColor), res.getColor(R.color.hpColorBackground), res.getColor(R.color.hpColorForeground));
|
||||
SetValueBar(xpBar, 1, 1, context.getString(R.string.XP_default),
|
||||
res.getColor(R.color.xpColor), res.getColor(R.color.xpColorBackground), res.getColor(R.color.xpColorForeground));
|
||||
SetValueBar(mpBar, 100, 100, context.getString(R.string.MP_default),
|
||||
res.getColor(R.color.mpColor), res.getColor(R.color.mpColorBackground),res.getColor(R.color.mpColorForeground));
|
||||
|
||||
}
|
||||
|
||||
public void UpdateData(HabitRPGUser user)
|
||||
{
|
||||
Stats stats = user.getStats();
|
||||
|
||||
SetValueBar(hpBar, stats.getHp().floatValue(), stats.getMaxHealth(), context.getString(R.string.HP_default),
|
||||
res.getColor(R.color.hpColor), res.getColor(R.color.hpColorBackground), res.getColor(R.color.hpColorForeground));
|
||||
SetValueBar(xpBar, stats.getExp().floatValue(), stats.getToNextLevel()+stats.getExp().floatValue(), context.getString(R.string.XP_default),
|
||||
res.getColor(R.color.xpColor), res.getColor(R.color.xpColorBackground), res.getColor(R.color.xpColorForeground));
|
||||
SetValueBar(mpBar, stats.getMp().floatValue(), stats.getMaxMP(), context.getString(R.string.MP_default),
|
||||
res.getColor(R.color.mpColor), res.getColor(R.color.mpColorBackground),res.getColor(R.color.mpColorForeground));
|
||||
|
||||
image.setImageBitmap(new UserPicture(user, context).draw());
|
||||
}
|
||||
|
||||
// Layout_Weight don't accepts 0.7/0.3 to have 70% filled instead it shows the 30% , so I had to switch the values
|
||||
// but on a 1.0/0.0 which switches to 0.0/1.0 it shows the blank part full size...
|
||||
private void SetValueBar(ValueBarBinding valueBar, float value, float valueMax, String postString, int color, int colorBackground, int textColor)
|
||||
{
|
||||
double percent = value / valueMax;
|
||||
|
||||
if(percent == 1)
|
||||
{
|
||||
valueBar.setWeightToShow(1);
|
||||
valueBar.setWeightToHide(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
valueBar.setWeightToShow((float) (1 - percent));
|
||||
valueBar.setWeightToHide((float) percent);
|
||||
}
|
||||
|
||||
valueBar.setText((int) value + "/" + (int) valueMax + " " + postString);
|
||||
valueBar.setBarForegroundColor(color);
|
||||
valueBar.setBarBackgroundColor(colorBackground);
|
||||
valueBar.setTextColor(textColor);
|
||||
}
|
||||
|
||||
@BindingAdapter("app:layout_weight")
|
||||
public static void setLayoutWeight(View view, float weight) {
|
||||
LinearLayout.LayoutParams layout = (LinearLayout.LayoutParams)view.getLayoutParams();
|
||||
|
||||
Log.d("setLayoutWeight", weight+"");
|
||||
|
||||
layout.weight = weight;
|
||||
|
||||
view.setLayoutParams(layout);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue