summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2021-03-12 13:38:41 +0100
committerArne Schwabe <arne@rfc2549.org>2021-03-12 16:00:27 +0100
commit5359c051f711bdb53706b264a94042fa4033a5c2 (patch)
tree98881c2c0f2f1b81ab9b42002e2ae8f9dbd85920
parentdc1b69e925423bcb449e3513736ff25234143b3a (diff)
Remove remaining GMS code
-rw-r--r--main/src/ui/java/de/blinkt/openvpn/fragments/AboutFragment.java201
-rw-r--r--main/src/ui/res/layout/about.xml8
2 files changed, 0 insertions, 209 deletions
diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/AboutFragment.java b/main/src/ui/java/de/blinkt/openvpn/fragments/AboutFragment.java
index ec07a77c..240fbe06 100644
--- a/main/src/ui/java/de/blinkt/openvpn/fragments/AboutFragment.java
+++ b/main/src/ui/java/de/blinkt/openvpn/fragments/AboutFragment.java
@@ -49,213 +49,20 @@ import kotlin.text.Charsets;
public class AboutFragment extends Fragment implements View.OnClickListener {
- private static final String INAPPITEM_TYPE_INAPP = "inapp";
private static final String RESPONSE_CODE = "RESPONSE_CODE";
- private static final int DONATION_CODE = 12;
- private static final int BILLING_RESPONSE_RESULT_OK = 0;
- private static final String RESPONSE_BUY_INTENT = "BUY_INTENT";
- private static final String[] donationSkus = { "donation1eur", "donation2eur", "donation5eur", "donation10eur",
- "donation1337eur","donation23eur","donation25eur",};
- IInAppBillingService mService;
- Hashtable<View, String> viewToProduct = new Hashtable<>();
- ServiceConnection mServiceConn = new ServiceConnection() {
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mService = null;
- }
-
- @Override
- public void onServiceConnected(ComponentName name,
- IBinder service) {
- mService = IInAppBillingService.Stub.asInterface(service);
- initGooglePlayDonation();
-
- }
- };
- private void initGooglePlayDonation() {
- new Thread("queryGMSInApp") {
- @Override
- public void run() {
- initGMSDonateOptions();
- }
- }.start();
- }
-
- private TextView gmsTextView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- /*
- getActivity().bindService(new
- Intent("com.android.vending.billing.InAppBillingService.BIND"),
- mServiceConn, Context.BIND_AUTO_CREATE);
- */
}
@Override
public void onDestroy() {
super.onDestroy();
- if (mService != null) {
- getActivity().unbindService(mServiceConn);
- }
-
- }
-
- private void initGMSDonateOptions() {
- try {
- int billingSupported = mService.isBillingSupported(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP);
- if (billingSupported != BILLING_RESPONSE_RESULT_OK) {
- Log.i("OpenVPN", "Play store billing not supported");
- return;
- }
-
- ArrayList skuList = new ArrayList();
- Collections.addAll(skuList, donationSkus);
- Bundle querySkus = new Bundle();
- querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
-
- Bundle ownedItems = mService.getPurchases(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP, null);
-
-
- if (ownedItems.getInt(RESPONSE_CODE) != BILLING_RESPONSE_RESULT_OK)
- return;
-
- final ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
-
- Bundle skuDetails = mService.getSkuDetails(3, getActivity().getPackageName(), INAPPITEM_TYPE_INAPP, querySkus);
-
-
- if (skuDetails.getInt(RESPONSE_CODE) != BILLING_RESPONSE_RESULT_OK)
- return;
-
- final ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
-
- if (getActivity() != null) {
- getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- createPlayBuyOptions(ownedSkus, responseList);
-
- }
- });
- }
-
- } catch (RemoteException e) {
- VpnStatus.logException(e);
- }
- }
-
- private static class SkuResponse {
- String title;
- String price;
-
- SkuResponse(String p, String t)
- {
- title=t;
- price=p;
- }
}
-
- private void createPlayBuyOptions(ArrayList<String> ownedSkus, ArrayList<String> responseList) {
- try {
- Vector<Pair<String,String>> gdonation = new Vector<Pair<String, String>>();
-
- gdonation.add(new Pair<String, String>(getString(R.string.donatePlayStore),null));
- HashMap<String, SkuResponse> responseMap = new HashMap<String, SkuResponse>();
- for (String thisResponse : responseList) {
- JSONObject object = new JSONObject(thisResponse);
- responseMap.put(
- object.getString("productId"),
- new SkuResponse(
- object.getString("price"),
- object.getString("title")));
-
- }
- for (String sku: donationSkus)
- if (responseMap.containsKey(sku))
- gdonation.add(getSkuTitle(sku,
- responseMap.get(sku).title, responseMap.get(sku).price, ownedSkus));
-
- String gmsTextString="";
- for(int i=0;i<gdonation.size();i++) {
- if(i==1)
- gmsTextString+= " ";
- else if(i>1)
- gmsTextString+= ", ";
- gmsTextString+=gdonation.elementAt(i).first;
- }
- SpannableString gmsText = new SpannableString(gmsTextString);
-
-
- int lStart = 0;
- int lEnd=0;
- for(Pair<String, String> item:gdonation){
- lEnd = lStart + item.first.length();
- if (item.second!=null) {
- final String mSku = item.second;
- ClickableSpan cspan = new ClickableSpan()
- {
- @Override
- public void onClick(View widget) {
- triggerBuy(mSku);
- }
- };
- gmsText.setSpan(cspan,lStart,lEnd,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- lStart = lEnd+2; // Account for ", " between items
- }
-
- if(gmsTextView !=null) {
- gmsTextView.setText(gmsText);
- gmsTextView.setMovementMethod(LinkMovementMethod.getInstance());
- gmsTextView.setVisibility(View.VISIBLE);
- }
-
- } catch (JSONException e) {
- VpnStatus.logException("Parsing Play Store IAP",e);
- }
-
- }
-
- private Pair<String,String> getSkuTitle(final String sku, String title, String price, ArrayList<String> ownedSkus) {
- String text;
- if (ownedSkus.contains(sku))
- return new Pair<String,String>(getString(R.string.thanks_for_donation, price),null);
-
- if (price.contains("€")|| price.contains("\u20ac")) {
- text= title;
- } else {
- text = String.format(Locale.getDefault(), "%s (%s)", title, price);
- }
- //return text;
- return new Pair<String,String>(price, sku);
-
- }
-
- private void triggerBuy(String sku) {
- try {
- Bundle buyBundle
- = mService.getBuyIntent(3, getActivity().getPackageName(),
- sku, INAPPITEM_TYPE_INAPP, "Thanks for the donation! :)");
-
-
- if (buyBundle.getInt(RESPONSE_CODE) == BILLING_RESPONSE_RESULT_OK) {
- PendingIntent buyIntent = buyBundle.getParcelable(RESPONSE_BUY_INTENT);
- getActivity().startIntentSenderForResult(buyIntent.getIntentSender(), DONATION_CODE, new Intent(),
- 0, 0, 0);
- }
-
- } catch (RemoteException e) {
- VpnStatus.logException(e);
- } catch (IntentSender.SendIntentException e) {
- VpnStatus.logException(e);
- }
- }
-
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -280,13 +87,7 @@ public class AboutFragment extends Fragment implements View.OnClickListener {
verO2.setText(String.format(Locale.US, "OpenVPN version: %s", NativeUtils.getOpenVPN2GitVersion()));
verO3.setText(String.format(Locale.US, "OpenVPN3 core version: %s", NativeUtils.getOpenVPN3GitVersion()));
- gmsTextView = (TextView) v.findViewById(R.id.donategms);
/* recreating view without onCreate/onDestroy cycle */
-
- // Disable GMS for now
- if (mService!=null)
- initGooglePlayDonation();
-
TextView translation = (TextView) v.findViewById(R.id.translation);
// Don't print a text for myself
@@ -323,8 +124,6 @@ public class AboutFragment extends Fragment implements View.OnClickListener {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- if (mService!=null)
- initGooglePlayDonation();
}
diff --git a/main/src/ui/res/layout/about.xml b/main/src/ui/res/layout/about.xml
index 8b40520b..acb1506f 100644
--- a/main/src/ui/res/layout/about.xml
+++ b/main/src/ui/res/layout/about.xml
@@ -70,14 +70,6 @@
android:text="@string/copyright_guicode" />
- <TextView
- android:paddingTop="12sp"
- android:id="@+id/donategms"
- android:text="@string/donatePlayStore"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:visibility="gone"
- tools:ignore="SelectableText"/>
<TextView