Added new items to free version banner
This commit is contained in:
parent
41d9e92f7c
commit
3c5e9f07c2
6 changed files with 376 additions and 97 deletions
|
@ -11,6 +11,8 @@
|
|||
-->
|
||||
|
||||
<!-- Not translatable -->
|
||||
<string name="full_version_price">€5</string>
|
||||
<string name="osm_live_price">€1.5</string>
|
||||
<string name="osm_live">OSM Live (Beta)</string>
|
||||
<string name="ga_api_key">UA-28342846-2</string>
|
||||
<string name="ga_dispatchPeriod">10</string>
|
||||
|
|
|
@ -9,91 +9,248 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@color/osmo_header_dark"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/list_header_padding"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:paddingTop="@dimen/list_header_padding"
|
||||
android:theme="@style/FreeVersionBanner"
|
||||
tools:showIn="@layout/local_index_fragment_header">
|
||||
android:theme="@style/FreeVersionBanner">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/freeVersionBannerTitle"
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/free_version_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/downloadsLeftTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="@string/downloads_left_template"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/freeVersionDescriptionTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
tools:text="@string/free_version_message"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:layout_margin="4dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/downloadsLeftProgressBar"
|
||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:max="10"
|
||||
android:progressDrawable="@drawable/number_of_downloads_progress_bar_drawable"
|
||||
android:saveEnabled="false"
|
||||
tools:progress="6"/>
|
||||
android:paddingBottom="@dimen/list_header_padding"
|
||||
android:paddingTop="@dimen/list_header_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/marksLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"/>
|
||||
</FrameLayout>
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonsLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/list_content_padding">
|
||||
<LinearLayout
|
||||
android:id="@+id/bannerTopLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/getFullVersionButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/blue_button_drawable"
|
||||
android:text="@string/get_full_version"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"
|
||||
osmand:textAllCapsCompat="true"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/freeVersionBannerTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp">
|
||||
|
||||
<net.osmand.plus.widgets.ButtonEx
|
||||
android:id="@+id/laterButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/later_button_drawable"
|
||||
android:text="@string/later"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"
|
||||
osmand:textAllCapsCompat="true"/>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/free_version_title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/downloadsLeftTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="@string/downloads_left_template"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/freeVersionDescriptionTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
tools:text="@string/free_version_message"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:layout_margin="4dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/downloadsLeftProgressBar"
|
||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:max="10"
|
||||
android:progressDrawable="@drawable/number_of_downloads_progress_bar_drawable"
|
||||
android:saveEnabled="false"
|
||||
tools:progress="6"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/marksLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/priceInfoLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/dashboard_divider_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fullVersionLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="32dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_osmand_logo"
|
||||
android:tint="@color/osmand_orange"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fullVersionTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OsmAnd+"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fullVersionDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/osmand_plus_banner_desc"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/fullVersionProgress"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/fullVersionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/blue_button_drawable"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="14dp"
|
||||
android:paddingRight="14dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="@color/color_white"
|
||||
android:visibility="visible"
|
||||
tools:text="GET FOR E5"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="54dp"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:background="@color/dashboard_divider_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/osmLiveLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="32dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_action_osm_live"
|
||||
android:tint="@color/osmand_orange"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/osmLiveTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/osm_live_subscription"
|
||||
android:textSize="@dimen/default_list_text_size_large"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/osmLiveDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/osm_live_banner_desc"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/osmLiveProgress"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/osmLiveButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@drawable/blue_button_drawable"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="14dp"
|
||||
android:paddingRight="14dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="@color/color_white"
|
||||
tools:text="GET FOR 1,5E PER MONTH"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="54dp"
|
||||
android:layout_marginTop="@dimen/list_content_padding"
|
||||
android:background="@color/dashboard_divider_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonsLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/laterButton"
|
||||
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_marginLeft="40dp"
|
||||
android:text="@string/later"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -9,6 +9,10 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="get_for">Get for %1$s</string>
|
||||
<string name="get_for_month">Get for %1$s month</string>
|
||||
<string name="osm_live_banner_desc">Get unlimited map downloads and updates more than once a month: hourly, daily or weekly.</string>
|
||||
<string name="osmand_plus_banner_desc">Full version of OsmAnd with unlimited map downloads and monthly map updates.</string>
|
||||
<string name="skip_map_downloading">Skip downloading maps</string>
|
||||
<string name="skip_map_downloading_desc">You have no offline map installed. You may choose a map from the list or download maps later via Menu - %1$s.</string>
|
||||
<string name="search_another_country">Select another region</string>
|
||||
|
|
|
@ -13,16 +13,19 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.widget.Space;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -38,12 +41,9 @@ import net.osmand.access.AccessibilityAssistant;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.map.WorldRegion.RegionParams;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.DrivingRegion;
|
||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.LocalIndexInfo;
|
||||
|
@ -57,6 +57,9 @@ import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
|||
import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
|
||||
import net.osmand.plus.download.ui.LocalIndexesFragment;
|
||||
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
||||
import net.osmand.plus.inapp.InAppHelper;
|
||||
import net.osmand.plus.inapp.InAppHelper.InAppListener;
|
||||
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
|
@ -76,7 +79,7 @@ import java.util.Timer;
|
|||
import java.util.TimerTask;
|
||||
|
||||
public class DownloadActivity extends AbstractDownloadActivity implements DownloadEvents,
|
||||
ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
OnRequestPermissionsResultCallback, InAppListener {
|
||||
private static final Log LOG = PlatformUtil.getLog(DownloadActivity.class);
|
||||
|
||||
public static final int UPDATES_TAB_NUMBER = 2;
|
||||
|
@ -110,6 +113,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
private DownloadIndexesThread downloadThread;
|
||||
protected WorldRegion downloadItem;
|
||||
protected String downloadTargetFileName;
|
||||
private InAppHelper inAppHelper;
|
||||
|
||||
private boolean srtmDisabled;
|
||||
private boolean srtmNeedsInstallation;
|
||||
|
@ -163,6 +167,14 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
viewPager.setCurrentItem(currentTab);
|
||||
visibleBanner = new BannerAndDownloadFreeVersion(findViewById(R.id.mainLayout), this, true);
|
||||
|
||||
if (Version.isFreeVersion(getMyApplication()) &&
|
||||
(!getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get() || Version.isDeveloperVersion(getMyApplication()))) {
|
||||
inAppHelper = new InAppHelper(getMyApplication(), true);
|
||||
inAppHelper.addListener(this);
|
||||
visibleBanner.setUpdatingPrices(true);
|
||||
inAppHelper.start(true);
|
||||
}
|
||||
|
||||
final Intent intent = getIntent();
|
||||
if (intent != null && intent.getExtras() != null) {
|
||||
filter = intent.getExtras().getString(FILTER_KEY);
|
||||
|
@ -172,6 +184,14 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
showFirstTimeExternalStorage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (inAppHelper != null) {
|
||||
inAppHelper.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadIndexesThread getDownloadThread() {
|
||||
return downloadThread;
|
||||
}
|
||||
|
@ -247,6 +267,29 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
visibleBanner.setUpdatingPrices(false);
|
||||
visibleBanner.updateFreeVersionBanner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetItems() {
|
||||
visibleBanner.setUpdatingPrices(false);
|
||||
visibleBanner.updateFreeVersionBanner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemPurchased(String sku) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showProgress() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissProgress() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@UiThread
|
||||
|
@ -287,18 +330,20 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
fragment.show(activity.getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
|
||||
private static class ToggleCollapseFreeVersionBanner implements View.OnClickListener {
|
||||
private static class ToggleCollapseFreeVersionBanner implements OnClickListener {
|
||||
private final View freeVersionDescriptionTextView;
|
||||
private final View buttonsLinearLayout;
|
||||
private final View freeVersionTitle;
|
||||
private final View priceInfoLayout;
|
||||
private final OsmandSettings settings;
|
||||
|
||||
private ToggleCollapseFreeVersionBanner(View freeVersionDescriptionTextView,
|
||||
View buttonsLinearLayout, View freeVersionTitle,
|
||||
OsmandSettings settings) {
|
||||
View priceInfoLayout, OsmandSettings settings) {
|
||||
this.freeVersionDescriptionTextView = freeVersionDescriptionTextView;
|
||||
this.buttonsLinearLayout = buttonsLinearLayout;
|
||||
this.freeVersionTitle = freeVersionTitle;
|
||||
this.priceInfoLayout = priceInfoLayout;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
|
@ -309,10 +354,12 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
&& isDownlodingPermitted(settings)) {
|
||||
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
||||
buttonsLinearLayout.setVisibility(View.GONE);
|
||||
priceInfoLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
||||
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
freeVersionTitle.setVisibility(View.VISIBLE);
|
||||
priceInfoLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -331,15 +378,21 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
private final TextView rightTextView;
|
||||
private final ProgressBar downloadsLeftProgressBar;
|
||||
private final View buttonsLinearLayout;
|
||||
private final View priceInfoLayout;
|
||||
private final TextView freeVersionDescriptionTextView;
|
||||
private final TextView downloadsLeftTextView;
|
||||
private final View laterButton;
|
||||
private final View fullVersionProgress;
|
||||
private final AppCompatButton fullVersionButton;
|
||||
private final View osmLiveProgress;
|
||||
private final AppCompatButton osmLiveButton;
|
||||
|
||||
private final DownloadActivity ctx;
|
||||
private final OsmandApplication application;
|
||||
private final boolean shouldShowFreeVersionBanner;
|
||||
private final View freeVersionBannerTitle;
|
||||
private boolean showSpace;
|
||||
private boolean updatingPrices;
|
||||
|
||||
public BannerAndDownloadFreeVersion(View view, final DownloadActivity ctx, boolean showSpace) {
|
||||
this.ctx = ctx;
|
||||
|
@ -353,11 +406,17 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
downloadsLeftTextView = (TextView) freeVersionBanner.findViewById(R.id.downloadsLeftTextView);
|
||||
downloadsLeftProgressBar = (ProgressBar) freeVersionBanner.findViewById(R.id.downloadsLeftProgressBar);
|
||||
buttonsLinearLayout = freeVersionBanner.findViewById(R.id.buttonsLinearLayout);
|
||||
priceInfoLayout = freeVersionBanner.findViewById(R.id.priceInfoLayout);
|
||||
freeVersionDescriptionTextView = (TextView) freeVersionBanner
|
||||
.findViewById(R.id.freeVersionDescriptionTextView);
|
||||
laterButton = freeVersionBanner.findViewById(R.id.laterButton);
|
||||
freeVersionBannerTitle = freeVersionBanner.findViewById(R.id.freeVersionBannerTitle);
|
||||
|
||||
fullVersionProgress = freeVersionBanner.findViewById(R.id.fullVersionProgress);
|
||||
fullVersionButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.fullVersionButton);
|
||||
osmLiveProgress = freeVersionBanner.findViewById(R.id.osmLiveProgress);
|
||||
osmLiveButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.osmLiveButton);
|
||||
|
||||
shouldShowFreeVersionBanner =
|
||||
(Version.isFreeVersion(application) && !application.getSettings().LIVE_UPDATES_PURCHASED.get())
|
||||
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
|
||||
|
@ -366,6 +425,14 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
updateBannerInProgress();
|
||||
}
|
||||
|
||||
public boolean isUpdatingPrices() {
|
||||
return updatingPrices;
|
||||
}
|
||||
|
||||
public void setUpdatingPrices(boolean updatingPrices) {
|
||||
this.updatingPrices = updatingPrices;
|
||||
}
|
||||
|
||||
public void updateBannerInProgress() {
|
||||
BasicProgressAsyncTask<?, ?, ?, ?> basicProgressAsyncTask = ctx.getDownloadThread().getCurrentRunningTask();
|
||||
final boolean isFinished = basicProgressAsyncTask == null
|
||||
|
@ -387,7 +454,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
|
||||
updateAvailableDownloads();
|
||||
downloadProgressLayout.setVisibility(View.VISIBLE);
|
||||
downloadProgressLayout.setOnClickListener(new View.OnClickListener() {
|
||||
downloadProgressLayout.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new ActiveDownloadsDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
|
||||
|
@ -423,7 +490,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
downloadsLeftProgressBar.setMax(DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS);
|
||||
freeVersionDescriptionTextView.setText(ctx.getString(R.string.free_version_message,
|
||||
DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS));
|
||||
freeVersionBanner.findViewById(R.id.getFullVersionButton).setOnClickListener(new View.OnClickListener() {
|
||||
fullVersionButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(
|
||||
|
@ -435,9 +502,17 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
}
|
||||
}
|
||||
});
|
||||
osmLiveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(ctx, OsmLiveActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
ctx.startActivity(intent);
|
||||
}
|
||||
});
|
||||
ToggleCollapseFreeVersionBanner clickListener =
|
||||
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout, freeVersionBannerTitle, application.getSettings());
|
||||
buttonsLinearLayout, freeVersionBannerTitle, priceInfoLayout, application.getSettings());
|
||||
laterButton.setOnClickListener(clickListener);
|
||||
|
||||
LinearLayout marksLinearLayout = (LinearLayout) freeVersionBanner.findViewById(R.id.marksLinearLayout);
|
||||
|
@ -479,8 +554,27 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
laterButton.setVisibility(View.GONE);
|
||||
}
|
||||
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
|
||||
freeVersionBanner.setOnClickListener(new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout, freeVersionBannerTitle, settings));
|
||||
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout, freeVersionBannerTitle, priceInfoLayout, settings));
|
||||
|
||||
if (InAppHelper.hasPrices() || !updatingPrices) {
|
||||
if (!InAppHelper.hasPrices()) {
|
||||
fullVersionButton.setText(ctx.getString(R.string.get_for, ctx.getString(R.string.full_version_price)));
|
||||
osmLiveButton.setText(ctx.getString(R.string.get_for_month, ctx.getString(R.string.osm_live_price)));
|
||||
} else {
|
||||
fullVersionButton.setText(ctx.getString(R.string.get_for, InAppHelper.getFullVersionPrice()));
|
||||
osmLiveButton.setText(ctx.getString(R.string.get_for_month, InAppHelper.getLiveUpdatesPrice()));
|
||||
}
|
||||
fullVersionProgress.setVisibility(View.GONE);
|
||||
fullVersionButton.setVisibility(View.VISIBLE);
|
||||
osmLiveProgress.setVisibility(View.GONE);
|
||||
osmLiveButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
fullVersionProgress.setVisibility(View.VISIBLE);
|
||||
fullVersionButton.setVisibility(View.GONE);
|
||||
osmLiveProgress.setVisibility(View.VISIBLE);
|
||||
osmLiveButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAvailableDownloads() {
|
||||
|
@ -495,10 +589,12 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
||||
buttonsLinearLayout.setVisibility(View.GONE);
|
||||
freeVersionBannerTitle.setVisibility(View.GONE);
|
||||
priceInfoLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
||||
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
||||
priceInfoLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -727,14 +823,14 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
|
||||
final ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
|
||||
closeImageButton.setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
|
||||
closeImageButton.setOnClickListener(new View.OnClickListener() {
|
||||
closeImageButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
actionButtonOk.setOnClickListener(new View.OnClickListener() {
|
||||
actionButtonOk.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (indexItem != null) {
|
||||
|
@ -745,7 +841,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
});
|
||||
|
||||
view.findViewById(R.id.actionButtonCancel)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
|
@ -794,7 +890,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
|
||||
final ImageButton closeImageButton = (ImageButton) view.findViewById(R.id.closeImageButton);
|
||||
closeImageButton.setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
|
||||
closeImageButton.setOnClickListener(new View.OnClickListener() {
|
||||
closeImageButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getActivity() instanceof DownloadActivity) {
|
||||
|
@ -805,7 +901,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
});
|
||||
|
||||
view.findViewById(R.id.actionButton)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||
|
|
|
@ -38,7 +38,9 @@ public class InAppHelper {
|
|||
private static boolean mSubscribedToLiveUpdates = false;
|
||||
private static String mLiveUpdatesPrice;
|
||||
private static long lastValidationCheckTime;
|
||||
private static String mFullVersionPrice;
|
||||
|
||||
private static final String SKU_FULL_VERSION_PRICE = "osmand_full_version_price";
|
||||
private static final String SKU_LIVE_UPDATES_FULL = "osm_live_subscription_2";
|
||||
private static final String SKU_LIVE_UPDATES_FREE = "osm_free_live_subscription_2";
|
||||
private static String SKU_LIVE_UPDATES;
|
||||
|
@ -51,6 +53,7 @@ public class InAppHelper {
|
|||
private IabHelper mHelper;
|
||||
private boolean stopAfterResult = false;
|
||||
private boolean isDeveloperVersion = false;
|
||||
private boolean forceRequestInventory = false;
|
||||
private String token = "";
|
||||
|
||||
private OsmandApplication ctx;
|
||||
|
@ -80,12 +83,21 @@ public class InAppHelper {
|
|||
return mLiveUpdatesPrice;
|
||||
}
|
||||
|
||||
public static String getFullVersionPrice() {
|
||||
return mFullVersionPrice;
|
||||
}
|
||||
|
||||
public static String getSkuLiveUpdates() {
|
||||
return SKU_LIVE_UPDATES;
|
||||
}
|
||||
|
||||
public InAppHelper(OsmandApplication ctx) {
|
||||
public static boolean hasPrices() {
|
||||
return !Algorithms.isEmpty(mLiveUpdatesPrice) && !Algorithms.isEmpty(mFullVersionPrice);
|
||||
}
|
||||
|
||||
public InAppHelper(OsmandApplication ctx, boolean forceRequestInventory) {
|
||||
this.ctx = ctx;
|
||||
this.forceRequestInventory = forceRequestInventory;
|
||||
if (SKU_LIVE_UPDATES == null) {
|
||||
if (Version.isFreeVersion(ctx)) {
|
||||
SKU_LIVE_UPDATES = SKU_LIVE_UPDATES_FREE;
|
||||
|
@ -148,14 +160,17 @@ public class InAppHelper {
|
|||
if (mHelper == null) return;
|
||||
|
||||
// IAB is fully set up. Now, let's get an inventory of stuff we own if needed.
|
||||
if (!isDeveloperVersion &&
|
||||
if (forceRequestInventory || (!isDeveloperVersion &&
|
||||
(!mSubscribedToLiveUpdates
|
||||
|| !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get()
|
||||
|| System.currentTimeMillis() - lastValidationCheckTime > PURCHASE_VALIDATION_PERIOD_MSEC)) {
|
||||
|| System.currentTimeMillis() - lastValidationCheckTime > PURCHASE_VALIDATION_PERIOD_MSEC))) {
|
||||
|
||||
logDebug("Setup successful. Querying inventory.");
|
||||
List<String> skus = new ArrayList<>();
|
||||
skus.add(SKU_LIVE_UPDATES);
|
||||
if (forceRequestInventory) {
|
||||
skus.add(SKU_FULL_VERSION_PRICE);
|
||||
}
|
||||
mHelper.queryInventoryAsync(true, skus, mGotInventoryListener);
|
||||
} else {
|
||||
notifyDismissProgress();
|
||||
|
@ -195,7 +210,7 @@ public class InAppHelper {
|
|||
|
||||
// Do we have the live updates?
|
||||
Purchase liveUpdatesPurchase = inventory.getPurchase(SKU_LIVE_UPDATES);
|
||||
mSubscribedToLiveUpdates = (liveUpdatesPurchase != null && liveUpdatesPurchase.getPurchaseState() == 0);
|
||||
mSubscribedToLiveUpdates = isDeveloperVersion || (liveUpdatesPurchase != null && liveUpdatesPurchase.getPurchaseState() == 0);
|
||||
if (mSubscribedToLiveUpdates) {
|
||||
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
|
||||
}
|
||||
|
@ -208,8 +223,13 @@ public class InAppHelper {
|
|||
mLiveUpdatesPrice = liveUpdatesDetails.getPrice();
|
||||
}
|
||||
|
||||
if (inventory.hasDetails(SKU_FULL_VERSION_PRICE)) {
|
||||
SkuDetails fullPriceDetails = inventory.getSkuDetails(SKU_FULL_VERSION_PRICE);
|
||||
mFullVersionPrice = fullPriceDetails.getPrice();
|
||||
}
|
||||
|
||||
boolean needSendToken = false;
|
||||
if (liveUpdatesPurchase != null) {
|
||||
if (!isDeveloperVersion && liveUpdatesPurchase != null) {
|
||||
OsmandSettings settings = ctx.getSettings();
|
||||
if (Algorithms.isEmpty(settings.BILLING_USER_ID.get())
|
||||
&& !Algorithms.isEmpty(liveUpdatesPurchase.getDeveloperPayload())) {
|
||||
|
|
|
@ -35,7 +35,7 @@ public class OsmLiveActivity extends AbstractDownloadActivity
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_livie_updates);
|
||||
|
||||
inAppHelper = new InAppHelper(getMyApplication());
|
||||
inAppHelper = new InAppHelper(getMyApplication(), false);
|
||||
if (Version.isDeveloperVersion(getMyApplication())) {
|
||||
inAppHelper = null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue