Merge branch 'rewards-design' into develop

# Conflicts:
#	Habitica/Habitica.iml
#	Habitica/build.gradle
This commit is contained in:
Phillip Thelen 2015-11-15 15:20:39 +01:00
commit e181c51fdc
5 changed files with 179 additions and 69 deletions

View file

@ -80,6 +80,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.3.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.7.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/0.8.5.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.clans/fab/1.6.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.mmin18.layoutcast/library/1.1.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.porokoro.paperboy/paperboy/2.1.0/jars" />
@ -131,8 +132,8 @@
<orderEntry type="library" exported="" name="materialdrawer-4.3.8" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="checkout-0.7.4" level="project" />
<orderEntry type="library" exported="" name="compilerCommon-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="compilerCommon-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="compiler-1.0-rc1" level="project" />
<orderEntry type="library" exported="" name="library-2.4.0" level="project" />
<orderEntry type="library" exported="" name="mimecraft-1.1.1" level="project" />
@ -172,6 +173,7 @@
<orderEntry type="library" exported="" name="eventbus-2.4.0" level="project" />
<orderEntry type="library" exported="" name="library-2.1.4" level="project" />
<orderEntry type="library" exported="" name="crashlytics-2.3.0" level="project" />
<orderEntry type="library" exported="" name="core-0.8.5.0" level="project" />
<orderEntry type="library" exported="" name="ST4-4.0.8" level="project" />
</component>
</module>

View file

