mirror of https://github.com/tasks/tasks
Name your own subscription price
parent
bad32d7455
commit
1c94179adf
@ -1,54 +0,0 @@
|
||||
// Copyright 2017 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package org.tasks.billing;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.tasks.billing.row.RowDataProvider;
|
||||
import org.tasks.billing.row.SkuRowData;
|
||||
|
||||
/** A separator for RecyclerView that keeps the specified spaces between headers and the cards. */
|
||||
public class CardsWithHeadersDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final RowDataProvider mRowDataProvider;
|
||||
private final int mHeaderGap, mRowGap;
|
||||
|
||||
public CardsWithHeadersDecoration(RowDataProvider rowDataProvider, int headerGap, int rowGap) {
|
||||
this.mRowDataProvider = rowDataProvider;
|
||||
this.mHeaderGap = headerGap;
|
||||
this.mRowGap = rowGap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(
|
||||
Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
|
||||
final int position = parent.getChildAdapterPosition(view);
|
||||
final SkuRowData data = mRowDataProvider.getData(position);
|
||||
|
||||
// We should add a space on top of every header card
|
||||
if (data.getRowType() == SkusAdapter.TYPE_HEADER || position == 0) {
|
||||
outRect.top = mHeaderGap;
|
||||
}
|
||||
|
||||
// Adding a space under the last item
|
||||
if (position == parent.getAdapter().getItemCount() - 1) {
|
||||
outRect.bottom = mHeaderGap;
|
||||
} else {
|
||||
outRect.bottom = mRowGap;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
package org.tasks.billing;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import com.android.billingclient.api.BillingClient.SkuType;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.button.MaterialButtonToggleGroup;
|
||||
import com.google.common.collect.ContiguousSet;
|
||||
import com.google.common.collect.DiscreteDomain;
|
||||
import com.google.common.collect.Range;
|
||||
import javax.inject.Inject;
|
||||
import org.tasks.LocalBroadcastManager;
|
||||
import org.tasks.R;
|
||||
import org.tasks.dialogs.DialogBuilder;
|
||||
import org.tasks.dialogs.IconLayoutManager;
|
||||
import org.tasks.injection.DialogFragmentComponent;
|
||||
import org.tasks.injection.ForActivity;
|
||||
import org.tasks.injection.InjectingDialogFragment;
|
||||
import org.tasks.locale.Locale;
|
||||
|
||||
public class NameYourPriceDialog extends InjectingDialogFragment implements OnPurchasesUpdated {
|
||||
|
||||
private static final String EXTRA_MONTHLY = "extra_monthly";
|
||||
private static final String EXTRA_PRICE = "extra_price";
|
||||
|
||||
@Inject DialogBuilder dialogBuilder;
|
||||
@Inject @ForActivity Context context;
|
||||
@Inject BillingClient billingClient;
|
||||
@Inject LocalBroadcastManager localBroadcastManager;
|
||||
@Inject Inventory inventory;
|
||||
@Inject Locale locale;
|
||||
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@BindView(R.id.screen_wait)
|
||||
View loadingView;
|
||||
|
||||
@BindView(R.id.buttons)
|
||||
MaterialButtonToggleGroup buttons;
|
||||
|
||||
@BindView(R.id.subscribe)
|
||||
MaterialButton subscribe;
|
||||
|
||||
@BindView(R.id.unsubscribe)
|
||||
MaterialButton unsubscribe;
|
||||
|
||||
private PurchaseAdapter adapter;
|
||||
private Purchase currentSubscription = null;
|
||||
private BroadcastReceiver purchaseReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
setup();
|
||||
}
|
||||
};
|
||||
private OnDismissListener listener;
|
||||
|
||||
static NameYourPriceDialog newNameYourPriceDialog() {
|
||||
return new NameYourPriceDialog();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
AlertDialog dialog =
|
||||
dialogBuilder
|
||||
.newDialog()
|
||||
.setTitle(R.string.name_your_price)
|
||||
.setView(R.layout.activity_purchase)
|
||||
.show();
|
||||
|
||||
ButterKnife.bind(this, dialog);
|
||||
|
||||
setWaitScreen(true);
|
||||
|
||||
adapter = new PurchaseAdapter((Activity) context, locale, this::onPriceChanged);
|
||||
|
||||
buttons.addOnButtonCheckedListener(this::onButtonChecked);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
buttons.check(
|
||||
savedInstanceState.getBoolean(EXTRA_MONTHLY)
|
||||
? R.id.button_monthly
|
||||
: R.id.button_annually);
|
||||
adapter.setSelected(savedInstanceState.getInt(EXTRA_PRICE));
|
||||
}
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private void onButtonChecked(MaterialButtonToggleGroup group, int id, boolean checked) {
|
||||
if (id == R.id.button_monthly) {
|
||||
if (!checked && group.getCheckedButtonId() != R.id.button_annually) {
|
||||
group.check(R.id.button_monthly);
|
||||
}
|
||||
} else {
|
||||
if (!checked && group.getCheckedButtonId() != R.id.button_monthly) {
|
||||
group.check(R.id.button_annually);
|
||||
}
|
||||
}
|
||||
updateSubscribeButton();
|
||||
}
|
||||
|
||||
private boolean isMonthly() {
|
||||
return buttons.getCheckedButtonId() == R.id.button_monthly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putBoolean(EXTRA_MONTHLY, isMonthly());
|
||||
outState.putInt(EXTRA_PRICE, adapter.getSelected());
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@OnClick(R.id.subscribe)
|
||||
protected void subscribe() {
|
||||
if (currentSubscriptionSelected() && currentSubscription.isCanceled()) {
|
||||
billingClient.initiatePurchaseFlow(
|
||||
(Activity) context, currentSubscription.getSku(), SkuType.SUBS, null);
|
||||
} else {
|
||||
billingClient.initiatePurchaseFlow(
|
||||
(Activity) context,
|
||||
String.format("%s_%02d", isMonthly() ? "monthly" : "annual", adapter.getSelected()),
|
||||
SkuType.SUBS,
|
||||
currentSubscription == null ? null : currentSubscription.getSku());
|
||||
}
|
||||
billingClient.addPurchaseCallback(this);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
currentSubscription = inventory.getSubscription();
|
||||
if (adapter.getSelected() == 0) {
|
||||
if (currentSubscription == null) {
|
||||
adapter.setSelected(1);
|
||||
} else {
|
||||
adapter.setSelected(currentSubscription.getSubscriptionPrice());
|
||||
buttons.check(currentSubscription.isMonthly() ? R.id.button_monthly : R.id.button_annually);
|
||||
}
|
||||
}
|
||||
unsubscribe.setVisibility(
|
||||
currentSubscription == null || currentSubscription.isCanceled() ? View.GONE : View.VISIBLE);
|
||||
updateSubscribeButton();
|
||||
setWaitScreen(false);
|
||||
adapter.submitList(
|
||||
newArrayList(ContiguousSet.create(Range.closed(1, 10), DiscreteDomain.integers())));
|
||||
recyclerView.setLayoutManager(new IconLayoutManager(context));
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@OnClick(R.id.unsubscribe)
|
||||
protected void manageSubscription() {
|
||||
startActivity(
|
||||
new Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse(getString(R.string.manage_subscription_url, currentSubscription.getSku()))));
|
||||
dismiss();
|
||||
}
|
||||
|
||||
private void onPriceChanged(Integer price) {
|
||||
adapter.setSelected(price);
|
||||
updateSubscribeButton();
|
||||
}
|
||||
|
||||
private void updateSubscribeButton() {
|
||||
subscribe.setEnabled(true);
|
||||
if (currentSubscription == null) {
|
||||
subscribe.setText(R.string.button_subscribe);
|
||||
} else if (currentSubscriptionSelected()) {
|
||||
if (currentSubscription.isCanceled()) {
|
||||
subscribe.setText(R.string.button_restore_subscription);
|
||||
} else {
|
||||
subscribe.setText(R.string.button_current_subscription);
|
||||
subscribe.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
subscribe.setText(isUpgrade() ? R.string.button_upgrade : R.string.button_downgrade);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isUpgrade() {
|
||||
return isMonthly() == currentSubscription.isMonthly()
|
||||
? currentSubscription.getSubscriptionPrice() < adapter.getSelected()
|
||||
: isMonthly();
|
||||
}
|
||||
|
||||
private boolean currentSubscriptionSelected() {
|
||||
return currentSubscription != null
|
||||
&& isMonthly() == currentSubscription.isMonthly()
|
||||
&& adapter.getSelected() == currentSubscription.getSubscriptionPrice();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(DialogFragmentComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void setWaitScreen(boolean isWaitScreen) {
|
||||
recyclerView.setVisibility(isWaitScreen ? View.GONE : View.VISIBLE);
|
||||
buttons.setVisibility(isWaitScreen ? View.GONE : View.VISIBLE);
|
||||
subscribe.setVisibility(isWaitScreen ? View.GONE : View.VISIBLE);
|
||||
loadingView.setVisibility(isWaitScreen ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
localBroadcastManager.registerPurchaseReceiver(purchaseReceiver);
|
||||
billingClient.queryPurchases();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
localBroadcastManager.unregisterReceiver(purchaseReceiver);
|
||||
}
|
||||
|
||||
NameYourPriceDialog setOnDismissListener(OnDismissListener listener) {
|
||||
this.listener = listener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
|
||||
if (listener != null) {
|
||||
listener.onDismiss(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPurchasesUpdated() {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@OnClick(R.id.button_more_info)
|
||||
public void openDocumentation() {
|
||||
startActivity(
|
||||
new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.subscription_help_url))));
|
||||
dismiss();
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package org.tasks.billing;
|
||||
|
||||
public interface OnPurchasesUpdated {
|
||||
void onPurchasesUpdated();
|
||||
}
|
@ -1,191 +1,45 @@
|
||||
package org.tasks.billing;
|
||||
|
||||
import static com.google.common.collect.Lists.transform;
|
||||
import static org.tasks.billing.NameYourPriceDialog.newNameYourPriceDialog;
|
||||
import static org.tasks.billing.PurchaseDialog.newPurchaseDialog;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.appcompat.widget.Toolbar.OnMenuItemClickListener;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import javax.inject.Inject;
|
||||
import org.tasks.BuildConfig;
|
||||
import org.tasks.LocalBroadcastManager;
|
||||
import org.tasks.R;
|
||||
import org.tasks.billing.SkusAdapter.OnClickHandler;
|
||||
import org.tasks.billing.row.SkuRowData;
|
||||
import org.tasks.injection.ActivityComponent;
|
||||
import org.tasks.injection.ForApplication;
|
||||
import org.tasks.injection.ThemedInjectingAppCompatActivity;
|
||||
import org.tasks.ui.MenuColorizer;
|
||||
|
||||
public class PurchaseActivity extends ThemedInjectingAppCompatActivity
|
||||
implements OnClickHandler, OnMenuItemClickListener {
|
||||
public class PurchaseActivity extends ThemedInjectingAppCompatActivity {
|
||||
|
||||
@Inject @ForApplication Context context;
|
||||
@Inject BillingClient billingClient;
|
||||
@Inject Inventory inventory;
|
||||
@Inject LocalBroadcastManager localBroadcastManager;
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
@BindView(R.id.list)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@BindView(R.id.screen_wait)
|
||||
View loadingView;
|
||||
private static final String FRAG_TAG_PURCHASE = "frag_tag_purchase";
|
||||
private static final String FRAG_TAG_PRICE = "frag_tag_price";
|
||||
|
||||
@BindView(R.id.error_textview)
|
||||
TextView errorTextView;
|
||||
|
||||
private SkusAdapter adapter;
|
||||
private BroadcastReceiver purchaseReceiver =
|
||||
new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
billingClient.querySkuDetails();
|
||||
}
|
||||
};
|
||||
private List<SkuDetails> iaps = Collections.emptyList();
|
||||
private List<SkuDetails> subscriptions = Collections.emptyList();
|
||||
@Inject Inventory inventory;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_purchase);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
toolbar.setTitle(R.string.upgrade);
|
||||
toolbar.setNavigationIcon(R.drawable.ic_outline_arrow_back_24px);
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
toolbar.inflateMenu(R.menu.menu_purchase_activity);
|
||||
toolbar.setOnMenuItemClickListener(this);
|
||||
MenuColorizer.colorToolbar(this, toolbar);
|
||||
|
||||
adapter = new SkusAdapter(context, inventory, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
Resources res = getResources();
|
||||
recyclerView.addItemDecoration(
|
||||
new CardsWithHeadersDecoration(
|
||||
adapter,
|
||||
(int) res.getDimension(R.dimen.header_gap),
|
||||
(int) res.getDimension(R.dimen.row_gap)));
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
setWaitScreen(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
billingClient.observeSkuDetails(this, this::onSubscriptionsUpdated, this::onIapsUpdated);
|
||||
billingClient.querySkuDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
localBroadcastManager.registerPurchaseReceiver(purchaseReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
|
||||
localBroadcastManager.unregisterReceiver(purchaseReceiver);
|
||||
}
|
||||
|
||||
private void onIapsUpdated(List<SkuDetails> iaps) {
|
||||
this.iaps = iaps;
|
||||
updateSkuDetails();
|
||||
}
|
||||
|
||||
private void onSubscriptionsUpdated(List<SkuDetails> subscriptions) {
|
||||
this.subscriptions = subscriptions;
|
||||
updateSkuDetails();
|
||||
}
|
||||
|
||||
private void updateSkuDetails() {
|
||||
List<SkuRowData> data = new ArrayList<>(transform(subscriptions, SkuRowData::new));
|
||||
if (iaps.size() > 0) {
|
||||
data.add(new SkuRowData(context.getString(R.string.owned)));
|
||||
data.addAll(transform(iaps, SkuRowData::new));
|
||||
}
|
||||
if (data.isEmpty()) {
|
||||
displayAnErrorIfNeeded();
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (inventory.hasPro()) {
|
||||
NameYourPriceDialog dialog = (NameYourPriceDialog) fragmentManager.findFragmentByTag(FRAG_TAG_PRICE);
|
||||
if (dialog == null) {
|
||||
dialog = newNameYourPriceDialog();
|
||||
dialog.show(fragmentManager, FRAG_TAG_PRICE);
|
||||
}
|
||||
dialog.setOnDismissListener(d -> finish());
|
||||
} else {
|
||||
adapter.setData(data);
|
||||
setWaitScreen(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayAnErrorIfNeeded() {
|
||||
if (!isFinishing()) {
|
||||
loadingView.setVisibility(View.GONE);
|
||||
errorTextView.setVisibility(View.VISIBLE);
|
||||
errorTextView.setText(billingClient.getErrorMessage());
|
||||
PurchaseDialog dialog = (PurchaseDialog) fragmentManager.findFragmentByTag(FRAG_TAG_PURCHASE);
|
||||
if (dialog == null) {
|
||||
dialog = newPurchaseDialog();
|
||||
dialog.show(fragmentManager, FRAG_TAG_PURCHASE);
|
||||
}
|
||||
dialog.setOnDismissListener(d -> finish());
|
||||
}
|
||||
}
|
||||
|
||||
private void setWaitScreen(boolean set) {
|
||||
recyclerView.setVisibility(set ? View.GONE : View.VISIBLE);
|
||||
loadingView.setVisibility(set ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject(ActivityComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clickAux(SkuRowData skuRowData) {
|
||||
startSubscribeActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(SkuRowData skuRowData) {
|
||||
String sku = skuRowData.getSku();
|
||||
String skuType = skuRowData.getSkuType();
|
||||
if (inventory.purchased(sku)) {
|
||||
if (BuildConfig.DEBUG && SkuDetails.TYPE_INAPP.equals(skuType)) {
|
||||
billingClient.consume(sku);
|
||||
}
|
||||
} else {
|
||||
billingClient.initiatePurchaseFlow(this, sku, skuType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_help:
|
||||
startSubscribeActivity();
|
||||
return true;
|
||||
case R.id.menu_refresh_purchases:
|
||||
billingClient.queryPurchases();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void startSubscribeActivity() {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://tasks.org/subscribe")));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
package org.tasks.billing;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.DiffUtil.ItemCallback;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import org.tasks.Callback;
|
||||
import org.tasks.R;
|
||||
import org.tasks.locale.Locale;
|
||||
|
||||
public class PurchaseAdapter extends ListAdapter<Integer, PurchaseHolder> {
|
||||
|
||||
private final Activity activity;
|
||||
private final Locale locale;
|
||||
private final Callback<Integer> onPriceChanged;
|
||||
private int selected;
|
||||
|
||||
PurchaseAdapter(Activity activity, Locale locale, Callback<Integer> onPriceChanged) {
|
||||
super(new DiffCallback());
|
||||
this.activity = activity;
|
||||
this.locale = locale;
|
||||
this.onPriceChanged = onPriceChanged;
|
||||
}
|
||||
|
||||
public int getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(int price) {
|
||||
int previous = selected;
|
||||
this.selected = price;
|
||||
notifyItemChanged(previous - 1, null);
|
||||
notifyItemChanged(price - 1, null);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PurchaseHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = activity.getLayoutInflater().inflate(R.layout.dialog_purchase_cell, parent, false);
|
||||
return new PurchaseHolder(activity, view, onPriceChanged, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PurchaseHolder holder, int position) {
|
||||
int price = position + 1;
|
||||
holder.bind(price, price == selected);
|
||||
}
|
||||
|
||||
private static class DiffCallback extends ItemCallback<Integer> {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull Integer oldItem, @NonNull Integer newItem) {
|
||||
return oldItem.equals(newItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull Integer oldItem, @NonNull Integer newItem) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package org.tasks.billing;
|
||||
|
||||
import static com.google.common.collect.Lists.transform;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.tasks.billing.NameYourPriceDialog.newNameYourPriceDialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.common.base.Joiner;
|
||||
import javax.inject.Inject;
|
||||
import org.tasks.R;
|
||||
import org.tasks.dialogs.DialogBuilder;
|
||||
import org.tasks.injection.DialogFragmentComponent;
|
||||
import org.tasks.injection.ForActivity;
|
||||
import org.tasks.injection.InjectingDialogFragment;
|
||||
|
||||
public class PurchaseDialog extends InjectingDialogFragment {
|
||||
|
||||
private static final String FRAG_TAG_PRICE = "frag_tag_price";
|
||||
|
||||
@Inject DialogBuilder dialogBuilder;
|
||||
@Inject @ForActivity Context context;
|
||||
private OnDismissListener listener;
|
||||
|
||||
public static PurchaseDialog newPurchaseDialog() {
|
||||
return new PurchaseDialog();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View view = ((Activity) context).getLayoutInflater().inflate(R.layout.dialog_purchase, null);
|
||||
TextView textView = view.findViewById(R.id.feature_list);
|
||||
String[] rows = context.getResources().getStringArray(R.array.pro_description);
|
||||
textView.setText(Joiner.on('\n').join(transform(asList(rows), item -> "\u2022 " + item)));
|
||||
return dialogBuilder
|
||||
.newDialog()
|
||||
.setTitle(R.string.pro_support_development)
|
||||
.setView(view)
|
||||
.setPositiveButton(
|
||||
R.string.name_your_price,
|
||||
(dialog, which) -> {
|
||||
newNameYourPriceDialog()
|
||||
.setOnDismissListener(listener)
|
||||
.show(getFragmentManager(), FRAG_TAG_PRICE);
|
||||
listener = null;
|
||||
dialog.dismiss();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
void setOnDismissListener(OnDismissListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(@NonNull DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
|
||||
if (listener != null) {
|
||||
listener.onDismiss(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(DialogFragmentComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package org.tasks.billing;
|
||||
|
||||
import static org.tasks.preferences.ResourceResolver.getData;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import org.tasks.Callback;
|
||||
import org.tasks.R;
|
||||
import org.tasks.locale.Locale;
|
||||
|
||||
public class PurchaseHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final Context context;
|
||||
private final Callback<Integer> onClick;
|
||||
private final Locale locale;
|
||||
|
||||
@BindView(R.id.price)
|
||||
TextView textView;
|
||||
|
||||
private int price;
|
||||
|
||||
PurchaseHolder(Context context, @NonNull View view, Callback<Integer> onClick, Locale locale) {
|
||||
super(view);
|
||||
this.locale = locale;
|
||||
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
this.context = context;
|
||||
this.onClick = onClick;
|
||||
}
|
||||
|
||||
@OnClick(R.id.price)
|
||||
void onClick() {
|
||||
onClick.call(price);
|
||||
}
|
||||
|
||||
public void bind(int price, boolean selected) {
|
||||
this.price = price;
|
||||
textView.setText(String.format("$%s", locale.formatNumber(price)));
|
||||
textView.setTextColor(
|
||||
selected
|
||||
? getData(context, R.attr.colorPrimary)
|
||||
: ContextCompat.getColor(context, R.color.text_primary));
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.tasks.billing;
|
||||
|
||||
import static com.google.common.collect.Lists.transform;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.List;
|
||||
import org.tasks.BuildConfig;
|
||||
import org.tasks.R;
|
||||
import org.tasks.billing.row.RowDataProvider;
|
||||
import org.tasks.billing.row.RowViewHolder;
|
||||
import org.tasks.billing.row.RowViewHolder.ButtonClick;
|
||||
import org.tasks.billing.row.SkuRowData;
|
||||
|
||||
public class SkusAdapter extends RecyclerView.Adapter<RowViewHolder>
|
||||
implements RowDataProvider, ButtonClick {
|
||||
|
||||
public static final int TYPE_HEADER = 0;
|
||||
public static final int TYPE_NORMAL = 1;
|
||||
private final Context context;
|
||||
private final Inventory inventory;
|
||||
private final OnClickHandler onClickHandler;
|
||||
private List<SkuRowData> data = ImmutableList.of();
|
||||
|
||||
SkusAdapter(Context context, Inventory inventory, OnClickHandler onClickHandler) {
|
||||
this.context = context;
|
||||
this.inventory = inventory;
|
||||
this.onClickHandler = onClickHandler;
|
||||
}
|
||||
|
||||
public void setData(List<SkuRowData> data) {
|
||||
this.data = data;
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @RowTypeDef int getItemViewType(int position) {
|
||||
return data.isEmpty() ? TYPE_HEADER : data.get(position).getRowType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public RowViewHolder onCreateViewHolder(@NonNull ViewGroup parent, @RowTypeDef int viewType) {
|
||||
// Selecting a flat layout for header rows
|
||||
if (viewType == SkusAdapter.TYPE_HEADER) {
|
||||
View item =
|
||||
LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.sku_details_row_header, parent, false);
|
||||
return new RowViewHolder(item, null);
|
||||
} else {
|
||||
View item =
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.sku_details_row, parent, false);
|
||||
return new RowViewHolder(item, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RowViewHolder holder, int position) {
|
||||
SkuRowData data = getData(position);
|
||||
if (data != null) {
|
||||
holder.title.setText(data.getTitle());
|
||||
if (getItemViewType(position) != SkusAdapter.TYPE_HEADER) {
|
||||
|
||||
String sku = data.getSku();
|
||||
if (SkuDetails.TYPE_SUBS.equals(data.getSkuType())) {
|
||||
String[] rows = context.getResources().getStringArray(R.array.pro_description);
|
||||
holder.description.setText(
|
||||
Joiner.on('\n').join(transform(asList(rows), item -> "\u2022 " + item)));
|
||||
holder.subscribeButton.setVisibility(View.VISIBLE);
|
||||
holder.price.setVisibility(View.VISIBLE);
|
||||
holder.price.setText(data.getPrice());
|
||||
if (inventory.purchased(sku)) {
|
||||
holder.subscribeButton.setText(R.string.button_subscribed);
|
||||
holder.auxiliaryButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.subscribeButton.setText(R.string.button_subscribe);
|
||||
holder.auxiliaryButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
holder.description.setText(data.getDescription());
|
||||
holder.subscribeButton.setVisibility(View.GONE);
|
||||
holder.price.setVisibility(View.GONE);
|
||||
holder.auxiliaryButton.setVisibility(View.GONE);
|
||||
if (BuildConfig.DEBUG) {
|
||||
holder.subscribeButton.setVisibility(View.VISIBLE);
|
||||
holder.subscribeButton.setText(
|
||||
inventory.purchased(sku) ? R.string.debug_consume : R.string.debug_buy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkuRowData getData(int position) {
|
||||
return data.isEmpty() ? null : data.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuxiliaryClick(int row) {
|
||||
onClickHandler.clickAux(getData(row));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(int row) {
|
||||
onClickHandler.click(getData(row));
|
||||
}
|
||||
|
||||
public interface OnClickHandler {
|
||||
void clickAux(SkuRowData skuRowData);
|
||||
|
||||
void click(SkuRowData skuRowData);
|
||||
}
|
||||
|
||||
/** Types for adapter rows */
|
||||
@Retention(SOURCE)
|
||||
@IntDef({TYPE_HEADER, TYPE_NORMAL})
|
||||
public @interface RowTypeDef {}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.tasks.billing.row;
|
||||
|
||||
/** Provider for data that corresponds to a particular row */
|
||||
public interface RowDataProvider {
|
||||
SkuRowData getData(int position);
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package org.tasks.billing.row;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.tasks.R;
|
||||
|
||||
public final class RowViewHolder extends RecyclerView.ViewHolder {
|
||||
public final TextView title;
|
||||
public final TextView description;
|
||||
public final TextView price;
|
||||
public final Button subscribeButton;
|
||||
public final Button auxiliaryButton;
|
||||
|
||||
public RowViewHolder(final View itemView, final ButtonClick onClick) {
|
||||
super(itemView);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
price = itemView.findViewById(R.id.price);
|
||||
description = itemView.findViewById(R.id.description);
|
||||
subscribeButton = itemView.findViewById(R.id.buy_button);
|
||||
auxiliaryButton = itemView.findViewById(R.id.aux_button);
|
||||
if (auxiliaryButton != null) {
|
||||
auxiliaryButton.setOnClickListener(view -> onClick.onAuxiliaryClick(getAdapterPosition()));
|
||||
}
|
||||
if (subscribeButton != null) {
|
||||
subscribeButton.setOnClickListener(view -> onClick.onClick(getAdapterPosition()));
|
||||
}
|
||||
}
|
||||
|
||||
public interface ButtonClick {
|
||||
void onAuxiliaryClick(int row);
|
||||
|
||||
void onClick(int row);
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.tasks.billing.row;
|
||||
|
||||
import org.tasks.billing.SkuDetails;
|
||||
import org.tasks.billing.SkusAdapter;
|
||||
import org.tasks.billing.SkusAdapter.RowTypeDef;
|
||||
|
||||
/** A model for SkusAdapter's row */
|
||||
public class SkuRowData {
|
||||
private String sku, title, price, description;
|
||||
private @RowTypeDef int type;
|
||||
private String billingType;
|
||||
|
||||
public SkuRowData(SkuDetails details) {
|
||||
sku = details.getSku();
|
||||
title = details.getTitle();
|
||||
price = details.getPrice();
|
||||
description = details.getDescription();
|
||||
type = SkusAdapter.TYPE_NORMAL;
|
||||
billingType = details.getSkuType();
|
||||
}
|
||||
|
||||
public SkuRowData(String title) {
|
||||
this.title = title;
|
||||
type = SkusAdapter.TYPE_HEADER;
|
||||
}
|
||||
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public @RowTypeDef int getRowType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getSkuType() {
|
||||
return billingType;
|
||||
}
|
||||
}
|
@ -1,32 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/window_background">
|
||||
|
||||
<include layout="@layout/loading_indicator"/>
|
||||
|
||||
<include
|
||||
layout="@layout/toolbar"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="top" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error_textview"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="@dimen/card_view_margin"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"/>
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:gravity="center"/>
|
||||
<ProgressBar
|
||||
android:id="@+id/screen_wait"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/buttons"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
app:checkedButton="@id/button_monthly"
|
||||
app:singleSelection="true">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_monthly"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/monthly"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_annually"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/annually"/>
|
||||
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/subscribe"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/button_subscribe"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/unsubscribe"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/button_unsubscribe"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_more_info"
|
||||
style="?attr/materialButtonOutlinedStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/button_more_info"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</ScrollView>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Body1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pro_description"/>
|
||||
|
||||
<TextView
|
||||
style="@style/TextAppearance.AppCompat.Body1"
|
||||
android:paddingTop="@dimen/keyline_first"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pro_subscribe_now"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/feature_list"
|
||||
style="@style/TextAppearance.AppCompat.Body1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/price"
|
||||
android:layout_width="@dimen/icon_picker_size"
|
||||
android:layout_height="@dimen/icon_picker_size"
|
||||
android:padding="8dp"
|
||||
android:textSize="18sp"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/text_primary"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
tools:ignore="ContentDescription"/>
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<ProgressBar
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/screen_wait"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/CardViewStyle"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/content_background">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/keyline_first"
|
||||
android:layout_marginBottom="@dimen/keyline_first"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="@dimen/keyline_first"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
android:paddingLeft="@dimen/keyline_first"
|
||||
android:paddingRight="@dimen/keyline_first"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="@dimen/sku_details_row_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/price"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="@dimen/keyline_first"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:textSize="@dimen/sku_details_row_text_size"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:textColor="@color/text_secondary"
|
||||
android:textSize="@dimen/sku_details_row_text_size"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/aux_button"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_marginTop="@dimen/card_view_margin"
|
||||
android:layout_marginBottom="@dimen/card_view_margin"
|
||||
android:layout_marginStart="@dimen/card_view_margin"
|
||||
android:layout_marginEnd="@dimen/card_view_margin"
|
||||
android:text="@string/button_more_info"
|
||||
android:contentDescription="@string/button_more_info"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/buy_button"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_marginTop="@dimen/card_view_margin"
|
||||
android:layout_marginBottom="@dimen/card_view_margin"
|
||||
android:layout_marginStart="@dimen/card_view_margin"
|
||||
android:layout_marginEnd="@dimen/card_view_margin"
|
||||
android:contentDescription="@string/button_subscribe"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
style="@style/CardViewStyle"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true"
|
||||
app:cardBackgroundColor="@color/content_background">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/TextAppearance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/keyline_first"
|
||||
android:layout_marginBottom="@dimen/keyline_first"
|
||||
android:layout_marginStart="@dimen/keyline_first"
|
||||
android:layout_marginEnd="@dimen/keyline_first"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textSize="@dimen/sku_details_row_text_size"
|
||||
app:fontFamily="sans-serif-medium"/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tasks="http://schemas.android.com/tools">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_help"
|
||||
android:icon="@drawable/ic_outline_help_outline_24px"
|
||||
android:title="@string/help"
|
||||
tasks:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_refresh_purchases"
|
||||
android:title="@string/refresh_purchases"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
Loading…
Reference in New Issue