Browse Source

Fixed #17 so that the list view rows show a proper selection (activation) background colour.

pull/82/head
Eric Kok 11 years ago
parent
commit
2aef2f0f78
  1. 26
      core/res/drawable/activatable_background_transdroid.xml
  2. 26
      core/res/drawable/activatable_background_transdroid2.xml
  3. 3
      core/res/layout/fragment_details.xml
  4. 2
      core/res/layout/fragment_filters.xml
  5. 2
      core/res/layout/fragment_rssfeeds.xml
  6. 2
      core/res/layout/fragment_rssitems.xml
  7. 2
      core/res/layout/fragment_searchresults.xml
  8. 2
      core/res/layout/fragment_torrents.xml
  9. 1
      core/res/layout/list_item_filter.xml
  10. 7
      core/res/layout/list_item_rssfeed.xml
  11. 2
      core/res/layout/list_item_rssitem.xml
  12. 2
      core/res/layout/list_item_searchresult.xml
  13. 5
      core/res/layout/list_item_searchsite.xml
  14. 2
      core/res/layout/list_item_torrent.xml
  15. 2
      core/res/layout/list_item_torrentfile.xml
  16. 1
      core/res/values/attrs.xml
  17. 2
      core/res/values/styles.xml
  18. 105
      core/src/fr/marvinlabs/widget/CheckableRelativeLayout.java
  19. 75
      core/src/fr/marvinlabs/widget/InertCheckBox.java
  20. 6
      core/src/org/transdroid/core/gui/DetailsFragment.java
  21. 4
      core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java
  22. 4
      core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java
  23. 4
      core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java
  24. 4
      core/src/org/transdroid/core/gui/search/SearchResultView.java

26
core/res/drawable/activatable_background_transdroid.xml

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime" >
<item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/list_focused_transdroid" />
<item android:state_pressed="true" android:drawable="@drawable/pressed_background_transdroid" />
<item android:state_activated="true" android:drawable="@drawable/list_focused_transdroid" />
<item android:drawable="@android:color/transparent" />
</selector>

26
core/res/drawable/activatable_background_transdroid2.xml

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime" >
<item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/list_focused_transdroid2" />
<item android:state_pressed="true" android:drawable="@drawable/pressed_background_transdroid2" />
<item android:state_activated="true" android:drawable="@drawable/list_focused_transdroid2" />
<item android:drawable="@android:color/transparent" />
</selector>

3
core/res/layout/fragment_details.xml

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/details_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@ -26,7 +27,7 @@ @@ -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" />
<ProgressBar

2
core/res/layout/fragment_filters.xml

@ -24,6 +24,6 @@ @@ -24,6 +24,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:listSelector="?attr/selectable_background_transdroid" />
android:listSelector="@null" />
</FrameLayout>

2
core/res/layout/fragment_rssfeeds.xml

@ -24,7 +24,7 @@ @@ -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" />
<TextView

2
core/res/layout/fragment_rssitems.xml

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="multipleChoiceModal"
android:listSelector="?attr/selectable_background_transdroid"
android:listSelector="@null"
android:visibility="gone" />
<TextView

2
core/res/layout/fragment_searchresults.xml

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="multipleChoiceModal"
android:listSelector="?attr/selectable_background_transdroid"
android:listSelector="@null"
android:visibility="gone" />
<ProgressBar

2
core/res/layout/fragment_torrents.xml

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="multipleChoiceModal"
android:listSelector="?attr/selectable_background_transdroid"
android:listSelector="@null"
android:visibility="gone" />
<ProgressBar

1
core/res/layout/list_item_filter.xml

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/activatable_background_transdroid"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default"

7
core/res/layout/list_item_rssfeed.xml

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/activatable_background_transdroid"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"
@ -37,8 +38,8 @@ @@ -37,8 +38,8 @@
android:id="@+id/name_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="1dip"
android:layout_weight="1"
android:textIsSelectable="false" />
<TextView
@ -46,9 +47,9 @@ @@ -46,9 +47,9 @@
style="@style/LabelTextView"
android:layout_width="wrap_content"
android:layout_height="24dip"
android:gravity="center_horizontal"
android:minWidth="24dip"
android:paddingLeft="4dip"
android:gravity="center_horizontal"
android:textIsSelectable="false" />
<ProgressBar
@ -59,4 +60,4 @@ @@ -59,4 +60,4 @@
android:indeterminate="true"
android:indeterminateOnly="true" />
</LinearLayout>
</LinearLayout>

