diff --git a/OsmAnd/res/layout/purchase_dialog_active_card.xml b/OsmAnd/res/layout/purchase_dialog_active_card.xml index dab863b2ed..c6501a7db5 100644 --- a/OsmAnd/res/layout/purchase_dialog_active_card.xml +++ b/OsmAnd/res/layout/purchase_dialog_active_card.xml @@ -2,6 +2,7 @@ + osmand:typeface="@string/font_roboto_regular" + tools:text="@string/osm_live_payment_desc"/> - - - - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/purchase_dialog_card.xml b/OsmAnd/res/layout/purchase_dialog_card.xml index c363fbc4be..847d5c6e7f 100644 --- a/OsmAnd/res/layout/purchase_dialog_card.xml +++ b/OsmAnd/res/layout/purchase_dialog_card.xml @@ -1,7 +1,7 @@ - + osmand:typeface="@string/font_roboto_regular" + tools:text="@string/osm_live_payment_desc"/> @@ -25,7 +26,8 @@ android:letterSpacing="@dimen/text_button_letter_spacing" android:textColor="@color/color_white" android:textSize="@dimen/text_button_text_size" - osmand:typeface="@string/font_roboto_medium"/> + osmand:typeface="@string/font_roboto_medium" + tools:text="Buy - 5€"/> + osmand:typeface="@string/font_roboto_regular" + tools:text="One time purchase"/> diff --git a/OsmAnd/res/layout/purchase_dialog_card_header.xml b/OsmAnd/res/layout/purchase_dialog_card_header.xml index a2a629dd6b..75d1b8f64e 100644 --- a/OsmAnd/res/layout/purchase_dialog_card_header.xml +++ b/OsmAnd/res/layout/purchase_dialog_card_header.xml @@ -19,8 +19,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_marginRight="@dimen/list_content_padding" android:layout_marginEnd="@dimen/list_content_padding" + android:layout_marginRight="@dimen/list_content_padding" android:orientation="vertical"> @@ -31,10 +32,10 @@ android:layout_marginRight="@dimen/list_content_padding" android:paddingBottom="@dimen/list_header_padding" android:paddingTop="@dimen/list_header_padding" - android:text="@string/shared_string_wikivoyage" android:textColor="?attr/dialog_title_color" android:textSize="@dimen/default_list_text_size" - osmand:typeface="@string/font_roboto_regular"/> + osmand:typeface="@string/font_roboto_regular" + tools:text="@string/shared_string_wikivoyage"/> diff --git a/OsmAnd/res/layout/purchase_dialog_card_selected_row.xml b/OsmAnd/res/layout/purchase_dialog_card_selected_row.xml index 3546616435..60aacabfb6 100644 --- a/OsmAnd/res/layout/purchase_dialog_card_selected_row.xml +++ b/OsmAnd/res/layout/purchase_dialog_card_selected_row.xml @@ -1,6 +1,7 @@ @@ -31,10 +32,10 @@ android:layout_marginRight="@dimen/list_content_padding" android:paddingBottom="@dimen/list_header_padding" android:paddingTop="@dimen/list_header_padding" - android:text="@string/shared_string_wikivoyage" android:textColor="?attr/dialog_title_color" android:textSize="@dimen/default_list_text_size" - osmand:typeface="@string/font_roboto_medium"/> + osmand:typeface="@string/font_roboto_medium" + tools:text="@string/shared_string_wikivoyage"/> diff --git a/OsmAnd/res/layout/purchase_dialog_fragment.xml b/OsmAnd/res/layout/purchase_dialog_fragment.xml index 557839d9ef..267130dd59 100644 --- a/OsmAnd/res/layout/purchase_dialog_fragment.xml +++ b/OsmAnd/res/layout/purchase_dialog_fragment.xml @@ -66,9 +66,7 @@ android:textColor="?attr/dialog_description_color" android:textSize="@dimen/default_list_text_size" osmand:typeface="@string/font_roboto_regular" - android:visibility="gone" - tools:text="@string/purchase_dialog_travel_description" - tools:visibility="visible"/> + tools:text="@string/purchase_dialog_travel_description"/> diff --git a/OsmAnd/src/net/osmand/plus/Version.java b/OsmAnd/src/net/osmand/plus/Version.java index ba80c3056d..42e0fe0cb6 100644 --- a/OsmAnd/src/net/osmand/plus/Version.java +++ b/OsmAnd/src/net/osmand/plus/Version.java @@ -126,7 +126,7 @@ public class Version { } public static boolean isDeveloperVersion(OsmandApplication ctx){ - return false;//getAppName(ctx).contains("~") || ctx.getPackageName().equals(FREE_DEV_VERSION_NAME); + return getAppName(ctx).contains("~") || ctx.getPackageName().equals(FREE_DEV_VERSION_NAME); } public static String getVersionForTracker(OsmandApplication ctx) { diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/ChoosePlanDialogFragment.java index 0d80f497d9..f75ebcaafe 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ChoosePlanDialogFragment.java @@ -2,8 +2,10 @@ package net.osmand.plus.dialogs; import android.app.Activity; import android.app.Dialog; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; @@ -19,15 +21,25 @@ import android.widget.LinearLayout; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.PlatformUtil; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndDialogFragment; +import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadValidationManager; import net.osmand.plus.inapp.InAppHelper; import net.osmand.plus.liveupdates.OsmLiveActivity; import net.osmand.plus.widgets.TextViewEx; +import org.apache.commons.logging.Log; + +import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_INAPP_PARAM; + public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment { public static final String TAG = ChoosePlanDialogFragment.class.getSimpleName(); + private static final Log LOG = PlatformUtil.getLog(ChoosePlanDialogFragment.class); private static final String PLAN_TYPE_KEY = "plan_type"; @@ -136,15 +148,32 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment { return null; } View view = inflate(R.layout.purchase_dialog_fragment, container); + + view.findViewById(R.id.button_back).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + } + }); + view.findViewById(R.id.button_later).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + } + }); + ViewGroup infoContainer = (ViewGroup) view.findViewById(R.id.info_container); TextViewEx infoDescription = (TextViewEx) view.findViewById(R.id.info_description); ViewGroup cardsContainer = (ViewGroup) view.findViewById(R.id.cards_container); - switch (planType) { + switch (planType) { case FREE_VERSION_BANNER: { - infoDescription.setVisibility(View.GONE); - View freeVersionInfoView = inflate(R.layout.purchase_dialog_info_free_version, infoContainer); - infoContainer.addView(freeVersionInfoView); + infoDescription.setText(ctx.getString(R.string.free_version_message, + DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS)); + //infoDescription.setVisibility(View.GONE); + //View freeVersionInfoView = inflate(R.layout.purchase_dialog_info_free_version, infoContainer); + //initFreeVersionInfoView(ctx, freeVersionInfoView); + //infoContainer.addView(freeVersionInfoView); break; } @@ -154,6 +183,46 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment { return view; } + /* + private void initFreeVersionInfoView(Context ctx, View freeVersionInfoView) { + TextView downloadsLeftTextView = (TextView) freeVersionInfoView.findViewById(R.id.downloadsLeftTextView); + ProgressBar downloadsLeftProgressBar = (ProgressBar) freeVersionInfoView.findViewById(R.id.downloadsLeftProgressBar); + TextView freeVersionDescriptionTextView = (TextView) freeVersionInfoView + .findViewById(R.id.freeVersionDescriptionTextView); + + OsmandSettings settings = getMyApplication().getSettings(); + final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get(); + downloadsLeftProgressBar.setProgress(mapsDownloaded); + int downloadsLeft = DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - mapsDownloaded; + downloadsLeft = Math.max(downloadsLeft, 0); + downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft)); + downloadsLeftProgressBar.setMax(DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS); + freeVersionDescriptionTextView.setText(ctx.getString(R.string.free_version_message, + DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS)); + + LinearLayout marksLinearLayout = (LinearLayout) freeVersionInfoView.findViewById(R.id.marksLinearLayout); + Space spaceView = new Space(ctx); + LinearLayout.LayoutParams layoutParams = + new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); + spaceView.setLayoutParams(layoutParams); + marksLinearLayout.addView(spaceView); + int markWidth = (int) (1 * ctx.getResources().getDisplayMetrics().density); + int colorBlack = ctx.getResources().getColor(nightMode ? R.color.wikivoyage_bg_dark : R.color.wikivoyage_bg_light); + for (int i = 1; i < DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS; i++) { + View markView = new View(ctx); + layoutParams = new LinearLayout.LayoutParams(markWidth, ViewGroup.LayoutParams.MATCH_PARENT); + markView.setLayoutParams(layoutParams); + markView.setBackgroundColor(colorBlack); + marksLinearLayout.addView(markView); + spaceView = new Space(ctx); + layoutParams = new LinearLayout.LayoutParams(0, + ViewGroup.LayoutParams.MATCH_PARENT, 1); + spaceView.setLayoutParams(layoutParams); + marksLinearLayout.addView(spaceView); + } + } + */ + private View inflate(@LayoutRes int layoutId, @Nullable ViewGroup container) { int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; return LayoutInflater.from(new ContextThemeWrapper(getContext(), themeRes)) @@ -320,7 +389,12 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment { } } - public static boolean showInstance(@NonNull FragmentManager fm, PlanType planType) { + public static void showFreeVersionInstance(@NonNull FragmentManager fm) { + PlanType planType = PlanType.FREE_VERSION_BANNER; + showInstance(fm, planType); + } + + private static void showInstance(@NonNull FragmentManager fm, PlanType planType) { try { Bundle args = new Bundle(); args.putString(PLAN_TYPE_KEY, planType.name()); @@ -328,10 +402,9 @@ public class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment { ChoosePlanDialogFragment fragment = new ChoosePlanDialogFragment(); fragment.setArguments(args); fragment.show(fm, TAG); - return true; } catch (RuntimeException e) { - return false; + LOG.error("showInstance", e); } } } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index a946b7a516..2ad07ae837 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -506,7 +506,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo collapseBanner(); } else { ctx.getMyApplication().logEvent(ctx, "click_free_dialog"); - ChoosePlanDialogFragment.showInstance(ctx.getSupportFragmentManager(), PlanType.FREE_VERSION_BANNER); + ChoosePlanDialogFragment.showFreeVersionInstance(ctx.getSupportFragmentManager()); } } };