From 0566981599e193897a74da32af98f51c5eff09fd Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Thu, 10 Mar 2016 15:23:24 +0300 Subject: [PATCH] [new downloader][android] add: Checkbox to disable autodownloading. --- android/res/layout/onmap_downloader.xml | 10 ++++++ .../maps/downloader/OnmapDownloader.java | 33 ++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/android/res/layout/onmap_downloader.xml b/android/res/layout/onmap_downloader.xml index 86378a1333..9a79d49340 100644 --- a/android/res/layout/onmap_downloader.xml +++ b/android/res/layout/onmap_downloader.xml @@ -18,6 +18,7 @@ android:layout_gravity="center" android:gravity="center_horizontal" android:background="?cardFrame" + android:animateLayoutChanges="true" tools:ignore="UselessParent"> + + \ No newline at end of file diff --git a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java index 022dd0ea26..11c27bef33 100644 --- a/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java +++ b/android/src/com/mapswithme/maps/downloader/OnmapDownloader.java @@ -6,6 +6,8 @@ import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.TextView; import java.util.ArrayDeque; @@ -35,6 +37,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener private final TextView mSize; private final WheelProgressView mProgress; private final Button mButton; + private final CheckBox mDisableAuto; private int mStorageSubscriptionSlot; @@ -89,6 +92,22 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener } }; + private final CompoundButton.OnCheckedChangeListener mDisableAutoCheckListener = new CompoundButton.OnCheckedChangeListener() + { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) + { + Config.setAutodownloadMaps(isChecked); + } + }; + + private void updateDisableAutoCheckbox() + { + mDisableAuto.setOnCheckedChangeListener(null); + mDisableAuto.setChecked(Config.isAutodownloadMaps()); + mDisableAuto.setOnCheckedChangeListener(mDisableAutoCheckListener); + } + public void updateState(boolean shouldAutoDownload) { boolean showFrame = (mCurrentCountry != null && @@ -152,6 +171,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener } UiUtils.showIf(showFrame, mFrame); + UiUtils.hide(mDisableAuto); } private void offerDisableAutodownloading() @@ -168,6 +188,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener public void onClick(DialogInterface dialog, int which) { Config.setAutodownloadMaps(false); + updateDisableAutoCheckbox(); } }).show(); } @@ -183,6 +204,7 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener View controls = mFrame.findViewById(R.id.downloader_controls_frame); mProgress = (WheelProgressView) controls.findViewById(R.id.downloader_progress); mButton = (Button) controls.findViewById(R.id.downloader_button); + mDisableAuto = (CheckBox) mFrame.findViewById(R.id.downloader_disable_auto); mProgress.setOnClickListener(new View.OnClickListener() { @@ -193,7 +215,16 @@ public class OnmapDownloader implements MwmActivity.LeftAnimationTrackListener Statistics.INSTANCE.trackEvent(Statistics.EventName.DOWNLOADER_CANCEL, Statistics.params().add(Statistics.EventParam.FROM, "map")); - if (!Config.isAutodownloadMaps() || Config.isAutodownloadDisableOfferShown()) + if (!Config.isAutodownloadMaps()) + return; + + if (ConnectionState.isWifiConnected()) + { + UiUtils.show(mDisableAuto); + updateDisableAutoCheckbox(); + } + + if (Config.isAutodownloadDisableOfferShown()) return; long now = System.currentTimeMillis();