mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 12:18:59 +00:00
fix task layout issues
This commit is contained in:
parent
4607e4cc7b
commit
a355cc4ecb
9 changed files with 47 additions and 46 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="1931"
|
||||
android:versionCode="1932"
|
||||
android:versionName="1.2"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@
|
|||
android:id="@+id/checklistDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/gray_500" />
|
||||
android:background="@color/gray_500"
|
||||
android:visibility="gone"/>
|
||||
<LinearLayout
|
||||
android:id="@id/checklistView"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/gray_300"
|
||||
tools:text="150"
|
||||
android:layout_marginLeft="6dp"
|
||||
style="@style/Body1"
|
||||
android:textSize="15sp" />
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -59,37 +59,35 @@ public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implement
|
|||
|
||||
@Override
|
||||
public void bindHolder(Task newTask, int position) {
|
||||
super.bindHolder(newTask, position);
|
||||
|
||||
boolean completed = this.task.completed;
|
||||
if (task.isPendingApproval()) {
|
||||
boolean completed = newTask.completed;
|
||||
if (newTask.isPendingApproval()) {
|
||||
completed = false;
|
||||
}
|
||||
this.checkbox.setChecked(completed);
|
||||
if (this.shouldDisplayAsActive() && !task.isPendingApproval()) {
|
||||
this.checkboxHolder.setBackgroundResource(this.task.getLightTaskColor());
|
||||
if (this.shouldDisplayAsActive(newTask) && !newTask.isPendingApproval()) {
|
||||
this.checkboxHolder.setBackgroundResource(newTask.getLightTaskColor());
|
||||
} else {
|
||||
this.checkboxHolder.setBackgroundColor(this.taskGray);
|
||||
}
|
||||
this.checklistCompletedTextView.setText(String.valueOf(task.getCompletedChecklistCount()));
|
||||
this.checklistAllTextView.setText(String.valueOf(task.getChecklist().size()));
|
||||
this.checklistCompletedTextView.setText(String.valueOf(newTask.getCompletedChecklistCount()));
|
||||
this.checklistAllTextView.setText(String.valueOf(newTask.getChecklist().size()));
|
||||
|
||||
this.checklistView.removeAllViews();
|
||||
this.updateChecklistDisplay();
|
||||
|
||||
this.checklistIndicatorWrapper.setVisibility(task.checklist.size() == 0 ? View.GONE : View.VISIBLE);
|
||||
this.checklistIndicatorWrapper.setVisibility(newTask.checklist.size() == 0 ? View.GONE : View.VISIBLE);
|
||||
if (this.rightBorderView != null) {
|
||||
this.rightBorderView.setVisibility(task.checklist.size() == 0 ? View.VISIBLE : View.GONE);
|
||||
if (this.task.getCompleted()) {
|
||||
this.rightBorderView.setBackgroundResource(this.task.getLightTaskColor());
|
||||
this.rightBorderView.setVisibility(newTask.checklist.size() == 0 ? View.VISIBLE : View.GONE);
|
||||
if (newTask.getCompleted()) {
|
||||
this.rightBorderView.setBackgroundResource(newTask.getLightTaskColor());
|
||||
} else {
|
||||
this.rightBorderView.setBackgroundColor(this.taskGray);
|
||||
}
|
||||
}
|
||||
|
||||
super.bindHolder(newTask, position);
|
||||
}
|
||||
|
||||
abstract public Boolean shouldDisplayAsActive();
|
||||
abstract public Boolean shouldDisplayAsActive(Task newTask);
|
||||
|
||||
public void updateChecklistDisplay() {
|
||||
//This needs to be a LinearLayout, as ListViews can not be inside other ListViews.
|
||||
|
|
@ -115,7 +113,7 @@ public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implement
|
|||
event.item = item;
|
||||
EventBus.getDefault().post(event);
|
||||
});
|
||||
RelativeLayout checkboxHolder = (RelativeLayout) itemView.findViewById(R.id.checkBoxHolder);
|
||||
ViewGroup checkboxHolder = (ViewGroup) itemView.findViewById(R.id.checkBoxHolder);
|
||||
expandCheckboxTouchArea(checkboxHolder, checkbox);
|
||||
this.checklistView.addView(itemView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,17 @@ public class DailyViewHolder extends ChecklistedViewHolder {
|
|||
|
||||
@Override
|
||||
public void bindHolder(Task newTask, int position) {
|
||||
super.bindHolder(newTask, position);
|
||||
if (this.task.isChecklistDisplayActive()) {
|
||||
this.checklistIndicatorWrapper.setBackgroundResource(this.task.getLightTaskColor());
|
||||
if (newTask.isChecklistDisplayActive()) {
|
||||
this.checklistIndicatorWrapper.setBackgroundResource(newTask.getLightTaskColor());
|
||||
} else {
|
||||
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
|
||||
}
|
||||
super.bindHolder(newTask, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean shouldDisplayAsActive() {
|
||||
return this.task.isDisplayedActive();
|
||||
public Boolean shouldDisplayAsActive(Task newTask) {
|
||||
return newTask.isDisplayedActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -40,11 +40,9 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
|
||||
@Override
|
||||
public void bindHolder(Task newTask, int position) {
|
||||
super.bindHolder(newTask, position);
|
||||
|
||||
if (this.task.up) {
|
||||
this.btnPlusWrapper.setBackgroundResource(this.task.getLightTaskColor());
|
||||
if (this.task.getLightTaskColor() == R.color.yellow_100) {
|
||||
if (newTask.up) {
|
||||
this.btnPlusWrapper.setBackgroundResource(newTask.getLightTaskColor());
|
||||
if (newTask.getLightTaskColor() == R.color.yellow_100) {
|
||||
this.btnPlusIconView.setImageResource(R.drawable.habit_plus_yellow);
|
||||
} else {
|
||||
this.btnPlusIconView.setImageResource(R.drawable.habit_plus);
|
||||
|
|
@ -58,9 +56,9 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
this.btnPlus.setClickable(false);
|
||||
}
|
||||
|
||||
if (this.task.down) {
|
||||
this.btnMinusWrapper.setBackgroundResource(this.task.getLightTaskColor());
|
||||
if (this.task.getLightTaskColor() == R.color.yellow_100) {
|
||||
if (newTask.down) {
|
||||
this.btnMinusWrapper.setBackgroundResource(newTask.getLightTaskColor());
|
||||
if (newTask.getLightTaskColor() == R.color.yellow_100) {
|
||||
this.btnMinusIconView.setImageResource(R.drawable.habit_minus_yellow);
|
||||
} else {
|
||||
this.btnMinusIconView.setImageResource(R.drawable.habit_minus);
|
||||
|
|
@ -75,11 +73,11 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
}
|
||||
|
||||
String streakString = "";
|
||||
if (task.counterUp > 0 && task.counterDown > 0) {
|
||||
if (newTask.counterUp > 0 && newTask.counterDown > 0) {
|
||||
streakString = streakString + "+" + String.valueOf(task.counterUp) + " | -" + String.valueOf(task.counterDown);
|
||||
} else if (task.counterUp > 0) {
|
||||
} else if (newTask.counterUp > 0) {
|
||||
streakString = streakString + "+" + String.valueOf(task.counterUp);
|
||||
} else if (task.counterUp > 0) {
|
||||
} else if (newTask.counterUp > 0) {
|
||||
streakString = streakString + "-" + String.valueOf(task.counterDown);
|
||||
}
|
||||
if (streakString.length() > 0) {
|
||||
|
|
@ -88,6 +86,7 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
} else {
|
||||
streakTextView.setVisibility(View.GONE);
|
||||
}
|
||||
super.bindHolder(newTask, position);
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnPlus)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.ui.viewHolders.tasks;
|
||||
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -37,12 +38,6 @@ public class RewardViewHolder extends BaseTaskViewHolder {
|
|||
goldIconView.setImageBitmap(HabiticaIconsHelper.imageOfGold());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindHolder(Task newTask, int position) {
|
||||
super.bindHolder(newTask, position);
|
||||
|
||||
this.priceLabel.setText(NumberAbbreviator.abbreviate(itemView.getContext(), this.task.value));
|
||||
}
|
||||
|
||||
private boolean isItem() {
|
||||
return this.task.specialTag != null && this.task.specialTag.equals("item");
|
||||
|
|
@ -90,6 +85,15 @@ public class RewardViewHolder extends BaseTaskViewHolder {
|
|||
}
|
||||
|
||||
public void bindHolder(Task reward, int position, boolean canBuy) {
|
||||
super.bindHolder(reward, position);
|
||||
this.priceLabel.setText(NumberAbbreviator.abbreviate(itemView.getContext(), this.task.value));
|
||||
|
||||
if (canBuy) {
|
||||
goldIconView.setAlpha(1.0f);
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.yellow_50));
|
||||
} else {
|
||||
goldIconView.setAlpha(0.4f);
|
||||
priceLabel.setTextColor(ContextCompat.getColor(context, R.color.gray_500));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,12 @@ public class TodoViewHolder extends ChecklistedViewHolder {
|
|||
|
||||
@Override
|
||||
public void bindHolder(Task newTask, int position) {
|
||||
super.bindHolder(newTask, position);
|
||||
if (this.task.getCompleted()) {
|
||||
if (newTask.getCompleted()) {
|
||||
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
|
||||
} else {
|
||||
this.checklistIndicatorWrapper.setBackgroundResource(this.task.getLightTaskColor());
|
||||
this.checklistIndicatorWrapper.setBackgroundResource(newTask.getLightTaskColor());
|
||||
}
|
||||
|
||||
super.bindHolder(newTask, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -39,7 +38,7 @@ public class TodoViewHolder extends ChecklistedViewHolder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean shouldDisplayAsActive() {
|
||||
return !this.task.getCompleted();
|
||||
public Boolean shouldDisplayAsActive(Task newTask) {
|
||||
return !newTask.getCompleted();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ public class YesterdailyDialog extends AlertDialog {
|
|||
|
||||
if (task.checklist.size() > 0) {
|
||||
View checklistDivider = taskView.findViewById(R.id.checklistDivider);
|
||||
checklistDivider.setVisibility(View.VISIBLE);
|
||||
ViewGroup checklistContainer = taskView.findViewById(R.id.checklistView);
|
||||
for (ChecklistItem item : task.checklist) {
|
||||
View checklistView = inflater.inflate(R.layout.checklist_item_row, yesterdailiesList, false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue