Allow donation through Google
This commit is contained in:
parent
327f6f0e8d
commit
761abc013f
|
@ -11,3 +11,4 @@
|
||||||
/app/fdroid_full/release/
|
/app/fdroid_full/release/
|
||||||
/app/google_full/
|
/app/google_full/
|
||||||
/app/google_acad/
|
/app/google_acad/
|
||||||
|
/app/src/google_donation/res/values/data.xml
|
||||||
|
|
|
@ -9,8 +9,8 @@ android {
|
||||||
|
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 34
|
versionCode 35
|
||||||
versionName "1.11.0"
|
versionName "1.11.1-test"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -117,27 +117,27 @@ android {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
fdroid_peertube_apps_educ {
|
fdroid_peertube_apps_educ {
|
||||||
res.srcDirs = ['src/main/res', 'src/acad/res']
|
res.srcDirs = ['src/main/res', 'src/acad/res']
|
||||||
java.srcDirs = ['src/main/java', 'src/acad/java']
|
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java']
|
||||||
}
|
}
|
||||||
google_peertube_apps_educ {
|
google_peertube_apps_educ {
|
||||||
res.srcDirs = ['src/main/res', 'src/acad/res']
|
res.srcDirs = ['src/main/res', 'src/acad/res']
|
||||||
java.srcDirs = ['src/main/java', 'src/acad/java']
|
java.srcDirs = ['src/main/java', 'src/acad/java', 'src/no_google_donation/java']
|
||||||
}
|
}
|
||||||
fdroid_full {
|
fdroid_full {
|
||||||
res.srcDirs = ['src/main/res', 'src/full/res']
|
res.srcDirs = ['src/main/res', 'src/full/res']
|
||||||
java.srcDirs = ['src/main/java', 'src/full/java']
|
java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java']
|
||||||
}
|
}
|
||||||
google_full {
|
google_full {
|
||||||
res.srcDirs = ['src/main/res', 'src/full/res']
|
res.srcDirs = ['src/main/res', 'src/full/res', 'src/google_donation/res']
|
||||||
java.srcDirs = ['src/main/java', 'src/full/java']
|
java.srcDirs = ['src/main/java', 'src/full/java', 'src/google_donation/java']
|
||||||
}
|
}
|
||||||
queermotion {
|
queermotion {
|
||||||
res.srcDirs = ['src/main/res', 'src/queermotion/res']
|
res.srcDirs = ['src/main/res', 'src/queermotion/res']
|
||||||
java.srcDirs = ['src/main/java', 'src/full/java']
|
java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java']
|
||||||
}
|
}
|
||||||
bittube {
|
bittube {
|
||||||
res.srcDirs = ['src/main/res', 'src/bittube/res']
|
res.srcDirs = ['src/main/res', 'src/bittube/res']
|
||||||
java.srcDirs = ['src/main/java', 'src/full/java']
|
java.srcDirs = ['src/main/java', 'src/full/java', 'src/no_google_donation/java']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,6 +200,7 @@ dependencies {
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
|
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.0'
|
||||||
implementation 'org.slf4j:slf4j-simple:1.7.30'
|
implementation 'org.slf4j:slf4j-simple:1.7.30'
|
||||||
|
|
||||||
|
google_fullImplementation 'com.anjlab.android.iab.v3:library:1.0.44'
|
||||||
|
|
||||||
fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
fdroid_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||||
google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
google_peertube_apps_educImplementation 'org.matomo.sdk:tracker:4.1.2'
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import com.anjlab.android.iab.v3.BillingProcessor;
|
||||||
|
import com.anjlab.android.iab.v3.TransactionDetails;
|
||||||
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.databinding.ActivityDonationBinding;
|
||||||
|
import app.fedilab.fedilabtube.fragment.DonationsFragment;
|
||||||
|
import app.fedilab.fedilabtube.fragment.MyDonationsFragment;
|
||||||
|
|
||||||
|
|
||||||
|
public class DonationActivity extends AppCompatActivity implements BillingProcessor.IBillingHandler {
|
||||||
|
|
||||||
|
BillingProcessor bp;
|
||||||
|
DonationsFragment donationsFragment;
|
||||||
|
MyDonationsFragment myDonationsFragment;
|
||||||
|
private ActivityDonationBinding binding;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = ActivityDonationBinding.inflate(getLayoutInflater());
|
||||||
|
View view = binding.getRoot();
|
||||||
|
setContentView(view);
|
||||||
|
bp = new BillingProcessor(this, getString(R.string.google_key), this);
|
||||||
|
bp.initialize();
|
||||||
|
if (getSupportActionBar() != null)
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
donationsFragment = new DonationsFragment();
|
||||||
|
myDonationsFragment = new MyDonationsFragment();
|
||||||
|
|
||||||
|
binding.tablayout.addTab(binding.tablayout.newTab().setText(getString(R.string.donate)));
|
||||||
|
binding.tablayout.addTab(binding.tablayout.newTab().setText(getString(R.string.my_donations)));
|
||||||
|
binding.viewpager.setOffscreenPageLimit(2);
|
||||||
|
|
||||||
|
PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
|
||||||
|
binding.viewpager.setAdapter(mPagerAdapter);
|
||||||
|
binding.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
TabLayout.Tab tab = binding.tablayout.getTabAt(position);
|
||||||
|
if (tab != null)
|
||||||
|
tab.select();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
|
binding.viewpager.setCurrentItem(tab.getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabUnselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProductPurchased(@NotNull String productId, TransactionDetails details) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPurchaseHistoryRestored() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBillingError(int errorCode, Throwable error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBillingInitialized() {
|
||||||
|
donationsFragment.initialized(bp);
|
||||||
|
myDonationsFragment.initialized(bp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
if (!bp.handleActivityResult(requestCode, resultCode, data)) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pager adapter for the 2 fragments
|
||||||
|
*/
|
||||||
|
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
ScreenSlidePagerAdapter(FragmentManager fm) {
|
||||||
|
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
if (position == 0) {
|
||||||
|
return donationsFragment;
|
||||||
|
} else {
|
||||||
|
return myDonationsFragment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package app.fedilab.fedilabtube.drawable;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.anjlab.android.iab.v3.BillingProcessor;
|
||||||
|
import com.anjlab.android.iab.v3.SkuDetails;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.DonationActivity;
|
||||||
|
import app.fedilab.fedilabtube.databinding.DrawerDonationBinding;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
|
||||||
|
|
||||||
|
public class DonationButtonAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
|
private final List<String> items;
|
||||||
|
private final BillingProcessor billingProcessor;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public DonationButtonAdapter(List<String> items, BillingProcessor billingProcessor) {
|
||||||
|
this.items = items;
|
||||||
|
this.billingProcessor = billingProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
context = parent.getContext();
|
||||||
|
DrawerDonationBinding itemBinding = DrawerDonationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||||
|
return new ViewHolder(itemBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
|
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||||
|
String item = items.get(position);
|
||||||
|
String product_item = "tubelab_donation_" + item;
|
||||||
|
SkuDetails skuDetails = billingProcessor.getPurchaseListingDetails(product_item);
|
||||||
|
String currency = skuDetails.currency;
|
||||||
|
Double price = skuDetails.priceValue;
|
||||||
|
holder.binding.buttonDonation.setText(String.format(Locale.getDefault(), "%.2f %s", price, currency));
|
||||||
|
holder.binding.buttonDonation.setOnClickListener(v -> billingProcessor.purchase((DonationActivity) context, product_item));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
DrawerDonationBinding binding;
|
||||||
|
|
||||||
|
ViewHolder(DrawerDonationBinding itemView) {
|
||||||
|
super(itemView.getRoot());
|
||||||
|
binding = itemView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package app.fedilab.fedilabtube.drawable;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.anjlab.android.iab.v3.BillingProcessor;
|
||||||
|
import com.anjlab.android.iab.v3.SkuDetails;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.DonationActivity;
|
||||||
|
import app.fedilab.fedilabtube.databinding.DrawerDonationBinding;
|
||||||
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
|
|
||||||
|
|
||||||
|
public class DonationHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
|
private final List<SkuDetails> items;
|
||||||
|
private final BillingProcessor billingProcessor;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public DonationHistoryAdapter(List<SkuDetails> items, BillingProcessor billingProcessor) {
|
||||||
|
this.items = items;
|
||||||
|
this.billingProcessor = billingProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
context = parent.getContext();
|
||||||
|
DrawerDonationBinding itemBinding = DrawerDonationBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
|
||||||
|
return new ViewHolder(itemBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
|
||||||
|
final ViewHolder holder = (ViewHolder) viewHolder;
|
||||||
|
SkuDetails item = items.get(position);
|
||||||
|
String product_item = "tubelab_donation_" + item;
|
||||||
|
SkuDetails skuDetails = billingProcessor.getPurchaseListingDetails(product_item);
|
||||||
|
String currency = skuDetails.currency;
|
||||||
|
Double price = skuDetails.priceValue;
|
||||||
|
holder.binding.buttonDonation.setText(String.format(Locale.getDefault(), "%.2f %s", price, currency));
|
||||||
|
holder.binding.buttonDonation.setOnClickListener(v -> billingProcessor.purchase((DonationActivity) context, product_item));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
DrawerDonationBinding binding;
|
||||||
|
|
||||||
|
ViewHolder(DrawerDonationBinding itemView) {
|
||||||
|
super(itemView.getRoot());
|
||||||
|
binding = itemView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package app.fedilab.fedilabtube.fragment;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
import com.anjlab.android.iab.v3.BillingProcessor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.databinding.FragmentDonationsBinding;
|
||||||
|
import app.fedilab.fedilabtube.drawable.DonationButtonAdapter;
|
||||||
|
|
||||||
|
|
||||||
|
public class DonationsFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String[] donations = {"1", "2", "5", "10"};
|
||||||
|
private FragmentDonationsBinding binding;
|
||||||
|
private View rootView;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
binding = FragmentDonationsBinding.inflate(LayoutInflater.from(context));
|
||||||
|
rootView = binding.getRoot();
|
||||||
|
context = getContext();
|
||||||
|
binding.loader.setVisibility(View.VISIBLE);
|
||||||
|
binding.lvProducts.setVisibility(View.GONE);
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialized(BillingProcessor bp) {
|
||||||
|
binding.loader.setVisibility(View.GONE);
|
||||||
|
binding.lvProducts.setVisibility(View.VISIBLE);
|
||||||
|
List<String> donationsList = new ArrayList<>();
|
||||||
|
Collections.addAll(donationsList, donations);
|
||||||
|
DonationButtonAdapter donationButtonAdapter = new DonationButtonAdapter(donationsList, bp);
|
||||||
|
binding.lvProducts.setAdapter(donationButtonAdapter);
|
||||||
|
binding.lvProducts.setLayoutManager(new LinearLayoutManager(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
rootView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle saveInstance) {
|
||||||
|
super.onCreate(saveInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package app.fedilab.fedilabtube.fragment;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
import com.anjlab.android.iab.v3.BillingProcessor;
|
||||||
|
import com.anjlab.android.iab.v3.SkuDetails;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import app.fedilab.fedilabtube.databinding.FragmentMyDonationsBinding;
|
||||||
|
import app.fedilab.fedilabtube.drawable.DonationHistoryAdapter;
|
||||||
|
|
||||||
|
import static app.fedilab.fedilabtube.fragment.DonationsFragment.donations;
|
||||||
|
|
||||||
|
|
||||||
|
public class MyDonationsFragment extends Fragment {
|
||||||
|
|
||||||
|
private FragmentMyDonationsBinding binding;
|
||||||
|
private View rootView;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
binding = FragmentMyDonationsBinding.inflate(LayoutInflater.from(context));
|
||||||
|
rootView = binding.getRoot();
|
||||||
|
context = getContext();
|
||||||
|
binding.loader.setVisibility(View.VISIBLE);
|
||||||
|
binding.lvPurchases.setVisibility(View.GONE);
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialized(BillingProcessor bp) {
|
||||||
|
binding.loader.setVisibility(View.GONE);
|
||||||
|
binding.lvPurchases.setVisibility(View.VISIBLE);
|
||||||
|
ArrayList<String> donationsList = new ArrayList<>();
|
||||||
|
Collections.addAll(donationsList, donations);
|
||||||
|
List<SkuDetails> skuDetailsList = bp.getPurchaseListingDetails(donationsList);
|
||||||
|
DonationHistoryAdapter donationHistoryAdapter = new DonationHistoryAdapter(skuDetailsList, bp);
|
||||||
|
binding.lvPurchases.setAdapter(donationHistoryAdapter);
|
||||||
|
binding.lvPurchases.setLayoutManager(new LinearLayoutManager(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
rootView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle saveInstance) {
|
||||||
|
super.onCreate(saveInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Copyright 2021 Thomas Schneider
|
||||||
|
|
||||||
|
This file is a part of TubeLab
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
see <http://www.gnu.org/licenses>.
|
||||||
|
-->
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
tools:context=".ShowChannelActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:theme="@style/ThemeOverlay.AppCompat.ActionBar">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:contentScrim="?attr/colorPrimary"
|
||||||
|
app:expandedTitleMarginEnd="64dp"
|
||||||
|
app:expandedTitleMarginStart="48dp"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
|
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/tablayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabMode="fixed"
|
||||||
|
app:tabSelectedTextColor="?colorAccent"
|
||||||
|
app:tabTextColor="@android:color/white" />
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.viewpager.widget.ViewPager
|
||||||
|
android:id="@+id/viewpager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_donation"
|
||||||
|
style="@style/Widget.AppCompat.Button.Colored"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:paddingStart="40dp"
|
||||||
|
android:paddingTop="15dp"
|
||||||
|
android:paddingEnd="40dp"
|
||||||
|
android:paddingBottom="15dp"
|
||||||
|
android:textSize="25sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Copyright 2021 Thomas Schneider
|
||||||
|
|
||||||
|
This file is a part of TubeLab
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
see <http://www.gnu.org/licenses>.
|
||||||
|
-->
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/fab_margin"
|
||||||
|
android:paddingRight="@dimen/fab_margin">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/donation_text" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/lv_products"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@null"
|
||||||
|
android:scrollbars="none" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Main Loader -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/loader"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<com.github.ybq.android.spinkit.SpinKitView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
style="@style/progress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
app:SpinKit_Color="?colorAccent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Copyright 2021 Thomas Schneider
|
||||||
|
|
||||||
|
This file is a part of TubeLab
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
see <http://www.gnu.org/licenses>.
|
||||||
|
-->
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/fab_margin"
|
||||||
|
android:paddingRight="@dimen/fab_margin">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/donations_description" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/lv_purchases"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@null"
|
||||||
|
android:scrollbars="none" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Main Loader -->
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/loader"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<com.github.ybq.android.spinkit.SpinKitView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
style="@style/progress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
app:SpinKit_Color="?colorAccent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="app.fedilab.fedilabtube">
|
package="app.fedilab.fedilabtube">
|
||||||
|
|
||||||
|
<uses-permission android:name="com.android.vending.BILLING" />
|
||||||
<application
|
<application
|
||||||
android:name=".FedilabTube"
|
android:name=".FedilabTube"
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
|
@ -30,5 +30,10 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".DonationActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:label="@string/support_the_app"
|
||||||
|
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
|
@ -687,7 +687,11 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
MenuItem incognitoItem = menu.findItem(R.id.action_incognito);
|
MenuItem incognitoItem = menu.findItem(R.id.action_incognito);
|
||||||
MenuItem instanceItem = menu.findItem(R.id.action_change_instance);
|
MenuItem instanceItem = menu.findItem(R.id.action_change_instance);
|
||||||
MenuItem accountItem = menu.findItem(R.id.action_account);
|
MenuItem accountItem = menu.findItem(R.id.action_account);
|
||||||
|
MenuItem donateItem = menu.findItem(R.id.action_donate);
|
||||||
|
|
||||||
|
if (BuildConfig.full_instances && BuildConfig.google_restriction) {
|
||||||
|
donateItem.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (BuildConfig.surfing_mode && ((Helper.isLoggedIn(MainActivity.this) && typeOfConnection == NORMAL) || typeOfConnection == SURFING)) {
|
if (BuildConfig.surfing_mode && ((Helper.isLoggedIn(MainActivity.this) && typeOfConnection == NORMAL) || typeOfConnection == SURFING)) {
|
||||||
binding.instances.setVisibility(View.VISIBLE);
|
binding.instances.setVisibility(View.VISIBLE);
|
||||||
|
@ -847,6 +851,9 @@ public class MainActivity extends AppCompatActivity implements ChromeCastsListen
|
||||||
} else if (item.getItemId() == R.id.action_about) {
|
} else if (item.getItemId() == R.id.action_about) {
|
||||||
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else if (item.getItemId() == R.id.action_donate) {
|
||||||
|
Intent intent = new Intent(MainActivity.this, DonationActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
} else if (item.getItemId() == R.id.action_incognito) {
|
} else if (item.getItemId() == R.id.action_incognito) {
|
||||||
item.setChecked(!item.isChecked());
|
item.setChecked(!item.isChecked());
|
||||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M11.8,10.9c-2.27,-0.59 -3,-1.2 -3,-2.15 0,-1.09 1.01,-1.85 2.7,-1.85 1.78,0 2.44,0.85 2.5,2.1h2.21c-0.07,-1.72 -1.12,-3.3 -3.21,-3.81V3h-3v2.16c-1.94,0.42 -3.5,1.68 -3.5,3.61 0,2.31 1.91,3.46 4.7,4.13 2.5,0.6 3,1.48 3,2.41 0,0.69 -0.49,1.79 -2.7,1.79 -2.06,0 -2.87,-0.92 -2.98,-2.1h-2.2c0.12,2.19 1.76,3.42 3.68,3.83V21h3v-2.15c1.95,-0.37 3.5,-1.5 3.5,-3.55 0,-2.84 -2.43,-3.81 -4.7,-4.4z" />
|
||||||
|
</vector>
|
|
@ -67,4 +67,10 @@
|
||||||
android:icon="@drawable/ic_baseline_info_24"
|
android:icon="@drawable/ic_baseline_info_24"
|
||||||
android:title="@string/about_the_app"
|
android:title="@string/about_the_app"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_donate"
|
||||||
|
android:icon="@drawable/ic_baseline_attach_money_24"
|
||||||
|
android:title="@string/make_a_donation"
|
||||||
|
android:visible="false"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -455,5 +455,11 @@
|
||||||
<string name="watermark">Watermark</string>
|
<string name="watermark">Watermark</string>
|
||||||
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
<string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string>
|
||||||
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
<string name="remote_account_from"><b>%1$s</b> remote account connected with the app.\n\nYou can proceed to some limited actions.</string>
|
||||||
|
<string name="donate">Donate</string>
|
||||||
|
<string name="my_donations">My donations</string>
|
||||||
|
<string name="donation_text">Here, you can make a donation for supporting the development of the app. This action will not bring extra features!</string>
|
||||||
|
<string name="make_a_donation">Make a donation</string>
|
||||||
|
<string name="donations_description">Here you will find the list of donations made to the app! Thank you!</string>
|
||||||
|
<string name="support_the_app">Support the app</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -0,0 +1,20 @@
|
||||||
|
package app.fedilab.fedilabtube;
|
||||||
|
/* Copyright 2021 Thomas Schneider
|
||||||
|
*
|
||||||
|
* This file is a part of TubeLab
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||||
|
* Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
//Do nothing
|
||||||
|
public class DonationActivity {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue