assign attribute points

This commit is contained in:
Phillip Thelen 2017-10-17 21:23:06 +02:00
parent c5b77cd59f
commit 438ebb2201
24 changed files with 725 additions and 76 deletions

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/gray_100"/>
<corners android:radius="200dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>

View file

@ -4,6 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="@color/md_grey_500"
android:scrollbars="vertical"
@ -14,12 +15,36 @@
android:layout_height="match_parent"
android:paddingTop="12dp"
android:paddingBottom="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:id="@+id/leftSparklesView"
android:layout_width="77dp"
android:layout_height="24dp"
android:scaleType="fitCenter"/>
<TextView
android:id="@+id/numberOfPointsTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="24dp"/>
<ImageView
android:id="@+id/rightSparklesView"
android:layout_width="77dp"
android:layout_height="24dp"
android:scaleType="fitCenter"/>
</LinearLayout>
<com.habitrpg.android.habitica.ui.views.StatsView
android:id="@+id/strengthStatsView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:statsTitle="@string/strength"
app:titleBackgroundColor="@color/red_50"
app:statsColor="@color/red_10"
android:layout_marginBottom="12dp"/>
<com.habitrpg.android.habitica.ui.views.StatsView
android:id="@+id/intelligenceStatsView"
@ -27,6 +52,7 @@
android:layout_height="wrap_content"
app:statsTitle="@string/intelligence"
app:titleBackgroundColor="@color/blue_50"
app:statsColor="@color/blue_10"
android:layout_marginBottom="12dp"/>
<com.habitrpg.android.habitica.ui.views.StatsView
android:id="@+id/constitutionStatsView"
@ -34,6 +60,7 @@
android:layout_height="wrap_content"
app:statsTitle="@string/constitution"
app:titleBackgroundColor="@color/yellow_10"
app:statsColor="@color/yellow_5"
android:layout_marginBottom="12dp"/>
<com.habitrpg.android.habitica.ui.views.StatsView
android:id="@+id/perceptionStatsView"
@ -41,19 +68,47 @@
android:layout_height="wrap_content"
app:statsTitle="@string/perception"
app:titleBackgroundColor="@color/brand_300"
app:statsColor="@color/brand_300"
android:layout_marginBottom="12dp"/>
<Switch
android:id="@+id/switch1"
android:id="@+id/automaticAllocationSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/auto_allocate_points"
android:layout_marginLeft="@dimen/content_border"
android:layout_marginRight="@dimen/content_border"/>
android:layout_marginRight="@dimen/content_border"
android:layout_marginBottom="20dp"/>
<RadioGroup
android:id="@+id/autoAllocationModeWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/content_border"
android:paddingRight="@dimen/content_border"
android:background="@color/gray_700"
android:paddingTop="16dp"
android:paddingBottom="16dp">
<RadioButton
android:id="@+id/distributeEvenlyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/distribute_evenly"
android:layout_marginBottom="4dp"/>
<RadioButton
android:id="@+id/distributeClassButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/distribute_class"
android:layout_marginBottom="4dp"/>
<RadioButton
android:id="@+id/distributeTaskButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/distribute_task"/>
</RadioGroup>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_600"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"/>
<LinearLayout
android:layout_width="match_parent"

View file

@ -10,7 +10,8 @@
<LinearLayout
android:id="@+id/titleWrapper"
android:layout_width="match_parent"
android:layout_height="43dp">
android:layout_height="43dp"
tools:background="@drawable/layout_rounded_bg_green">
<TextView
android:id="@id/titleTextView"
android:layout_width="0dp"
@ -29,6 +30,7 @@
tools:text="130"
android:gravity="center_vertical"
style="@style/Headline"
android:textStyle="bold"
android:textColor="@color/white"
android:layout_marginRight="12dp"/>
</LinearLayout>
@ -45,7 +47,8 @@
android:id="@+id/levelValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Title1"
style="@style/Subheader2"
android:textSize="20sp"
tools:text="20"
android:gravity="center_horizontal"/>
<TextView
@ -66,7 +69,8 @@
android:id="@+id/equipmentValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Title1"
style="@style/Subheader2"
android:textSize="20sp"
tools:text="20"
android:gravity="center_horizontal"/>
<TextView
@ -87,7 +91,8 @@
android:id="@+id/buffValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Title1"
style="@style/Subheader2"
android:textSize="20sp"
tools:text="20"
android:gravity="center_horizontal"/>
<TextView
@ -109,10 +114,12 @@
android:id="@+id/allocatedValueTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Title1"
style="@style/Subheader2"
android:textSize="20sp"
tools:text="20"
android:gravity="center_horizontal"/>
<TextView
android:id="@+id/allocatedLabelView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/allocated"

View file

@ -51,5 +51,6 @@
<declare-styleable name="StatsView">
<attr name="titleBackgroundColor" format="color" />
<attr name="statsTitle" format="string" />
<attr name="statsColor" format="color" />
</declare-styleable>
</resources>

View file

@ -30,6 +30,7 @@
<color name="yellow_100">#FFBE5D</color>
<color name="yellow_50">#FFB445</color>
<color name="yellow_10">#FFA624</color>
<color name="yellow_5">#EE9109</color>
<color name="green_500">#77f4c7</color>
<color name="green_100">#24CC8F</color>

View file

@ -703,4 +703,9 @@
<string name="perception_description">Increases the likelihood of finding drops when completing Tasks, the daily drop-cap, Streak Bonuses, and the amount of gold awarded for Tasks.</string>
<string name="buffs">Buffs</string>
<string name="allocated">Allocated</string>
<string name="distribute_evenly">Distribute Evenly</string>
<string name="distribute_class">Distribute based on class</string>
<string name="distribute_task">Distribute based on task activity</string>
<string name="no_points_to_allocate">No Points to Allocate</string>
<string name="points_to_allocate" formatted="false">%d Points to Allocate</string>
</resources>

View file

@ -1,7 +1,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="android:listSeparatorTextViewStyle">@style/MyOwnListSeperatorTextViewStyle</item>
<item name="android:elevation" tools:targetApi="21">0dp</item>

View file

@ -29,6 +29,7 @@ import com.habitrpg.android.habitica.models.social.Group;
import com.habitrpg.android.habitica.models.tasks.Task;
import com.habitrpg.android.habitica.models.tasks.TaskList;
import com.habitrpg.android.habitica.models.user.Items;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.models.user.User;
import java.util.List;
@ -346,4 +347,7 @@ public interface ApiService {
@PUT("user/auth/update-password")
Observable<HabitResponse<Void>> updatePassword(@Body Map<String, String> data);
@POST("user/allocate")
Observable<HabitResponse<Stats>> allocatePoint(@Query("stat") String stat);
}

