mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 05:38:55 +00:00
Design fixes
This commit is contained in:
parent
c8adf7bd78
commit
f3afda0720
13 changed files with 62 additions and 58 deletions
|
|
@ -67,7 +67,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:gravity="center_vertical">
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
android:id="@+id/gold_icon"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:paddingBottom="4dp"/>
|
||||
android:paddingBottom="8dp"/>
|
||||
<TextView
|
||||
android:id="@id/priceLabel"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -29,11 +29,7 @@
|
|||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/layout_rounded_bg_shopitem_price">
|
||||
<ImageView
|
||||
android:id="@+id/currency_icon_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"/>
|
||||
<TextView
|
||||
<com.habitrpg.android.habitica.ui.views.CurrencyView
|
||||
android:id="@+id/priceLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
android:layout_height="@dimen/shop_scene_height" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_marginTop="138dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginTop="97dp"
|
||||
android:background="@drawable/gradient_white"/>
|
||||
|
||||
<TextView
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
android:gravity="center_vertical"
|
||||
android:textColor="@color/white"
|
||||
android:layout_marginLeft="45dp"
|
||||
android:layout_marginTop="126dp"
|
||||
android:layout_marginTop="83dp"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:id="@+id/descriptionView"
|
||||
|
|
@ -37,7 +37,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="156dp"
|
||||
tools:text="Welcome to the Market! Stock up on new gear or buy rare eggs and potions. Check in periodically for new stock."
|
||||
/>
|
||||
android:layout_marginTop="124dp"
|
||||
tools:text="Welcome to the Market! Stock up on new gear or buy rare eggs and potions. Check in periodically for new stock." />
|
||||
</FrameLayout>
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
<dimen name="bottom_menu_padding">18dp</dimen>
|
||||
<dimen name="pet_image_width">81dp</dimen>
|
||||
<dimen name="pet_image_height">99dp</dimen>
|
||||
<dimen name="shop_height">192dp</dimen>
|
||||
<dimen name="shop_height">124dp</dimen>
|
||||
<dimen name="bar_icon_padding">10dp</dimen>
|
||||
<dimen name="task_text_padding">16dp</dimen>
|
||||
<dimen name="task_text_compactpadding">4dp</dimen>
|
||||
|
|
@ -112,7 +112,7 @@
|
|||
<dimen name="shopitem_width">84dp</dimen>
|
||||
<dimen name="shopitem_status_size">24dp</dimen>
|
||||
<dimen name="shopitem_image_size">68dp</dimen>
|
||||
<dimen name="shop_scene_height">186dp</dimen>
|
||||
<dimen name="shop_scene_height">124dp</dimen>
|
||||
<dimen name="currency_icon_size">24dp</dimen>
|
||||
<dimen name="shopitem_dialog_content_inset">24dp</dimen>
|
||||
<dimen name="reward_width">84dp</dimen>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class AvatarWithBarsViewModel {
|
|||
|
||||
ButterKnife.bind(this, v);
|
||||
|
||||
hpBar.setIcon(HabiticaIconsHelper.imageOfHeartDarkBg());
|
||||
hpBar.setIcon(HabiticaIconsHelper.imageOfHeartLightBg());
|
||||
xpBar.setIcon(HabiticaIconsHelper.imageOfExperience());
|
||||
mpBar.setIcon(HabiticaIconsHelper.imageOfMagic());
|
||||
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ import org.greenrobot.eventbus.EventBus;
|
|||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -214,7 +215,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
@Nullable
|
||||
private AccountHeader accountHeader;
|
||||
@Nullable
|
||||
private BaseMainFragment activeFragment;
|
||||
private WeakReference<BaseMainFragment> activeFragment;
|
||||
private AvatarWithBarsViewModel avatarInHeader;
|
||||
private AlertDialog faintDialog;
|
||||
private AvatarView sideAvatarView;
|
||||
|
|
@ -271,7 +272,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
userRepository.getUser(hostConfig.getUser())
|
||||
.subscribe(newUser -> {
|
||||
MainActivity.this.user = newUser;
|
||||
MainActivity.this.setUserData(true);
|
||||
MainActivity.this.setUserData();
|
||||
}, RxErrorHandler.handleEmptyError());
|
||||
|
||||
}
|
||||
|
|
@ -309,7 +310,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
//a state can arise in which the active fragment no longer has a
|
||||
//reference to the tabLayout (and all its adapters are null).
|
||||
//Recreate the fragment as a result.
|
||||
if (activeFragment != null && activeFragment.tabLayout == null) {
|
||||
if (activeFragment != null && activeFragment.get() != null && activeFragment.get().tabLayout == null) {
|
||||
activeFragment = null;
|
||||
if (drawer != null) {
|
||||
drawer.setSelectionAtPosition(this.sharedPreferences.getInt("lastActivePosition", 1));
|
||||
|
|
@ -336,13 +337,13 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
|
||||
@SuppressLint("ObsoleteSdkInt")
|
||||
public void displayFragment(BaseMainFragment fragment) {
|
||||
if (this.activeFragment != null && fragment.getClass() == this.activeFragment.getClass()) {
|
||||
if (this.activeFragment != null && activeFragment.get() != null && fragment.getClass() == this.activeFragment.get().getClass()) {
|
||||
return;
|
||||
}
|
||||
if (SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && this.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
this.activeFragment = fragment;
|
||||
this.activeFragment = new WeakReference<>(fragment);
|
||||
fragment.setArguments(getIntent().getExtras());
|
||||
fragment.setUser(user);
|
||||
fragment.setActivity(this);
|
||||
|
|
@ -362,7 +363,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
}
|
||||
}
|
||||
|
||||
protected void setUserData(boolean fromLocalDb) {
|
||||
protected void setUserData() {
|
||||
if (user != null) {
|
||||
|
||||
Preferences preferences = user.getPreferences();
|
||||
|
|
@ -374,8 +375,8 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
runOnUiThread(() -> {
|
||||
updateHeader();
|
||||
updateSidebar();
|
||||
if (activeFragment != null) {
|
||||
activeFragment.updateUserData(user);
|
||||
if (activeFragment != null && activeFragment.get() != null) {
|
||||
activeFragment.get().updateUserData(user);
|
||||
} else {
|
||||
if (drawer != null) {
|
||||
drawer.setSelectionAtPosition(1);
|
||||
|
|
@ -421,7 +422,7 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
avatarInHeader.updateData(user);
|
||||
}
|
||||
if (activeFragment != null) {
|
||||
setTranslatedFragmentTitle(activeFragment);
|
||||
setTranslatedFragmentTitle(activeFragment.get());
|
||||
}
|
||||
|
||||
if (drawer != null) {
|
||||
|
|
@ -489,10 +490,10 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
}
|
||||
|
||||
public void setActiveFragment(@Nullable BaseMainFragment fragment) {
|
||||
this.activeFragment = fragment;
|
||||
this.activeFragment = new WeakReference<BaseMainFragment>(fragment);
|
||||
setTranslatedFragmentTitle(fragment);
|
||||
if (this.drawer != null && this.activeFragment != null) {
|
||||
this.drawer.setSelectionAtPosition(this.activeFragment.fragmentSidebarPosition, false);
|
||||
if (this.drawer != null && this.activeFragment != null && activeFragment.get() != null) {
|
||||
this.drawer.setSelectionAtPosition(this.activeFragment.get().fragmentSidebarPosition, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -515,8 +516,8 @@ public class MainActivity extends BaseActivity implements TutorialView.OnTutoria
|
|||
drawer.closeDrawer();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
if (this.activeFragment != null) {
|
||||
this.activeFragment.updateUserData(user);
|
||||
if (this.activeFragment != null && activeFragment.get() != null) {
|
||||
this.activeFragment.get().updateUserData(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.facebook.imagepipeline.image.CloseableImage;
|
|||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler;
|
||||
import com.habitrpg.android.habitica.models.inventory.Item;
|
||||
import com.habitrpg.android.habitica.models.shops.Shop;
|
||||
import com.habitrpg.android.habitica.models.shops.ShopCategory;
|
||||
|
|
@ -35,17 +36,20 @@ import com.habitrpg.android.habitica.ui.viewHolders.SectionViewHolder;
|
|||
import com.habitrpg.android.habitica.ui.viewHolders.ShopItemViewHolder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
|
||||
public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private List<Object> items;
|
||||
private String shopIdentifier;
|
||||
private Map<String, Item> ownedItems;
|
||||
private Map<String, Item> ownedItems = new HashMap<>();
|
||||
|
||||
public void setShop(Shop shop) {
|
||||
shopIdentifier = shop.identifier;
|
||||
|
|
@ -182,7 +186,9 @@ public class ShopRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
int width = Math.round(height * aspectRatio);
|
||||
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, width, height, false));
|
||||
drawable.setTileModeX(Shader.TileMode.REPEAT);
|
||||
backgroundView.setBackground(drawable);
|
||||
Observable.just(drawable)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(bitmapDrawable -> backgroundView.setBackground(bitmapDrawable), RxErrorHandler.handleEmptyError());
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,11 +157,15 @@ public abstract class BaseMainFragment extends BaseFragment {
|
|||
}
|
||||
|
||||
public void hideToolbar() {
|
||||
activity.avatar_with_bars.setVisibility(View.GONE);
|
||||
if (activity != null) {
|
||||
activity.avatar_with_bars.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void showToolbar() {
|
||||
activity.avatar_with_bars.setVisibility(View.VISIBLE);
|
||||
if (activity != null) {
|
||||
activity.avatar_with_bars.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void disableToolbarScrolling() {
|
||||
|
|
|
|||
|
|
@ -142,10 +142,8 @@ public class ShopFragment extends BaseFragment {
|
|||
this.adapter.setShop(shop);
|
||||
}, RxErrorHandler.handleEmptyError());
|
||||
|
||||
this.inventoryRepository.getOwnedItems(user)
|
||||
.subscribe(ownedItems -> {
|
||||
adapter.setOwnedItems(ownedItems);
|
||||
}, RxErrorHandler.handleEmptyError());
|
||||
compositeSubscription.add(this.inventoryRepository.getOwnedItems(user)
|
||||
.subscribe(ownedItems -> adapter.setOwnedItems(ownedItems), RxErrorHandler.handleEmptyError()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.habitrpg.android.habitica.HabiticaBaseApplication;
|
|||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.models.shops.ShopItem;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.ui.views.CurrencyView;
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper;
|
||||
import com.habitrpg.android.habitica.ui.views.shops.PurchaseDialog;
|
||||
|
||||
|
|
@ -26,10 +27,8 @@ public class ShopItemViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
SimpleDraweeView imageView;
|
||||
@BindView(R.id.buyButton)
|
||||
View buyButton;
|
||||
@BindView(R.id.currency_icon_view)
|
||||
ImageView currencyIconView;
|
||||
@BindView(R.id.priceLabel)
|
||||
TextView priceLabel;
|
||||
CurrencyView priceLabel;
|
||||
|
||||
@BindView(R.id.item_detail_indicator)
|
||||
TextView itemDetailIndicator;
|
||||
|
|
@ -66,16 +65,8 @@ public class ShopItemViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
|
||||
if (item.getUnlockCondition() == null || !item.getLocked()) {
|
||||
priceLabel.setText(String.valueOf(item.getValue()));
|
||||
if (item.getCurrency().equals("gold")) {
|
||||
currencyIconView.setImageBitmap(HabiticaIconsHelper.imageOfGold());
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.gold));
|
||||
} else if (item.getCurrency().equals("gems")) {
|
||||
currencyIconView.setImageBitmap(HabiticaIconsHelper.imageOfGem());
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.green_10));
|
||||
} else if (item.getCurrency().equals("hourglasses")) {
|
||||
currencyIconView.setImageBitmap(HabiticaIconsHelper.imageOfHourglass());
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.brand_300));
|
||||
} else {
|
||||
priceLabel.setCurrency(item.getCurrency());
|
||||
if (item.getCurrency() == null) {
|
||||
buyButton.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -89,13 +80,10 @@ public class ShopItemViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
itemDetailIndicator.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
priceLabel.setLocked(item.getLocked());
|
||||
if (item.getLocked()) {
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.gray_300));
|
||||
currencyIconView.setAlpha(0.5f);
|
||||
itemDetailIndicator.setBackground(lockedDrawable);
|
||||
itemDetailIndicator.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
currencyIconView.setAlpha(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ public class CurrencyView extends android.support.v7.widget.AppCompatTextView {
|
|||
private void setIcon(Bitmap iconBitmap) {
|
||||
drawable = new BitmapDrawable(getResources(), iconBitmap);
|
||||
this.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
|
||||
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getContext().getResources().getDisplayMetrics());
|
||||
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getContext().getResources().getDisplayMetrics());
|
||||
setCompoundDrawablePadding(padding);
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +52,11 @@ public class CurrencyView extends android.support.v7.widget.AppCompatTextView {
|
|||
}
|
||||
} else if ("gems".equals(currency)) {
|
||||
setIcon(HabiticaIconsHelper.imageOfGem());
|
||||
setTextColor(ContextCompat.getColor(getContext(), R.color.green_50));
|
||||
if (lightbackground) {
|
||||
setTextColor(ContextCompat.getColor(getContext(), R.color.green_100));
|
||||
} else {
|
||||
setTextColor(ContextCompat.getColor(getContext(), R.color.green_50));
|
||||
}
|
||||
} else if ("hourglasses".equals(currency)) {
|
||||
setIcon(HabiticaIconsHelper.imageOfHourglass());
|
||||
if (lightbackground) {
|
||||
|
|
@ -75,6 +80,9 @@ public class CurrencyView extends android.support.v7.widget.AppCompatTextView {
|
|||
}
|
||||
|
||||
public void setLocked(boolean isLocked) {
|
||||
if (drawable == null) {
|
||||
return;
|
||||
}
|
||||
if (isLocked) {
|
||||
this.setTextColor(ContextCompat.getColor(getContext(), R.color.gray_300));
|
||||
drawable.setAlpha(127);
|
||||
|
|
@ -86,6 +94,9 @@ public class CurrencyView extends android.support.v7.widget.AppCompatTextView {
|
|||
}
|
||||
|
||||
public void setCantAfford(boolean cantAfford) {
|
||||
if (drawable == null) {
|
||||
return;
|
||||
}
|
||||
if (cantAfford) {
|
||||
this.setTextColor(ContextCompat.getColor(getContext(), R.color.red_50));
|
||||
drawable.setAlpha(127);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.google.gson.JsonObject;
|
|||
import com.google.gson.JsonParseException;
|
||||
import com.habitrpg.android.habitica.models.inventory.Quest;
|
||||
import com.habitrpg.android.habitica.models.members.Member;
|
||||
import com.habitrpg.android.habitica.models.members.MemberPreferences;
|
||||
import com.habitrpg.android.habitica.models.social.UserParty;
|
||||
import com.habitrpg.android.habitica.models.user.ContributorInfo;
|
||||
import com.habitrpg.android.habitica.models.user.Flags;
|
||||
|
|
@ -42,7 +43,7 @@ public class MemberSerialization implements JsonDeserializer<Member> {
|
|||
member.setInbox(context.deserialize(obj.get("inbox"), Inbox.class));
|
||||
}
|
||||
if (obj.has("preferences")) {
|
||||
member.setPreferences(context.deserialize(obj.get("preferences"), Preferences.class));
|
||||
member.setPreferences(context.deserialize(obj.get("preferences"), MemberPreferences.class));
|
||||
}
|
||||
if (obj.has("profile")) {
|
||||
member.setProfile(context.deserialize(obj.get("profile"), Profile.class));
|
||||
|
|
|
|||
Loading…
Reference in a new issue