Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Marchuk <alexm@maps.me>2016-03-18 15:35:39 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:57:00 +0300
commitb8367ec73f3c788e16a62162696da8bdd732ca43 (patch)
tree0e3862db43044e87ad89361d5b7d786310f607d5
parent1fe0101092002159c141e9d043bc22f21266f9b5 (diff)
[new downloader][android] fix: Crash while displaying downloading error message.
fix: Layout fixes.
-rw-r--r--android/res/layout-land/fragment_suggest_country_download.xml119
-rw-r--r--android/res/layout/fragment_suggest_country_download.xml12
-rw-r--r--android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java63
-rw-r--r--android/src/com/mapswithme/util/UiUtils.java45
4 files changed, 43 insertions, 196 deletions
diff --git a/android/res/layout-land/fragment_suggest_country_download.xml b/android/res/layout-land/fragment_suggest_country_download.xml
deleted file mode 100644
index 1cac5e3482..0000000000
--- a/android/res/layout-land/fragment_suggest_country_download.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:wheel="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clickable="true">
-
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:id="@+id/ll__select_download"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center_horizontal"
- android:orientation="vertical"
- android:paddingLeft="@dimen/margin_base"
- android:paddingRight="@dimen/margin_base"
- android:paddingTop="@dimen/margin_half_plus"
- tools:ignore="UnusedAttribute">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="@string/search_without_internet_advertisement"
- android:textAppearance="@style/MwmTextAppearance.Body2"/>
-
- <LinearLayout
- android:id="@+id/ll__location_determined"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:gravity="center_horizontal">
-
- <TextView
- android:id="@+id/tv__country_name"
- android:layout_width="match_parent"
- android:layout_height="@dimen/height_block_base"
- android:layout_marginTop="@dimen/margin_half"
- android:gravity="center"
- android:textAppearance="@style/MwmTextAppearance.Title"
- tools:text="Some country"/>
-
- <Button
- android:id="@+id/btn__download_map"
- style="@style/MwmWidget.Button.Accent"
- android:layout_marginTop="@dimen/margin_quarter"
- android:text="@string/downloader_download_map"
- android:textAppearance="@style/MwmTextAppearance.Body1"/>
-
- <Button
- android:id="@+id/btn__select_other_map"
- style="@style/MwmWidget.Button"
- android:layout_marginTop="@dimen/margin_base_plus"
- android:text="@string/search_select_other_map"
- android:textAppearance="@style/MwmTextAppearance.Body3"
- android:textColor="?colorAccent"/>
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/ll__location_unknown"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:gravity="center_horizontal"
- android:visibility="gone">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="@dimen/height_block_base"
- android:layout_marginTop="@dimen/margin_half"
- android:gravity="center"
- android:text="@string/unknown_current_position"
- android:textAppearance="@style/MwmTextAppearance.Body3"/>
-
- <Button
- android:id="@+id/btn__select_map"
- style="@style/MwmWidget.Button.Accent"
- android:layout_width="280dp"
- android:layout_height="@dimen/height_block_base"
- android:layout_marginTop="@dimen/margin_half"
- android:text="@string/search_select_map"
- android:textAppearance="@style/MwmTextAppearance.Body1"/>
- </LinearLayout>
- </LinearLayout>
- </ScrollView>
-
- <LinearLayout
- android:id="@+id/ll__active_download"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:gravity="center_horizontal"
- android:orientation="vertical"
- android:padding="@dimen/margin_double_and_half"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/tv__active_country_name"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/height_block_base"
- android:textAppearance="@style/MwmTextAppearance.Title"/>
-
- <com.mapswithme.maps.widget.WheelProgressView
- android:id="@+id/wpv__download_progress"
- android:layout_width="@dimen/downloader_status_size"
- android:layout_height="@dimen/downloader_status_size"
- android:layout_marginTop="@dimen/margin_half_plus"
- android:background="?clickableBackground"
- wheel:wheelProgressColor="?colorAccent"
- wheel:wheelSecondaryColor="?dividerHorizontal"
- wheel:wheelThickness="@dimen/margin_quarter"/>
- </LinearLayout>
-</FrameLayout> \ No newline at end of file
diff --git a/android/res/layout/fragment_suggest_country_download.xml b/android/res/layout/fragment_suggest_country_download.xml
index 017cf13ddf..eb973760aa 100644
--- a/android/res/layout/fragment_suggest_country_download.xml
+++ b/android/res/layout/fragment_suggest_country_download.xml
@@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?windowBackgroundForced"
+ android:animateLayoutChanges="true"
android:clickable="true">
<LinearLayout
android:id="@+id/ll__select_download"
@@ -102,14 +103,21 @@
<TextView
android:id="@+id/tv__active_country_name"
android:layout_width="wrap_content"
- android:layout_height="@dimen/height_block_base"
+ android:layout_height="wrap_content"
android:textAppearance="@style/MwmTextAppearance.Title"/>
+ <TextView
+ android:id="@+id/downloader_progress"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/margin_half"
+ android:textAppearance="@style/MwmTextAppearance.Body2"
+ tools:text="1024%"/>
+
<com.mapswithme.maps.widget.WheelProgressView
android:id="@+id/wpv__download_progress"
android:layout_width="@dimen/downloader_status_size"
android:layout_height="@dimen/downloader_status_size"
- android:layout_marginTop="@dimen/margin_half_plus"
android:background="?clickableBackground"
wheel:wheelProgressColor="?colorAccent"
wheel:wheelSecondaryColor="?dividerHorizontal"
diff --git a/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java b/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java
index 22335512e9..2454bde6d5 100644
--- a/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java
+++ b/android/src/com/mapswithme/maps/downloader/CountrySuggestFragment.java
@@ -13,6 +13,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;
+import java.util.Locale;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmFragment;
@@ -31,6 +32,7 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
private WheelProgressView mWpvDownloadProgress;
private TextView mTvCountry;
private TextView mTvActiveCountry;
+ private TextView mTvProgress;
private Button mBtnDownloadMap;
private CountryItem mCurrentCountry;
@@ -59,21 +61,29 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
return;
for (MapManager.StorageCallbackData item : data)
- if (item.isLeafNode)
+ {
+ if (!item.isLeafNode)
+ continue;
+
+ if (mDownloadingCountry == null)
+ mDownloadingCountry = CountryItem.fill(item.countryId);
+ else if (!item.countryId.equals(mDownloadingCountry.id))
+ continue;
+
+ switch (item.newStatus)
{
- switch (item.newStatus)
- {
- case CountryItem.STATUS_FAILED:
- refreshViews();
- UiUtils.checkConnectionAndShowAlert(getActivity(), getString(R.string.download_country_failed, mDownloadingCountry.name));
- return;
-
- case CountryItem.STATUS_DONE:
- exitFragment();
- return;
- }
+ case CountryItem.STATUS_FAILED:
+ refreshViews();
+ return;
+
+ case CountryItem.STATUS_DONE:
+ exitFragment();
+ return;
}
+ break;
+ }
+
refreshViews();
}
@@ -123,16 +133,7 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
MapManager.nativeUnsubscribe(mListenerSlot);
}
- private void refreshCountryName()
- {
- if (mDownloadingCountry == null || !isAdded())
- return;
-
- mTvCountry.setText(mDownloadingCountry.name);
- mTvActiveCountry.setText(mDownloadingCountry.name);
- }
-
- private void refreshCountrySize()
+ private void refreshDownloadButton()
{
if (mCurrentCountry == null || !isAdded())
return;
@@ -156,6 +157,7 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
mWpvDownloadProgress.setOnClickListener(this);
mTvCountry = (TextView) view.findViewById(R.id.tv__country_name);
mTvActiveCountry = (TextView) view.findViewById(R.id.tv__active_country_name);
+ mTvProgress = (TextView) view.findViewById(R.id.downloader_progress);
UiUtils.updateAccentButton(mBtnDownloadMap);
UiUtils.updateAccentButton(selectMap);
@@ -170,18 +172,18 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
UiUtils.showIf(downloading, mLlActiveDownload);
UiUtils.showIf(!downloading, mLlSelectDownload);
- if (downloading)
+ if (!downloading)
{
- refreshCountryName();
+ boolean hasLocation = (mCurrentCountry != null);
+ UiUtils.showIf(hasLocation, mLlWithLocation);
+ UiUtils.showIf(!hasLocation, mLlNoLocation);
+ refreshDownloadButton();
return;
}
- boolean hasLocation = (mCurrentCountry != null);
- UiUtils.showIf(hasLocation, mLlWithLocation);
- UiUtils.showIf(!hasLocation, mLlNoLocation);
-
- refreshCountryName();
- refreshCountrySize();
+ mTvCountry.setText(mDownloadingCountry.name);
+ mTvActiveCountry.setText(mDownloadingCountry.name);
+ mTvProgress.setText(String.format(Locale.US, "%d%%", mDownloadingCountry.progress));
}
@Override
@@ -190,6 +192,7 @@ public class CountrySuggestFragment extends BaseMwmFragment implements View.OnCl
switch (v.getId())
{
case R.id.btn__download_map:
+ mDownloadingCountry = mCurrentCountry;
MapManager.nativeDownload(mCurrentCountry.id);
break;
diff --git a/android/src/com/mapswithme/util/UiUtils.java b/android/src/com/mapswithme/util/UiUtils.java
index 628928cfeb..2aa1f1a327 100644
--- a/android/src/com/mapswithme/util/UiUtils.java
+++ b/android/src/com/mapswithme/util/UiUtils.java
@@ -3,10 +3,8 @@ package com.mapswithme.util;
import android.animation.Animator;
import android.app.Activity;
import android.content.DialogInterface;
-import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
-import android.provider.Settings;
import android.support.annotation.DimenRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
@@ -214,49 +212,6 @@ public final class UiUtils
showIf(!TextUtils.isEmpty(text), tv);
}
- public static void checkConnectionAndShowAlert(final Activity activity, final String message)
- {
- if (!ConnectionState.isConnected())
- {
- activity.runOnUiThread(new Runnable()
- {
- @Override
- public void run()
- {
- new AlertDialog.Builder(activity)
- .setCancelable(false)
- .setMessage(message)
- .setPositiveButton(activity.getString(R.string.connection_settings), new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dlg, int which)
- {
- try
- {
- activity.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
- } catch (final Exception ex)
- {
- ex.printStackTrace();
- }
-
- dlg.dismiss();
- }
- })
- .setNegativeButton(activity.getString(R.string.close), new DialogInterface.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dlg, int which)
- {
- dlg.dismiss();
- }
- })
- .create()
- .show();
- }
- });
- }
- }
-
public static void showHomeUpButton(Toolbar toolbar)
{
toolbar.setNavigationIcon(ThemeUtils.getResource(toolbar.getContext(), R.attr.homeAsUpIndicator));