2
core/res/layout/list_item_rssitem.xml

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<org.transdroid.core.gui.rss.RssitemStatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/selectable_background_transdroid"
android:background="?attr/activatable_background_transdroid"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default"

2
core/res/layout/list_item_searchresult.xml

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<org.transdroid.core.gui.rss.RssitemStatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/selectable_background_transdroid"
android:background="?attr/activatable_background_transdroid"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default"

5
core/res/layout/list_item_searchsite.xml

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/activatable_background_transdroid"
android:orientation="horizontal"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"
@ -37,8 +38,8 @@ @@ -37,8 +38,8 @@
android:id="@+id/name_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="1dip"
android:layout_weight="1"
android:textIsSelectable="false" />
</LinearLayout>
</LinearLayout>

2
core/res/layout/list_item_torrent.xml

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<org.transdroid.core.gui.lists.TorrentStatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/selectable_background_transdroid"
android:background="?attr/activatable_background_transdroid"
android:orientation="vertical"
android:paddingRight="@dimen/margin_default" >

2
core/res/layout/list_item_torrentfile.xml

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<org.transdroid.core.gui.lists.TorrentFilePriorityLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/selectable_background_transdroid"
android:background="?attr/activatable_background_transdroid"
android:orientation="vertical"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"

1
core/res/values/attrs.xml

@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
<attr name="ic_action_website" format="reference"/>
<attr name="ic_action_done" format="reference"/>
<attr name="loading_progress" format="reference"/>
<attr name="activatable_background_transdroid" format="reference"/>
<attr name="selectable_background_transdroid" format="reference"/>
<attr name="text_bright" format="reference" />
<attr name="text_actionbar" format="reference" />

2
core/res/values/styles.xml

@ -43,6 +43,7 @@ @@ -43,6 +43,7 @@
<item name="ic_action_trackers">@drawable/ic_action_trackers_light</item>
<item name="ic_action_website">@drawable/ic_action_website_light</item>
<item name="loading_progress">@drawable/loading_progress_light</item>
<item name="activatable_background_transdroid">@drawable/activatable_background_transdroid2</item>
<item name="selectable_background_transdroid">@drawable/selectable_background_transdroid2</item>
<item name="text_bright">@color/text_bright_light</item>
<item name="text_actionbar">@color/text_actionbar_light</item>
@ -75,6 +76,7 @@ @@ -75,6 +76,7 @@
<item name="ic_action_trackers">@drawable/ic_action_trackers_dark</item>
<item name="ic_action_website">@drawable/ic_action_website_dark</item>
<item name="loading_progress">@drawable/loading_progress_dark</item>
<item name="activatable_background_transdroid">@drawable/activatable_background_transdroid</item>
<item name="selectable_background_transdroid">@drawable/selectable_background_transdroid</item>
<item name="text_bright">@color/text_bright_dark</item>
<item name="text_actionbar">@color/text_actionbar_dark</item>

105
core/src/fr/marvinlabs/widget/CheckableRelativeLayout.java

@ -1,105 +0,0 @@ @@ -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<Checkable> 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<Checkable>(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));
}
}
}
}

75
core/src/fr/marvinlabs/widget/InertCheckBox.java

@ -1,75 +0,0 @@ @@ -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;
}
}

6
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -92,6 +92,8 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -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 @@ -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);
}
}

4
core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java

@ -24,7 +24,7 @@ import android.graphics.Canvas; @@ -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; @@ -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);

4
core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java

@ -24,7 +24,7 @@ import android.graphics.Canvas; @@ -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; @@ -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);

4
core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java

@ -21,14 +21,14 @@ import android.graphics.Canvas; @@ -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);

4
core/src/org/transdroid/core/gui/search/SearchResultView.java

@ -23,15 +23,15 @@ import org.transdroid.core.app.search.SearchResult; @@ -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

Loading…
Cancel
Save