mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-14 02:01:56 +00:00
create gem purchase activity
This commit is contained in:
parent
b510097c9e
commit
32fc3642b4
12 changed files with 175 additions and 23 deletions
|
|
@ -129,6 +129,8 @@
|
|||
<activity android:name=".ui.activities.MaintenanceActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||
<activity android:name=".ui.activities.GemPurchaseActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<receiver android:process=":remote" android:name=".NotificationPublisher" />
|
||||
|
||||
<receiver android:process=":remote" android:name=".receivers.TaskReceiver"></receiver>
|
||||
|
|
|
|||
BIN
Habitica/res/drawable-hdpi/support_habitica.png
Normal file
BIN
Habitica/res/drawable-hdpi/support_habitica.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
Habitica/res/drawable-mdpi/support_habitica.png
Normal file
BIN
Habitica/res/drawable-mdpi/support_habitica.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
Habitica/res/drawable-xhdpi/support_habitica.png
Normal file
BIN
Habitica/res/drawable-xhdpi/support_habitica.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
Habitica/res/drawable-xxhdpi/support_habitica.png
Normal file
BIN
Habitica/res/drawable-xxhdpi/support_habitica.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
87
Habitica/res/layout/activity_gem_purchase.xml
Normal file
87
Habitica/res/layout/activity_gem_purchase.xml
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activities.MainActivity"
|
||||
android:id="@+id/overlayFrameLayout">
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:gravity="center">
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="0dp"
|
||||
tools:context=".ui.activities.MainActivity">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="false">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="false"
|
||||
app:titleEnabled="false"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:expandedTitleMarginEnd="?attr/actionBarSize"
|
||||
app:expandedTitleMarginStart="0dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/headerImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
app:layout_collapseMode="parallax"
|
||||
android:src="@drawable/support_habitica"
|
||||
android:paddingBottom="21dp"
|
||||
android:contentDescription="@string/support_habitica"/>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/Theme.AppCompat.Light" />
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/detail_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@color/brand_200"
|
||||
android:elevation="0dp"
|
||||
android:fillViewport="false"
|
||||
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:layout_anchor="@+id/collapsing_toolbar"
|
||||
app:layout_anchorGravity="bottom"
|
||||
|
||||
app:layout_collapseMode="pin"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabMode="fixed"
|
||||
android:visibility="gone"/>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
</FrameLayout>
|
||||
|
|
@ -414,11 +414,13 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="widget_dailies">Habitica Dailies</string>
|
||||
<string name="widget_add_task">Habitica Add Task</string>
|
||||
<string name="google_services_missing">Google play services could not be found.</string>
|
||||
<string name="gem.purchase.toolbartitle">Purchase</string>
|
||||
<string name="gem.purchase.title">Buying gems supports the developers and helps keep Habitica running</string>
|
||||
<string name="gem.purchase.subtitle">Gems allow you to buy fun extras for you account, including:</string>
|
||||
<string name="gem.purchase.listitem1">Cool costumes for your avatar</string>
|
||||
<string name="gem.purchase.listitem2">Awesome backgrounds</string>
|
||||
<string name="gem.purchase.listitem3">Quests that reward you with pet eggs</string>
|
||||
<string name="gem.purchase.listitem4">The ability to change your class before level 100</string>
|
||||
<string name="support_habitica">Support Habitica</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import java.util.List;
|
|||
|
||||
public class PurchaseTypes {
|
||||
|
||||
public static String Purchase4Gems = "com.habitrpg.android.habitica.4gems";
|
||||
public static String Purchase21Gems = "com.habitrpg.android.habitica.21gems";
|
||||
public static String Purchase42Gems = "com.habitrpg.android.habitica.42gems";
|
||||
public static String Purchase84Gems = "com.habitrpg.android.habitica.84gems";
|
||||
public static String Purchase4Gems = "com.habitrpg.android.habitica.iap.4gems";
|
||||
public static String Purchase21Gems = "com.habitrpg.android.habitica.iap.21gems";
|
||||
public static String Purchase42Gems = "com.habitrpg.android.habitica.iap.42gems";
|
||||
public static String Purchase84Gems = "com.habitrpg.android.habitica.iap.84gems";
|
||||
|
||||
public static List<String> allTypes = Arrays.asList(Purchase4Gems, Purchase21Gems, Purchase42Gems, Purchase84Gems);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package com.habitrpg.android.habitica.ui.activities;
|
||||
|
||||
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.ui.fragments.GemsPurchaseFragment;
|
||||
|
||||
import org.solovyev.android.checkout.ActivityCheckout;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
public class GemPurchaseActivity extends BaseActivity implements GemsPurchaseFragment.Listener {
|
||||
|
||||
private ActivityCheckout checkout;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_gem_purchase;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void injectActivity(AppComponent component) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setupCheckout();
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
getSupportActionBar().setTitle(R.string.gem_purchase_toolbartitle);
|
||||
}
|
||||
|
||||
GemsPurchaseFragment firstFragment = new GemsPurchaseFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fragment_container, firstFragment).commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void setupCheckout() {
|
||||
checkout = Checkout.forActivity(this, HabiticaApplication.getInstance(this).getCheckout());
|
||||
checkout.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityCheckout getActivityCheckout() {
|
||||
return checkout;
|
||||
}
|
||||
}
|
||||
|
|
@ -163,8 +163,7 @@ import static com.habitrpg.android.habitica.ui.helpers.UiUtils.SnackbarDisplayTy
|
|||
import static com.habitrpg.android.habitica.ui.helpers.UiUtils.showSnackbar;
|
||||
|
||||
public class MainActivity extends BaseActivity implements Action1<Throwable>, HabitRPGUserCallback.OnUserReceived,
|
||||
TaskScoringCallback.OnTaskScored,
|
||||
GemsPurchaseFragment.Listener, TutorialView.OnTutorialReaction {
|
||||
TaskScoringCallback.OnTaskScored, TutorialView.OnTutorialReaction {
|
||||
|
||||
public static final int SELECT_CLASS_RESULT = 11;
|
||||
public static final int MIN_LEVEL_FOR_SKILLS = 11;
|
||||
|
|
@ -274,7 +273,6 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
.append(this.drawer);
|
||||
}
|
||||
|
||||
setupCheckout();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
|
|
@ -324,15 +322,6 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void setupCheckout() {
|
||||
checkout = Checkout.forActivity(this, HabiticaApplication.getInstance(this).getCheckout());
|
||||
checkout.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityCheckout getActivityCheckout() {
|
||||
return checkout;
|
||||
}
|
||||
|
||||
private void saveLoginInformation() {
|
||||
HabiticaApplication.User = user;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import butterknife.BindView;
|
|||
import butterknife.OnClick;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
public class GemsPurchaseFragment extends BaseMainFragment {
|
||||
public class GemsPurchaseFragment extends BaseFragment {
|
||||
|
||||
@BindView(R.id.gems_4_view)
|
||||
GemPurchaseOptionsView gems4View;
|
||||
|
|
@ -66,10 +66,7 @@ public class GemsPurchaseFragment extends BaseMainFragment {
|
|||
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
gems4View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase4Gems));
|
||||
gems21View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase21Gems));
|
||||
gems42View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase42Gems));
|
||||
gems84View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase84Gems));
|
||||
priceMap = new HashMap<>();
|
||||
|
||||
return inflater.inflate(R.layout.fragment_gem_purchase, container, false);
|
||||
}
|
||||
|
|
@ -83,6 +80,11 @@ public class GemsPurchaseFragment extends BaseMainFragment {
|
|||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
gems4View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase4Gems));
|
||||
gems21View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase21Gems));
|
||||
gems42View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase42Gems));
|
||||
gems84View.setOnPurchaseClickListener(v -> purchaseGems(PurchaseTypes.Purchase84Gems));
|
||||
|
||||
final ActivityCheckout checkout = listener.getActivityCheckout();
|
||||
|
||||
if (checkout != null) {
|
||||
|
|
@ -169,7 +171,7 @@ public class GemsPurchaseFragment extends BaseMainFragment {
|
|||
public void onSuccess(@NonNull Purchases purchases) {
|
||||
for (Purchase purchase : purchases.list) {
|
||||
if (PurchaseTypes.allTypes.contains(purchase.sku)) {
|
||||
billingRequests.consume(purchase.token, new RequestListener<Object>) {
|
||||
billingRequests.consume(purchase.token, new RequestListener<Object>() {
|
||||
@Override
|
||||
public void onSuccess(@NonNull Object o) {
|
||||
EventBus.getDefault().post(new BoughtGemsEvent(GEMS_TO_ADD));
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.ui.menu;
|
|||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.ui.activities.AboutActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.GemPurchaseActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.PrefsActivity;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
|
||||
|
|
@ -148,7 +149,7 @@ public class MainDrawerBuilder {
|
|||
break;
|
||||
}
|
||||
case SIDEBAR_PURCHASE: {
|
||||
fragment = new GemsPurchaseFragment();
|
||||
newActivityClass = GemPurchaseActivity.class;
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_NEWS: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue