diff --git a/Habitica/build.gradle b/Habitica/build.gradle
index f17f14154..90d18be15 100644
--- a/Habitica/build.gradle
+++ b/Habitica/build.gradle
@@ -117,13 +117,13 @@ dependencies {
compile 'io.reactivex:rxjava:1.2.0'
//Analytics
- compile 'com.amplitude:android-sdk:2.13.1'
+ compile 'com.amplitude:android-sdk:2.13.3'
// Fresco Image Management Library
- compile('com.facebook.fresco:fresco:1.0.1') {
+ compile('com.facebook.fresco:fresco:1.3.0') {
exclude module: 'bolts-android'
}
- compile('com.facebook.fresco:animated-gif:1.0.1') {
+ compile('com.facebook.fresco:animated-gif:1.3.0') {
exclude module: 'bolts-android'
}
//Tests
@@ -162,6 +162,7 @@ android {
defaultConfig {
applicationId "com.habitrpg.android.habitica"
vectorDrawables.useSupportLibrary = true
+ buildConfigField "String", "STORE", "\"google\""
}
lintOptions {
@@ -198,6 +199,10 @@ android {
prod {
}
+
+ amazon {
+ buildConfigField "String", "STORE", "\"amazon\""
+ }
}
sourceSets {
@@ -294,7 +299,7 @@ if (HRPG_RES_FILE.canRead()) {
}
tasks.whenTaskAdded { task ->
- if (task.name.equals("lint")) {
+ if (task.name == "lint") {
task.enabled = false
}
}
diff --git a/Habitica/res/layout/fragment_gem_purchase.xml b/Habitica/res/layout/fragment_gem_purchase.xml
index 1872fab2a..7f574ca97 100644
--- a/Habitica/res/layout/fragment_gem_purchase.xml
+++ b/Habitica/res/layout/fragment_gem_purchase.xml
@@ -24,7 +24,25 @@
android:drawableTop="@drawable/ic_heart_large"
android:textSize="14sp"
android:lineSpacingExtra="4dp" />
+
+
diff --git a/Habitica/res/layout/fragment_subscription.xml b/Habitica/res/layout/fragment_subscription.xml
index e96657d89..8d8ff203e 100644
--- a/Habitica/res/layout/fragment_subscription.xml
+++ b/Habitica/res/layout/fragment_subscription.xml
@@ -150,6 +150,25 @@
android:layout_height="wrap_content"
android:id="@+id/loadingIndicator"/>
+
+
+
+
Reload Content
Set Dailies default to ‘due’ tab
With this option set, the Dailies tasks will default to ‘due’ instead of ‘all’
+ Your device does not have any of the supported payment methods. Please use the habitica website if you want to purchase gems.
+ Your device does not have any of the supported payment methods. Please use the habitica website if you want to purchase a subscription.
Save
Location
Gem reward
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/HabiticaBaseApplication.java b/Habitica/src/main/java/com/habitrpg/android/habitica/HabiticaBaseApplication.java
index 608a41388..30538c961 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/HabiticaBaseApplication.java
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/HabiticaBaseApplication.java
@@ -18,6 +18,7 @@ import android.support.multidex.MultiDexApplication;
import android.util.Log;
import com.amplitude.api.Amplitude;
+import com.amplitude.api.Identify;
import com.facebook.FacebookSdk;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.habitrpg.android.habitica.components.AppComponent;
@@ -140,6 +141,8 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
if (!BuildConfig.DEBUG) {
try {
Amplitude.getInstance().initialize(this, getString(R.string.amplitude_app_id)).enableForegroundTracking(this);
+ Identify identify = new Identify().setOnce("androidStore", BuildConfig.STORE);
+ Amplitude.getInstance().identify(identify);
} catch (Resources.NotFoundException e) {
//pass
}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/GemsPurchaseFragment.java b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/GemsPurchaseFragment.java
index f88f09816..49e2ff500 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/GemsPurchaseFragment.java
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/GemsPurchaseFragment.java
@@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.ui.fragments;
+import com.habitrpg.android.habitica.BuildConfig;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.components.AppComponent;
import com.habitrpg.android.habitica.helpers.PurchaseTypes;
@@ -14,6 +15,9 @@ import org.solovyev.android.checkout.ProductTypes;
import org.solovyev.android.checkout.RequestListener;
import org.solovyev.android.checkout.Sku;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -21,10 +25,13 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
import javax.inject.Inject;
import butterknife.BindView;
+import butterknife.OnClick;
public class GemsPurchaseFragment extends BaseFragment implements GemPurchaseActivity.CheckoutFragment {
@@ -36,12 +43,20 @@ public class GemsPurchaseFragment extends BaseFragment implements GemPurchaseAct
GemPurchaseOptionsView gems42View;
@BindView(R.id.gems_84_view)
GemPurchaseOptionsView gems84View;
+ @BindView(R.id.gemPurchaseOptions)
+ ViewGroup gemPurchaseOptions;
+
+ @BindView(R.id.notAvailableTextView)
+ TextView billingNotAvailableTextView;
+ @BindView(R.id.notAvailableButton)
+ Button billingNotAvailableButton;
@Inject
CrashlyticsProxy crashlyticsProxy;
private GemPurchaseActivity listener;
private BillingRequests billingRequests;
+ private boolean billingNotSupported;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -67,6 +82,10 @@ public class GemsPurchaseFragment extends BaseFragment implements GemPurchaseAct
gems84View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase84Gems));
gems84View.seedsImageButton.setOnClickListener(v -> ((GemPurchaseActivity) this.getActivity()).showSeedsPromo(getString(R.string.seeds_interstitial_gems), "store"));
+
+ if (billingNotSupported) {
+ setBillingNotSupported();
+ }
}
@Override
@@ -80,7 +99,7 @@ public class GemsPurchaseFragment extends BaseFragment implements GemPurchaseAct
products -> {
Inventory.Product gems = products.get(ProductTypes.IN_APP);
if (!gems.supported) {
- // billing is not supported, user can't purchase anything
+ setBillingNotSupported();
return;
}
java.util.List skus = gems.getSkus();
@@ -91,6 +110,15 @@ public class GemsPurchaseFragment extends BaseFragment implements GemPurchaseAct
}
}
+ private void setBillingNotSupported() {
+ billingNotSupported = true;
+ if (gemPurchaseOptions != null) {
+ gemPurchaseOptions.setVisibility(View.GONE);
+ billingNotAvailableButton.setVisibility(View.VISIBLE);
+ billingNotAvailableTextView.setVisibility(View.VISIBLE);
+ }
+ }
+
@Override
public void setListener(GemPurchaseActivity listener) {
this.listener = listener;
@@ -136,6 +164,11 @@ public class GemsPurchaseFragment extends BaseFragment implements GemPurchaseAct
crashlyticsProxy.fabricLogE("Purchase", "Error", e);
}
});
+ }
+ @OnClick(R.id.notAvailableButton)
+ public void openWebsite() {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.BASE_URL + "/"));
+ getContext().startActivity(intent);
}
}
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/SubscriptionFragment.java b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/SubscriptionFragment.java
index dac10da15..f0259e24c 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/SubscriptionFragment.java
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/fragments/SubscriptionFragment.java
@@ -97,6 +97,11 @@ public class SubscriptionFragment extends BaseFragment implements GemPurchaseAct
@BindView(R.id.subscribeBenefitsTitle)
TextView subscribeBenefitsTitle;
+ @BindView(R.id.notAvailableTextView)
+ TextView billingNotAvailableTextView;
+ @BindView(R.id.notAvailableButton)
+ Button billingNotAvailableButton;
+
@Nullable
Sku selectedSubscriptionSku;
List skus;
@@ -106,6 +111,7 @@ public class SubscriptionFragment extends BaseFragment implements GemPurchaseAct
private HabitRPGUser user;
private boolean hasLoadedSubscriptionOptions;
+ private boolean billingNotSupported;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -145,6 +151,10 @@ public class SubscriptionFragment extends BaseFragment implements GemPurchaseAct
this.subscribeListitem2Box.setOnClickListener(view1 -> toggleDescriptionView(this.subscribeListitem2Button, this.subscribeListItem2Description));
this.subscribeListitem3Box.setOnClickListener(view1 -> toggleDescriptionView(this.subscribeListitem3Button, this.subscribeListItem3Description));
this.subscribeListitem4Box.setOnClickListener(view1 -> toggleDescriptionView(this.subscribeListitem4Button, this.subscribeListItem4Description));
+
+ if (billingNotSupported) {
+ setBillingNotSupported();
+ }
}
private void toggleDescriptionView(ImageView button, TextView descriptionView) {
@@ -173,6 +183,11 @@ public class SubscriptionFragment extends BaseFragment implements GemPurchaseAct
products -> {
Inventory.Product subscriptions = products.get(ProductTypes.SUBSCRIPTION);
+ if (!subscriptions.supported) {
+ setBillingNotSupported();
+ return;
+ }
+
skus = subscriptions.getSkus();
for (Sku sku : skus) {
@@ -185,6 +200,16 @@ public class SubscriptionFragment extends BaseFragment implements GemPurchaseAct
}
}
+ private void setBillingNotSupported() {
+ billingNotSupported = true;
+ if (subscriptionOptions != null) {
+ subscriptionOptions.setVisibility(View.GONE);
+ loadingIndicator.setVisibility(View.GONE);
+ billingNotAvailableButton.setVisibility(View.VISIBLE);
+ billingNotAvailableTextView.setVisibility(View.VISIBLE);
+ }
+ }
+
private void updateButtonLabel(Sku sku, String price, Inventory.Product subscriptions) {
SubscriptionOptionView matchingView = buttonForSku(sku);
if (matchingView != null) {
@@ -288,6 +313,8 @@ public class SubscriptionFragment extends BaseFragment implements GemPurchaseAct
this.subscriptionDetailsView.setPlan(plan);
this.subscribeBenefitsTitle.setText(R.string.subscribe_prompt_thanks);
this.subscriptionOptions.setVisibility(View.GONE);
+ billingNotAvailableButton.setVisibility(View.GONE);
+ billingNotAvailableTextView.setVisibility(View.GONE);
} else {
if (!hasLoadedSubscriptionOptions) {
return;
diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/login/LoginBackgroundView.java b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/login/LoginBackgroundView.java
index f84fdcd9b..8f1291dea 100644
--- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/login/LoginBackgroundView.java
+++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/login/LoginBackgroundView.java
@@ -8,7 +8,9 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
+import android.util.DisplayMetrics;
import android.view.View;
+import android.view.WindowManager;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
@@ -44,6 +46,11 @@ public class LoginBackgroundView extends RelativeLayout {
public LoginBackgroundView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.random = new Random();
+
+ DisplayMetrics metrics = new DisplayMetrics();
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ windowManager.getDefaultDisplay().getMetrics(metrics);
+ height = (int) (metrics.heightPixels*SIZE_FACTOR);
}
@Override
@@ -69,10 +76,7 @@ public class LoginBackgroundView extends RelativeLayout {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
- int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
- int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
- this.width = parentWidth;
- this.height = (int)(parentHeight*SIZE_FACTOR);
+ this.width = MeasureSpec.getSize(widthMeasureSpec);
this.setMeasuredDimension(width, height);
params.width = width;
params.height = height;