rename sub-layouts to profile_* , extract resources, toggle attributes, hide costume card if the user doesn't activated it

This commit is contained in:
Negue 2016-08-09 22:29:05 +02:00
parent a46a54644a
commit 9f3d67419b
6 changed files with 70 additions and 38 deletions

View file

@ -167,7 +167,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Equipment"
android:text="@string/battle_gear"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
@ -187,7 +187,7 @@
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/costume_group"
android:id="@+id/profile_costume_card"
style="@style/CardView.Default"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -201,7 +201,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Costume"
android:text="@string/costume"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
@ -222,8 +222,11 @@
<android.support.v7.widget.CardView
style="@style/CardView.Default"
android:id="@+id/profile_attributes_card"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true">
<LinearLayout
android:layout_width="match_parent"
@ -244,7 +247,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Attributes"
android:text="@string/attributes"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
@ -296,7 +299,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pets &amp; Mounts"
android:text="@string/profile_pets_and_mounts"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
@ -310,7 +313,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pet-Count" />
android:text="@string/profile_pets_found" />
<TextView
android:id="@+id/profile_pet_count"
@ -324,7 +327,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Mount-Count" />
android:text="@string/profile_mounts_tamed" />
<TextView
android:id="@+id/profile_mount_count"

View file

@ -9,7 +9,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:text="Chat"
android:text="@string/chat"
android:id="@+id/new_message_title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/material_drawer_primary_text" />

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="profile_pets_and_mounts">Pets &amp; Mounts</string>
<string name="profile_pets_found">Pets Found</string>
<string name="profile_mounts_tamed">Mounts Tamed</string>
<string name="profile_loading_data">loading member data..</string>
<string name="profile_send_message_to">Send message to %s</string>
<string name="profile_message_sent_to">Message sent to %s</string>
<string name="profile_level">Level:</string>
<string name="profile_class_bonus">Class-Bonus:</string>
<string name="profile_allocated">Allocated:</string>
<string name="profile_boosts">Boosts:</string>
</resources>

View file

