diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-07-05 16:43:57 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-07-05 16:43:57 +0200 |
commit | 3768761e9031e1ccc1136d44fc1f8f0fe6dadb26 (patch) | |
tree | 3e693b74f0e74426765e9567a04470d1e326ea6a | |
parent | 3c4df7a89dbe1e82d99ccb42d7c4215b7fa112b4 (diff) | |
download | AntennaPod-3768761e9031e1ccc1136d44fc1f8f0fe6dadb26.zip |
Listitems are now highlighted when in actionmode
-rw-r--r-- | res/drawable-v11/borderless_button.xml | 7 | ||||
-rw-r--r-- | res/values-v11/colors.xml | 5 | ||||
-rw-r--r-- | res/values/colors.xml | 1 | ||||
-rw-r--r-- | src/de/podfetcher/activity/DownloadActivity.java | 2 | ||||
-rw-r--r-- | src/de/podfetcher/adapter/DownloadlistAdapter.java | 22 | ||||
-rw-r--r-- | src/de/podfetcher/adapter/FeedItemlistAdapter.java | 39 | ||||
-rw-r--r-- | src/de/podfetcher/adapter/FeedlistAdapter.java | 20 | ||||
-rw-r--r-- | src/de/podfetcher/fragment/FeedlistFragment.java | 81 | ||||
-rw-r--r-- | src/de/podfetcher/fragment/ItemlistFragment.java | 3 |
9 files changed, 129 insertions, 51 deletions
diff --git a/res/drawable-v11/borderless_button.xml b/res/drawable-v11/borderless_button.xml index cfc630005..28945a631 100644 --- a/res/drawable-v11/borderless_button.xml +++ b/res/drawable-v11/borderless_button.xml @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true"><shape android:shape="rectangle"> - <solid android:color="#33B5E5" /> + <solid android:color="@color/selection_background" /> </shape></item> - <item android:state_focused="true"><shape android:shape="rectangle"> - <solid android:color="#33B5E5" /> + <item android:state_focused="true"><shape android:shape="rectangle"> + <solid android:color="@color/selection_background" /> </shape></item> <item><shape android:shape="rectangle"> <solid android:color="@android:color/transparent" /> diff --git a/res/values-v11/colors.xml b/res/values-v11/colors.xml new file mode 100644 index 000000000..86b0fae09 --- /dev/null +++ b/res/values-v11/colors.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="selection_background">#33B5E5</color> + +</resources>
\ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index 1de0f1d98..8a8dc03e7 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -18,5 +18,6 @@ <color name="navy">#000080</color> <color name="black">#000000</color> <color name="bright_blue">#33B5E5</color> + <color name="selection_background">#FEBB20</color> </resources>
\ No newline at end of file diff --git a/src/de/podfetcher/activity/DownloadActivity.java b/src/de/podfetcher/activity/DownloadActivity.java index 33678e78c..b9f814d94 100644 --- a/src/de/podfetcher/activity/DownloadActivity.java +++ b/src/de/podfetcher/activity/DownloadActivity.java @@ -73,6 +73,7 @@ public class DownloadActivity extends SherlockListActivity implements if (selection != null && mActionMode != null) { mActionMode.finish(); } + dla.setSelectedItemIndex(position); selectedDownload = selection; mActionMode = startActionMode(DownloadActivity.this); return true; @@ -138,5 +139,6 @@ public class DownloadActivity extends SherlockListActivity implements public void onDestroyActionMode(ActionMode mode) { mActionMode = null; selectedDownload = null; + dla.setSelectedItemIndex(DownloadlistAdapter.SELECTION_NONE); } } diff --git a/src/de/podfetcher/adapter/DownloadlistAdapter.java b/src/de/podfetcher/adapter/DownloadlistAdapter.java index f1b63cb37..b128bcf16 100644 --- a/src/de/podfetcher/adapter/DownloadlistAdapter.java +++ b/src/de/podfetcher/adapter/DownloadlistAdapter.java @@ -16,9 +16,14 @@ import de.podfetcher.feed.FeedMedia; import de.podfetcher.util.Converter; public class DownloadlistAdapter extends ArrayAdapter<DownloadStatus> { + private int selectedItemIndex; + + public static final int SELECTION_NONE = -1; + public DownloadlistAdapter(Context context, int textViewResourceId, DownloadStatus[] objects) { super(context, textViewResourceId, objects); + selectedItemIndex = SELECTION_NONE; } @Override @@ -47,6 +52,13 @@ public class DownloadlistAdapter extends ArrayAdapter<DownloadStatus> { holder = (Holder) convertView.getTag(); } + if (position == selectedItemIndex) { + convertView.setBackgroundColor(convertView.getResources().getColor( + R.color.selection_background)); + } else { + convertView.setBackgroundResource(0); + } + String titleText = null; if (feedFile.getClass() == FeedMedia.class) { titleText = ((FeedMedia) feedFile).getItem().getTitle(); @@ -72,4 +84,14 @@ public class DownloadlistAdapter extends ArrayAdapter<DownloadStatus> { TextView percent; ProgressBar progbar; } + + public int getSelectedItemIndex() { + return selectedItemIndex; + } + + public void setSelectedItemIndex(int selectedItemIndex) { + this.selectedItemIndex = selectedItemIndex; + notifyDataSetChanged(); + } + } diff --git a/src/de/podfetcher/adapter/FeedItemlistAdapter.java b/src/de/podfetcher/adapter/FeedItemlistAdapter.java index 544cd371a..d710a466a 100644 --- a/src/de/podfetcher/adapter/FeedItemlistAdapter.java +++ b/src/de/podfetcher/adapter/FeedItemlistAdapter.java @@ -18,17 +18,23 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.content.Context; +import android.graphics.Color; import android.graphics.Typeface; public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { private OnClickListener onButActionClicked; private boolean showFeedtitle; - + private int selectedItemIndex; + + public static final int SELECTION_NONE = -1; + public FeedItemlistAdapter(Context context, int textViewResourceId, - List<FeedItem> objects, OnClickListener onButActionClicked, boolean showFeedtitle) { + List<FeedItem> objects, OnClickListener onButActionClicked, + boolean showFeedtitle) { super(context, textViewResourceId, objects); this.onButActionClicked = onButActionClicked; this.showFeedtitle = showFeedtitle; + this.selectedItemIndex = SELECTION_NONE; } @Override @@ -57,14 +63,22 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { holder.encInfo = (RelativeLayout) convertView .findViewById(R.id.enc_info); if (showFeedtitle) { - holder.feedtitle = (TextView) convertView.findViewById(R.id.txtvFeedname); + holder.feedtitle = (TextView) convertView + .findViewById(R.id.txtvFeedname); } - + convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); } + if (position == selectedItemIndex) { + convertView.setBackgroundColor(convertView.getResources().getColor( + R.color.selection_background)); + } else { + convertView.setBackgroundResource(0); + } + holder.title.setText(item.getTitle()); if (showFeedtitle) { holder.feedtitle.setVisibility(View.VISIBLE); @@ -94,15 +108,15 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { .getSize())); holder.downloaded.setVisibility(View.GONE); } - + if (item.getMedia().isDownloading()) { holder.downloading.setVisibility(View.VISIBLE); } else { holder.downloading.setVisibility(View.GONE); } - + String type = item.getMedia().getMime_type(); - + if (type.startsWith("audio")) { holder.type.setImageResource(R.drawable.type_audio); } else if (type.startsWith("video")) { @@ -114,6 +128,7 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { holder.butAction.setFocusable(false); holder.butAction.setOnClickListener(onButActionClicked); + return convertView; } @@ -129,4 +144,14 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { ImageButton butAction; RelativeLayout encInfo; } + + public int getSelectedItemIndex() { + return selectedItemIndex; + } + + public void setSelectedItemIndex(int selectedItemIndex) { + this.selectedItemIndex = selectedItemIndex; + notifyDataSetChanged(); + } + } diff --git a/src/de/podfetcher/adapter/FeedlistAdapter.java b/src/de/podfetcher/adapter/FeedlistAdapter.java index 99676e866..9cf37793b 100644 --- a/src/de/podfetcher/adapter/FeedlistAdapter.java +++ b/src/de/podfetcher/adapter/FeedlistAdapter.java @@ -24,9 +24,13 @@ import android.graphics.Color; public class FeedlistAdapter extends ArrayAdapter<Feed> { private static final String TAG = "FeedlistAdapter"; + private int selectedItemIndex; + public static final int SELECTION_NONE = -1; + public FeedlistAdapter(Context context, int textViewResourceId, List<Feed> objects) { super(context, textViewResourceId, objects); + selectedItemIndex = SELECTION_NONE; } @Override @@ -57,6 +61,13 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> { holder = (Holder) convertView.getTag(); } + if (position == selectedItemIndex) { + convertView.setBackgroundColor(convertView.getResources().getColor( + R.color.selection_background)); + } else { + convertView.setBackgroundResource(0); + } + holder.title.setText(feed.getTitle()); holder.lastUpdate.setText("Last Update: " + DateUtils.formatSameDayTime(feed.getLastUpdate().getTime(), @@ -93,4 +104,13 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> { ImageView image; } + public int getSelectedItemIndex() { + return selectedItemIndex; + } + + public void setSelectedItemIndex(int selectedItemIndex) { + this.selectedItemIndex = selectedItemIndex; + notifyDataSetChanged(); + } + } diff --git a/src/de/podfetcher/fragment/FeedlistFragment.java b/src/de/podfetcher/fragment/FeedlistFragment.java index c76e3c051..1003aa068 100644 --- a/src/de/podfetcher/fragment/FeedlistFragment.java +++ b/src/de/podfetcher/fragment/FeedlistFragment.java @@ -28,7 +28,8 @@ import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; import android.util.Log; -public class FeedlistFragment extends SherlockListFragment { +public class FeedlistFragment extends SherlockListFragment implements + ActionMode.Callback { private static final String TAG = "FeedlistFragment"; public static final String EXTRA_SELECTED_FEED = "extra.de.podfetcher.activity.selected_feed"; @@ -83,9 +84,10 @@ public class FeedlistFragment extends SherlockListFragment { if (mActionMode != null) { mActionMode.finish(); } + fla.setSelectedItemIndex(position); selectedFeed = selection; mActionMode = getSherlockActivity().startActionMode( - mActionModeCallback); + FeedlistFragment.this); } return true; @@ -132,48 +134,45 @@ public class FeedlistFragment extends SherlockListFragment { pActivity.startActivity(showFeed); } - private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() { - - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - FeedMenuHandler.onCreateOptionsMenu(mode.getMenuInflater(), menu); - mode.setTitle(selectedFeed.getTitle()); - return true; - } + @Override + public boolean onCreateActionMode(ActionMode mode, Menu menu) { + FeedMenuHandler.onCreateOptionsMenu(mode.getMenuInflater(), menu); + mode.setTitle(selectedFeed.getTitle()); + return true; + } - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - return FeedMenuHandler.onPrepareOptionsMenu(menu, selectedFeed); - } + @Override + public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + return FeedMenuHandler.onPrepareOptionsMenu(menu, selectedFeed); + } - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - if (FeedMenuHandler.onOptionsItemClicked(getSherlockActivity(), - item, selectedFeed)) { - fla.notifyDataSetChanged(); - } else { - switch (item.getItemId()) { - case R.id.remove_item: - FeedRemover remover = new FeedRemover(getSherlockActivity()) { - @Override - protected void onPostExecute(Void result) { - super.onPostExecute(result); - fla.notifyDataSetChanged(); - } - }; - remover.execute(selectedFeed); - break; - } + @Override + public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + if (FeedMenuHandler.onOptionsItemClicked(getSherlockActivity(), item, + selectedFeed)) { + fla.notifyDataSetChanged(); + } else { + switch (item.getItemId()) { + case R.id.remove_item: + FeedRemover remover = new FeedRemover(getSherlockActivity()) { + @Override + protected void onPostExecute(Void result) { + super.onPostExecute(result); + fla.notifyDataSetChanged(); + } + }; + remover.execute(selectedFeed); + break; } - mode.finish(); - return true; } + mode.finish(); + return true; + } - @Override - public void onDestroyActionMode(ActionMode mode) { - mActionMode = null; - selectedFeed = null; - - } - }; + @Override + public void onDestroyActionMode(ActionMode mode) { + mActionMode = null; + selectedFeed = null; + fla.setSelectedItemIndex(FeedlistAdapter.SELECTION_NONE); + } } diff --git a/src/de/podfetcher/fragment/ItemlistFragment.java b/src/de/podfetcher/fragment/ItemlistFragment.java index ff1f4cc7c..438f0873d 100644 --- a/src/de/podfetcher/fragment/ItemlistFragment.java +++ b/src/de/podfetcher/fragment/ItemlistFragment.java @@ -140,6 +140,7 @@ public class ItemlistFragment extends SherlockListFragment implements selectedItem = newSelectedItem; mActionMode = getSherlockActivity().startActionMode( ItemlistFragment.this); + fila.setSelectedItemIndex(index); } else { mActionMode.finish(); } @@ -151,6 +152,7 @@ public class ItemlistFragment extends SherlockListFragment implements @Override public void onViewCreated(View view, Bundle savedInstanceState) { this.getListView().setItemsCanFocus(true); + getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); } @Override @@ -162,6 +164,7 @@ public class ItemlistFragment extends SherlockListFragment implements public void onDestroyActionMode(ActionMode mode) { mActionMode = null; selectedItem = null; + fila.setSelectedItemIndex(FeedItemlistAdapter.SELECTION_NONE); } @Override |