forked from organicmaps/organicmaps
[AND] Colors and layout updates.
This commit is contained in:
parent
8c3ad5847a
commit
1a9592a000
7 changed files with 76 additions and 117 deletions
|
@ -1,14 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp" >
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center" >
|
||||
|
||||
<FrameLayout
|
||||
|
@ -16,16 +14,15 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="5dip"
|
||||
android:visibility="visible" >
|
||||
android:layout_centerVertical="true" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/country_flag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="3dp"
|
||||
android:paddingLeft="@dimen/dp_x_3"
|
||||
android:paddingRight="@dimen/dp_x_3"
|
||||
android:scaleType="center" />
|
||||
|
||||
<!-- Invisible by default -->
|
||||
|
@ -35,6 +32,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|left"
|
||||
android:paddingLeft="@dimen/dp_x_1"
|
||||
android:paddingTop="@dimen/dp_x_1"
|
||||
android:src="@drawable/ic_guide_mark" />
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -45,16 +44,19 @@
|
|||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/country_menu"
|
||||
android:layout_toRightOf="@id/flagContainer"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:maxLines="2"
|
||||
android:textAppearance="@style/Holo.TextAppearance.Large.Light" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/country_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="10dip"
|
||||
android:background="@drawable/list_selector_holo_light"
|
||||
android:paddingLeft="@dimen/dp_x_3"
|
||||
android:paddingRight="@dimen/dp_x_3"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_country_menu" />
|
||||
</RelativeLayout>
|
||||
|
@ -65,7 +67,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="-6dp"
|
||||
android:layout_marginBottom="-7dp"
|
||||
android:max="100"
|
||||
android:padding="0dp" />
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp" >
|
||||
android:minHeight="?android:attr/listPreferredItemHeight" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/country_flag"
|
||||
|
@ -12,7 +10,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="8dip"
|
||||
android:padding="@dimen/dp_x_3"
|
||||
android:scaleType="center" />
|
||||
|
||||
<ImageView
|
||||
|
@ -21,7 +19,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="10dip"
|
||||
android:paddingLeft="@dimen/dp_x_3"
|
||||
android:paddingRight="@dimen/dp_x_3"
|
||||
android:src="@drawable/ic_next_item" />
|
||||
|
||||
<TextView
|
||||
|
@ -31,6 +30,7 @@
|
|||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@id/disclosure_image"
|
||||
android:layout_toRightOf="@+id/country_flag"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:textAppearance="@style/Holo.TextAppearance.Large.Light" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -3,9 +3,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp" >
|
||||
android:minHeight="?android:attr/listPreferredItemHeight" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
@ -13,6 +11,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/dp_x_3"
|
||||
android:fontFamily="@string/robotoLight"
|
||||
android:textAppearance="@style/Holo.TextAppearance.Large.Light" />
|
||||
|
||||
<ImageView
|
||||
|
@ -21,7 +21,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="10dip"
|
||||
android:paddingLeft="@dimen/dp_x_3"
|
||||
android:paddingRight="@dimen/dp_x_3"
|
||||
android:src="@drawable/ic_next_item" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,6 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<string name="robotoLight">sans-serif-light</string>
|
||||
|
||||
<style name="Widget.MapButtonZoom" parent="android:Widget.Holo.ImageButton">
|
||||
<item name="android:background">@null</item>
|
||||
<item name="android:layout_marginBottom">5dip</item>
|
||||
|
@ -61,8 +63,8 @@
|
|||
<item name="android:textSize">@dimen/sp_x_4</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="MWMMain" parent="@style/Holo.Theme.Light"></style>
|
||||
|
||||
<style name="MWMMain.NoBar" parent="@style/Holo.Theme.Light.NoActionBar"></style>
|
||||
|
||||
<!-- Dialog Holo.Light theme for Activity -->
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MWMActivity.ShowCountryTask;
|
||||
import com.mapswithme.maps.MWMApplication;
|
||||
import com.mapswithme.maps.MapStorage;
|
||||
import com.mapswithme.maps.MapStorage.Index;
|
||||
|
@ -89,9 +90,9 @@ class DownloadAdapter extends BaseAdapter
|
|||
//TODO introduce resources
|
||||
switch (mStatus)
|
||||
{
|
||||
case MapStorage.ON_DISK: return 0xFF00A144;
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE: return 0xFFFF69B4;
|
||||
case MapStorage.NOT_DOWNLOADED: return 0xFF000000;
|
||||
case MapStorage.ON_DISK: return 0xFF333333;
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE: return 0xFF000000;
|
||||
case MapStorage.NOT_DOWNLOADED: return 0xFF999999;
|
||||
case MapStorage.DOWNLOAD_FAILED: return 0xFFFF0000;
|
||||
case MapStorage.DOWNLOADING: return 0xFF342BB6;
|
||||
case MapStorage.IN_QUEUE: return 0xFF5B94DE;
|
||||
|
@ -172,30 +173,33 @@ class DownloadAdapter extends BaseAdapter
|
|||
}
|
||||
|
||||
/// Process list item click.
|
||||
public boolean onItemClick(int position)
|
||||
public boolean onItemClick(int position, View view)
|
||||
{
|
||||
if (mItems[position].mStatus < 0)
|
||||
{
|
||||
// expand next level
|
||||
mIdx = mIdx.getChild(position);
|
||||
|
||||
fillList();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
processCountry(position);
|
||||
if (getItemViewType(position) == TYPE_COUNTRY_READY)
|
||||
showCountry(getItem(position).mCountryIdx);
|
||||
else
|
||||
onCountryMenuClicked(position, getItem(position), view);
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showNotEnoughFreeSpaceDialog(String spaceNeeded, String countryName)
|
||||
{
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setMessage(String.format(mContext.getString(R.string.free_space_for_country), spaceNeeded, countryName))
|
||||
.setNegativeButton(mContext.getString(R.string.close), m_alertCancelHandler)
|
||||
.create()
|
||||
.show();
|
||||
.setMessage(String.format(mContext.getString(R.string.free_space_for_country), spaceNeeded, countryName))
|
||||
.setNegativeButton(mContext.getString(R.string.close), m_alertCancelHandler)
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private boolean hasFreeSpace(long size)
|
||||
|
@ -204,45 +208,6 @@ class DownloadAdapter extends BaseAdapter
|
|||
return app.hasFreeSpace(size);
|
||||
}
|
||||
|
||||
private void processCountry(int position)
|
||||
{
|
||||
final Index idx = mIdx.getChild(position);
|
||||
final String name = mItems[position].mName;
|
||||
|
||||
// Get actual status here
|
||||
switch (mStorage.countryStatus(idx))
|
||||
{
|
||||
case MapStorage.ON_DISK:
|
||||
processOnDisk(idx, name);
|
||||
break;
|
||||
|
||||
case MapStorage.ON_DISK_OUT_OF_DATE:
|
||||
processOutOfDate(idx, name);
|
||||
break;
|
||||
|
||||
case MapStorage.NOT_DOWNLOADED:
|
||||
processNotDownloaded(idx, name);
|
||||
break;
|
||||
|
||||
case MapStorage.DOWNLOAD_FAILED:
|
||||
// Do not confirm downloading if status is failed, just start it
|
||||
mStorage.downloadCountry(idx);
|
||||
break;
|
||||
|
||||
case MapStorage.DOWNLOADING:
|
||||
processDownloading(idx, name);
|
||||
break;
|
||||
|
||||
case MapStorage.IN_QUEUE:
|
||||
// Silently discard country from the queue
|
||||
mStorage.deleteCountry(idx);
|
||||
break;
|
||||
}
|
||||
|
||||
// Actual status will be updated in "updateStatus" callback.
|
||||
}
|
||||
|
||||
|
||||
private void processNotDownloaded(final Index idx, final String name)
|
||||
{
|
||||
final long size = mStorage.countryRemoteSizeInBytes(idx);
|
||||
|
@ -273,8 +238,6 @@ class DownloadAdapter extends BaseAdapter
|
|||
.show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void processOutOfDate(final Index idx, final String name)
|
||||
{
|
||||
final long remoteSize = mStorage.countryRemoteSizeInBytes(idx);
|
||||
|
@ -481,7 +444,18 @@ class DownloadAdapter extends BaseAdapter
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
setItemText(position, holder);
|
||||
convertView.setBackgroundResource(R.drawable.list_selector_holo_light);
|
||||
final View fview = convertView;
|
||||
convertView.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
onItemClick(position, fview);
|
||||
}
|
||||
});
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
@ -496,7 +470,7 @@ class DownloadAdapter extends BaseAdapter
|
|||
UiUtils.show(holder.mProgress);
|
||||
}
|
||||
else
|
||||
UiUtils.hide(holder.mProgress);
|
||||
UiUtils.invisible(holder.mProgress);
|
||||
}
|
||||
|
||||
|
||||
|
@ -572,11 +546,16 @@ class DownloadAdapter extends BaseAdapter
|
|||
}
|
||||
}
|
||||
|
||||
public void onCountryMenuClicked(int position, final CountryItem countryItem, View view)
|
||||
private void showCountry(final Index countryIndex)
|
||||
{
|
||||
mStorage.showCountry(countryIndex);
|
||||
mContext.finish();
|
||||
}
|
||||
|
||||
private void onCountryMenuClicked(int position, final CountryItem countryItem, View anchor)
|
||||
{
|
||||
final int MENU_DELETE = 0;
|
||||
final int MENU_UPDATE = 1;
|
||||
final int MENU_SHOW = 2;
|
||||
final int MENU_GUIDE = 3;
|
||||
final int MENU_DOWNLOAD = 4;
|
||||
final int MENU_CANCEL = 5;
|
||||
|
@ -593,30 +572,15 @@ class DownloadAdapter extends BaseAdapter
|
|||
final int id = item.getItemId();
|
||||
|
||||
if (MENU_DELETE == id)
|
||||
{
|
||||
processOnDisk(countryIndex, name);
|
||||
}
|
||||
else if (MENU_UPDATE == id)
|
||||
{
|
||||
processOutOfDate(countryIndex, name);
|
||||
}
|
||||
else if (MENU_SHOW == id)
|
||||
{
|
||||
mStorage.showCountry(countryIndex);
|
||||
mContext.finish();
|
||||
}
|
||||
else if (MENU_GUIDE == id)
|
||||
{
|
||||
GuidesUtils.openOrDownloadGuide(Framework.getGuideInfoForIndex(countryIndex), mContext);
|
||||
}
|
||||
else if (MENU_DOWNLOAD == id)
|
||||
{
|
||||
processNotDownloaded(countryIndex, name);
|
||||
}
|
||||
else if (MENU_CANCEL == id)
|
||||
{
|
||||
processDownloading(countryIndex, name);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
|
@ -624,7 +588,7 @@ class DownloadAdapter extends BaseAdapter
|
|||
}
|
||||
};
|
||||
|
||||
view.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
|
||||
anchor.setOnCreateContextMenuListener(new OnCreateContextMenuListener()
|
||||
{
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
|
||||
|
@ -632,14 +596,9 @@ class DownloadAdapter extends BaseAdapter
|
|||
menu.setHeaderTitle(countryItem.mName);
|
||||
|
||||
if (status == MapStorage.ON_DISK || status == MapStorage.ON_DISK_OUT_OF_DATE)
|
||||
{
|
||||
menu.add(0, MENU_DELETE, MENU_DELETE, mContext.getString(R.string.delete))
|
||||
.setOnMenuItemClickListener(menuItemClickListener);
|
||||
|
||||
menu.add(0, MENU_SHOW, MENU_SHOW, "Show") // TODO: add translation
|
||||
.setOnMenuItemClickListener(menuItemClickListener);
|
||||
}
|
||||
|
||||
if (status == MapStorage.ON_DISK_OUT_OF_DATE)
|
||||
{
|
||||
final String titleUpdate = formatStringWithSize(R.string.update_mb_or_kb, countryIndex);
|
||||
|
@ -651,7 +610,8 @@ class DownloadAdapter extends BaseAdapter
|
|||
.setOnMenuItemClickListener(menuItemClickListener);
|
||||
|
||||
if (mHasGoogleStore)
|
||||
{ final GuideInfo info = Framework.getGuideInfoForIndex(countryItem.mCountryIdx);
|
||||
{
|
||||
final GuideInfo info = Framework.getGuideInfoForIndex(countryItem.mCountryIdx);
|
||||
if (info != null)
|
||||
menu.add(0, MENU_GUIDE, MENU_GUIDE, info.mTitle) // TODO: add translation
|
||||
.setOnMenuItemClickListener(menuItemClickListener);
|
||||
|
@ -665,8 +625,8 @@ class DownloadAdapter extends BaseAdapter
|
|||
}
|
||||
});
|
||||
|
||||
view.showContextMenu();
|
||||
view.setOnCreateContextMenuListener(null);
|
||||
anchor.showContextMenu();
|
||||
anchor.setOnCreateContextMenuListener(null);
|
||||
}
|
||||
|
||||
private String getSizeString(long size)
|
||||
|
|
|
@ -69,18 +69,6 @@ public class DownloadUI extends MapsWithMeBaseListActivity implements MapStorage
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id)
|
||||
{
|
||||
super.onListItemClick(l, v, position, id);
|
||||
|
||||
if (getDA().onItemClick(position))
|
||||
{
|
||||
// scroll list view to the top
|
||||
setSelection(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCountryStatusChanged(final Index idx)
|
||||
{
|
||||
|
|
|
@ -39,16 +39,22 @@ public final class UiUtils
|
|||
|
||||
public static void hide(View ... views)
|
||||
{
|
||||
for (View v : views)
|
||||
for (final View v : views)
|
||||
v.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public static void show(View ... views)
|
||||
{
|
||||
for (View v : views)
|
||||
for (final View v : views)
|
||||
v.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public static void invisible(View ... views)
|
||||
{
|
||||
for (final View v : views)
|
||||
v.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
||||
public static Drawable setCompoundDrawableBounds(int drawableId, int dimenId, Resources res)
|
||||
{
|
||||
|
@ -66,7 +72,7 @@ public final class UiUtils
|
|||
final String colorString = parts[parts.length - 1];
|
||||
color = colorByName(colorString, Color.BLACK);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (final Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
// We do nothing in this case
|
||||
|
|
Loading…
Add table
Reference in a new issue