[new downloader][android] fix: Downloader status icons reworked.
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 238 B |
BIN
android/res/drawable-hdpi/ic_download.png
Normal file
After Width: | Height: | Size: 255 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 469 B |
BIN
android/res/drawable-hdpi/ic_downloader_download_night.png
Normal file
After Width: | Height: | Size: 478 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 486 B |
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 140 B After Width: | Height: | Size: 182 B |
BIN
android/res/drawable-mdpi/ic_download.png
Normal file
After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 185 B After Width: | Height: | Size: 326 B |
BIN
android/res/drawable-mdpi/ic_downloader_download_night.png
Normal file
After Width: | Height: | Size: 338 B |
Before Width: | Height: | Size: 820 B After Width: | Height: | Size: 334 B |
Before Width: | Height: | Size: 555 B After Width: | Height: | Size: 381 B |
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 263 B |
BIN
android/res/drawable-xhdpi/ic_download.png
Normal file
After Width: | Height: | Size: 285 B |
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 594 B |
BIN
android/res/drawable-xhdpi/ic_downloader_download_night.png
Normal file
After Width: | Height: | Size: 602 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 630 B |
Before Width: | Height: | Size: 991 B After Width: | Height: | Size: 697 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 363 B |
BIN
android/res/drawable-xxhdpi/ic_download.png
Normal file
After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 838 B |
BIN
android/res/drawable-xxhdpi/ic_downloader_download_night.png
Normal file
After Width: | Height: | Size: 849 B |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 947 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 434 B |
BIN
android/res/drawable-xxxhdpi/ic_download.png
Normal file
After Width: | Height: | Size: 481 B |
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 1.2 KiB |
BIN
android/res/drawable-xxxhdpi/ic_downloader_download_night.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
11
android/res/drawable/downloader_done.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="?colorAccent"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:drawable="@drawable/ic_done"/>
|
||||
</layer-list>
|
11
android/res/drawable/downloader_download.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="?iconTintLight"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:drawable="@drawable/ic_downloader_download"/>
|
||||
</layer-list>
|
11
android/res/drawable/downloader_download_night.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="?iconTintLight"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:drawable="@drawable/ic_downloader_download_night"/>
|
||||
</layer-list>
|
11
android/res/drawable/downloader_failed.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/base_red"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:drawable="@drawable/ic_downloader_retry"/>
|
||||
</layer-list>
|
11
android/res/drawable/downloader_update.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/base_accent_night"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:drawable="@drawable/ic_downloader_update"/>
|
||||
</layer-list>
|
|
@ -34,7 +34,7 @@
|
|||
android:duplicateParentState="false"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
tools:src="@drawable/ic_downloader_download"/>
|
||||
tools:src="@drawable/downloader_failed"/>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
android:layout_gravity="end"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_downloader_download"/>
|
||||
android:src="@drawable/ic_download"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/update_all"
|
||||
|
|
|
@ -104,4 +104,15 @@
|
|||
<item name="android:colorControlNormal" tools:ignore="NewApi">?dividerHorizontal</item>
|
||||
<item name="colorControlNormal">?dividerHorizontal</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmTheme.Downloader">
|
||||
<item name="status_done">@drawable/downloader_done</item>
|
||||
<item name="status_downloadable">@drawable/downloader_download</item>
|
||||
<item name="status_failed">@drawable/downloader_failed</item>
|
||||
<item name="status_updatable">@drawable/downloader_update</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmTheme.Downloader.Night">
|
||||
<item name="status_downloadable">@drawable/downloader_download_night</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -3,8 +3,8 @@ package com.mapswithme.maps.downloader;
|
|||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Location;
|
||||
import android.support.annotation.AttrRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
|
@ -13,6 +13,7 @@ import android.support.v7.widget.LinearLayoutManager;
|
|||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -35,8 +36,8 @@ import com.mapswithme.maps.location.LocationHelper;
|
|||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.maps.widget.WheelProgressView;
|
||||
import com.mapswithme.util.BottomSheetHelper;
|
||||
import com.mapswithme.util.Graphics;
|
||||
import com.mapswithme.util.StringUtils;
|
||||
import com.mapswithme.util.ThemeUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
import com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersAdapter;
|
||||
|
@ -58,13 +59,13 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
|
|||
private final SparseArray<String> mHeaders = new SparseArray<>();
|
||||
private final Stack<PathEntry> mPath = new Stack<>();
|
||||
|
||||
private final SparseArray<Drawable> mIconsCache = new SparseArray<>();
|
||||
private final SparseIntArray mIconsCache = new SparseIntArray();
|
||||
|
||||
private int mListenerSlot;
|
||||
|
||||
private enum MenuItem
|
||||
{
|
||||
DOWNLOAD(R.drawable.ic_downloader_download, R.string.downloader_download_map)
|
||||
DOWNLOAD(R.drawable.ic_download, R.string.downloader_download_map)
|
||||
{
|
||||
@Override
|
||||
void invoke(CountryItem item, DownloaderAdapter adapter)
|
||||
|
@ -435,39 +436,41 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
|
|||
|
||||
private void updateStatus()
|
||||
{
|
||||
boolean inProgress = (mItem.status == CountryItem.STATUS_PROGRESS ||
|
||||
mItem.status == CountryItem.STATUS_ENQUEUED);
|
||||
boolean pending = (mItem.status == CountryItem.STATUS_ENQUEUED);
|
||||
boolean inProgress = (mItem.status == CountryItem.STATUS_PROGRESS || pending);
|
||||
|
||||
UiUtils.showIf(inProgress, mProgress);
|
||||
UiUtils.showIf(!inProgress, mStatus);
|
||||
mProgress.setPending(pending);
|
||||
|
||||
if (inProgress)
|
||||
{
|
||||
mProgress.setProgress(mItem.status == CountryItem.STATUS_PROGRESS ? mItem.progress : 0);
|
||||
if (!pending)
|
||||
mProgress.setProgress(mItem.progress);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean clickable = mItem.isExpandable();
|
||||
@DrawableRes int iconRes;
|
||||
@AttrRes int iconAttr;
|
||||
|
||||
switch (mItem.status)
|
||||
{
|
||||
case CountryItem.STATUS_DONE:
|
||||
clickable = false;
|
||||
iconRes = R.drawable.ic_done;
|
||||
iconAttr = R.attr.status_done;
|
||||
break;
|
||||
|
||||
case CountryItem.STATUS_DOWNLOADABLE:
|
||||
case CountryItem.STATUS_PARTLY:
|
||||
iconRes = R.drawable.ic_downloader_download;
|
||||
iconAttr = R.attr.status_downloadable;
|
||||
break;
|
||||
|
||||
case CountryItem.STATUS_FAILED:
|
||||
iconRes = R.drawable.ic_downloader_retry;
|
||||
iconAttr = R.attr.status_failed;
|
||||
break;
|
||||
|
||||
case CountryItem.STATUS_UPDATABLE:
|
||||
iconRes = R.drawable.ic_downloader_update;
|
||||
iconAttr = R.attr.status_updatable;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -475,7 +478,7 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
|
|||
}
|
||||
|
||||
mStatus.setFocusable(clickable);
|
||||
mStatus.setImageDrawable(resolveIcon(iconRes));
|
||||
mStatus.setImageResource(resolveIcon(iconAttr));
|
||||
}
|
||||
|
||||
void bind(CountryItem item)
|
||||
|
@ -514,27 +517,13 @@ class DownloaderAdapter extends RecyclerView.Adapter<DownloaderAdapter.ViewHolde
|
|||
}
|
||||
}
|
||||
|
||||
private Drawable resolveIcon(@DrawableRes int iconRes)
|
||||
private @DrawableRes int resolveIcon(@AttrRes int iconAttr)
|
||||
{
|
||||
Drawable res = mIconsCache.get(iconRes);
|
||||
if (res == null)
|
||||
int res = mIconsCache.get(iconAttr);
|
||||
if (res == 0)
|
||||
{
|
||||
switch (iconRes)
|
||||
{
|
||||
case R.drawable.ic_downloader_download:
|
||||
res = Graphics.tint(mActivity, iconRes);
|
||||
break;
|
||||
|
||||
case R.drawable.ic_done:
|
||||
res = Graphics.tint(mActivity, iconRes, R.attr.colorAccent);
|
||||
break;
|
||||
|
||||
default:
|
||||
//noinspection deprecation
|
||||
res = mActivity.getResources().getDrawable(iconRes);
|
||||
}
|
||||
|
||||
mIconsCache.put(iconRes, res);
|
||||
res = ThemeUtils.getResource(mActivity, R.attr.downloaderTheme, iconAttr);
|
||||
mIconsCache.put(iconAttr, res);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|