@ -2,21 +2,13 @@ package com.habitrpg.android.habitica.ui.activities;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.Animatable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.util.ArrayMap;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TableLayout;
@ -32,11 +24,8 @@ import com.habitrpg.android.habitica.ContentCache;
import com.habitrpg.android.habitica.HabiticaApplication;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.components.AppComponent;
import com.habitrpg.android.habitica.events.commands.SendNewInboxMessageCommand;
import com.habitrpg.android.habitica.ui.AvatarView;
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
import com.habitrpg.android.habitica.ui.fragments.social.InboxMessageListFragment;
import com.habitrpg.android.habitica.ui.helpers.EmojiKeyboard;
import com.habitrpg.android.habitica.ui.helpers.UiUtils;
import com.magicmicky.habitrpgwrapper.lib.models.Buffs;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
@ -47,8 +36,6 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.ItemData;
import net.pherth.android.emoji_library.EmojiEditText;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -75,6 +62,9 @@ public class FullProfileActivity extends BaseActivity {
@BindView(R.id.avatarView)
AvatarView avatarView;
@BindView(R.id.profile_attributes_card)
CardView attributesCardView;
@BindView(R.id.attributes_table)
TableLayout attributesTableLayout;
@ -93,6 +83,9 @@ public class FullProfileActivity extends BaseActivity {
@BindView(R.id.avatar_costume_progress)
ProgressBar costumeProgress;
@BindView(R.id.profile_costume_card)
CardView costumeCard;
@BindView(R.id.avatar_with_bars)
View avatar_with_bars;
private AvatarWithBarsViewModel avatarWithBars;
@ -114,7 +107,7 @@ public class FullProfileActivity extends BaseActivity {
Bundle bundle = intent.getExtras();
this.userId = bundle.getString("userId");
setTitle("loading member data..");
setTitle(R.string.profile_loading_data);
apiHelper.apiService.GetMember(this.userId)
.compose(apiHelper.configureApiCallObserver())
@ -129,6 +122,9 @@ public class FullProfileActivity extends BaseActivity {
avatarWithBars.valueBarLabelsToBlack();
avatar_with_bars.setBackgroundColor(getResources().getColor(R.color.transparent));
attributeRows.clear();
attributesCardView.setOnClickListener(view -> toggleAttributeDetails());
}
@Override
@ -138,12 +134,12 @@ public class FullProfileActivity extends BaseActivity {
if (id == R.id.private_message) {
LayoutInflater factory = LayoutInflater.from(this);
final View newMessageView = factory.inflate(
R.layout.fullprofile_new_message_dialog, null);
R.layout.profile_new_message_dialog, null);
EmojiEditText emojiEditText = (EmojiEditText)newMessageView.findViewById(R.id.edit_new_message_text);
TextView newMessageTitle = (TextView)newMessageView.findViewById(R.id.new_message_title);
newMessageTitle.setText("Send message to "+userName);
newMessageTitle.setText(String.format(getString(R.string.profile_send_message_to), userName));
final AlertDialog addMessageDialog = new AlertDialog.Builder(this)
.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
@ -155,7 +151,7 @@ public class FullProfileActivity extends BaseActivity {
.compose(apiHelper.configureApiCallObserver())
.subscribe(postChatMessageResult -> {
UiUtils.showSnackbar(FullProfileActivity.this, FullProfileActivity.this.fullprofile_scrollview,
"Message sent to "+userName, UiUtils.SnackbarDisplayType.NORMAL);
String.format(getString(R.string.profile_message_sent_to), userName), UiUtils.SnackbarDisplayType.NORMAL);
}, throwable -> {
});
@ -259,7 +255,7 @@ public class FullProfileActivity extends BaseActivity {
}
private TableRow addEquipmentRow(TableLayout table, String gearKey, String text, String stats) {
TableRow gearRow = (TableRow) getLayoutInflater().inflate(R.layout.fullprofile_gear_tablerow, null);
TableRow gearRow = (TableRow) getLayoutInflater().inflate(R.layout.profile_gear_tablerow, null);
SimpleDraweeView draweeView = (SimpleDraweeView) gearRow.findViewById(R.id.gear_drawee);
@ -291,7 +287,7 @@ public class FullProfileActivity extends BaseActivity {
// endregion
// region Stats
// region Attributes
private float attributeStrSum = 0;
private float attributeIntSum = 0;
@ -301,7 +297,7 @@ public class FullProfileActivity extends BaseActivity {
private void addLevelAttributes(Stats stats, HabitRPGUser user) {
float byLevelStat = stats.getLvl() / 2.0f;
addAttributeRow("Level: ", byLevelStat, byLevelStat, byLevelStat, byLevelStat, false);
addAttributeRow(getString(R.string.profile_level), byLevelStat, byLevelStat, byLevelStat, byLevelStat, false);
LoadItemDataByOutfit(user.getItems().getGear().getEquipped(), obj -> {
GotGear(obj, user);
@ -310,9 +306,13 @@ public class FullProfileActivity extends BaseActivity {
stopAndHideProgress(attributesProgress);
});
LoadItemDataByOutfit(user.getItems().getGear().getCostume(), obj -> {
GotCostume(obj);
});
if(user.getPreferences().getCostume()){
LoadItemDataByOutfit(user.getItems().getGear().getCostume(), obj -> {
GotCostume(obj);
});
} else {
costumeCard.setVisibility(View.GONE);
}
}
private void LoadItemDataByOutfit(Outfit outfit, ContentCache.GotContentEntryCallback<List<ItemData>> gotEntries) {
@ -373,7 +373,7 @@ public class FullProfileActivity extends BaseActivity {
stopAndHideProgress(equipmentProgress);
equipmentTableLayout.setVisibility(View.VISIBLE);
addAttributeRow("Equipment: ", strAttributes, intAttributes, conAttributes, perAttributes, false);
addAttributeRow(getString(R.string.battle_gear) +": ", strAttributes, intAttributes, conAttributes, perAttributes, false);
if (!user.getPreferences().isDisableClasses()) {
float strClassBonus = 0;
@ -400,7 +400,7 @@ public class FullProfileActivity extends BaseActivity {
break;
}
addAttributeRow("Class-Bonus: ", strClassBonus, intClassBonus, conClassBonus, perClassBonus, false);
addAttributeRow(getString(R.string.profile_class_bonus), strClassBonus, intClassBonus, conClassBonus, perClassBonus, false);
}
}
@ -417,14 +417,15 @@ public class FullProfileActivity extends BaseActivity {
private void addNormalAddBuffAttributes(Stats stats) {
Buffs buffs = stats.getBuffs();
addAttributeRow("Allocated: ", stats.getStr(), stats.get_int(), stats.getCon(), stats.getPer(), false);
addAttributeRow("Boosts: ", buffs.getStr(), buffs.get_int(), buffs.getCon(), buffs.getPer(), false);
addAttributeRow(getString(R.string.profile_allocated), stats.getStr(), stats.get_int(), stats.getCon(), stats.getPer(), false);
addAttributeRow(getString(R.string.profile_boosts), buffs.getStr(), buffs.get_int(), buffs.getCon(), buffs.getPer(), false);
// Summary row
addAttributeRow("", attributeStrSum, attributeIntSum, attributeConSum, attributePerSum, true);
}
private TableRow addAttributeRow(String label, float strVal, float intVal, float conVal, float perVal, boolean isSummary) {
TableRow tableRow = (TableRow) getLayoutInflater().inflate(R.layout.fullprofile_attributetablerow, null);
TableRow tableRow = (TableRow) getLayoutInflater().inflate(R.layout.profile_attributetablerow, null);
TextView keyTextView = (TextView) tableRow.findViewById(R.id.tv_attribute_type);
keyTextView.setText(label);
@ -451,6 +452,9 @@ public class FullProfileActivity extends BaseActivity {
attributeIntSum += intVal;
attributeConSum += conVal;
attributePerSum += perVal;
attributeRows.add(tableRow);
tableRow.setVisibility(View.GONE);
}
attributesTableLayout.addView(tableRow);
@ -458,6 +462,18 @@ public class FullProfileActivity extends BaseActivity {
return tableRow;
}
private boolean attributeDetailsHidden = true;
private ArrayList<TableRow> attributeRows = new ArrayList<>();
private void toggleAttributeDetails(){
attributeDetailsHidden = !attributeDetailsHidden;
for (TableRow row : attributeRows){
row.setVisibility(attributeDetailsHidden ? View.GONE : View.VISIBLE);
}
}
// endregion
// region Navigation