View file

@ -30,6 +30,7 @@ import com.habitrpg.android.habitica.models.social.Group;
import com.habitrpg.android.habitica.models.tasks.Task;
import com.habitrpg.android.habitica.models.tasks.TaskList;
import com.habitrpg.android.habitica.models.user.Items;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.models.user.User;
import java.util.List;
@ -246,4 +247,6 @@ public interface ApiClient {
Observable<Void> updateEmail(String newEmail, String password);
Observable<Void> updatePassword(String newPassword, String oldPassword, String oldPasswordConfirmation);
Observable<Stats> allocatePoint(String stat);
}

View file

@ -1,6 +1,7 @@
package com.habitrpg.android.habitica.data;
import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
import com.habitrpg.android.habitica.models.Skill;
import com.habitrpg.android.habitica.models.inventory.Customization;
@ -9,6 +10,7 @@ import com.habitrpg.android.habitica.models.responses.SkillResponse;
import com.habitrpg.android.habitica.models.responses.UnlockResponse;
import com.habitrpg.android.habitica.models.social.ChatMessage;
import com.habitrpg.android.habitica.models.tasks.Task;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.models.user.User;
import org.jetbrains.annotations.NotNull;
@ -23,8 +25,8 @@ public interface UserRepository extends BaseRepository {
Observable<User> getUser(String userID);
Observable<User> getUser();
Observable<User> updateUser(User user, Map<String, Object> updateData);
Observable<User> updateUser(User user, String key, Object value);
Observable<User> updateUser(@Nullable User user, Map<String, Object> updateData);
Observable<User> updateUser(@Nullable User user, String key, Object value);
Observable<User> retrieveUser(Boolean withTasks);
Observable<User> retrieveUser(Boolean withTasks, Boolean forced);
@ -72,4 +74,7 @@ public interface UserRepository extends BaseRepository {
Observable<Void> updateLoginName(@NotNull String newLoginName, @NotNull String password);
Observable<Void> updateEmail(@NotNull String newEmail, @NotNull String password);
Observable<Void> updatePassword(@NotNull String newPassword, @NotNull String oldPassword, String oldPasswordConfirmation);
@NotNull
Observable<Stats> allocatePoint(@Nullable User user, @Stats.StatsTypes String s);
}

View file

@ -62,6 +62,7 @@ import com.habitrpg.android.habitica.models.tasks.Task;
import com.habitrpg.android.habitica.models.tasks.TaskList;
import com.habitrpg.android.habitica.models.user.Items;
import com.habitrpg.android.habitica.models.user.Purchases;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.models.user.User;
import com.habitrpg.android.habitica.proxy.CrashlyticsProxy;
import com.habitrpg.android.habitica.utils.BooleanAsIntAdapter;
@ -981,4 +982,9 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
updateObject.put("confirmPassowrd", oldPasswordConfirmation);
return apiService.updatePassword(updateObject).compose(configureApiCallObserver());
}
@Override
public Observable<Stats> allocatePoint(String stat) {
return apiService.allocatePoint(stat).compose(configureApiCallObserver());
}
}

View file

