mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 20:29:02 +00:00
improve yesterdailies
This commit is contained in:
parent
f7dc8f936b
commit
a760c0052a
4 changed files with 61 additions and 58 deletions
|
|
@ -1,37 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:id="@+id/imageView" />
|
||||
android:id="@+id/imageView"
|
||||
android:layout_marginTop="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:text=""
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginLeft="25dp"
|
||||
android:layout_marginRight="25dp"
|
||||
android:id="@+id/you_earned_message" />
|
||||
android:id="@+id/you_earned_message"
|
||||
tools:text="You unlocked something"/>
|
||||
|
||||
<TextView
|
||||
android:text=""
|
||||
tools:text="Next prize unlocks in 2 check-ins."
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="50dp"
|
||||
android:id="@+id/next_unlock_message" />
|
||||
|
||||
<Button
|
||||
android:text="@string/see_you_tomorrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="50dp"
|
||||
android:id="@+id/confirm_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored" />
|
||||
android:layout_marginTop="20dp"
|
||||
android:id="@+id/next_unlock_message"
|
||||
android:textColor="@color/best_10"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/titleTextView"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -1,21 +1,26 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.Space;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.google.repacked.kotlin.Unit;
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.data.ApiClient;
|
||||
import com.habitrpg.android.habitica.models.Notification;
|
||||
import com.habitrpg.android.habitica.models.notifications.Reward;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.ui.helpers.UiUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -43,16 +48,16 @@ public class PopupNotificationsManager {
|
|||
}
|
||||
|
||||
Boolean displayNotification(Notification notification) {
|
||||
String title = notification.data.message;
|
||||
String youEarnedMessage = "";
|
||||
|
||||
LayoutInflater factory = LayoutInflater.from(context);
|
||||
final View view = factory.inflate(R.layout.dialog_login_incentive, null);
|
||||
|
||||
SimpleDraweeView imageView = (SimpleDraweeView) view.findViewById(R.id.imageView);
|
||||
String imageKey = "inventory_present_11";
|
||||
if (notification.data.rewardKey != null) {
|
||||
imageKey = notification.data.rewardKey.get(0);
|
||||
String title = notification.data.message;
|
||||
String youEarnedMessage = "";
|
||||
|
||||
LayoutInflater factory = LayoutInflater.from(context);
|
||||
final View view = factory.inflate(R.layout.dialog_login_incentive, null);
|
||||
|
||||
SimpleDraweeView imageView = (SimpleDraweeView) view.findViewById(R.id.imageView);
|
||||
String imageKey = "shop_" + notification.data.rewardKey.get(0);
|
||||
DataBindingUtils.loadImage(imageView, imageKey);
|
||||
|
||||
if (notification.data.reward != null && notification.data.reward.size() > 0) {
|
||||
String earnedString = "";
|
||||
|
|
@ -66,39 +71,42 @@ public class PopupNotificationsManager {
|
|||
}
|
||||
youEarnedMessage = context.getString(R.string.checkInRewardEarned, earnedString);
|
||||
}
|
||||
|
||||
TextView titleTextView = new TextView(context);
|
||||
titleTextView.setBackgroundResource(R.color.best_100);
|
||||
titleTextView.setTextColor(ContextCompat.getColor(context, R.color.white));
|
||||
float density = context.getResources().getDisplayMetrics().density;
|
||||
int paddingDp = (int) (16 * density);
|
||||
titleTextView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
|
||||
titleTextView.setTextSize(18);
|
||||
titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
titleTextView.setText(title);
|
||||
|
||||
TextView youEarnedTexView = (TextView) view.findViewById(R.id.you_earned_message);
|
||||
youEarnedTexView.setText(youEarnedMessage);
|
||||
|
||||
String message = context.getString(R.string.nextPrizeUnlocks, notification.data.nextRewardAt);
|
||||
TextView nextUnlockTextView = (TextView) view.findViewById(R.id.next_unlock_message);
|
||||
nextUnlockTextView.setText(message);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(HabiticaApplication.currentActivity, R.style.AlertDialogTheme)
|
||||
.setView(view)
|
||||
.setCustomTitle(titleTextView)
|
||||
.setPositiveButton(R.string.start_day, (dialog, which) -> {
|
||||
if (apiClient != null) {
|
||||
// @TODO: This should be handled somewhere else? MAybe we notifiy via event
|
||||
apiClient.readNotificaiton(notification.getId())
|
||||
.subscribe(next -> {
|
||||
}, RxErrorHandler.handleEmptyError());
|
||||
}
|
||||
})
|
||||
.setMessage("");
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
} else {
|
||||
UiUtils.showSnackbar(context, null, context.getString(R.string.nextPrizeUnlocks, notification.data.nextRewardAt), UiUtils.SnackbarDisplayType.BLUE);
|
||||
}
|
||||
DataBindingUtils.loadImage(imageView, imageKey);
|
||||
|
||||
TextView youEarnedTexView = (TextView) view.findViewById(R.id.you_earned_message);
|
||||
youEarnedTexView.setTextColor(ContextCompat.getColor(context, R.color.textColorLight));
|
||||
youEarnedTexView.setText(youEarnedMessage);
|
||||
|
||||
String message = context.getString(R.string.nextPrizeUnlocks, notification.data.nextRewardAt);
|
||||
TextView nextUnlockTextView = (TextView) view.findViewById(R.id.next_unlock_message);
|
||||
nextUnlockTextView.setTextColor(ContextCompat.getColor(context, R.color.textColorLight));
|
||||
nextUnlockTextView.setText(message);
|
||||
|
||||
Button confirmButton = (Button) view.findViewById(R.id.confirm_button);
|
||||
confirmButton.setTextColor(ContextCompat.getColor(context, R.color.brand_300));
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(HabiticaApplication.currentActivity, R.style.AlertDialogTheme)
|
||||
.setTitle(title)
|
||||
.setView(view)
|
||||
.setMessage("");
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
confirmButton.setOnClickListener(view1 -> {
|
||||
if (apiClient != null) {
|
||||
// @TODO: This should be handled somewhere else? MAybe we notifiy via event
|
||||
apiClient.readNotificaiton(notification.getId())
|
||||
.subscribe(next -> {}, RxErrorHandler.handleEmptyError());
|
||||
}
|
||||
|
||||
dialog.hide();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class UiUtils {
|
|||
snackbarView.setBackgroundColor(ContextCompat.getColor(context, R.color.worse_10));
|
||||
break;
|
||||
case FAILURE_BLUE:
|
||||
case BLUE:
|
||||
snackbarView.setBackgroundColor(ContextCompat.getColor(context, R.color.best_100));
|
||||
break;
|
||||
case DROP:
|
||||
|
|
@ -72,7 +73,7 @@ public class UiUtils {
|
|||
}
|
||||
|
||||
public enum SnackbarDisplayType {
|
||||
NORMAL, FAILURE, FAILURE_BLUE, DROP
|
||||
NORMAL, FAILURE, FAILURE_BLUE, DROP, BLUE
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue