Fix banner
This commit is contained in:
parent
67bfa8381a
commit
a738f4fb4a
6 changed files with 74 additions and 39 deletions
|
@ -4,7 +4,8 @@
|
|||
|
||||
<application
|
||||
android:icon="@drawable/icon_free"
|
||||
tools:replace="android:icon">
|
||||
android:label="@string/app_name_free"
|
||||
tools:replace="android:icon, android:label">
|
||||
|
||||
<service
|
||||
android:name="net.osmand.plus.NavigationService"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="app_name">OsmAnd~</string>
|
||||
<string name="app_name_free">OsmAnd</string>
|
||||
<string name="app_version">2.4.0</string>
|
||||
<!--
|
||||
Note: For our dev build apk's, the above "app_version" is provided (via osmand/build.xml) as the base version prefix to our build number in the format:
|
||||
|
|
|
@ -229,26 +229,7 @@
|
|||
|
||||
</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:paddingLeft="14dp"
|
||||
android:paddingRight="14dp"
|
||||
android:text="@string/later"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
|
@ -9,6 +9,7 @@ public class Version {
|
|||
private final String appVersion;
|
||||
private final String appName;
|
||||
private final static String FREE_VERSION_NAME = "net.osmand";
|
||||
private final static String FREE_DEV_VERSION_NAME = "net.osmand.dev";
|
||||
private final static String SHERPAFY_VERSION_NAME = "net.osmand.sherpafy";
|
||||
|
||||
|
||||
|
@ -91,7 +92,7 @@ public class Version {
|
|||
}
|
||||
|
||||
public static boolean isFreeVersion(OsmandApplication ctx){
|
||||
return ctx.getPackageName().equals(FREE_VERSION_NAME);
|
||||
return ctx.getPackageName().equals(FREE_VERSION_NAME) || ctx.getPackageName().equals(FREE_DEV_VERSION_NAME);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityAssistant;
|
||||
|
@ -55,6 +54,7 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
|||
import net.osmand.plus.download.ui.ActiveDownloadsDialogFragment;
|
||||
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
||||
import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
|
||||
import net.osmand.plus.download.ui.FreeVersionDialogFragment;
|
||||
import net.osmand.plus.download.ui.LocalIndexesFragment;
|
||||
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
||||
import net.osmand.plus.inapp.InAppHelper;
|
||||
|
@ -347,16 +347,16 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
private final TextView freeVersionDescriptionTextView;
|
||||
private final TextView downloadsLeftTextView;
|
||||
private final ProgressBar downloadsLeftProgressBar;
|
||||
private final View laterButton;
|
||||
|
||||
private final View buttonsLinearLayout;
|
||||
|
||||
// private final View laterButton;
|
||||
// private final View buttonsLinearLayout;
|
||||
|
||||
private final View fullVersionProgress;
|
||||
private final AppCompatButton fullVersionButton;
|
||||
private final View osmLiveProgress;
|
||||
private final AppCompatButton osmLiveButton;
|
||||
private DownloadActivity ctx;
|
||||
private boolean dialog;
|
||||
|
||||
|
||||
private OnClickListener onCollapseListener = new OnClickListener() {
|
||||
|
@ -366,22 +366,24 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
&& isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
|
||||
collapseBanner();
|
||||
} else {
|
||||
expandBanner();
|
||||
new FreeVersionDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
|
||||
// expandBanner();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public FreeVersionDialog(View view, final DownloadActivity ctx) {
|
||||
public FreeVersionDialog(View view, final DownloadActivity ctx, boolean dialog) {
|
||||
this.ctx = ctx;
|
||||
this.dialog = dialog;
|
||||
freeVersionBanner = view.findViewById(R.id.freeVersionBanner);
|
||||
downloadsLeftTextView = (TextView) freeVersionBanner.findViewById(R.id.downloadsLeftTextView);
|
||||
downloadsLeftProgressBar = (ProgressBar) freeVersionBanner.findViewById(R.id.downloadsLeftProgressBar);
|
||||
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);
|
||||
buttonsLinearLayout = freeVersionBanner.findViewById(R.id.buttonsLinearLayout);
|
||||
// laterButton = freeVersionBanner.findViewById(R.id.laterButton);
|
||||
// buttonsLinearLayout = freeVersionBanner.findViewById(R.id.buttonsLinearLayout);
|
||||
|
||||
fullVersionProgress = freeVersionBanner.findViewById(R.id.fullVersionProgress);
|
||||
fullVersionButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.fullVersionButton);
|
||||
|
@ -396,20 +398,20 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
|
||||
private void collapseBanner() {
|
||||
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
||||
buttonsLinearLayout.setVisibility(View.GONE);
|
||||
// buttonsLinearLayout.setVisibility(View.GONE);
|
||||
priceInfoLayout.setVisibility(View.GONE);
|
||||
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void expandBanner() {
|
||||
public void expandBanner() {
|
||||
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
||||
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
// buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
priceInfoLayout.setVisibility(View.VISIBLE);
|
||||
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
private void initFreeVersionBanner() {
|
||||
public void initFreeVersionBanner() {
|
||||
if (!shouldShowFreeVersionBanner(ctx.getMyApplication())) {
|
||||
freeVersionBanner.setVisibility(View.GONE);
|
||||
return;
|
||||
|
@ -438,7 +440,6 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
ctx.startActivity(intent);
|
||||
}
|
||||
});
|
||||
laterButton.setOnClickListener(onCollapseListener);
|
||||
|
||||
LinearLayout marksLinearLayout = (LinearLayout) freeVersionBanner.findViewById(R.id.marksLinearLayout);
|
||||
Space spaceView = new Space(ctx);
|
||||
|
@ -462,10 +463,14 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
}
|
||||
|
||||
updateFreeVersionBanner();
|
||||
collapseBanner();
|
||||
if(dialog) {
|
||||
expandBanner();
|
||||
} else {
|
||||
collapseBanner();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFreeVersionBanner() {
|
||||
public void updateFreeVersionBanner() {
|
||||
if (!shouldShowFreeVersionBanner(ctx.getMyApplication())) {
|
||||
return;
|
||||
}
|
||||
|
@ -476,7 +481,9 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
int downloadsLeft = DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - mapsDownloaded;
|
||||
downloadsLeft = Math.max(downloadsLeft, 0);
|
||||
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
|
||||
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(onCollapseListener);
|
||||
if(!dialog) {
|
||||
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(onCollapseListener);
|
||||
}
|
||||
|
||||
if (InAppHelper.hasPrices() || !updatingPrices) {
|
||||
if (!InAppHelper.hasPrices()) {
|
||||
|
@ -530,7 +537,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
public BannerAndDownloadFreeVersion(View view, final DownloadActivity ctx, boolean showSpace) {
|
||||
this.ctx = ctx;
|
||||
this.showSpace = showSpace;
|
||||
freeVersionDialog = new FreeVersionDialog(view, ctx);
|
||||
freeVersionDialog = new FreeVersionDialog(view, ctx, false);
|
||||
|
||||
downloadProgressLayout = view.findViewById(R.id.downloadProgressLayout);
|
||||
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package net.osmand.plus.download.ui;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity.FreeVersionDialog;
|
||||
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FreeVersionDialogFragment extends DialogFragment {
|
||||
|
||||
|
||||
private FreeVersionDialog dialog;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setNegativeButton(R.string.later, null);
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.free_version_banner, null);
|
||||
builder.setView(view);
|
||||
dialog = new DownloadActivity.FreeVersionDialog(view, getDownloadActivity(), true);
|
||||
dialog.initFreeVersionBanner();
|
||||
dialog.expandBanner();
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
DownloadActivity getDownloadActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue