diff --git a/.idea/modules.xml b/.idea/modules.xml
index b7971c4..1157461 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,8 +2,8 @@
-
+
\ No newline at end of file
diff --git a/RiskAhead.iml b/RiskAhead.iml
index 16a12ec..267a21a 100644
--- a/RiskAhead.iml
+++ b/RiskAhead.iml
@@ -1,5 +1,5 @@
-
+
diff --git a/app/app.iml b/app/app.iml
index 56250d7..04efb76 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -1,5 +1,5 @@
-
+
@@ -96,7 +96,6 @@
-
diff --git a/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java b/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java
index 0e391fc..a335247 100644
--- a/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java
+++ b/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java
@@ -1,62 +1,133 @@
package org.deke.risk.riskahead;
-import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
+import android.os.Handler;
import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
import android.view.View;
import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
import com.android.vending.billing.IInAppBillingService;
+import com.beardedhen.androidbootstrap.BootstrapButton;
import org.deke.risk.riskahead.helper.BaseActivity;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
-public class SubscriptionsActivity extends BaseActivity implements ServiceConnection{
+public class SubscriptionsActivity extends BaseActivity{
private final static String mActivityTitle = "Subscriptions";
- private final static String TAG = StartActivity.class.getSimpleName();
+ private final static String TAG = SubscriptionsActivity.class.getSimpleName();
- private Button btnPurchaseNoAds;
- private Button btnPurchaseExtraFunctions;
+ private TableLayout tblBillings;
IInAppBillingService mService;
ServiceConnection mServiceConn;
+ Bundle querySkus;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userHasToBeLoggedIn();
- btnPurchaseNoAds = (Button) findViewById(R.id.btn_subscription_1);
- btnPurchaseExtraFunctions = (Button) findViewById(R.id.btn_subscription_2);
+ tblBillings = (TableLayout) findViewById(R.id.tbl_billing);
- //Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
- // serviceIntent.setPackage("com.android.vending");
- //bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
-
- // Bundle activeSubs = mService.getPurchases(3, "org.deke.risk.riskahead", "subs", continueToken);
-
- btnPurchaseNoAds.setOnClickListener(new View.OnClickListener() {
+ ServiceConnection mServiceConn = new ServiceConnection() {
@Override
- public void onClick(View v) {
- /*
- Bundle bundle = mService.getBuyIntent(3, "org.deke.risk.riskahead",MY_SKU, "subs", developerPayload);
-
- PendingIntent pendingIntent = bundle.getParcelable(RESPONSE_BUY_INTENT);
- if (bundle.getInt(RESPONSE_CODE) == BILLING_RESPONSE_RESULT_OK) {
- // Start purchase flow (this brings up the Google Play UI).
- // Result will be delivered through onActivityResult().
- startIntentSenderForResult(pendingIntent, RC_BUY, new Intent(),
- Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
- }
- */
+ public void onServiceDisconnected(ComponentName name) {
+ mService = null;
+ Log.d(TAG,"Disconnected from InApp Billing Service");
}
- });
+ @Override
+ public void onServiceConnected(ComponentName name,
+ IBinder service) {
+ mService = IInAppBillingService.Stub.asInterface(service);
+ Log.d(TAG,"Connected to InApp Billing Service");
+
+ initBillingOptions();
+ }
+ };
+
+ Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
+ serviceIntent.setPackage("com.android.vending");
+ bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
+
+ ArrayList skuList = new ArrayList();
+ skuList.add("no_ads_01");
+ skuList.add("extra_functions_01");
+ querySkus = new Bundle();
+ querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
+
+
+
+
+ }
+
+ private void initBillingOptions() {
+ try {
+ Bundle skuDetails = mService.getSkuDetails(3,
+ getPackageName(), "subs", querySkus);
+
+ int response = skuDetails.getInt("RESPONSE_CODE");
+
+ Log.d(TAG, "InApp Response_Code: " + response);
+ if (response == 0) {
+ ArrayList responseList
+ = skuDetails.getStringArrayList("DETAILS_LIST");
+
+ TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
+
+ for (String thisResponse : responseList) {
+ JSONObject object = new JSONObject(thisResponse);
+ TableRow tableRow = new TableRow(getApplicationContext());
+ tableRow.setLayoutParams(rowParams);
+
+ TextView textView = new TextView(getApplicationContext());
+ textView.setLayoutParams(rowParams);
+ textView.setText(object.getString("title"));
+
+ BootstrapButton btnPurchase = new BootstrapButton(getApplicationContext());
+ btnPurchase.setText(object.getString("price"));
+ btnPurchase.setLayoutParams(rowParams);
+ btnPurchase.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Log.d(TAG,"Purchase item");
+ }
+ });
+
+ tableRow.addView(textView);
+ tableRow.addView(btnPurchase);
+
+ tblBillings.addView(tableRow);
+
+
+
+ String sku = object.getString("productId");
+ String price = object.getString("price");
+ Log.d(TAG,"Product: "+sku+" Price: "+price);
+ }
+ }
+
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
}
@Override
@@ -75,16 +146,6 @@ public class SubscriptionsActivity extends BaseActivity implements ServiceConnec
@Override
protected String getActivityName() { return mActivityTitle; }
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mService = IInAppBillingService.Stub.asInterface(service);
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mService = null;
- }
-
@Override
public void onDestroy() {
super.onDestroy();
diff --git a/app/src/main/java/org/deke/risk/riskahead/helper/NotificationService.java b/app/src/main/java/org/deke/risk/riskahead/helper/NotificationService.java
index 0556e23..6e5a9af 100644
--- a/app/src/main/java/org/deke/risk/riskahead/helper/NotificationService.java
+++ b/app/src/main/java/org/deke/risk/riskahead/helper/NotificationService.java
@@ -75,7 +75,7 @@ public class NotificationService extends Service {
myPosition = session.getLocation();
radius = session.getNotificationRadius();
- pollFrequency = session.getNotificationPollFreq() * 1000; //TODO add minutes
+ pollFrequency = session.getNotificationPollFreq() * 1000 * 60;
notifyEnabled = session.getNotificationEnabled();
Log.d(this.toString(), "Run Notification Task. Notifications enabled = "+notifyEnabled);
diff --git a/app/src/main/res/layout/activity_subscriptions.xml b/app/src/main/res/layout/activity_subscriptions.xml
index 8cf8ee3..5f256a8 100644
--- a/app/src/main/res/layout/activity_subscriptions.xml
+++ b/app/src/main/res/layout/activity_subscriptions.xml
@@ -6,6 +6,7 @@
android:background="@drawable/layout_bg_gradient"
android:layout_width="match_parent"
android:layout_height="match_parent"
+
tools:context=".SubscriptionsActivity">
-
+
+
+
+
+
+
+ android:layout_height="wrap_content">
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-