InApp fixes
This commit is contained in:
parent
26f5699a27
commit
7ab983a94c
3 changed files with 195 additions and 160 deletions
|
@ -33,192 +33,203 @@
|
|||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/shadow_bottom"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="56dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/emailIcon"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_message"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/emailEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:hint="E-mail address"
|
||||
android:inputType="textEmailAddress"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="We need it to provide you information about contributions"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
|
||||
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="56dp"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/userNameIcon"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_person"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="56dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/userNameEdit"
|
||||
<ImageView
|
||||
android:id="@+id/emailIcon"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_message"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/emailEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:hint="E-mail address"
|
||||
android:inputType="textEmailAddress"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:hint="Public Name"
|
||||
android:inputType="text"/>
|
||||
android:text="We need it to provide you information about contributions"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
<CheckBox
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Don't show my name in reports"
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="56dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/countryIcon"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_world_globe_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="56dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.AutoCompleteTextViewEx
|
||||
android:id="@+id/selectCountryEdit"
|
||||
android:layout_width="fill_parent"
|
||||
<ImageView
|
||||
android:id="@+id/userNameIcon"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_person"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/userNameEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:hint="Public Name"
|
||||
android:inputType="text"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Don't show my name in reports"
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:minHeight="56dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/countryIcon"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_world_globe_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<net.osmand.plus.widgets.AutoCompleteTextViewEx
|
||||
android:id="@+id/selectCountryEdit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||
android:editable="false"
|
||||
android:hint="Support region"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="?attr/bg_card"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Month cost"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/priceTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:text="@string/osm_live_default_price"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:hint="Support region"
|
||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||
android:editable="false"/>
|
||||
android:text="Monthly payment"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="?attr/divider_color"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/subscribeButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Subscribe"
|
||||
android:textColor="?attr/color_dialog_buttons"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="?attr/bg_card"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Month cost"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/priceTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:text="@string/osm_live_default_price"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="Monthly payment"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="?attr/divider_color"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/subscribeButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="6dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="Subscribe"
|
||||
android:textColor="?attr/color_dialog_buttons"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</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.Inventory;
|
||||
import net.osmand.plus.inapp.util.Purchase;
|
||||
import net.osmand.plus.inapp.util.SkuDetails;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
@ -31,6 +32,7 @@ public class InAppHelper {
|
|||
static final String TAG = "InAppHelper";
|
||||
|
||||
private static boolean mSubscribedToLiveUpdates = false;
|
||||
private static String mLiveUpdatesPrice;
|
||||
|
||||
public static final String SKU_LIVE_UPDATES = "osm_live_subscription_1";
|
||||
|
||||
|
@ -63,6 +65,10 @@ public class InAppHelper {
|
|||
return mSubscribedToLiveUpdates;
|
||||
}
|
||||
|
||||
public static String getLiveUpdatesPrice() {
|
||||
return mLiveUpdatesPrice;
|
||||
}
|
||||
|
||||
public InAppHelper(OsmandApplication ctx, InAppCallbacks callbacks) {
|
||||
this.ctx = ctx;
|
||||
this.callbacks = callbacks;
|
||||
|
@ -159,6 +165,11 @@ public class InAppHelper {
|
|||
Log.d(TAG, "User " + (mSubscribedToLiveUpdates ? "HAS" : "DOES NOT HAVE")
|
||||
+ " live updates purchased.");
|
||||
|
||||
if (inventory.hasDetails(SKU_LIVE_UPDATES)) {
|
||||
SkuDetails liveUpdatesDetails = inventory.getSkuDetails(SKU_LIVE_UPDATES);
|
||||
mLiveUpdatesPrice = liveUpdatesDetails.getPrice();
|
||||
}
|
||||
|
||||
if (callbacks != null) {
|
||||
callbacks.showHideProgress(false);
|
||||
callbacks.onGetItems();
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
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);
|
||||
subscribeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -166,7 +169,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
|
|||
|
||||
@Override
|
||||
public void onGetItems() {
|
||||
|
||||
updatePrice();
|
||||
}
|
||||
|
||||
@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() {
|
||||
final WorldRegion root = getMyApplication().getRegions().getWorldRegion();
|
||||
ArrayList<WorldRegion> groups = new ArrayList<>();
|
||||
|
|
Loading…
Reference in a new issue