Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-19 15:08:26 +02:00
commit 57ccbb863c
6 changed files with 184 additions and 135 deletions

View file

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

View file

@ -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:
@ -11,8 +12,7 @@
-->
<!-- Not translatable -->
<string name="full_version_price">€5</string>
<string name="osm_live_price">€1.5</string>
<string name="full_version_price">€5,99</string>
<string name="osm_live">OSM Live (Beta)</string>
<string name="ga_api_key">UA-28342846-2</string>
<string name="ga_dispatchPeriod">10</string>

View file

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

View file

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

View file

@ -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;
@ -269,13 +269,11 @@ 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
@ -339,146 +337,82 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
return (Version.isFreeVersion(application) && !application.getSettings().LIVE_UPDATES_PURCHASED.get())
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
}
public static class BannerAndDownloadFreeVersion {
public static class FreeVersionDialog {
private final View freeVersionBanner;
private final View downloadProgressLayout;
private final ProgressBar progressBar;
private final TextView leftTextView;
private final TextView rightTextView;
private final ProgressBar downloadsLeftProgressBar;
private final View buttonsLinearLayout;
private final View freeVersionBannerTitle;
private boolean updatingPrices;
private final View priceInfoLayout;
private final TextView freeVersionDescriptionTextView;
private final TextView downloadsLeftTextView;
private final View laterButton;
private final ProgressBar downloadsLeftProgressBar;
// 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 final DownloadActivity ctx;
private final OsmandApplication application;
private final boolean shouldShowFreeVersionBanner;
private final View freeVersionBannerTitle;
private boolean showSpace;
private boolean updatingPrices;
private static boolean wasCollapsed;
private OnClickListener onCollapseListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (freeVersionDescriptionTextView.getVisibility() == View.VISIBLE
&& isDownlodingPermitted(application.getSettings())) {
&& isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
collapseBanner();
wasCollapsed = true;
} else {
expandBanner();
new FreeVersionDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
// expandBanner();
}
}
};
public BannerAndDownloadFreeVersion(View view, final DownloadActivity ctx, boolean showSpace) {
public FreeVersionDialog(View view, final DownloadActivity ctx, boolean dialog) {
this.ctx = ctx;
this.showSpace = showSpace;
application = (OsmandApplication) ctx.getApplicationContext();
this.dialog = dialog;
freeVersionBanner = view.findViewById(R.id.freeVersionBanner);
downloadProgressLayout = view.findViewById(R.id.downloadProgressLayout);
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
leftTextView = (TextView) view.findViewById(R.id.leftTextView);
rightTextView = (TextView) view.findViewById(R.id.rightTextView);
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);
// 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);
osmLiveProgress = freeVersionBanner.findViewById(R.id.osmLiveProgress);
osmLiveButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.osmLiveButton);
shouldShowFreeVersionBanner = shouldShowFreeVersionBanner(application);
initFreeVersionBanner();
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
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
if (isFinished) {
downloadProgressLayout.setOnClickListener(null);
updateDescriptionTextWithSize(ctx, downloadProgressLayout);
if (ctx.getCurrentTab() == UPDATES_TAB_NUMBER || !showSpace) {
downloadProgressLayout.setVisibility(View.GONE);
} else {
downloadProgressLayout.setVisibility(View.VISIBLE);
}
updateFreeVersionBanner();
} else {
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
String message = basicProgressAsyncTask.getDescription();
int percent = basicProgressAsyncTask.getProgressPercentage();
setMinimizedFreeVersionBanner(true);
updateAvailableDownloads();
downloadProgressLayout.setVisibility(View.VISIBLE);
downloadProgressLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new ActiveDownloadsDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
}
});
progressBar.setIndeterminate(indeterminate);
if (indeterminate) {
leftTextView.setText(message);
rightTextView.setText(null);
} else {
progressBar.setProgress(percent);
// final String format = ctx.getString(R.string.downloading_number_of_files);
leftTextView.setText(message);
rightTextView.setText(percent + "%");
}
}
updateFreeVersionBanner();
}
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);
}
public void hideDownloadProgressLayout() {
downloadProgressLayout.setVisibility(View.GONE);
}
public void showDownloadProgressLayout() {
downloadProgressLayout.setVisibility(View.VISIBLE);
}
private void initFreeVersionBanner() {
if (!shouldShowFreeVersionBanner) {
public void initFreeVersionBanner() {
if (!shouldShowFreeVersionBanner(ctx.getMyApplication())) {
freeVersionBanner.setVisibility(View.GONE);
return;
}
@ -506,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);
@ -530,28 +463,32 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
}
updateFreeVersionBanner();
if (wasCollapsed) {
if(dialog) {
expandBanner();
} else {
collapseBanner();
}
}
private void updateFreeVersionBanner() {
if (!shouldShowFreeVersionBanner) {
public void updateFreeVersionBanner() {
if (!shouldShowFreeVersionBanner(ctx.getMyApplication())) {
return;
}
setMinimizedFreeVersionBanner(false);
OsmandSettings settings = application.getSettings();
OsmandSettings settings = ctx.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));
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(onCollapseListener);
if(!dialog) {
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(onCollapseListener);
}
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)));
osmLiveButton.setText(ctx.getString(R.string.get_for_month, ctx.getString(R.string.osm_live_default_price)));
} else {
fullVersionButton.setText(ctx.getString(R.string.get_for, InAppHelper.getFullVersionPrice()));
osmLiveButton.setText(ctx.getString(R.string.get_for_month, InAppHelper.getLiveUpdatesPrice()));
@ -567,22 +504,107 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
osmLiveButton.setVisibility(View.GONE);
}
}
private void updateAvailableDownloads() {
int activeTasks = ctx.getDownloadThread().getCountedDownloads();
OsmandSettings settings = application.getSettings();
final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get() + activeTasks;
downloadsLeftProgressBar.setProgress(mapsDownloaded);
}
private void setMinimizedFreeVersionBanner(boolean minimize) {
if (minimize && isDownlodingPermitted(application.getSettings())) {
if (minimize && isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
collapseBanner();
freeVersionBannerTitle.setVisibility(View.GONE);
} else {
freeVersionBannerTitle.setVisibility(View.VISIBLE);
}
}
private void updateAvailableDownloads() {
int activeTasks = ctx.getDownloadThread().getCountedDownloads();
OsmandSettings settings = ctx.getMyApplication().getSettings();
final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get() + activeTasks;
downloadsLeftProgressBar.setProgress(mapsDownloaded);
}
}
public static class BannerAndDownloadFreeVersion {
private final View downloadProgressLayout;
private final ProgressBar progressBar;
private final TextView leftTextView;
private final TextView rightTextView;
private final DownloadActivity ctx;
private boolean showSpace;
private FreeVersionDialog freeVersionDialog;
public BannerAndDownloadFreeVersion(View view, final DownloadActivity ctx, boolean showSpace) {
this.ctx = ctx;
this.showSpace = showSpace;
freeVersionDialog = new FreeVersionDialog(view, ctx, false);
downloadProgressLayout = view.findViewById(R.id.downloadProgressLayout);
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
leftTextView = (TextView) view.findViewById(R.id.leftTextView);
rightTextView = (TextView) view.findViewById(R.id.rightTextView);
freeVersionDialog.initFreeVersionBanner();
updateBannerInProgress();
}
public void setUpdatingPrices(boolean updatingPrices) {
freeVersionDialog.setUpdatingPrices(updatingPrices);
}
public void updateBannerInProgress() {
BasicProgressAsyncTask<?, ?, ?, ?> basicProgressAsyncTask = ctx.getDownloadThread().getCurrentRunningTask();
final boolean isFinished = basicProgressAsyncTask == null
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
if (isFinished) {
downloadProgressLayout.setOnClickListener(null);
updateDescriptionTextWithSize(ctx, downloadProgressLayout);
if (ctx.getCurrentTab() == UPDATES_TAB_NUMBER || !showSpace) {
downloadProgressLayout.setVisibility(View.GONE);
} else {
downloadProgressLayout.setVisibility(View.VISIBLE);
}
freeVersionDialog.updateFreeVersionBanner();
} else {
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
String message = basicProgressAsyncTask.getDescription();
int percent = basicProgressAsyncTask.getProgressPercentage();
freeVersionDialog.setMinimizedFreeVersionBanner(true);
freeVersionDialog.updateAvailableDownloads();
downloadProgressLayout.setVisibility(View.VISIBLE);
downloadProgressLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new ActiveDownloadsDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
}
});
progressBar.setIndeterminate(indeterminate);
if (indeterminate) {
leftTextView.setText(message);
rightTextView.setText(null);
} else {
progressBar.setProgress(percent);
// final String format = ctx.getString(R.string.downloading_number_of_files);
leftTextView.setText(message);
rightTextView.setText(percent + "%");
}
}
}
public void hideDownloadProgressLayout() {
downloadProgressLayout.setVisibility(View.GONE);
}
public void showDownloadProgressLayout() {
downloadProgressLayout.setVisibility(View.VISIBLE);
}
}
public void reloadLocalIndexes() {

View file

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