From 2aef2f0f789f2afc5337f53fbad9b390c88ef136 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Fri, 11 Oct 2013 17:28:00 +0200 Subject: [PATCH] Fixed #17 so that the list view rows show a proper selection (activation) background colour. --- .../activatable_background_transdroid.xml | 26 +++++ .../activatable_background_transdroid2.xml | 26 +++++ core/res/layout/fragment_details.xml | 3 +- core/res/layout/fragment_filters.xml | 2 +- core/res/layout/fragment_rssfeeds.xml | 2 +- core/res/layout/fragment_rssitems.xml | 2 +- core/res/layout/fragment_searchresults.xml | 2 +- core/res/layout/fragment_torrents.xml | 2 +- core/res/layout/list_item_filter.xml | 1 + core/res/layout/list_item_rssfeed.xml | 7 +- core/res/layout/list_item_rssitem.xml | 2 +- core/res/layout/list_item_searchresult.xml | 2 +- core/res/layout/list_item_searchsite.xml | 5 +- core/res/layout/list_item_torrent.xml | 2 +- core/res/layout/list_item_torrentfile.xml | 2 +- core/res/values/attrs.xml | 1 + core/res/values/styles.xml | 2 + .../widget/CheckableRelativeLayout.java | 105 ------------------ .../fr/marvinlabs/widget/InertCheckBox.java | 75 ------------- .../transdroid/core/gui/DetailsFragment.java | 6 +- .../gui/lists/TorrentFilePriorityLayout.java | 4 +- .../core/gui/lists/TorrentStatusLayout.java | 4 +- .../core/gui/rss/RssitemStatusLayout.java | 4 +- .../core/gui/search/SearchResultView.java | 4 +- 24 files changed, 86 insertions(+), 205 deletions(-) create mode 100644 core/res/drawable/activatable_background_transdroid.xml create mode 100644 core/res/drawable/activatable_background_transdroid2.xml delete mode 100644 core/src/fr/marvinlabs/widget/CheckableRelativeLayout.java delete mode 100644 core/src/fr/marvinlabs/widget/InertCheckBox.java diff --git a/core/res/drawable/activatable_background_transdroid.xml b/core/res/drawable/activatable_background_transdroid.xml new file mode 100644 index 00000000..20757ad7 --- /dev/null +++ b/core/res/drawable/activatable_background_transdroid.xml @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/res/drawable/activatable_background_transdroid2.xml b/core/res/drawable/activatable_background_transdroid2.xml new file mode 100644 index 00000000..c6c078b0 --- /dev/null +++ b/core/res/drawable/activatable_background_transdroid2.xml @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file diff --git a/core/res/layout/fragment_details.xml b/core/res/layout/fragment_details.xml index e2700c2c..96e5a962 100644 --- a/core/res/layout/fragment_details.xml +++ b/core/res/layout/fragment_details.xml @@ -16,6 +16,7 @@ along with Transdroid. If not, see . --> @@ -26,7 +27,7 @@ android:choiceMode="multipleChoiceModal" android:divider="@null" android:dividerHeight="0dip" - android:listSelector="?attr/selectable_background_transdroid" + android:listSelector="@null" android:visibility="gone" /> + android:listSelector="@null" /> diff --git a/core/res/layout/fragment_rssfeeds.xml b/core/res/layout/fragment_rssfeeds.xml index 8eb1f7a4..eb64ec87 100644 --- a/core/res/layout/fragment_rssfeeds.xml +++ b/core/res/layout/fragment_rssfeeds.xml @@ -24,7 +24,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:choiceMode="singleChoice" - android:listSelector="?attr/selectable_background_transdroid" + android:listSelector="@null" android:visibility="gone" /> - + \ No newline at end of file diff --git a/core/res/layout/list_item_rssitem.xml b/core/res/layout/list_item_rssitem.xml index 9d0f93df..630d6a7d 100644 --- a/core/res/layout/list_item_rssitem.xml +++ b/core/res/layout/list_item_rssitem.xml @@ -18,7 +18,7 @@ - + \ No newline at end of file diff --git a/core/res/layout/list_item_torrent.xml b/core/res/layout/list_item_torrent.xml index 6d513ee1..def4594a 100644 --- a/core/res/layout/list_item_torrent.xml +++ b/core/res/layout/list_item_torrent.xml @@ -18,7 +18,7 @@ diff --git a/core/res/layout/list_item_torrentfile.xml b/core/res/layout/list_item_torrentfile.xml index 7eba161b..8decf552 100644 --- a/core/res/layout/list_item_torrentfile.xml +++ b/core/res/layout/list_item_torrentfile.xml @@ -18,7 +18,7 @@ + diff --git a/core/res/values/styles.xml b/core/res/values/styles.xml index 4e0cbf9a..0a3b3561 100644 --- a/core/res/values/styles.xml +++ b/core/res/values/styles.xml @@ -43,6 +43,7 @@ @drawable/ic_action_trackers_light @drawable/ic_action_website_light @drawable/loading_progress_light + @drawable/activatable_background_transdroid2 @drawable/selectable_background_transdroid2 @color/text_bright_light @color/text_actionbar_light @@ -75,6 +76,7 @@ @drawable/ic_action_trackers_dark @drawable/ic_action_website_dark @drawable/loading_progress_dark + @drawable/activatable_background_transdroid @drawable/selectable_background_transdroid @color/text_bright_dark @color/text_actionbar_dark diff --git a/core/src/fr/marvinlabs/widget/CheckableRelativeLayout.java b/core/src/fr/marvinlabs/widget/CheckableRelativeLayout.java deleted file mode 100644 index 93009032..00000000 --- a/core/src/fr/marvinlabs/widget/CheckableRelativeLayout.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Public Domain - * CheckableRelativeLayout.java by marvinlabs - * http://www.marvinlabs.com/2010/10/29/custom-listview-ability-check-items/ - */ -package fr.marvinlabs.widget; - -import java.util.ArrayList; -import java.util.List; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Checkable; -import android.widget.RelativeLayout; - -/** - * Extension of a relative layout to provide a checkable behaviour - * - * @author marvinlabs - */ -public class CheckableRelativeLayout extends RelativeLayout implements Checkable { - - private boolean isChecked; - private List checkableViews; - - public CheckableRelativeLayout(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - initialise(attrs); - } - - public CheckableRelativeLayout(Context context, AttributeSet attrs) { - super(context, attrs); - initialise(attrs); - } - - public CheckableRelativeLayout(Context context) { - super(context); - initialise(null); - } - - /* - * @see android.widget.Checkable#isChecked() - */ - public boolean isChecked() { - return isChecked; - } - - /* - * @see android.widget.Checkable#setChecked(boolean) - */ - public void setChecked(boolean isChecked) { - this.isChecked = isChecked; - for (Checkable c : checkableViews) { - c.setChecked(isChecked); - } - } - - /* - * @see android.widget.Checkable#toggle() - */ - public void toggle() { - this.isChecked = !this.isChecked; - for (Checkable c : checkableViews) { - c.toggle(); - } - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - - final int childCount = this.getChildCount(); - for (int i = 0; i < childCount; ++i) { - findCheckableChildren(this.getChildAt(i)); - } - } - - /** - * Read the custom XML attributes - */ - private void initialise(AttributeSet attrs) { - this.isChecked = false; - this.checkableViews = new ArrayList(5); - } - - /** - * Add to our checkable list all the children of the view that implement the - * interface Checkable - */ - private void findCheckableChildren(View v) { - if (v instanceof Checkable) { - this.checkableViews.add((Checkable) v); - } - - if (v instanceof ViewGroup) { - final ViewGroup vg = (ViewGroup) v; - final int childCount = vg.getChildCount(); - for (int i = 0; i < childCount; ++i) { - findCheckableChildren(vg.getChildAt(i)); - } - } - } -} diff --git a/core/src/fr/marvinlabs/widget/InertCheckBox.java b/core/src/fr/marvinlabs/widget/InertCheckBox.java deleted file mode 100644 index b2d0db4f..00000000 --- a/core/src/fr/marvinlabs/widget/InertCheckBox.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Public Domain - * InertCheckBox.java by marvinlabs - * http://www.marvinlabs.com/2010/10/29/custom-listview-ability-check-items/ - */ -package fr.marvinlabs.widget; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.widget.CheckBox; - -/** - * CheckBox that does not react to any user event in order to let the container handle them. - */ -public class InertCheckBox extends CheckBox { - - // Provide the same constructors as the superclass - public InertCheckBox(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - // Provide the same constructors as the superclass - public InertCheckBox(Context context, AttributeSet attrs) { - super(context, attrs); - } - - // Provide the same constructors as the superclass - public InertCheckBox(Context context) { - super(context); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - // Make the checkbox not respond to any user event - return false; - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - // Make the checkbox not respond to any user event - return false; - } - - @Override - public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) { - // Make the checkbox not respond to any user event - return false; - } - - @Override - public boolean onKeyPreIme(int keyCode, KeyEvent event) { - // Make the checkbox not respond to any user event - return false; - } - - @Override - public boolean onKeyShortcut(int keyCode, KeyEvent event) { - // Make the checkbox not respond to any user event - return false; - } - - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { - // Make the checkbox not respond to any user event - return false; - } - - @Override - public boolean onTrackballEvent(MotionEvent event) { - // Make the checkbox not respond to any user event - return false; - } -} diff --git a/core/src/org/transdroid/core/gui/DetailsFragment.java b/core/src/org/transdroid/core/gui/DetailsFragment.java index d934e154..d38c26d2 100644 --- a/core/src/org/transdroid/core/gui/DetailsFragment.java +++ b/core/src/org/transdroid/core/gui/DetailsFragment.java @@ -92,6 +92,8 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat private ServerSetting currentServerSettings = null; // Views + @ViewById(resName = "details_container") + protected View detailsContainer; @ViewById(resName = "details_list") protected SherlockListView detailsList; @ViewById @@ -106,9 +108,9 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat // line to separate the lists visually if (!NavigationHelper_.getInstance_(getActivity()).isSmallScreen()) { if (SystemSettings_.getInstance_(getActivity()).useDarkTheme()) { - detailsList.setBackgroundResource(R.drawable.details_list_background_dark); + detailsContainer.setBackgroundResource(R.drawable.details_list_background_dark); } else { - detailsList.setBackgroundResource(R.drawable.details_list_background_light); + detailsContainer.setBackgroundResource(R.drawable.details_list_background_light); } } diff --git a/core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java b/core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java index 480dfdaa..c53ba957 100644 --- a/core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java +++ b/core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java @@ -24,7 +24,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; -import fr.marvinlabs.widget.CheckableRelativeLayout; +import android.widget.RelativeLayout; /** * A relative layout that that is checkable (to be used in a contextual action bar) and shows a coloured bar in the far @@ -32,7 +32,7 @@ import fr.marvinlabs.widget.CheckableRelativeLayout; * the file isn't downloaded at all. * @author Eric Kok */ -public class TorrentFilePriorityLayout extends CheckableRelativeLayout { +public class TorrentFilePriorityLayout extends RelativeLayout { private final float scale = getContext().getResources().getDisplayMetrics().density; private final int WIDTH = (int) (6 * scale + 0.5f); diff --git a/core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java b/core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java index 7b9f6954..ea2cfedd 100644 --- a/core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java +++ b/core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java @@ -24,7 +24,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; -import fr.marvinlabs.widget.CheckableRelativeLayout; +import android.widget.RelativeLayout; /** * A relative layout that is checkable (to be used in a contextual action bar) and shows a coloured bar in the far left @@ -32,7 +32,7 @@ import fr.marvinlabs.widget.CheckableRelativeLayout; * red, etc. * @author Eric Kok */ -public class TorrentStatusLayout extends CheckableRelativeLayout { +public class TorrentStatusLayout extends RelativeLayout { private final float scale = getContext().getResources().getDisplayMetrics().density; private final int WIDTH = (int) (6 * scale + 0.5f); diff --git a/core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java b/core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java index 3a548f04..453cf7de 100644 --- a/core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java +++ b/core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java @@ -21,14 +21,14 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; -import fr.marvinlabs.widget.CheckableRelativeLayout; +import android.widget.RelativeLayout; /** * A relative layout that that is checkable (to be used in a contextual action bar) and shows a coloured bar in the far * left indicating the view status, that is, if the item is new to the user or was viewed earlier. * @author Eric Kok */ -public class RssitemStatusLayout extends CheckableRelativeLayout { +public class RssitemStatusLayout extends RelativeLayout { private final float scale = getContext().getResources().getDisplayMetrics().density; private final int WIDTH = (int) (6 * scale + 0.5f); diff --git a/core/src/org/transdroid/core/gui/search/SearchResultView.java b/core/src/org/transdroid/core/gui/search/SearchResultView.java index 13f0508d..6f2a2ad1 100644 --- a/core/src/org/transdroid/core/gui/search/SearchResultView.java +++ b/core/src/org/transdroid/core/gui/search/SearchResultView.java @@ -23,15 +23,15 @@ import org.transdroid.core.app.search.SearchResult; import android.content.Context; import android.text.format.DateUtils; +import android.widget.RelativeLayout; import android.widget.TextView; -import fr.marvinlabs.widget.CheckableRelativeLayout; /** * View that represents a {@link SearchResult} object from an in-app search * @author Eric Kok */ @EViewGroup(resName = "list_item_searchresult") -public class SearchResultView extends CheckableRelativeLayout { +public class SearchResultView extends RelativeLayout { // Views @ViewById