@ -1,5 +1,7 @@
package com.habitrpg.android.habitica.data.implementation;
import android.support.annotation.Nullable;
import com.habitrpg.android.habitica.data.ApiClient;
import com.habitrpg.android.habitica.data.TaskRepository;
import com.habitrpg.android.habitica.data.UserRepository;
@ -14,6 +16,7 @@ import com.habitrpg.android.habitica.models.responses.TaskScoringResult;
import com.habitrpg.android.habitica.models.responses.UnlockResponse;
import com.habitrpg.android.habitica.models.social.ChatMessage;
import com.habitrpg.android.habitica.models.tasks.Task;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.models.user.User;
import org.jetbrains.annotations.NotNull;
@ -56,13 +59,16 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserLocalRepository>
}
@Override
public Observable<User> updateUser(User user, Map<String, Object> updateData) {
public Observable<User> updateUser(@Nullable User user, Map<String, Object> updateData) {
if (user == null) {
return Observable.just(null);
}
return apiClient.updateUser(updateData)
.map(newUser -> mergeUser(user, newUser));
}
@Override
public Observable<User> updateUser(User user, String key, Object value) {
public Observable<User> updateUser(@Nullable User user, String key, Object value) {
Map<String, Object> updateData = new HashMap<>();
updateData.put(key, value);
return updateUser(user, updateData);
@ -273,6 +279,27 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserLocalRepository>
return apiClient.updatePassword(newPassword, oldPassword, oldPasswordConfirmation);
}
@NotNull
@Override
public Observable<Stats> allocatePoint(@Nullable User user, String stat) {
if (user != null && user.isManaged()) {
localRepository.executeTransaction(realm -> user.getStats().points -= 1);
}
return apiClient.allocatePoint(stat)
.doOnNext(stats -> {
if (user != null && user.isManaged()) {
localRepository.executeTransaction(realm -> {
user.getStats().str = stats.str;
user.getStats().con = stats.con;
user.getStats().per = stats.per;
user.getStats()._int = stats._int;
user.getStats().points = stats.points;
user.getStats().mp = stats.mp;
});
}
});
}
@Override
public void runCron(List<Task> tasks) {
Observable<List<TaskScoringResult>> observable;

View file

@ -0,0 +1,9 @@
package com.habitrpg.android.habitica.extensions
import android.content.Context
public fun Int.dpToPx(context: Context?): Int {
val displayMetrics = context?.resources?.displayMetrics
return ((this * (displayMetrics?.density ?: 1.0f)) + 0.5).toInt()
}

View file

@ -0,0 +1,9 @@
package com.habitrpg.android.habitica.extensions
import android.content.Context
import android.view.View
public fun View.setScaledPadding(context: Context?, left: Int, top: Int, right: Int, bottom: Int) {
this.setPadding(left.dpToPx(context), top.dpToPx(context), right.dpToPx(context), bottom.dpToPx(context))
}

View file

@ -3,15 +3,19 @@ package com.habitrpg.android.habitica.models.tasks;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
import com.google.gson.annotations.SerializedName;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.models.Tag;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
import org.json.JSONArray;
import org.json.JSONException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@ -29,6 +33,11 @@ public class Task extends RealmObject implements Parcelable {
public static final String TYPE_TODO = "todo";
public static final String TYPE_DAILY = "daily";
public static final String TYPE_REWARD = "reward";
@StringDef({TYPE_HABIT, TYPE_DAILY, TYPE_TODO, TYPE_REWARD})
@Retention(RetentionPolicy.SOURCE)
public @interface TaskTypes {}
public static final String FILTER_ALL = "all";
public static final String FILTER_WEAK = "weak";
public static final String FILTER_STRONG = "strong";
@ -38,15 +47,13 @@ public class Task extends RealmObject implements Parcelable {
public static final String FILTER_COMPLETED = "completed";
public static final String FREQUENCY_WEEKLY = "weekly";
public static final String FREQUENCY_DAILY = "daily";
public static final String ATTRIBUTE_STRENGTH = "str";
public static final String ATTRIBUTE_CONSTITUTION = "con";
public static final String ATTRIBUTE_INTELLIGENCE = "int";
public static final String ATTRIBUTE_PERCEPTION = "per";
public String userId;
public float priority;
public String text, notes, attribute, type;
public String text, notes;
@TaskTypes public String type;
@Stats.StatsTypes public String attribute;
public double value;
public RealmList<Tag> tags;
public Date dateCreated;

View file

@ -229,4 +229,12 @@ public class Preferences extends RealmObject implements AvatarPreferences {
public boolean hasTaskBasedAllocation() {
return allocationMode.equals("taskBased") && !automaticAllocation;
}
public boolean getAutomaticAllocation() {
return this.automaticAllocation;
}
public void setAutomaticAllocation(boolean automaticAllocation) {
this.automaticAllocation = automaticAllocation;
}
}

View file

@ -1,16 +1,28 @@
package com.habitrpg.android.habitica.models.user;
import android.content.Context;
import android.support.annotation.StringDef;
import com.google.gson.annotations.SerializedName;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.models.HabitRpgClass;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
public class Stats extends RealmObject {
public static final String STRENGTH = "str";
public static final String INTELLIGENCE = "int";
public static final String CONSTITUTION = "con";
public static final String PERCEPTION = "per";
@StringDef({Stats.STRENGTH, Stats.INTELLIGENCE, Stats.CONSTITUTION, Stats.PERCEPTION})
@Retention(RetentionPolicy.SOURCE)
public @interface StatsTypes {}
@PrimaryKey
private String userId;

View file

@ -53,6 +53,7 @@ import com.habitrpg.android.habitica.models.tasks.ChecklistItem;
import com.habitrpg.android.habitica.models.tasks.Days;
import com.habitrpg.android.habitica.models.tasks.RemindersItem;
import com.habitrpg.android.habitica.models.tasks.Task;
import com.habitrpg.android.habitica.models.user.Stats;
import com.habitrpg.android.habitica.modules.AppModule;
import com.habitrpg.android.habitica.ui.WrapContentRecyclerViewLayoutManager;
import com.habitrpg.android.habitica.ui.adapter.tasks.CheckListAdapter;
@ -1008,16 +1009,16 @@ public class TaskFormActivity extends BaseActivity implements AdapterView.OnItem
String attribute = task.getAttribute();
if (attribute != null) {
switch (attribute) {
case Task.ATTRIBUTE_STRENGTH:
case Stats.STRENGTH:
taskAttributeSpinner.setSelection(0);
break;
case Task.ATTRIBUTE_INTELLIGENCE:
case Stats.INTELLIGENCE:
taskAttributeSpinner.setSelection(1);
break;
case Task.ATTRIBUTE_CONSTITUTION:
case Stats.CONSTITUTION:
taskAttributeSpinner.setSelection(2);
break;
case Task.ATTRIBUTE_PERCEPTION:
case Stats.PERCEPTION:
taskAttributeSpinner.setSelection(3);
break;
}
@ -1132,20 +1133,20 @@ public class TaskFormActivity extends BaseActivity implements AdapterView.OnItem
}
if (!taskBasedAllocation) {
task.setAttribute(Task.ATTRIBUTE_STRENGTH);
task.setAttribute(Stats.STRENGTH);
} else {
switch (taskAttributeSpinner.getSelectedItemPosition()) {
case 0:
task.setAttribute(Task.ATTRIBUTE_STRENGTH);
task.setAttribute(Stats.STRENGTH);
break;
case 1:
task.setAttribute(Task.ATTRIBUTE_INTELLIGENCE);
task.setAttribute(Stats.INTELLIGENCE);
break;
case 2:
task.setAttribute(Task.ATTRIBUTE_CONSTITUTION);
task.setAttribute(Stats.CONSTITUTION);
break;
case 3:
task.setAttribute(Task.ATTRIBUTE_PERCEPTION);
task.setAttribute(Stats.PERCEPTION);
break;
}
}

View file

@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebChromeClient
import com.habitrpg.android.habitica.BuildConfig
import com.habitrpg.android.habitica.R
@ -21,6 +22,7 @@ class NewsFragment : BaseMainFragment() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val address = if (BuildConfig.DEBUG) BuildConfig.BASE_URL else context.getString(R.string.base_url)
newsWebview.webChromeClient = WebChromeClient()
newsWebview.loadUrl(address + "/static/new-stuff")
}

View file

@ -1,6 +1,7 @@
package com.habitrpg.android.habitica.ui.fragments
import android.os.Bundle
import android.support.v4.content.ContextCompat
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -9,7 +10,10 @@ import com.habitrpg.android.habitica.components.AppComponent
import com.habitrpg.android.habitica.data.InventoryRepository
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.helpers.UserStatComputer
import com.habitrpg.android.habitica.models.user.Stats
import com.habitrpg.android.habitica.modules.AppModule
import com.habitrpg.android.habitica.extensions.setScaledPadding
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
import kotlinx.android.synthetic.main.fragment_stats.*
import rx.functions.Action1
import java.util.ArrayList
@ -52,10 +56,81 @@ class StatsFragment: BaseMainFragment() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
leftSparklesView.setImageBitmap(HabiticaIconsHelper.imageOfAttributeSparklesLeft())
rightSparklesView.setImageBitmap(HabiticaIconsHelper.imageOfAttributeSparklesRight())
compositeSubscription.add(userRepository.getUser(userId).subscribe(Action1 {
user = it
updateStats()
updateAttributePoints()
}, RxErrorHandler.handleEmptyError()))
autoAllocationModeWrapper.setOnCheckedChangeListener { _, checkedId ->
val allocationMode = when (checkedId) {
R.id.distributeEvenlyButton -> "flat"
R.id.distributeClassButton -> "classbased"
R.id.distributeTaskButton -> "taskbased"
else -> ""
}
userRepository.updateUser(user, "preferences.allocationMode", allocationMode).subscribe(Action1 {}, RxErrorHandler.handleEmptyError())
}
automaticAllocationSwitch.setOnCheckedChangeListener{ _, isChecked ->
userRepository.updateUser(user, "preferences.automaticAllocation", isChecked).subscribe(Action1 {}, RxErrorHandler.handleEmptyError())
}
strengthStatsView.allocateAction = {
allocatePoint(Stats.STRENGTH)
}
intelligenceStatsView.allocateAction = {
allocatePoint(Stats.INTELLIGENCE)
}
constitutionStatsView.allocateAction = {
allocatePoint(Stats.CONSTITUTION)
}
perceptionStatsView.allocateAction = {
allocatePoint(Stats.PERCEPTION)
}
}
private fun allocatePoint(@Stats.StatsTypes stat: String) {
userRepository.allocatePoint(user, stat).subscribe(Action1 { }, RxErrorHandler.handleEmptyError())
}
private fun updateAttributePoints() {
val automaticAllocation = user?.preferences?.automaticAllocation ?: false
automaticAllocationSwitch.isChecked = automaticAllocation
autoAllocationModeWrapper.visibility = if (automaticAllocation) View.VISIBLE else View.GONE
when (user?.preferences?.allocationMode ?: "") {
"flat" -> distributeEvenlyButton.isChecked = true
"classbased" -> distributeClassButton.isChecked = true
"taskbased" -> distributeTaskButton.isChecked = true
}
val canDistributePoints = !automaticAllocation && 0 < (user?.stats?.points ?: 0)
strengthStatsView.canDistributePoints = canDistributePoints
intelligenceStatsView.canDistributePoints = canDistributePoints
constitutionStatsView.canDistributePoints = canDistributePoints
perceptionStatsView.canDistributePoints = canDistributePoints
numberOfPointsTextView.visibility = View.VISIBLE
if (canDistributePoints) {
val points = user?.stats?.points ?: 0
numberOfPointsTextView.text = getString(R.string.points_to_allocate, points)
numberOfPointsTextView.setTextColor(ContextCompat.getColor(context, R.color.white))
numberOfPointsTextView.background = ContextCompat.getDrawable(context, R.drawable.pill_bg_gray_100)
leftSparklesView.visibility = View.VISIBLE
rightSparklesView.visibility = View.VISIBLE
} else {
if (automaticAllocation) {
numberOfPointsTextView.visibility = View.GONE
}
numberOfPointsTextView.text = getString(R.string.no_points_to_allocate)
numberOfPointsTextView.setTextColor(ContextCompat.getColor(context, R.color.gray_300))
numberOfPointsTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.transparent))
leftSparklesView.visibility = View.GONE
rightSparklesView.visibility = View.GONE
}
numberOfPointsTextView.setScaledPadding(context, 18, 4, 18, 4)
}
override fun injectFragment(component: AppComponent) {
@ -128,10 +203,10 @@ class StatsFragment: BaseMainFragment() {
totalIntelligence += intelligence
totalConstitution += constitution
totalPerception += perception
strengthStatsView.equipmentValue += strength
intelligenceStatsView.equipmentValue += intelligence
constitutionStatsView.equipmentValue += constitution
perceptionStatsView.equipmentValue += perception
strengthStatsView.equipmentValue = strength
intelligenceStatsView.equipmentValue = intelligence
constitutionStatsView.equipmentValue = constitution
perceptionStatsView.equipmentValue = perception
}, RxErrorHandler.handleEmptyError())
}
@ -142,4 +217,4 @@ class StatsFragment: BaseMainFragment() {
} else getString(R.string.sidebar_stats)
}
}
}

