InApp fixes
This commit is contained in:
parent
26f5699a27
commit
7ab983a94c
3 changed files with 195 additions and 160 deletions
|
@ -34,6 +34,14 @@
|
||||||
|
|
||||||
<include layout="@layout/shadow_bottom"/>
|
<include layout="@layout/shadow_bottom"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -70,7 +78,6 @@
|
||||||
android:textColor="?android:attr/textColorSecondary"/>
|
android:textColor="?android:attr/textColorSecondary"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -101,6 +108,7 @@
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -114,9 +122,9 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="56dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:minHeight="56dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -139,9 +147,9 @@
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:hint="Support region"
|
|
||||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||||
android:editable="false"/>
|
android:editable="false"
|
||||||
|
android:hint="Support region"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -220,5 +228,8 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.osmand.plus.inapp.util.IabHelper;
|
||||||
import net.osmand.plus.inapp.util.IabResult;
|
import net.osmand.plus.inapp.util.IabResult;
|
||||||
import net.osmand.plus.inapp.util.Inventory;
|
import net.osmand.plus.inapp.util.Inventory;
|
||||||
import net.osmand.plus.inapp.util.Purchase;
|
import net.osmand.plus.inapp.util.Purchase;
|
||||||
|
import net.osmand.plus.inapp.util.SkuDetails;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -31,6 +32,7 @@ public class InAppHelper {
|
||||||
static final String TAG = "InAppHelper";
|
static final String TAG = "InAppHelper";
|
||||||
|
|
||||||
private static boolean mSubscribedToLiveUpdates = false;
|
private static boolean mSubscribedToLiveUpdates = false;
|
||||||
|
private static String mLiveUpdatesPrice;
|
||||||
|
|
||||||
public static final String SKU_LIVE_UPDATES = "osm_live_subscription_1";
|
public static final String SKU_LIVE_UPDATES = "osm_live_subscription_1";
|
||||||
|
|
||||||
|
@ -63,6 +65,10 @@ public class InAppHelper {
|
||||||
return mSubscribedToLiveUpdates;
|
return mSubscribedToLiveUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLiveUpdatesPrice() {
|
||||||
|
return mLiveUpdatesPrice;
|
||||||
|
}
|
||||||
|
|
||||||
public InAppHelper(OsmandApplication ctx, InAppCallbacks callbacks) {
|
public InAppHelper(OsmandApplication ctx, InAppCallbacks callbacks) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.callbacks = callbacks;
|
this.callbacks = callbacks;
|
||||||
|
@ -159,6 +165,11 @@ public class InAppHelper {
|
||||||
Log.d(TAG, "User " + (mSubscribedToLiveUpdates ? "HAS" : "DOES NOT HAVE")
|
Log.d(TAG, "User " + (mSubscribedToLiveUpdates ? "HAS" : "DOES NOT HAVE")
|
||||||
+ " live updates purchased.");
|
+ " live updates purchased.");
|
||||||
|
|
||||||
|
if (inventory.hasDetails(SKU_LIVE_UPDATES)) {
|
||||||
|
SkuDetails liveUpdatesDetails = inventory.getSkuDetails(SKU_LIVE_UPDATES);
|
||||||
|
mLiveUpdatesPrice = liveUpdatesDetails.getPrice();
|
||||||
|
}
|
||||||
|
|
||||||
if (callbacks != null) {
|
if (callbacks != null) {
|
||||||
callbacks.showHideProgress(false);
|
callbacks.showHideProgress(false);
|
||||||
callbacks.onGetItems();
|
callbacks.onGetItems();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
|
@ -104,6 +105,8 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updatePrice();
|
||||||
|
|
||||||
Button subscribeButton = (Button) view.findViewById(R.id.subscribeButton);
|
Button subscribeButton = (Button) view.findViewById(R.id.subscribeButton);
|
||||||
subscribeButton.setOnClickListener(new View.OnClickListener() {
|
subscribeButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,7 +169,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGetItems() {
|
public void onGetItems() {
|
||||||
|
updatePrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -202,6 +205,16 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updatePrice() {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
TextView priceTextView = (TextView) view.findViewById(R.id.priceTextView);
|
||||||
|
if (InAppHelper.getLiveUpdatesPrice() != null) {
|
||||||
|
priceTextView.setText(InAppHelper.getLiveUpdatesPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initCountries() {
|
private void initCountries() {
|
||||||
final WorldRegion root = getMyApplication().getRegions().getWorldRegion();
|
final WorldRegion root = getMyApplication().getRegions().getWorldRegion();
|
||||||
ArrayList<WorldRegion> groups = new ArrayList<>();
|
ArrayList<WorldRegion> groups = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in a new issue