|
|
@ -34,7 +34,6 @@ import android.widget.LinearLayout;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.ProgressBar;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import net.osmand.IProgress;
|
|
|
|
import net.osmand.IProgress;
|
|
|
|
import net.osmand.PlatformUtil;
|
|
|
|
import net.osmand.PlatformUtil;
|
|
|
|
import net.osmand.access.AccessibilityAssistant;
|
|
|
|
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.ActiveDownloadsDialogFragment;
|
|
|
|
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
|
|
|
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
|
|
|
import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
|
|
|
|
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.LocalIndexesFragment;
|
|
|
|
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
|
|
|
import net.osmand.plus.download.ui.UpdatesIndexFragment;
|
|
|
|
import net.osmand.plus.inapp.InAppHelper;
|
|
|
|
import net.osmand.plus.inapp.InAppHelper;
|
|
|
@ -269,13 +269,11 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onError(String error) {
|
|
|
|
public void onError(String error) {
|
|
|
|
visibleBanner.setUpdatingPrices(false);
|
|
|
|
visibleBanner.setUpdatingPrices(false);
|
|
|
|
visibleBanner.updateFreeVersionBanner();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onGetItems() {
|
|
|
|
public void onGetItems() {
|
|
|
|
visibleBanner.setUpdatingPrices(false);
|
|
|
|
visibleBanner.setUpdatingPrices(false);
|
|
|
|
visibleBanner.updateFreeVersionBanner();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -340,145 +338,81 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|
|
|
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
|
|
|
|
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class BannerAndDownloadFreeVersion {
|
|
|
|
|
|
|
|
|
|
|
|
public static class FreeVersionDialog {
|
|
|
|
private final View freeVersionBanner;
|
|
|
|
private final View freeVersionBanner;
|
|
|
|
private final View downloadProgressLayout;
|
|
|
|
private final View freeVersionBannerTitle;
|
|
|
|
private final ProgressBar progressBar;
|
|
|
|
private boolean updatingPrices;
|
|
|
|
private final TextView leftTextView;
|
|
|
|
|
|
|
|
private final TextView rightTextView;
|
|
|
|
|
|
|
|
private final ProgressBar downloadsLeftProgressBar;
|
|
|
|
|
|
|
|
private final View buttonsLinearLayout;
|
|
|
|
|
|
|
|
private final View priceInfoLayout;
|
|
|
|
private final View priceInfoLayout;
|
|
|
|
private final TextView freeVersionDescriptionTextView;
|
|
|
|
private final TextView freeVersionDescriptionTextView;
|
|
|
|
private final TextView downloadsLeftTextView;
|
|
|
|
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 View fullVersionProgress;
|
|
|
|
private final AppCompatButton fullVersionButton;
|
|
|
|
private final AppCompatButton fullVersionButton;
|
|
|
|
private final View osmLiveProgress;
|
|
|
|
private final View osmLiveProgress;
|
|
|
|
private final AppCompatButton osmLiveButton;
|
|
|
|
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() {
|
|
|
|
private OnClickListener onCollapseListener = new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
|
if (freeVersionDescriptionTextView.getVisibility() == View.VISIBLE
|
|
|
|
if (freeVersionDescriptionTextView.getVisibility() == View.VISIBLE
|
|
|
|
&& isDownlodingPermitted(application.getSettings())) {
|
|
|
|
&& isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
|
|
|
|
collapseBanner();
|
|
|
|
collapseBanner();
|
|
|
|
wasCollapsed = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} 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.ctx = ctx;
|
|
|
|
this.showSpace = showSpace;
|
|
|
|
this.dialog = dialog;
|
|
|
|
application = (OsmandApplication) ctx.getApplicationContext();
|
|
|
|
|
|
|
|
freeVersionBanner = view.findViewById(R.id.freeVersionBanner);
|
|
|
|
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);
|
|
|
|
downloadsLeftTextView = (TextView) freeVersionBanner.findViewById(R.id.downloadsLeftTextView);
|
|
|
|
downloadsLeftProgressBar = (ProgressBar) freeVersionBanner.findViewById(R.id.downloadsLeftProgressBar);
|
|
|
|
downloadsLeftProgressBar = (ProgressBar) freeVersionBanner.findViewById(R.id.downloadsLeftProgressBar);
|
|
|
|
buttonsLinearLayout = freeVersionBanner.findViewById(R.id.buttonsLinearLayout);
|
|
|
|
|
|
|
|
priceInfoLayout = freeVersionBanner.findViewById(R.id.priceInfoLayout);
|
|
|
|
priceInfoLayout = freeVersionBanner.findViewById(R.id.priceInfoLayout);
|
|
|
|
freeVersionDescriptionTextView = (TextView) freeVersionBanner
|
|
|
|
freeVersionDescriptionTextView = (TextView) freeVersionBanner
|
|
|
|
.findViewById(R.id.freeVersionDescriptionTextView);
|
|
|
|
.findViewById(R.id.freeVersionDescriptionTextView);
|
|
|
|
laterButton = freeVersionBanner.findViewById(R.id.laterButton);
|
|
|
|
|
|
|
|
freeVersionBannerTitle = freeVersionBanner.findViewById(R.id.freeVersionBannerTitle);
|
|
|
|
freeVersionBannerTitle = freeVersionBanner.findViewById(R.id.freeVersionBannerTitle);
|
|
|
|
|
|
|
|
// laterButton = freeVersionBanner.findViewById(R.id.laterButton);
|
|
|
|
|
|
|
|
// buttonsLinearLayout = freeVersionBanner.findViewById(R.id.buttonsLinearLayout);
|
|
|
|
|
|
|
|
|
|
|
|
fullVersionProgress = freeVersionBanner.findViewById(R.id.fullVersionProgress);
|
|
|
|
fullVersionProgress = freeVersionBanner.findViewById(R.id.fullVersionProgress);
|
|
|
|
fullVersionButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.fullVersionButton);
|
|
|
|
fullVersionButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.fullVersionButton);
|
|
|
|
osmLiveProgress = freeVersionBanner.findViewById(R.id.osmLiveProgress);
|
|
|
|
osmLiveProgress = freeVersionBanner.findViewById(R.id.osmLiveProgress);
|
|
|
|
osmLiveButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.osmLiveButton);
|
|
|
|
osmLiveButton = (AppCompatButton) freeVersionBanner.findViewById(R.id.osmLiveButton);
|
|
|
|
|
|
|
|
|
|
|
|
shouldShowFreeVersionBanner = shouldShowFreeVersionBanner(application);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initFreeVersionBanner();
|
|
|
|
|
|
|
|
updateBannerInProgress();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isUpdatingPrices() {
|
|
|
|
|
|
|
|
return updatingPrices;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setUpdatingPrices(boolean updatingPrices) {
|
|
|
|
public void setUpdatingPrices(boolean updatingPrices) {
|
|
|
|
this.updatingPrices = 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();
|
|
|
|
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 + "%");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void collapseBanner() {
|
|
|
|
private void collapseBanner() {
|
|
|
|
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
|
|
|
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
|
|
|
buttonsLinearLayout.setVisibility(View.GONE);
|
|
|
|
// buttonsLinearLayout.setVisibility(View.GONE);
|
|
|
|
priceInfoLayout.setVisibility(View.GONE);
|
|
|
|
priceInfoLayout.setVisibility(View.GONE);
|
|
|
|
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
|
|
|
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void expandBanner() {
|
|
|
|
public void expandBanner() {
|
|
|
|
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
|
|
|
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
|
|
|
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
|
|
|
// buttonsLinearLayout.setVisibility(View.VISIBLE);
|
|
|
|
priceInfoLayout.setVisibility(View.VISIBLE);
|
|
|
|
priceInfoLayout.setVisibility(View.VISIBLE);
|
|
|
|
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
|
|
|
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void hideDownloadProgressLayout() {
|
|
|
|
|
|
|
|
downloadProgressLayout.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void showDownloadProgressLayout() {
|
|
|
|
public void initFreeVersionBanner() {
|
|
|
|
downloadProgressLayout.setVisibility(View.VISIBLE);
|
|
|
|
if (!shouldShowFreeVersionBanner(ctx.getMyApplication())) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initFreeVersionBanner() {
|
|
|
|
|
|
|
|
if (!shouldShowFreeVersionBanner) {
|
|
|
|
|
|
|
|
freeVersionBanner.setVisibility(View.GONE);
|
|
|
|
freeVersionBanner.setVisibility(View.GONE);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -506,7 +440,6 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|
|
|
ctx.startActivity(intent);
|
|
|
|
ctx.startActivity(intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
laterButton.setOnClickListener(onCollapseListener);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LinearLayout marksLinearLayout = (LinearLayout) freeVersionBanner.findViewById(R.id.marksLinearLayout);
|
|
|
|
LinearLayout marksLinearLayout = (LinearLayout) freeVersionBanner.findViewById(R.id.marksLinearLayout);
|
|
|
|
Space spaceView = new Space(ctx);
|
|
|
|
Space spaceView = new Space(ctx);
|
|
|
@ -530,28 +463,32 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateFreeVersionBanner();
|
|
|
|
updateFreeVersionBanner();
|
|
|
|
if (wasCollapsed) {
|
|
|
|
if(dialog) {
|
|
|
|
|
|
|
|
expandBanner();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
collapseBanner();
|
|
|
|
collapseBanner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateFreeVersionBanner() {
|
|
|
|
public void updateFreeVersionBanner() {
|
|
|
|
if (!shouldShowFreeVersionBanner) {
|
|
|
|
if (!shouldShowFreeVersionBanner(ctx.getMyApplication())) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setMinimizedFreeVersionBanner(false);
|
|
|
|
setMinimizedFreeVersionBanner(false);
|
|
|
|
OsmandSettings settings = application.getSettings();
|
|
|
|
OsmandSettings settings = ctx.getMyApplication().getSettings();
|
|
|
|
final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get();
|
|
|
|
final Integer mapsDownloaded = settings.NUMBER_OF_FREE_DOWNLOADS.get();
|
|
|
|
downloadsLeftProgressBar.setProgress(mapsDownloaded);
|
|
|
|
downloadsLeftProgressBar.setProgress(mapsDownloaded);
|
|
|
|
int downloadsLeft = DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - mapsDownloaded;
|
|
|
|
int downloadsLeft = DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS - mapsDownloaded;
|
|
|
|
downloadsLeft = Math.max(downloadsLeft, 0);
|
|
|
|
downloadsLeft = Math.max(downloadsLeft, 0);
|
|
|
|
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
|
|
|
|
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
|
|
|
|
|
|
|
|
if(!dialog) {
|
|
|
|
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(onCollapseListener);
|
|
|
|
freeVersionBanner.findViewById(R.id.bannerTopLayout).setOnClickListener(onCollapseListener);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (InAppHelper.hasPrices() || !updatingPrices) {
|
|
|
|
if (InAppHelper.hasPrices() || !updatingPrices) {
|
|
|
|
if (!InAppHelper.hasPrices()) {
|
|
|
|
if (!InAppHelper.hasPrices()) {
|
|
|
|
fullVersionButton.setText(ctx.getString(R.string.get_for, ctx.getString(R.string.full_version_price)));
|
|
|
|
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 {
|
|
|
|
} else {
|
|
|
|
fullVersionButton.setText(ctx.getString(R.string.get_for, InAppHelper.getFullVersionPrice()));
|
|
|
|
fullVersionButton.setText(ctx.getString(R.string.get_for, InAppHelper.getFullVersionPrice()));
|
|
|
|
osmLiveButton.setText(ctx.getString(R.string.get_for_month, InAppHelper.getLiveUpdatesPrice()));
|
|
|
|
osmLiveButton.setText(ctx.getString(R.string.get_for_month, InAppHelper.getLiveUpdatesPrice()));
|
|
|
@ -568,21 +505,106 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
private void setMinimizedFreeVersionBanner(boolean minimize) {
|
|
|
|
if (minimize && isDownlodingPermitted(application.getSettings())) {
|
|
|
|
if (minimize && isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
|
|
|
|
collapseBanner();
|
|
|
|
collapseBanner();
|
|
|
|
freeVersionBannerTitle.setVisibility(View.GONE);
|
|
|
|
freeVersionBannerTitle.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
freeVersionBannerTitle.setVisibility(View.VISIBLE);
|
|
|
|
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() {
|
|
|
|
public void reloadLocalIndexes() {
|
|
|
|