fix design issues

This commit is contained in:
Phillip Thelen 2017-09-26 15:35:32 +02:00
parent cf6242336f
commit 7a71d621a8
10 changed files with 36 additions and 13 deletions

View file

@ -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="1932"
android:versionCode="1934"
android:versionName="1.2"
android:screenOrientation="portrait"
android:installLocation="auto" >

View file

@ -10,14 +10,14 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/task_min_height">
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="false">
android:baselineAligned="false"
android:minHeight="@dimen/task_min_height">
<FrameLayout
android:id="@+id/checkBoxHolder"

View file

@ -3,8 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/task_min_height">
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
@ -12,7 +11,8 @@
android:background="@color/white"
android:baselineAligned="false"
android:foreground="?selectableItemBackground"
android:orientation="horizontal">
android:orientation="horizontal"
android:minHeight="@dimen/task_min_height">
<FrameLayout
android:id="@+id/btnPlusWrapper"

View file

@ -10,15 +10,15 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/task_min_height">
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false">
android:baselineAligned="false"
android:minHeight="@dimen/task_min_height">
<FrameLayout
android:id="@+id/checkBoxHolder"

View file

@ -2,6 +2,8 @@ package com.habitrpg.android.habitica.ui.helpers;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Build;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
@ -39,7 +41,7 @@ public class NavbarUtils {
/**
* http://stackoverflow.com/a/14871974
*/
private static boolean hasSoftKeys(@NonNull Context context) {
public static boolean hasSoftKeys(@NonNull Context context) {
boolean hasSoftwareKeys = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
@ -66,4 +68,12 @@ public class NavbarUtils {
return hasSoftwareKeys;
}
public static boolean isBehindNavbar(int[] parentLocation, Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return parentLocation[1] > (size.y - getNavbarHeight(context));
}
}

View file

@ -19,6 +19,7 @@ public class DailyViewHolder extends ChecklistedViewHolder {
@Override
public void bindHolder(Task newTask, int position) {
this.task = newTask;
if (newTask.isChecklistDisplayActive()) {
this.checklistIndicatorWrapper.setBackgroundResource(newTask.getLightTaskColor());
} else {

View file

@ -40,6 +40,7 @@ public class HabitViewHolder extends BaseTaskViewHolder {
@Override
public void bindHolder(Task newTask, int position) {
this.task = newTask;
if (newTask.up) {
this.btnPlusWrapper.setBackgroundResource(newTask.getLightTaskColor());
if (newTask.getLightTaskColor() == R.color.yellow_100) {

View file

@ -85,6 +85,7 @@ public class RewardViewHolder extends BaseTaskViewHolder {
}
public void bindHolder(Task reward, int position, boolean canBuy) {
this.task = reward;
super.bindHolder(reward, position);
this.priceLabel.setText(NumberAbbreviator.abbreviate(itemView.getContext(), this.task.value));

View file

@ -17,6 +17,7 @@ public class TodoViewHolder extends ChecklistedViewHolder {
@Override
public void bindHolder(Task newTask, int position) {
this.task = newTask;
if (newTask.getCompleted()) {
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
} else {

View file

@ -1,6 +1,7 @@
package com.habitrpg.android.habitica.ui.views;
import android.content.Context;
import android.graphics.Rect;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.design.widget.BaseTransientBottomBar;
@ -15,6 +16,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.ui.helpers.NavbarUtils;
import javax.annotation.Resource;
@ -34,6 +36,13 @@ public class HabiticaSnackbar extends BaseTransientBottomBar<HabiticaSnackbar> {
private static HabiticaSnackbar make(@NonNull ViewGroup parent, int duration) {
final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
final View content = inflater.inflate(R.layout.snackbar_view, parent, false);
if (NavbarUtils.hasSoftKeys(parent.getContext())) {
int[] parentLocation = new int[2];
parent.getLocationInWindow(parentLocation);
if (NavbarUtils.isBehindNavbar(parentLocation, parent.getContext())) {
content.setPadding(0, 0, 0, NavbarUtils.getNavbarHeight(parent.getContext()));
}
}
final ContentViewCallback viewCallback = new ContentViewCallback(content);
final HabiticaSnackbar customSnackbar = new HabiticaSnackbar(parent, content, viewCallback);
customSnackbar.setDuration(duration);
@ -84,13 +93,13 @@ public class HabiticaSnackbar extends BaseTransientBottomBar<HabiticaSnackbar> {
@Override
public void animateContentIn(int delay, int duration) {
ViewCompat.setScaleY(content, 0f);
content.setScaleY(0f);
ViewCompat.animate(content).scaleY(1f).setDuration(duration).setStartDelay(delay);
}
@Override
public void animateContentOut(int delay, int duration) {
ViewCompat.setScaleY(content, 1f);
content.setScaleY(1);
ViewCompat.animate(content).scaleY(0f).setDuration(duration).setStartDelay(delay);
}
}