InApp fixes
This commit is contained in:
parent
26f5699a27
commit
7ab983a94c
3 changed files with 195 additions and 160 deletions
|
@ -34,191 +34,202 @@
|
||||||
|
|
||||||
<include layout="@layout/shadow_bottom"/>
|
<include layout="@layout/shadow_bottom"/>
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
<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
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<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:orientation="vertical">
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/userNameIcon"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="56dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:minHeight="56dp"
|
||||||
android:scaleType="center"
|
android:orientation="horizontal">
|
||||||
android:src="@drawable/ic_person"/>
|
|
||||||
|
|
||||||
<EditText
|
<ImageView
|
||||||
android:id="@+id/userNameEdit"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="72dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:hint="Public Name"
|
android:text="We need it to provide you information about contributions"
|
||||||
android:inputType="text"/>
|
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
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
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
|
<ImageView
|
||||||
android:id="@+id/selectCountryEdit"
|
android:id="@+id/userNameIcon"
|
||||||
android:layout_width="fill_parent"
|
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_height="wrap_content"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginTop="4dp"
|
android:text="Monthly payment"
|
||||||
android:hint="Support region"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
android:editable="false"/>
|
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>
|
||||||
|
|
||||||
</LinearLayout>
|
</ScrollView>
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
|
|
||||||
</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