Free version banner working.
This commit is contained in:
parent
32e02ac2c8
commit
c50397188f
2 changed files with 48 additions and 12 deletions
|
@ -157,12 +157,14 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/getFullVersionButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="GET FULL VERSION"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/laterButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package net.osmand.plus.download.newimplementation;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
@ -11,6 +14,7 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.download.BaseDownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
|
||||
|
@ -32,22 +36,30 @@ public final class DownloadsUiHelper {
|
|||
|
||||
final View buttonsLinearLayout = header.findViewById(R.id.buttonsLinearLayout);
|
||||
|
||||
header.findViewById(R.id.freeVersionBanner).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (freeVersionDescriptionTextView.getVisibility() == View.VISIBLE) {
|
||||
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
||||
buttonsLinearLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
||||
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
header.findViewById(R.id.freeVersionBanner).setOnClickListener(
|
||||
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout));
|
||||
|
||||
ProgressBar downloadsLeftProgressBar =
|
||||
(ProgressBar) header.findViewById(R.id.downloadsLeftProgressBar);
|
||||
downloadsLeftProgressBar.setProgress(settings.NUMBER_OF_FREE_DOWNLOADS.get());
|
||||
|
||||
header.findViewById(R.id.getFullVersionButton).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
BaseDownloadActivity context = (BaseDownloadActivity) v.getContext();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(Version.marketPrefix(context.getMyApplication())
|
||||
+ "net.osmand.plus"));
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
header.findViewById(R.id.laterButton).setOnClickListener(
|
||||
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout));
|
||||
}
|
||||
|
||||
public static void showDialog(FragmentActivity activity, DialogFragment fragment) {
|
||||
|
@ -61,6 +73,28 @@ public final class DownloadsUiHelper {
|
|||
fragment.show(ft, "dialog");
|
||||
}
|
||||
|
||||
private static class ToggleCollapseFreeVersionBanner implements View.OnClickListener {
|
||||
private final View freeVersionDescriptionTextView;
|
||||
private final View buttonsLinearLayout;
|
||||
|
||||
private ToggleCollapseFreeVersionBanner(View freeVersionDescriptionTextView,
|
||||
View buttonsLinearLayout) {
|
||||
this.freeVersionDescriptionTextView = freeVersionDescriptionTextView;
|
||||
this.buttonsLinearLayout = buttonsLinearLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (freeVersionDescriptionTextView.getVisibility() == View.VISIBLE) {
|
||||
freeVersionDescriptionTextView.setVisibility(View.GONE);
|
||||
buttonsLinearLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
||||
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapDownloadListener implements DownloadActivity.OnProgressUpdateListener {
|
||||
private final View freeVersionBanner;
|
||||
private final View downloadProgressLayout;
|
||||
|
|
Loading…
Reference in a new issue