From 2810c35d8ebb30733d781a321303022a22c58891 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Tue, 6 Oct 2015 11:56:41 +0300 Subject: [PATCH] Item onClick animation and click on item to download --- OsmAnd/res/layout/download_item_list_section.xml | 7 +++++-- OsmAnd/res/layout/simple_list_menu_item.xml | 2 -- .../layout/two_line_with_images_list_item.xml | 4 +--- OsmAnd/res/values/sizes.xml | 2 +- OsmAnd/res/values/strings.xml | 1 + .../plus/download/items/ItemViewHolder.java | 13 +------------ .../plus/download/items/RegionItemsFragment.java | 16 ++++++++-------- .../plus/download/items/WorldItemsFragment.java | 7 ------- 8 files changed, 17 insertions(+), 35 deletions(-) diff --git a/OsmAnd/res/layout/download_item_list_section.xml b/OsmAnd/res/layout/download_item_list_section.xml index 2a91cfe92f..a60c8efe1b 100644 --- a/OsmAnd/res/layout/download_item_list_section.xml +++ b/OsmAnd/res/layout/download_item_list_section.xml @@ -2,6 +2,7 @@ - \ No newline at end of file diff --git a/OsmAnd/res/layout/simple_list_menu_item.xml b/OsmAnd/res/layout/simple_list_menu_item.xml index ad144df7d7..ca86b409de 100644 --- a/OsmAnd/res/layout/simple_list_menu_item.xml +++ b/OsmAnd/res/layout/simple_list_menu_item.xml @@ -11,8 +11,6 @@ android:layout_height="@dimen/list_item_height" android:layout_gravity="center_vertical" android:drawablePadding="24dp" - android:focusable="false" - android:focusableInTouchMode="false" android:gravity="center_vertical" android:paddingLeft="16dp" android:textColor="?android:textColorPrimary" diff --git a/OsmAnd/res/layout/two_line_with_images_list_item.xml b/OsmAnd/res/layout/two_line_with_images_list_item.xml index 1ed62d8160..0ae308daf2 100644 --- a/OsmAnd/res/layout/two_line_with_images_list_item.xml +++ b/OsmAnd/res/layout/two_line_with_images_list_item.xml @@ -64,8 +64,6 @@ android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/dashFavIconMargin" android:background="?attr/dashboard_button" - android:focusable="false" - android:focusableInTouchMode="false" tools:src="@drawable/ic_action_import" tools:visibility="visible" android:visibility="gone"/> @@ -76,7 +74,7 @@ android:layout_height="40dp" android:layout_gravity="center_vertical" android:layout_marginRight="4dp" - android:text="BUY" + android:text="@string/buy" android:visibility="gone"/> diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index cb3cd275d2..f030633c54 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -34,7 +34,7 @@ 12dp 8dp - 18dp + 24dp 10dp 13dp 16dp diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f9b45ef71d..0dcd453d21 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2000,4 +2000,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Downloading - %1$d file Show free version banner Even if you have paid version you still can see free version banner + BUY diff --git a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java index c4b5c5cb0f..1f54279fa6 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java @@ -15,7 +15,6 @@ import net.osmand.access.AccessibleToast; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.WorldRegion; -import net.osmand.plus.download.BaseDownloadActivity; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.IndexItem; @@ -113,19 +112,9 @@ public class ItemViewHolder { } else { descrTextView.setText(indexItem.getSizeDescription(context)); } + // TODO replace with imageView. rightImageButton.setVisibility(View.VISIBLE); rightImageButton.setImageDrawable(getContextIcon(context, R.drawable.ic_action_import)); - rightImageButton.setTag(R.id.index_item, indexItem); - rightImageButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ((BaseDownloadActivity) v.getContext()) - .startDownload((IndexItem) v.getTag(R.id.index_item)); -// progressBar.setVisibility(View.VISIBLE); -// rightImageButton.setImageDrawable(getContextIcon(context, -// R.drawable.ic_action_remove_dark)); - } - }); progressBar.setVisibility(View.GONE); if (rightButtonAction != RightButtonAction.UNKNOWN) { diff --git a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java index 70e315f4b4..506fbf13c3 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java @@ -19,7 +19,9 @@ import net.osmand.plus.Version; import net.osmand.plus.WorldRegion; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.activities.OsmandExpandableListFragment; +import net.osmand.plus.download.BaseDownloadActivity; import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.IndexItem; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin; @@ -93,9 +95,13 @@ public class RegionItemsFragment extends OsmandExpandableListFragment { ((RegionDialogFragment) getParentFragment()) .onRegionSelected(region.getRegionId()); return true; - } else { - return false; + } else if (obj instanceof ItemsListBuilder.ResourceItem) { + IndexItem indexItem = ((ItemsListBuilder.ResourceItem) obj).getIndexItem(); + ((BaseDownloadActivity) getActivity()) + .startDownload(indexItem); + return true; } + return false; } private void expandAllGroups() { @@ -233,12 +239,6 @@ public class RegionItemsFragment extends OsmandExpandableListFragment { } } - TypedValue typedValue = new TypedValue(); - Resources.Theme theme = getActivity().getTheme(); - theme.resolveAttribute(R.attr.bg_color, typedValue, true); - int mainBackgroundColor = typedValue.resourceId; - convertView.setBackgroundResource(mainBackgroundColor); - return convertView; } diff --git a/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java index 233d41b491..698b7722aa 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/items/WorldItemsFragment.java @@ -251,12 +251,6 @@ public class WorldItemsFragment extends OsmandExpandableListFragment { viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null); viewHolder.textView.setText(item.getName()); - TypedValue typedValue = new TypedValue(); - Resources.Theme theme = getActivity().getTheme(); - theme.resolveAttribute(R.attr.bg_color, typedValue, true); - int mainBackgroundColor = typedValue.resourceId; - convertView.setBackgroundResource(mainBackgroundColor); - } else if (groupPosition == worldMapsIndex) { ItemsListBuilder.ResourceItem item = (ItemsListBuilder.ResourceItem) child; ItemViewHolder viewHolder; @@ -272,7 +266,6 @@ public class WorldItemsFragment extends OsmandExpandableListFragment { viewHolder.setNauticalPluginDisabled(nauticalPluginDisabled); viewHolder.setFreeVersion(freeVersion); viewHolder.bindIndexItem(item.getIndexItem(), getDownloadActivity(), false, false); - } else if (groupPosition == voicePromptsIndex) { String item = (String)child; SimpleViewHolder viewHolder;