Fix choose plan ui

This commit is contained in:
Alexey Kulish 2018-04-21 17:42:04 +03:00
parent 13f4452e42
commit 79cddfda66
11 changed files with 106 additions and 76 deletions

View file

@ -2,6 +2,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/list_header_padding"
@ -36,7 +37,8 @@
android:gravity="center"
android:textColor="?attr/card_description_text_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"/>
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/osm_live_payment_desc"/>
<FrameLayout
android:layout_width="match_parent"

View file

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/card_row_min_height"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/dialog_content_margin"
android:scaleType="center"
android:src="@drawable/ic_action_plus"
android:tint="?attr/wikivoyage_active_color"/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/list_content_padding"
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"/>
</LinearLayout>
<View
android:id="@+id/div"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/card_title_row_min_height"
android:layout_marginRight="1dp"
android:background="?attr/wikivoyage_card_divider_color"/>
</LinearLayout>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/tools"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/list_header_padding"
@ -34,7 +34,8 @@
android:gravity="center"
android:textColor="?attr/card_description_text_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular"/>
osmand:typeface="@string/font_roboto_regular"
tools:text="@string/osm_live_payment_desc"/>
<FrameLayout
android:layout_width="match_parent"

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/wikivoyage_active_card_bg">
@ -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€"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/card_button_subtitle"
@ -35,7 +37,8 @@
android:letterSpacing="@dimen/text_button_letter_spacing"
android:textColor="@color/white_50_transparent"
android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_regular"/>
osmand:typeface="@string/font_roboto_regular"
tools:text="One time purchase"/>
</LinearLayout>

View file

@ -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">
<TextView

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"/>
</LinearLayout>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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_medium"/>
osmand:typeface="@string/font_roboto_medium"
tools:text="@string/shared_string_wikivoyage"/>
</LinearLayout>

View file

@ -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"/>
</LinearLayout>

View file

@ -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) {

View file

@ -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);
}
}
}

View file

@ -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());
}
}
};