@ -90,6 +90,8 @@ dependencies {
compile 'org.solovyev.android:checkout:0.7.4@aar'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
//Material Dialogs
compile('com.github.afollestad.material-dialogs:core:0.8.5.0@aar')
}
android {

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- view background color -->
<solid
android:color="@color/brand_100" >
</solid>
<!-- Here is the corner radius -->
<corners
android:radius="5dp" >
</corners>
</shape>

View file

@ -13,84 +13,95 @@
</data>
<LinearLayout
android:id="@+id/gearElementsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white">
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/btnLayout">
<Button
android:id="@+id/btnReward"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:textSize="15sp"
android:drawableLeft="@drawable/gold"
android:text='@{String.format("%.0f", reward.value)}'
app:backgroundColor="@{reward.getLightTaskColor}" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="60dp"
android:padding="5dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:visibility='@{reward.specialTag == "item" ? View.VISIBLE : View.GONE}'
bind:imageName='@{"shop_"+reward.id}'/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true">
<TextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:paddingTop="5dp"
android:text="@{reward.text}" />
android:orientation="horizontal"
android:layout_centerVertical="true"
android:weightSum="1">
<TextView
android:id="@+id/textView6"
style="@style/CardText"
android:layout_width="match_parent"
<ImageView
android:id="@+id/imageView3"
android:layout_width="60dp"
android:padding="5dp"
android:layout_height="60dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:visibility='@{reward.specialTag == "item" ? View.VISIBLE : View.VISIBLE}'
bind:imageName='@{"shop_"+reward.id}'/>
<LinearLayout
android:id="@+id/textReward"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{reward.notes}"
android:visibility="@{reward.notes != null ? View.VISIBLE : View.GONE}"/>
android:layout_weight="1">
<TextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:paddingTop="5dp"
android:text="@{reward.text}" />
<TextView
android:id="@+id/textView6"
style="@style/CardText"
android:layout_width="wrap_content"
android:layout_height="41dp"
android:text="@{reward.notes}"
android:visibility="@{reward.notes != null ? View.VISIBLE : View.GONE}"/>
</LinearLayout>
<Button
android:id="@+id/btnReward"
android:layout_width="50dp"
android:layout_height="25dp"
android:padding="3dp"
android:textColor="@color/white"
android:layout_gravity="center_vertical"
android:textSize="15sp"
android:drawableLeft="@drawable/ic_header_gold"
android:text='@{String.format("%.0f", reward.value)}'
android:background="@drawable/rounded_purple_square"
android:layout_weight="2"
android:layout_marginRight="10dp" />
</LinearLayout>
<View
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
app:backgroundColor="@{reward.getLightTaskColor}"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
<View
android:id="@+id/bottomBorderView"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/cell_separator"/>
</LinearLayout>
</layout>

View file

@ -5,18 +5,23 @@ import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.ObservableArrayList;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.databinding.DailyItemCardBinding;
import com.habitrpg.android.habitica.databinding.HabitItemCardBinding;
@ -32,6 +37,7 @@ import com.habitrpg.android.habitica.events.TaskTappedEvent;
import com.habitrpg.android.habitica.events.TaskUpdatedEvent;
import com.habitrpg.android.habitica.events.commands.FilterTasksByTagsCommand;
import com.habitrpg.android.habitica.helpers.TagsHelper;
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ChecklistItem;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import com.raizlabs.android.dbflow.runtime.FlowContentObserver;
@ -53,8 +59,7 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
implements FlowContentObserver.OnModelStateChangedListener, IReceiveNewEntries {
public interface IAdditionalEntries
{
public interface IAdditionalEntries {
void GetAdditionalEntries(IReceiveNewEntries callBack);
}
@ -115,16 +120,16 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
}
public void onEvent(TaskUpdatedEvent evnt){
if(!taskType.equals(evnt.task.getType()))
public void onEvent(TaskUpdatedEvent evnt) {
if (!taskType.equals(evnt.task.getType()))
return;
this.filter();
notifyDataSetChanged();
}
public void onEvent(TaskCreatedEvent evnt){
if(!taskType.equals(evnt.task.getType()))
public void onEvent(TaskCreatedEvent evnt) {
if (!taskType.equals(evnt.task.getType()))
return;
observableContent.add(0, evnt.task);
@ -472,20 +477,94 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
binding.btnReward.setClickable(true);
binding.btnReward.setOnClickListener(this);
binding.imageView3.setOnClickListener(this);
binding.gearElementsLayout.setOnClickListener(this);
binding.imageView3.setVisibility(View.GONE);
}
@Override
public void onClick(View v) {
BuyRewardTappedEvent event = new BuyRewardTappedEvent();
if (v == binding.btnReward || v == binding.imageView3 || v == binding.gearElementsLayout) {
BuyRewardTappedEvent event = new BuyRewardTappedEvent();
LinearLayout contentViewForDialog = createContentViewForDialog();
if (v == binding.btnReward) {
event.Reward = Item;
MaterialDialog dialog = createGearDialog(event, contentViewForDialog);
dialog.show();
EventBus.getDefault().post(event);
} else super.onClick(v);
}
private MaterialDialog createGearDialog(final BuyRewardTappedEvent event, LinearLayout contentViewForDialog) {
return new MaterialDialog.Builder(context)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
event.Reward = Item;
EventBus.getDefault().post(event);
}
})
.positiveColor(context.getResources().getColor(R.color.brand_200))
.positiveText("Buy")
.title(binding.getReward().getText())
.customView(contentViewForDialog, true)
.negativeText("Dismiss")
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog materialDialog, DialogAction dialogAction) {
materialDialog.dismiss();
}
}).build();
}
@NonNull
private LinearLayout createContentViewForDialog() {
String price = String.format("%.0f", binding.getReward().value);
String content = binding.getReward().getNotes();
LinearLayout contentViewLayout = new LinearLayout(context);
contentViewLayout.setOrientation(LinearLayout.VERTICAL);
ImageView imageView = new ImageView(context);
imageView.setMinimumWidth(200);
imageView.setMinimumHeight(200);
DataBindingUtils.loadImage(imageView, "shop_" + binding.getReward().getId());
TextView contentTextView = new TextView(context, null);
contentTextView.setText(content);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.bottomMargin = 20;
layoutParams.gravity = Gravity.CENTER;
LinearLayout goldPriceLayout = new LinearLayout(context);
goldPriceLayout.setOrientation(LinearLayout.HORIZONTAL);
goldPriceLayout.setLayoutParams(layoutParams);
TextView priceTextView = new TextView(context);
priceTextView.setText(price);
ImageView gold = new ImageView(context);
gold.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_header_gold));
gold.setMinimumHeight(50);
gold.setMinimumWidth(50);
gold.setPadding(0, 0, 5, 0);
goldPriceLayout.addView(gold);
goldPriceLayout.addView(priceTextView);
if(imageView.getDrawable()!= null){
contentViewLayout.addView(imageView);
}
contentViewLayout.addView(goldPriceLayout);
contentViewLayout.addView(contentTextView);
return contentViewLayout;
}
@Override
public void bindHolder(Task reward, int position) {
super.bindHolder(reward, position);
@ -506,7 +585,7 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
.orderBy(OrderBy.columns("dateCreated").descending())
.queryList());
if(additionalEntries != null){
if (additionalEntries != null) {
additionalEntries.GetAdditionalEntries(this);
}
}