@7.01.15 Dennis Thießen: Subscriptions eingebaut... muss noch schöner dargestellt werden

This commit is contained in:
Dennis Thießen
2016-01-09 08:35:18 +01:00
parent cd3f486dce
commit 64949edcbd
6 changed files with 135 additions and 130 deletions

2
.idea/modules.xml generated
View File

@@ -2,8 +2,8 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <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$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/riskAhead.iml" filepath="$PROJECT_DIR$/riskAhead.iml" />
</modules> </modules>
</component> </component>
</project> </project>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle"> <facet type="java-gradle" name="Java-Gradle">
<configuration> <configuration>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle"> <facet type="android-gradle" name="Android-Gradle">
<configuration> <configuration>
@@ -96,7 +96,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" /> <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/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />

View File

@@ -1,62 +1,133 @@
package org.deke.risk.riskahead; package org.deke.risk.riskahead;
import android.app.PendingIntent;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Button; 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.android.vending.billing.IInAppBillingService;
import com.beardedhen.androidbootstrap.BootstrapButton;
import org.deke.risk.riskahead.helper.BaseActivity; 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 mActivityTitle = "Subscriptions";
private final static String TAG = StartActivity.class.getSimpleName(); private final static String TAG = SubscriptionsActivity.class.getSimpleName();
private Button btnPurchaseNoAds; private TableLayout tblBillings;
private Button btnPurchaseExtraFunctions;
IInAppBillingService mService; IInAppBillingService mService;
ServiceConnection mServiceConn; ServiceConnection mServiceConn;
Bundle querySkus;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
userHasToBeLoggedIn(); userHasToBeLoggedIn();
btnPurchaseNoAds = (Button) findViewById(R.id.btn_subscription_1); tblBillings = (TableLayout) findViewById(R.id.tbl_billing);
btnPurchaseExtraFunctions = (Button) findViewById(R.id.btn_subscription_2);
//Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); ServiceConnection mServiceConn = new ServiceConnection() {
// 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() {
@Override @Override
public void onClick(View v) { public void onServiceDisconnected(ComponentName name) {
/* mService = null;
Bundle bundle = mService.getBuyIntent(3, "org.deke.risk.riskahead",MY_SKU, "subs", developerPayload); Log.d(TAG,"Disconnected from InApp Billing Service");
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));
}
*/
} }
});
@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 @Override
@@ -75,16 +146,6 @@ public class SubscriptionsActivity extends BaseActivity implements ServiceConnec
@Override @Override
protected String getActivityName() { return mActivityTitle; } 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 @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();

View File

@@ -75,7 +75,7 @@ public class NotificationService extends Service {
myPosition = session.getLocation(); myPosition = session.getLocation();
radius = session.getNotificationRadius(); radius = session.getNotificationRadius();
pollFrequency = session.getNotificationPollFreq() * 1000; //TODO add minutes pollFrequency = session.getNotificationPollFreq() * 1000 * 60;
notifyEnabled = session.getNotificationEnabled(); notifyEnabled = session.getNotificationEnabled();
Log.d(this.toString(), "Run Notification Task. Notifications enabled = "+notifyEnabled); Log.d(this.toString(), "Run Notification Task. Notifications enabled = "+notifyEnabled);

View File

@@ -6,6 +6,7 @@
android:background="@drawable/layout_bg_gradient" android:background="@drawable/layout_bg_gradient"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".SubscriptionsActivity"> tools:context=".SubscriptionsActivity">
<include <include
@@ -19,105 +20,49 @@
<LinearLayout <LinearLayout
android:id="@+id/layoutMain" android:id="@+id/layoutMain"
android:layout_below="@+id/toolbar" android:layout_below="@+id/toolbar"
android:layout_margin="0dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> 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_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content">
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">
<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 </TableLayout>
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>
<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> </LinearLayout>