mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-04 17:59:17 +00:00
Merge branch 'develop' of https://github.com/HabitRPG/habitica-android into create_challenges
Conflicts: Habitica/res/values/strings.xml
This commit is contained in:
commit
ffd74efa23
8 changed files with 120 additions and 9 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,25 @@
|
|||
android:drawableTop="@drawable/ic_heart_large"
|
||||
android:textSize="14sp"
|
||||
android:lineSpacingExtra="4dp" />
|
||||
<TextView
|
||||
android:id="@+id/notAvailableTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/no_billing_gems"
|
||||
android:paddingTop="50dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:visibility="gone" />
|
||||
<Button
|
||||
android:id="@+id/notAvailableButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/visit_habitica_website"
|
||||
android:layout_marginBottom="50dp"
|
||||
style="@style/Button.Purple"
|
||||
android:visibility="gone" />
|
||||
<LinearLayout
|
||||
android:id="@+id/gemPurchaseOptions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
|
|
|||
|
|
@ -150,6 +150,25 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/loadingIndicator"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/notAvailableTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/no_billing_subscriptions"
|
||||
android:paddingTop="50dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:visibility="gone" />
|
||||
<Button
|
||||
android:id="@+id/notAvailableButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/visit_habitica_website"
|
||||
android:layout_marginBottom="50dp"
|
||||
style="@style/Button.Purple"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/subscriptionOptions"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -569,6 +569,8 @@
|
|||
<string name="reload_content">Reload Content</string>
|
||||
<string name="dailyDueDefaultView">Set Dailies default to ‘due’ tab</string>
|
||||
<string name="dailyDueDefaultViewDescription">With this option set, the Dailies tasks will default to ‘due’ instead of ‘all’</string>
|
||||
<string name="no_billing_gems">Your device does not have any of the supported payment methods. Please use the habitica website if you want to purchase gems.</string>
|
||||
<string name="no_billing_subscriptions">Your device does not have any of the supported payment methods. Please use the habitica website if you want to purchase a subscription.</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="location">Location</string>
|
||||
<string name="gem_reward">Gem reward</string>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Sku> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Sku> 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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue