Buttons for banner, second line removed

This commit is contained in:
GaidamakUA 2015-10-07 11:08:12 +03:00
parent 0d207ce241
commit fc769ce8db
3 changed files with 64 additions and 49 deletions

View file

@ -46,7 +46,8 @@
android:maxLines="25" android:maxLines="25"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" android:textSize="@dimen/default_sub_text_size"
tools:text="Map, Contour Lines, Wikipedia"/> tools:text="Map, Contour Lines, Wikipedia"
tools:visibility="gone"/>
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"

View file

@ -356,6 +356,13 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
} }
@Override
public boolean startDownload(IndexItem item) {
final boolean b = super.startDownload(item);
visibleBanner.initFreeVersionBanner();
return b;
}
@Override @Override
public void downloadedIndexes() { public void downloadedIndexes() {
for (WeakReference<Fragment> ref : fragSet) { for (WeakReference<Fragment> ref : fragSet) {
@ -660,7 +667,12 @@ public class DownloadActivity extends BaseDownloadActivity {
private final TextView leftTextView; private final TextView leftTextView;
private final TextView rightTextView; private final TextView rightTextView;
private final Context ctx; private final Context ctx;
private final boolean shouldShowFreeVersionBanner;
private final ProgressBar downloadsLeftProgressBar;
private final View buttonsLinearLayout;
private final TextView freeVersionDescriptionTextView;
private OsmandApplication application; private OsmandApplication application;
private final TextView downloadsLeftTextView;
public BannerAndDownloadFreeVersion(View view, Context ctx) { public BannerAndDownloadFreeVersion(View view, Context ctx) {
this.ctx = ctx; this.ctx = ctx;
@ -670,13 +682,22 @@ public class DownloadActivity extends BaseDownloadActivity {
leftTextView = (TextView) view.findViewById(R.id.leftTextView); leftTextView = (TextView) view.findViewById(R.id.leftTextView);
rightTextView = (TextView) view.findViewById(R.id.rightTextView); rightTextView = (TextView) view.findViewById(R.id.rightTextView);
application = (OsmandApplication) ctx.getApplicationContext(); application = (OsmandApplication) ctx.getApplicationContext();
onCreateBanner(view); shouldShowFreeVersionBanner = Version.isFreeVersion(application)
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
initFreeVersionBanner();
downloadsLeftTextView = (TextView) freeVersionBanner.findViewById(R.id.downloadsLeftTextView);
downloadsLeftProgressBar = (ProgressBar) freeVersionBanner.findViewById(R.id.downloadsLeftProgressBar);
buttonsLinearLayout = freeVersionBanner.findViewById(R.id.buttonsLinearLayout);
freeVersionDescriptionTextView = (TextView) freeVersionBanner
.findViewById(R.id.freeVersionDescriptionTextView);
} }
public void updateProgress(boolean isFinished, boolean indeterminate, int percent, String message) { public void updateProgress(boolean isFinished, boolean indeterminate, int percent, String message) {
if (isFinished) { if (isFinished) {
downloadProgressLayout.setVisibility(View.GONE); downloadProgressLayout.setVisibility(View.GONE);
freeVersionBanner.setVisibility(View.VISIBLE); // TODO
// freeVersionBanner.setVisibility(View.VISIBLE);
} else { } else {
if (freeVersionBanner.getVisibility() == View.VISIBLE) { if (freeVersionBanner.getVisibility() == View.VISIBLE) {
freeVersionBanner.setVisibility(View.GONE); freeVersionBanner.setVisibility(View.GONE);
@ -697,33 +718,15 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
private void onCreateBanner(View view) { private void initFreeVersionBanner() {
OsmandSettings settings = application.getSettings(); if (!shouldShowFreeVersionBanner) {
if (!Version.isFreeVersion(application) && !settings.SHOULD_SHOW_FREE_VERSION_BANNER.get()) {
freeVersionBanner.setVisibility(View.GONE); freeVersionBanner.setVisibility(View.GONE);
return; return;
} }
downloadsLeftProgressBar.setMax(BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS);
TextView downloadsLeftTextView = (TextView) view.findViewById(R.id.downloadsLeftTextView);
final int downloadsLeft = BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS
- settings.NUMBER_OF_FREE_DOWNLOADS.get();
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
final TextView freeVersionDescriptionTextView = (TextView) view
.findViewById(R.id.freeVersionDescriptionTextView);
freeVersionDescriptionTextView.setText(ctx.getString(R.string.free_version_message, freeVersionDescriptionTextView.setText(ctx.getString(R.string.free_version_message,
BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS)); BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS));
freeVersionBanner.findViewById(R.id.getFullVersionButton).setOnClickListener(new View.OnClickListener() {
View buttonsLinearLayout = view.findViewById(R.id.buttonsLinearLayout);
freeVersionBanner.setOnClickListener(new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
buttonsLinearLayout));
ProgressBar downloadsLeftProgressBar = (ProgressBar) view.findViewById(R.id.downloadsLeftProgressBar);
downloadsLeftProgressBar.setProgress(settings.NUMBER_OF_FREE_DOWNLOADS.get());
view.findViewById(R.id.getFullVersionButton).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
BaseDownloadActivity context = (BaseDownloadActivity) v.getContext(); BaseDownloadActivity context = (BaseDownloadActivity) v.getContext();
@ -735,9 +738,21 @@ public class DownloadActivity extends BaseDownloadActivity {
} }
} }
}); });
view.findViewById(R.id.laterButton).setOnClickListener( freeVersionBanner.findViewById(R.id.laterButton).setOnClickListener(
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView, buttonsLinearLayout)); new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView, buttonsLinearLayout));
} }
private void updateFreeVersionBanner() {
if (!shouldShowFreeVersionBanner) return;
OsmandSettings settings = application.getSettings();
downloadsLeftProgressBar.setProgress(settings.NUMBER_OF_FREE_DOWNLOADS.get());
final int downloadsLeft = BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS
- settings.NUMBER_OF_FREE_DOWNLOADS.get();
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
// TODO review logic
freeVersionBanner.setOnClickListener(new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
buttonsLinearLayout));
}
} }
} }

View file

@ -115,6 +115,7 @@ public class ItemViewHolder {
} }
} }
descrTextView.setVisibility(View.VISIBLE);
if (!showTypeInTitle && (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE || if (!showTypeInTitle && (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) { indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
descrTextView.setText(indexItem.getType().getString(context)); descrTextView.setText(indexItem.getType().getString(context));
@ -188,10 +189,8 @@ public class ItemViewHolder {
} }
stringBuilder.append(activityType.getString(context)); stringBuilder.append(activityType.getString(context));
} }
descrTextView.setText(stringBuilder.toString());
} else {
descrTextView.setText(R.string.shared_string_others);
} }
descrTextView.setVisibility(View.GONE);
leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map)); leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map));
rightImageButton.setVisibility(View.GONE); rightImageButton.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);