New task setup view
BIN
Habitica/res/drawable-hdpi/diamond_button.9.png
Normal file
|
After Width: | Height: | Size: 645 B |
BIN
Habitica/res/drawable-hdpi/diamond_button_white.9.png
Normal file
|
After Width: | Height: | Size: 535 B |
BIN
Habitica/res/drawable-mdpi/diamond_button.9.png
Normal file
|
After Width: | Height: | Size: 436 B |
BIN
Habitica/res/drawable-mdpi/diamond_button_white.9.png
Normal file
|
After Width: | Height: | Size: 368 B |
BIN
Habitica/res/drawable-xhdpi/diamond_button.9.png
Normal file
|
After Width: | Height: | Size: 777 B |
BIN
Habitica/res/drawable-xhdpi/diamond_button_white.9.png
Normal file
|
After Width: | Height: | Size: 666 B |
BIN
Habitica/res/drawable-xxhdpi/diamond_button.9.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Habitica/res/drawable-xxhdpi/diamond_button_white.9.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
|
|
@ -50,8 +50,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_toLeftOf="@id/nextButton"
|
||||
android:layout_toRightOf="@id/previousButton"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
|
|
@ -1,27 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/light_gray_bg"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:id="@+id/heart_icon"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:src="@drawable/ic_heart_large"
|
||||
android:layout_marginTop="@dimen/setup_vertical_spacing"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/avatar_background"
|
||||
android:layout_marginTop="@dimen/setup_vertical_spacing"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/task_setup_description"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_marginBottom="6dp" />
|
||||
</LinearLayout>
|
||||
android:layout_below="@id/heart_icon"
|
||||
android:src="@drawable/creator_purple_bg"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="@dimen/avatar_small_width"
|
||||
android:layout_height="@dimen/avatar_small_height"
|
||||
app:showBackground="false"
|
||||
app:showMount="false"
|
||||
app:showPet="false"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignTop="@id/avatar_background"
|
||||
android:layout_marginTop="6dp"/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/recyclerView"/>
|
||||
</LinearLayout>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/avatar_customization_category_bg"
|
||||
android:id="@+id/recyclerView"
|
||||
android:padding="17dp"/>
|
||||
|
||||
<com.habitrpg.android.habitica.ui.SpeechBubbleView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:namePlate="Justin"
|
||||
app:text="@string/avatar_setup_description"
|
||||
app:npcDrawable="@drawable/npc_justin_only"
|
||||
android:layout_marginLeft="@dimen/content_inset"
|
||||
android:layout_marginRight="@dimen/content_inset"
|
||||
android:layout_above="@id/recyclerView"
|
||||
android:layout_marginBottom="12dp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -1,42 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
<Button xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/textView"
|
||||
android:layout_height="36dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="1">
|
||||
<RelativeLayout
|
||||
android:id="@+id/checkBoxHolder"
|
||||
android:layout_width="@dimen/button_width"
|
||||
android:layout_height="match_parent">
|
||||
<CheckBox
|
||||
android:id="@+id/checkBox"
|
||||
android:layout_width="@dimen/checkbox_size"
|
||||
android:layout_height="@dimen/checkbox_size"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:button="@drawable/daily_checkbox"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:clickable="false" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:id="@+id/checkedTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:id="@+id/bottomBorderView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/hairline_height"
|
||||
android:background="@color/cell_separator"/>
|
||||
</LinearLayout>
|
||||
style="@style/DiamondButton"
|
||||
android:background="@drawable/diamond_button_white"
|
||||
android:layout_margin="6dp" />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@
|
|||
|
||||
<style name="DiamondButton" parent="@style/Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:layout_height">36dp</item>
|
||||
<item name="android:background">@drawable/login_button</item>
|
||||
<item name="android:background">@drawable/diamond_button</item>
|
||||
<item name="android:paddingLeft">36dp</item>
|
||||
<item name="android:paddingRight">36dp</item>
|
||||
<item name="android:textColor">@color/white</item>
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
}
|
||||
|
||||
public static boolean checkUserAuthentication(Context context, HostConfig hostConfig) {
|
||||
startActivity(SetupActivity.class, context);
|
||||
if (hostConfig == null || hostConfig.getApi() == null || hostConfig.getApi().equals("") || hostConfig.getUser() == null || hostConfig.getUser().equals("")) {
|
||||
startActivity(IntroActivity.class, context);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import com.habitrpg.android.habitica.APIHelper;
|
|||
import com.habitrpg.android.habitica.HostConfig;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.callbacks.HabitRPGUserCallback;
|
||||
import com.habitrpg.android.habitica.callbacks.ItemsCallback;
|
||||
import com.habitrpg.android.habitica.callbacks.MergeUserCallback;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.events.commands.EquipCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.UpdateUserCommand;
|
||||
import com.habitrpg.android.habitica.helpers.AmplitudeManager;
|
||||
import com.habitrpg.android.habitica.ui.fragments.setup.AvatarSetupFragment;
|
||||
|
|
@ -30,6 +32,7 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.content.res.AppCompatResources;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
|
@ -95,7 +98,7 @@ public class SetupActivity extends BaseActivity implements ViewPager.OnPageChang
|
|||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = getWindow();
|
||||
window.setStatusBarColor(getResources().getColor(R.color.light_gray_bg));
|
||||
window.setStatusBarColor(ContextCompat.getColor(this, R.color.days_gray));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,6 +147,14 @@ public class SetupActivity extends BaseActivity implements ViewPager.OnPageChang
|
|||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(EquipCommand event) {
|
||||
this.apiHelper.apiService.equipItem(event.type, event.key)
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(new ItemsCallback(this, this.user), throwable -> {
|
||||
});
|
||||
}
|
||||
|
||||
@OnClick(R.id.nextButton)
|
||||
public void nextClicked(View v) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
|
@ -197,6 +208,7 @@ public class SetupActivity extends BaseActivity implements ViewPager.OnPageChang
|
|||
this.nextButton.setText(this.getString(R.string.intro_finish_button));
|
||||
} else {
|
||||
this.setPreviousButtonEnabled(true);
|
||||
this.nextButton.setText(this.getString(R.string.next_button));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +269,7 @@ public class SetupActivity extends BaseActivity implements ViewPager.OnPageChang
|
|||
}
|
||||
case 2: {
|
||||
taskSetupFragment = new TaskSetupFragment();
|
||||
taskSetupFragment.setUser(user);
|
||||
fragment = taskSetupFragment;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
|
|||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.commands.EquipCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.UpdateUserCommand;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Customization;
|
||||
|
|
@ -165,18 +166,21 @@ public class CustomizationSetupAdapter extends RecyclerView.Adapter<RecyclerView
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
UpdateUserCommand command = new UpdateUserCommand();
|
||||
Map<String, Object> updateData = new HashMap<>();
|
||||
if (customization.path.equals("glasses")) {
|
||||
String updatePath = "items.gear.equipped.eyewear";
|
||||
updateData.put(updatePath, customization.key);
|
||||
EquipCommand command = new EquipCommand();
|
||||
command.key = customization.key;
|
||||
command.type = "equipped";
|
||||
EventBus.getDefault().post(command);
|
||||
} else {
|
||||
UpdateUserCommand command = new UpdateUserCommand();
|
||||
Map<String, Object> updateData = new HashMap<>();
|
||||
String updatePath = "preferences." + customization.getPath();
|
||||
updateData.put(updatePath, customization.key);
|
||||
}
|
||||
command.updateData = updateData;
|
||||
|
||||
EventBus.getDefault().post(command);
|
||||
command.updateData = updateData;
|
||||
|
||||
EventBus.getDefault().post(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ package com.habitrpg.android.habitica.ui.adapter.setup;
|
|||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -51,28 +55,26 @@ public class TaskSetupAdapter extends RecyclerView.Adapter<TaskSetupAdapter.Task
|
|||
|
||||
class TaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
|
||||
@BindView(R.id.checkedTextView)
|
||||
private final Drawable icon;
|
||||
@BindView(R.id.textView)
|
||||
TextView textView;
|
||||
|
||||
@BindView(R.id.checkBoxHolder)
|
||||
RelativeLayout checkBoxHolder;
|
||||
|
||||
@BindView(R.id.checkBox)
|
||||
CheckBox checkBox;
|
||||
|
||||
String[] taskGroup;
|
||||
Boolean isChecked;
|
||||
|
||||
Resources resources;
|
||||
Context context;
|
||||
|
||||
public TaskViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
ButterKnife.bind(this, itemView);
|
||||
|
||||
resources = itemView.getResources();
|
||||
context = itemView.getContext();
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
|
||||
icon = ContextCompat.getDrawable(context, R.drawable.ic_check);
|
||||
icon.setColorFilter(ContextCompat.getColor(context, R.color.brand_100), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
public void bind(String[] taskGroup, Boolean isChecked) {
|
||||
|
|
@ -80,8 +82,15 @@ public class TaskSetupAdapter extends RecyclerView.Adapter<TaskSetupAdapter.Task
|
|||
this.isChecked = isChecked;
|
||||
|
||||
this.textView.setText(this.taskGroup[0]);
|
||||
this.checkBox.setChecked(this.isChecked);
|
||||
this.checkBoxHolder.setBackgroundResource(R.color.brand_200);
|
||||
if (this.isChecked) {
|
||||
this.textView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||
textView.getBackground().setColorFilter(ContextCompat.getColor(context, R.color.white), PorterDuff.Mode.MULTIPLY);
|
||||
textView.setTextColor(ContextCompat.getColor(context, R.color.brand_100));
|
||||
} else {
|
||||
this.textView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||
textView.getBackground().setColorFilter(ContextCompat.getColor(context, R.color.brand_100), PorterDuff.Mode.MULTIPLY);
|
||||
textView.setTextColor(ContextCompat.getColor(context, R.color.white));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,14 +2,17 @@ package com.habitrpg.android.habitica.ui.fragments.setup;
|
|||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.ui.AvatarView;
|
||||
import com.habitrpg.android.habitica.ui.activities.SetupActivity;
|
||||
import com.habitrpg.android.habitica.ui.adapter.setup.TaskSetupAdapter;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Days;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -31,9 +34,12 @@ public class TaskSetupFragment extends BaseFragment {
|
|||
View view;
|
||||
@BindView(R.id.recyclerView)
|
||||
RecyclerView recyclerView;
|
||||
@BindView(R.id.avatarView)
|
||||
AvatarView avatarView;
|
||||
TaskSetupAdapter adapter;
|
||||
private String[][] taskGroups;
|
||||
private Object[][] tasks;
|
||||
private HabitRPGUser user;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
|
@ -47,11 +53,27 @@ public class TaskSetupFragment extends BaseFragment {
|
|||
unbinder = ButterKnife.bind(this, view);
|
||||
this.adapter = new TaskSetupAdapter();
|
||||
this.adapter.setTaskList(this.taskGroups);
|
||||
this.recyclerView.setLayoutManager(new LinearLayoutManager(activity));
|
||||
this.recyclerView.setLayoutManager(new GridLayoutManager(activity, 2));
|
||||
this.recyclerView.setAdapter(this.adapter);
|
||||
|
||||
if (this.user != null) {
|
||||
this.updateAvatar();
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setUser(HabitRPGUser user) {
|
||||
this.user = user;
|
||||
if (avatarView != null) {
|
||||
updateAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAvatar() {
|
||||
avatarView.setUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectFragment(AppComponent component) {
|
||||
component.inject(this);
|
||||
|
|
|
|||