View file

@ -48,7 +48,7 @@ public class CurrencyView extends android.support.v7.widget.AppCompatTextView {
if ("gold".equals(currency)) {
setIcon(HabiticaIconsHelper.imageOfGold());
if (lightbackground) {
setTextColor(ContextCompat.getColor(getContext(), R.color.yellow_10));
setTextColor(ContextCompat.getColor(getContext(), R.color.yellow_5));
} else {
setTextColor(ContextCompat.getColor(getContext(), R.color.yellow_100));
}

View file

@ -16,7 +16,7 @@ import java.util.Stack;
/**
* Created by Phillip Thelen on 27.09.17.
* Created by Phillip Thelen on 17.10.17.
* Copyright © 2017 HabitRPG Inc.. All rights reserved.
*
* Generated by PaintCode
@ -77,13 +77,13 @@ public class HabiticaIcons {
Paint paint = CacheForHeart.paint;
// Local Colors
int fillColor5 = Color.argb(64, 255, 255, 255);
int fillColor4 = Color.argb(89, 181, 36, 40);
int fillColor6 = Color.argb(128, 181, 36, 40);
int heartDarkBackground = Color.argb(178, 255, 255, 255);
int heartLightBackground = Color.argb(255, 247, 78, 82);
int fillColor2 = Color.argb(255, 255, 97, 101);
int fillColor3 = Color.argb(128, 255, 255, 255);
int fillColor4 = Color.argb(89, 181, 36, 40);
int heartLightBackground = Color.argb(255, 247, 78, 82);
int heartDarkBackground = Color.argb(178, 255, 255, 255);
int fillColor6 = Color.argb(128, 181, 36, 40);
int fillColor5 = Color.argb(64, 255, 255, 255);
// Local Variables
int expression = darkBackground ? heartDarkBackground : heartLightBackground;
@ -588,11 +588,11 @@ public class HabiticaIcons {
Paint paint = CacheForMagic.paint;
// Local Colors
int fillColor5 = Color.argb(64, 255, 255, 255);
int fillColor3 = Color.argb(128, 255, 255, 255);
int fillColor9 = Color.argb(64, 31, 112, 154);
int fillColor5 = Color.argb(64, 255, 255, 255);
int fillColor7 = Color.argb(255, 41, 149, 205);
int fillColor8 = Color.argb(255, 80, 181, 233);
int fillColor7 = Color.argb(255, 41, 149, 205);
// Resize to Target Frame
canvas.save();
@ -740,8 +740,8 @@ public class HabiticaIcons {
// Local Colors
int fillColor12 = Color.argb(128, 191, 125, 26);
int fillColor13 = Color.argb(191, 191, 125, 26);
int fillColor5 = Color.argb(64, 255, 255, 255);
int fillColor13 = Color.argb(191, 191, 125, 26);
int fillColor3 = Color.argb(128, 255, 255, 255);
int fillColor10 = Color.argb(255, 255, 166, 35);
@ -894,8 +894,8 @@ public class HabiticaIcons {
// Local Colors
int fillColor3 = Color.argb(128, 255, 255, 255);
int fillColor15 = Color.argb(89, 27, 153, 107);
int fillColor5 = Color.argb(64, 255, 255, 255);
int fillColor15 = Color.argb(89, 27, 153, 107);
int fillColor14 = Color.argb(255, 36, 204, 143);
// Resize to Target Frame
@ -1520,14 +1520,14 @@ public class HabiticaIcons {
Paint paint = CacheForWarrior.paint;
// Local Colors
int fillColor42 = Color.argb(255, 255, 149, 152);
int fillColor43 = Color.argb(255, 200, 43, 43);
int fillColor21 = Color.argb(255, 255, 182, 184);
int fillColor20 = Color.argb(255, 255, 181, 183);
int fillColor22 = Color.argb(255, 242, 123, 134);
int fillColor41 = Color.argb(255, 255, 149, 152);
int fillColor23 = Color.argb(255, 229, 65, 77);
int fillColor20 = Color.argb(255, 255, 181, 183);
int fillColor = Color.argb(255, 240, 97, 102);
int fillColor42 = Color.argb(255, 255, 149, 152);
int fillColor22 = Color.argb(255, 242, 123, 134);
int fillColor21 = Color.argb(255, 255, 182, 184);
int fillColor41 = Color.argb(255, 255, 149, 152);
// Local Variables
boolean lightBackground = !darkBackground;
@ -2778,8 +2778,8 @@ public class HabiticaIcons {
int fillColor25 = Color.argb(255, 225, 224, 227);
// Local Variables
boolean isHalf = singleDifficulty == 0.5f;
boolean isFull = singleDifficulty == 1f;
boolean isHalf = singleDifficulty == 0.5f;
// Resize to Target Frame
canvas.save();
@ -2884,8 +2884,8 @@ public class HabiticaIcons {
Paint paint = CacheForStarSmall.paint;
// Local Colors
int fillColor26 = Color.argb(102, 229, 220, 255);
int fillColor27 = Color.argb(255, 229, 220, 255);
int fillColor26 = Color.argb(102, 229, 220, 255);
// Resize to Target Frame
canvas.save();
@ -3431,9 +3431,9 @@ public class HabiticaIcons {
Paint paint = CacheForStarMedium.paint;
// Local Colors
int fillColor34 = Color.argb(38, 229, 220, 255);
int fillColor27 = Color.argb(255, 229, 220, 255);
int fillColor33 = Color.argb(77, 229, 220, 255);
int fillColor34 = Color.argb(38, 229, 220, 255);
int fillColor32 = Color.argb(153, 229, 220, 255);
// Resize to Target Frame
@ -3961,13 +3961,13 @@ public class HabiticaIcons {
Paint paint = CacheForItemIndicator.paint;
// Local Colors
int indicatorLocked = Color.argb(255, 237, 236, 238);
int strokeColor = Color.argb(255, 97, 51, 180);
int shadowTint = Color.argb(255, 26, 24, 29);
int fillColor38 = Color.argb(255, 165, 161, 172);
int fillColor40 = Color.argb(255, 165, 161, 172);
int strokeColor = Color.argb(255, 97, 51, 180);
int indicatorLocked = Color.argb(255, 237, 236, 238);
int fillColor39 = Color.argb(255, 189, 168, 255);
int fillColor40 = Color.argb(255, 165, 161, 172);
int strokeColor2 = Color.argb(255, 189, 168, 255);
int fillColor38 = Color.argb(255, 165, 161, 172);
// Local Shadows
PaintCodeShadow shadow = CacheForItemIndicator.shadow.get(PaintCodeColor.colorByChangingAlpha(shadowTint, (int) (Color.alpha(shadowTint) * 0.12f * 255f)), 0f, 1f, 1f);
@ -4386,13 +4386,13 @@ public class HabiticaIcons {
Paint paint = CacheForRogue.paint;
// Local Colors
int fillColor36 = Color.argb(255, 97, 51, 180);
int fillColor19 = Color.argb(255, 79, 42, 147);
int fillColor47 = Color.argb(255, 198, 182, 228);
int fillColor45 = Color.argb(255, 155, 129, 226);
int fillColor44 = Color.argb(255, 204, 190, 237);
int fillColor46 = Color.argb(255, 122, 84, 192);
int fillColor48 = Color.argb(255, 137, 102, 199);
int fillColor45 = Color.argb(255, 155, 129, 226);
int fillColor47 = Color.argb(255, 198, 182, 228);
int fillColor44 = Color.argb(255, 204, 190, 237);
int fillColor19 = Color.argb(255, 79, 42, 147);
int fillColor36 = Color.argb(255, 97, 51, 180);
int fillColor46 = Color.argb(255, 122, 84, 192);
// Local Variables
boolean lightBackground = !darkBackground;
@ -5183,18 +5183,18 @@ public class HabiticaIcons {
Paint paint = CacheForHealer.paint;
// Local Colors
int fillColor56 = Color.argb(255, 255, 166, 35);
int fillColor50 = Color.argb(255, 226, 158, 69);
int fillColor55 = Color.argb(255, 253, 198, 126);
int fillColor53 = Color.argb(255, 206, 129, 41);
int fillColor54 = Color.argb(255, 207, 130, 41);
int fillColor52 = Color.argb(255, 253, 198, 126);
int fillColor59 = Color.argb(255, 255, 228, 201);
int fillColor58 = Color.argb(255, 229, 144, 37);
int fillColor10 = Color.argb(255, 255, 166, 35);
int fillColor51 = Color.argb(255, 229, 144, 37);
int fillColor52 = Color.argb(255, 253, 198, 126);
int fillColor53 = Color.argb(255, 206, 129, 41);
int fillColor59 = Color.argb(255, 255, 228, 201);
int fillColor55 = Color.argb(255, 253, 198, 126);
int fillColor57 = Color.argb(255, 255, 221, 181);
int fillColor54 = Color.argb(255, 207, 130, 41);
int fillColor56 = Color.argb(255, 255, 166, 35);
int fillColor50 = Color.argb(255, 226, 158, 69);
int fillColor49 = Color.argb(255, 255, 215, 168);
int fillColor51 = Color.argb(255, 229, 144, 37);
// Local Variables
boolean lightBackground = !darkBackground;
@ -6021,16 +6021,16 @@ public class HabiticaIcons {
// Local Colors
int fillColor61 = Color.argb(255, 39, 138, 191);
int fillColor65 = Color.argb(255, 107, 196, 233);
int fillColor60 = Color.argb(255, 182, 225, 247);
int fillColor68 = Color.argb(255, 31, 110, 162);
int fillColor64 = Color.argb(255, 77, 178, 214);
int fillColor69 = Color.argb(255, 169, 219, 245);
int fillColor66 = Color.argb(255, 107, 196, 233);
int fillColor62 = Color.argb(255, 83, 180, 229);
int fillColor68 = Color.argb(255, 31, 110, 162);
int fillColor66 = Color.argb(255, 107, 196, 233);
int fillColor69 = Color.argb(255, 169, 219, 245);
int fillColor63 = Color.argb(255, 42, 160, 207);
int fillColor70 = Color.argb(255, 132, 207, 242);
int fillColor67 = Color.argb(255, 83, 180, 229);
int fillColor65 = Color.argb(255, 107, 196, 233);
int fillColor60 = Color.argb(255, 182, 225, 247);
// Local Variables
boolean lightBackground = !darkBackground;
@ -6596,8 +6596,8 @@ public class HabiticaIcons {
Paint paint = CacheForHourglassShop.paint;
// Local Colors
int fillColor19 = Color.argb(255, 79, 42, 147);
int fillColor18 = Color.argb(255, 154, 98, 255);
int fillColor19 = Color.argb(255, 79, 42, 147);
int fillColor17 = Color.argb(230, 255, 255, 255);
int fillColor16 = Color.argb(204, 169, 220, 246);
@ -6847,6 +6847,305 @@ public class HabiticaIcons {
canvas.restore();
}
private static class CacheForAttributeSparklesLeft {
private static Paint paint = new Paint();
private static RectF originalFrame = new RectF(0f, 0f, 77f, 24f);
private static RectF resizedFrame = new RectF();
private static RectF starRect = new RectF();
private static Path starPath = new Path();
private static RectF star2Rect = new RectF();
private static Path star2Path = new Path();
private static RectF star3Rect = new RectF();
private static Path star3Path = new Path();
private static RectF star4Rect = new RectF();
private static Path star4Path = new Path();
}
public static void drawAttributeSparklesLeft(Canvas canvas) {
HabiticaIcons.drawAttributeSparklesLeft(canvas, new RectF(0f, 0f, 77f, 24f), ResizingBehavior.AspectFit);
}
public static void drawAttributeSparklesLeft(Canvas canvas, RectF targetFrame, ResizingBehavior resizing) {
// General Declarations
Paint paint = CacheForAttributeSparklesLeft.paint;
// Local Colors
int fillColor73 = Color.argb(255, 255, 180, 69);
int fillColor18 = Color.argb(255, 154, 98, 255);
int fillColor71 = Color.argb(255, 80, 181, 233);
int fillColor72 = Color.argb(255, 255, 97, 101);
// Resize to Target Frame
canvas.save();
RectF resizedFrame = CacheForAttributeSparklesLeft.resizedFrame;
HabiticaIcons.resizingBehaviorApply(resizing, CacheForAttributeSparklesLeft.originalFrame, targetFrame, resizedFrame);
canvas.translate(resizedFrame.left, resizedFrame.top);
canvas.scale(resizedFrame.width() / 77f, resizedFrame.height() / 24f);
// Star
RectF starRect = CacheForAttributeSparklesLeft.starRect;
starRect.set(36f, 0f, 49f, 13f);
Path starPath = CacheForAttributeSparklesLeft.starPath;
starPath.reset();
starPath.moveTo(42.5f, 0f);
starPath.lineTo(44.66f, 4.34f);
starPath.lineTo(49f, 6.5f);
starPath.lineTo(44.66f, 8.66f);
starPath.lineTo(42.5f, 13f);
starPath.lineTo(40.34f, 8.66f);
starPath.lineTo(36f, 6.5f);
starPath.lineTo(40.34f, 4.34f);
starPath.lineTo(42.5f, 0f);
starPath.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor71);
canvas.drawPath(starPath, paint);
// Star 2
RectF star2Rect = CacheForAttributeSparklesLeft.star2Rect;
star2Rect.set(61f, 6f, 77f, 22f);
Path star2Path = CacheForAttributeSparklesLeft.star2Path;
star2Path.reset();
star2Path.moveTo(69f, 6f);
star2Path.lineTo(71.65f, 11.35f);
star2Path.lineTo(77f, 14f);
star2Path.lineTo(71.65f, 16.65f);
star2Path.lineTo(69f, 22f);
star2Path.lineTo(66.35f, 16.65f);
star2Path.lineTo(61f, 14f);
star2Path.lineTo(66.35f, 11.35f);
star2Path.lineTo(69f, 6f);
star2Path.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor18);
canvas.drawPath(star2Path, paint);
// Star 3
RectF star3Rect = CacheForAttributeSparklesLeft.star3Rect;
star3Rect.set(17f, 14f, 27f, 24f);
Path star3Path = CacheForAttributeSparklesLeft.star3Path;
star3Path.reset();
star3Path.moveTo(22f, 14f);
star3Path.lineTo(23.66f, 17.34f);
star3Path.lineTo(27f, 19f);
star3Path.lineTo(23.66f, 20.66f);
star3Path.lineTo(22f, 24f);
star3Path.lineTo(20.34f, 20.66f);
star3Path.lineTo(17f, 19f);
star3Path.lineTo(20.34f, 17.34f);
star3Path.lineTo(22f, 14f);
star3Path.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor72);
canvas.drawPath(star3Path, paint);
// Star 4
RectF star4Rect = CacheForAttributeSparklesLeft.star4Rect;
star4Rect.set(0f, 9f, 7f, 16f);
Path star4Path = CacheForAttributeSparklesLeft.star4Path;
star4Path.reset();
star4Path.moveTo(3.5f, 9f);
star4Path.lineTo(4.67f, 11.33f);
star4Path.lineTo(7f, 12.5f);
star4Path.lineTo(4.67f, 13.67f);
star4Path.lineTo(3.5f, 16f);
star4Path.lineTo(2.33f, 13.67f);
star4Path.lineTo(0f, 12.5f);
star4Path.lineTo(2.33f, 11.33f);
star4Path.lineTo(3.5f, 9f);
star4Path.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor73);
canvas.drawPath(star4Path, paint);
canvas.restore();
}
private static class CacheForAttributeSparklesRight {
private static Paint paint = new Paint();
private static RectF originalFrame = new RectF(0f, 0f, 77f, 24f);
private static RectF resizedFrame = new RectF();
private static RectF starRect = new RectF();
private static Path starPath = new Path();
private static RectF star2Rect = new RectF();
private static Path star2Path = new Path();
private static RectF star3Rect = new RectF();
private static Path star3Path = new Path();
private static RectF star4Rect = new RectF();
private static Path star4Path = new Path();
}
public static void drawAttributeSparklesRight(Canvas canvas) {
HabiticaIcons.drawAttributeSparklesRight(canvas, new RectF(0f, 0f, 77f, 24f), ResizingBehavior.AspectFit);
}
public static void drawAttributeSparklesRight(Canvas canvas, RectF targetFrame, ResizingBehavior resizing) {
// General Declarations
Paint paint = CacheForAttributeSparklesRight.paint;
// Local Colors
int fillColor71 = Color.argb(255, 80, 181, 233);
int fillColor18 = Color.argb(255, 154, 98, 255);
int fillColor74 = Color.argb(255, 255, 190, 93);
int fillColor72 = Color.argb(255, 255, 97, 101);
// Resize to Target Frame
canvas.save();
RectF resizedFrame = CacheForAttributeSparklesRight.resizedFrame;
HabiticaIcons.resizingBehaviorApply(resizing, CacheForAttributeSparklesRight.originalFrame, targetFrame, resizedFrame);
canvas.translate(resizedFrame.left, resizedFrame.top);
canvas.scale(resizedFrame.width() / 77f, resizedFrame.height() / 24f);
// Star
RectF starRect = CacheForAttributeSparklesRight.starRect;
starRect.set(28f, 0f, 41f, 13f);
Path starPath = CacheForAttributeSparklesRight.starPath;
starPath.reset();
starPath.moveTo(34.5f, 0f);
starPath.lineTo(36.66f, 4.34f);
starPath.lineTo(41f, 6.5f);
starPath.lineTo(36.66f, 8.66f);
starPath.lineTo(34.5f, 13f);
starPath.lineTo(32.34f, 8.66f);
starPath.lineTo(28f, 6.5f);
starPath.lineTo(32.34f, 4.34f);
starPath.lineTo(34.5f, 0f);
starPath.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor72);
canvas.drawPath(starPath, paint);
// Star 2
RectF star2Rect = CacheForAttributeSparklesRight.star2Rect;
star2Rect.set(0f, 6f, 16f, 22f);
Path star2Path = CacheForAttributeSparklesRight.star2Path;
star2Path.reset();
star2Path.moveTo(8f, 6f);
star2Path.lineTo(10.65f, 11.35f);
star2Path.lineTo(16f, 14f);
star2Path.lineTo(10.65f, 16.65f);
star2Path.lineTo(8f, 22f);
star2Path.lineTo(5.35f, 16.65f);
star2Path.lineTo(0f, 14f);
star2Path.lineTo(5.35f, 11.35f);
star2Path.lineTo(8f, 6f);
star2Path.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor74);
canvas.drawPath(star2Path, paint);
// Star 3
RectF star3Rect = CacheForAttributeSparklesRight.star3Rect;
star3Rect.set(50f, 14f, 60f, 24f);
Path star3Path = CacheForAttributeSparklesRight.star3Path;
star3Path.reset();
star3Path.moveTo(55f, 14f);
star3Path.lineTo(56.66f, 17.34f);
star3Path.lineTo(60f, 19f);
star3Path.lineTo(56.66f, 20.66f);
star3Path.lineTo(55f, 24f);
star3Path.lineTo(53.34f, 20.66f);
star3Path.lineTo(50f, 19f);
star3Path.lineTo(53.34f, 17.34f);
star3Path.lineTo(55f, 14f);
star3Path.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor18);
canvas.drawPath(star3Path, paint);
// Star 4
RectF star4Rect = CacheForAttributeSparklesRight.star4Rect;
star4Rect.set(70f, 9f, 77f, 16f);
Path star4Path = CacheForAttributeSparklesRight.star4Path;
star4Path.reset();
star4Path.moveTo(73.5f, 9f);
star4Path.lineTo(74.67f, 11.33f);
star4Path.lineTo(77f, 12.5f);
star4Path.lineTo(74.67f, 13.67f);
star4Path.lineTo(73.5f, 16f);
star4Path.lineTo(72.33f, 13.67f);
star4Path.lineTo(70f, 12.5f);
star4Path.lineTo(72.33f, 11.33f);
star4Path.lineTo(73.5f, 9f);
star4Path.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor71);
canvas.drawPath(star4Path, paint);
canvas.restore();
}
private static class CacheForAttributeAllocateButton {
private static Paint paint = new Paint();
private static RectF originalFrame = new RectF(0f, 0f, 24f, 15f);
private static RectF resizedFrame = new RectF();
private static RectF bezierRect = new RectF();
private static Path bezierPath = new Path();
}
public static void drawAttributeAllocateButton(Canvas canvas) {
HabiticaIcons.drawAttributeAllocateButton(canvas, new RectF(0f, 0f, 24f, 15f), ResizingBehavior.AspectFit);
}
public static void drawAttributeAllocateButton(Canvas canvas, RectF targetFrame, ResizingBehavior resizing) {
// General Declarations
Paint paint = CacheForAttributeAllocateButton.paint;
// Local Colors
int fillColor75 = Color.argb(255, 135, 129, 144);
// Resize to Target Frame
canvas.save();
RectF resizedFrame = CacheForAttributeAllocateButton.resizedFrame;
HabiticaIcons.resizingBehaviorApply(resizing, CacheForAttributeAllocateButton.originalFrame, targetFrame, resizedFrame);
canvas.translate(resizedFrame.left, resizedFrame.top);
canvas.scale(resizedFrame.width() / 24f, resizedFrame.height() / 15f);
// Bezier
RectF bezierRect = CacheForAttributeAllocateButton.bezierRect;
bezierRect.set(0f, 0f, 24f, 15f);
Path bezierPath = CacheForAttributeAllocateButton.bezierPath;
bezierPath.reset();
bezierPath.moveTo(0f, 15f);
bezierPath.lineTo(12f, 0f);
bezierPath.lineTo(24f, 15f);
bezierPath.lineTo(0f, 15f);
bezierPath.close();
paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
bezierPath.setFillType(Path.FillType.EVEN_ODD);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor75);
canvas.drawPath(bezierPath, paint);
canvas.restore();
}
// Canvas Images
// Tab
@ -7215,6 +7514,42 @@ public class HabiticaIcons {
return imageOfHourglassShop;
}
private static Bitmap imageOfAttributeSparklesLeft = null;
public static Bitmap imageOfAttributeSparklesLeft() {
if (imageOfAttributeSparklesLeft != null)
return imageOfAttributeSparklesLeft;
imageOfAttributeSparklesLeft = Bitmap.createBitmap(77, 24, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfAttributeSparklesLeft);
HabiticaIcons.drawAttributeSparklesLeft(canvas);
return imageOfAttributeSparklesLeft;
}
private static Bitmap imageOfAttributeSparklesRight = null;
public static Bitmap imageOfAttributeSparklesRight() {
if (imageOfAttributeSparklesRight != null)
return imageOfAttributeSparklesRight;
imageOfAttributeSparklesRight = Bitmap.createBitmap(77, 24, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfAttributeSparklesRight);
HabiticaIcons.drawAttributeSparklesRight(canvas);
return imageOfAttributeSparklesRight;
}
private static Bitmap imageOfAttributeAllocateButton = null;
public static Bitmap imageOfAttributeAllocateButton() {
if (imageOfAttributeAllocateButton != null)
return imageOfAttributeAllocateButton;
imageOfAttributeAllocateButton = Bitmap.createBitmap(24, 15, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfAttributeAllocateButton);
HabiticaIcons.drawAttributeAllocateButton(canvas);
return imageOfAttributeAllocateButton;
}
// Resizing Behavior
public static void resizingBehaviorApply(ResizingBehavior behavior, RectF rect, RectF target, RectF result) {

View file

@ -433,4 +433,43 @@ public class HabiticaIconsHelper {
return imageOfHourglassShop;
}
private static Bitmap imageOfAttributeSparklesLeft = null;
public static Bitmap imageOfAttributeSparklesLeft() {
if (imageOfAttributeSparklesLeft != null)
return imageOfAttributeSparklesLeft;
imageOfAttributeSparklesLeft = Bitmap.createBitmap(scaleSize(77), scaleSize(24), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfAttributeSparklesLeft);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawAttributeSparklesLeft(canvas);
return imageOfAttributeSparklesLeft;
}
private static Bitmap imageOfAttributeSparklesRight = null;
public static Bitmap imageOfAttributeSparklesRight() {
if (imageOfAttributeSparklesRight != null)
return imageOfAttributeSparklesRight;
imageOfAttributeSparklesRight = Bitmap.createBitmap(scaleSize(77), scaleSize(24), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfAttributeSparklesRight);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawAttributeSparklesRight(canvas);
return imageOfAttributeSparklesRight;
}
private static Bitmap imageOfAttributeAllocateButton = null;
public static Bitmap imageOfAttributeAllocateButton() {
if (imageOfAttributeAllocateButton != null)
return imageOfAttributeAllocateButton;
imageOfAttributeAllocateButton = Bitmap.createBitmap(scaleSize(24), scaleSize(15), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(imageOfAttributeAllocateButton);
canvas.scale(displayDensity, displayDensity);
HabiticaIcons.drawAttributeAllocateButton(canvas);
return imageOfAttributeAllocateButton;
}
}

View file

@ -13,26 +13,52 @@ class StatsView(context: Context?, attrs: AttributeSet?) : LinearLayout(context,
var levelValue: Int = 0
set(value) {
field = value
levelValueTextView.text = value.toString()
}
var equipmentValue: Int = 0
set(value) {
field = value
equipmentValueTextView.text = value.toString()
}
var buffValue: Int = 0
set(value) {
field = value
buffValueTextView.text = value.toString()
}
var allocatedValue: Int = 0
set(value) {
field = value
allocatedValueTextView.text = value.toString()
}
var totalValue: Int = 0
set(value) {
field = value
totalValueTextView.text = value.toString()
}
var canDistributePoints: Boolean = false
set(value) {
field = value
allocateButton.visibility = if (value) View.VISIBLE else View.GONE
if (value) {
allocatedWrapper.setBackgroundColor(ContextCompat.getColor(context, R.color.gray_600_30))
allocateButton.setBackgroundColor(ContextCompat.getColor(context, R.color.gray_600_30))
allocatedValueTextView.setTextColor(statColor)
allocatedLabelView.setTextColor(statColor)
} else {
allocatedWrapper.setBackgroundColor(ContextCompat.getColor(context, R.color.gray_700))
allocateButton.setBackgroundColor(ContextCompat.getColor(context, R.color.gray_700))
allocatedValueTextView.setTextColor(ContextCompat.getColor(context, R.color.gray_50))
allocatedLabelView.setTextColor(ContextCompat.getColor(context, R.color.gray_300))
}
}
var allocateAction: (() -> Unit)? = null
private var statColor: Int = 0
init {
View.inflate(context, R.layout.stats_view, this)
@ -43,10 +69,16 @@ class StatsView(context: Context?, attrs: AttributeSet?) : LinearLayout(context,
val backgroundDrawable = ContextCompat.getDrawable(context, R.drawable.layout_top_rounded_bg)
if (attributes != null) {
statColor = attributes.getColor(R.styleable.StatsView_statsColor, 0)
backgroundDrawable.setColorFilter(attributes.getColor(R.styleable.StatsView_titleBackgroundColor, 0), PorterDuff.Mode.MULTIPLY)
titleTextView.text = attributes.getString(R.styleable.StatsView_statsTitle)
}
titleWrapper.background = backgroundDrawable
}
allocateButton.setOnClickListener {
allocateAction?.invoke()
}
allocateButton.setImageBitmap(HabiticaIconsHelper.imageOfAttributeAllocateButton())
}
}