@7.01.15 Dennis Thießen: Subscriptions eingebaut... muss noch schöner dargestellt werden
This commit is contained in:
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@@ -2,8 +2,8 @@
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/RiskAhead.iml" filepath="$PROJECT_DIR$/RiskAhead.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/riskAhead.iml" filepath="$PROJECT_DIR$/riskAhead.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="RiskAhead" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.id="riskAhead" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="RiskAhead" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="riskAhead" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
@@ -96,7 +96,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/release" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
|
||||
@@ -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<String> skuList = new ArrayList<String>();
|
||||
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<String> 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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
android:background="@drawable/layout_bg_gradient"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
tools:context=".SubscriptionsActivity">
|
||||
|
||||
<include
|
||||
@@ -19,105 +20,49 @@
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutMain"
|
||||
android:layout_below="@+id/toolbar"
|
||||
android:layout_margin="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layoutContent"
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_main_txt1"
|
||||
android:text="Subscriptions"
|
||||
android:textColor="@color/bg_common_2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_margin="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_main_txt2"
|
||||
android:text="Maintaining RiskAhead is cost-intensive."
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_margin="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_main_txt3"
|
||||
android:text="Help us by purchasing subscriptions or single packages.\nThis allows us to maintain and enhance RiskAhead."
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_margin="5dp"
|
||||
android:textColor="@color/text_light_grey"/>
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/tbl_billing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:padding="8dp"
|
||||
android:background="@drawable/layout_bg"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_subscription_title"
|
||||
android:text="Subscriptions"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="3dp"
|
||||
android:gravity="center"
|
||||
android:stretchColumns="1"
|
||||
android:layout_below="@+id/lbl_subscription_title"
|
||||
android:id="@+id/tableLayout2">
|
||||
|
||||
<TableRow android:padding="1dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_subscription_1_title"
|
||||
android:text="No Ads"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_subscription_1_desription"
|
||||
android:text="You can subscripe this option to have no more ads. This is a recuring subscriptions for $5 a month"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Purchase"
|
||||
android:id="@+id/btn_subscription_1" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:padding="1dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_subscription_2_title"
|
||||
android:text="Unlimited Access"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_subscription_2_description"
|
||||
android:text="You can get unlimimited access to the report map with this reccuring subscription for $10 a month"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Purchase"
|
||||
android:id="@+id/btn_subscription_2" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user