Browse Source

Merge branch 'dev'

pull/82/head
Eric Kok 11 years ago
parent
commit
565c2730f6
  1. 26
      core/res/drawable/activatable_background_transdroid.xml
  2. 26
      core/res/drawable/activatable_background_transdroid2.xml
  3. 16
      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. 38
      core/src/org/transdroid/core/gui/DetailsActivity.java
  21. 46
      core/src/org/transdroid/core/gui/DetailsFragment.java
  22. 5
      core/src/org/transdroid/core/gui/TorrentTasksExecutor.java
  23. 42
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  24. 28
      core/src/org/transdroid/core/gui/TorrentsFragment.java
  25. 4
      core/src/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java
  26. 4
      core/src/org/transdroid/core/gui/lists/TorrentStatusLayout.java
  27. 28
      core/src/org/transdroid/core/gui/navigation/RefreshableActivity.java
  28. 4
      core/src/org/transdroid/core/gui/rss/RssitemStatusLayout.java
  29. 5
      core/src/org/transdroid/core/gui/rss/RssitemsFragment.java
  30. 4
      core/src/org/transdroid/core/gui/search/SearchResultView.java
  31. 5
      core/src/org/transdroid/core/gui/search/SearchResultsFragment.java
  32. 4
      core/src/org/transdroid/core/service/ConnectivityHelper.java
  33. 6
      core/src/org/transdroid/core/widget/WidgetConfigActivity.java
  34. 102
      core/src/org/transdroid/core/widget/WidgetPreviewAdapter.java
  35. 2
      full/AndroidManifest.xml

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>

16
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
@ -52,4 +53,17 @@ @@ -52,4 +53,17 @@
android:textIsSelectable="false"
android:visibility="visible" />
<TextView
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="8dip"
android:drawableTop="?attr/loading_progress"
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:textIsSelectable="false"
android:visibility="gone" />
</FrameLayout>

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;
}
}

38
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -35,6 +35,7 @@ import org.transdroid.core.gui.lists.LocalTorrent; @@ -35,6 +35,7 @@ import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.IDaemonAdapter;
@ -79,7 +80,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -79,7 +80,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/
@EActivity(resName = "activity_details")
@OptionsMenu(resName = "activity_details")
public class DetailsActivity extends SherlockFragmentActivity implements TorrentTasksExecutor {
public class DetailsActivity extends SherlockFragmentActivity implements TorrentTasksExecutor, RefreshableActivity {
@Extra
@InstanceState
@ -148,8 +149,8 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -148,8 +149,8 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
}
@OptionsItem(resName = "action_refresh")
protected void refreshScreen() {
fragmentDetails.updateIsLoading(true);
public void refreshScreen() {
fragmentDetails.updateIsLoading(true, null);
refreshTorrent();
refreshTorrentDetails(torrent);
refreshTorrentFiles(torrent);
@ -162,7 +163,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -162,7 +163,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(),
((RetrieveTaskSuccessResult) result).getLabels());
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, true);
}
}
@ -174,7 +175,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -174,7 +175,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof GetTorrentDetailsTaskSuccessResult) {
onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails());
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -186,7 +187,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -186,7 +187,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof GetFileListTaskSuccessResult) {
onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles());
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -198,7 +199,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -198,7 +199,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -210,7 +211,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -210,7 +211,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -222,7 +223,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -222,7 +223,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -234,7 +235,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -234,7 +235,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -247,7 +248,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -247,7 +248,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed,
torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -267,7 +268,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -267,7 +268,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -278,7 +279,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -278,7 +279,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -289,7 +290,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -289,7 +290,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -301,7 +302,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -301,7 +302,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@ -326,9 +327,10 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -326,9 +327,10 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
}
@UiThread
protected void onCommunicationError(DaemonTaskFailureResult result) {
protected void onCommunicationError(DaemonTaskFailureResult result, boolean isCritical) {
Log.i(this, result.getException().toString());
fragmentDetails.updateIsLoading(false);
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
fragmentDetails.updateIsLoading(false, isCritical? error: null);
Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())),
NavigationHelper.CROUTON_ERROR_STYLE);
}
@ -336,7 +338,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -336,7 +338,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread
protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) {
// Update the details fragment accordingly
fragmentDetails.updateIsLoading(false);
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.perhapsUpdateTorrent(torrents);
fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels,
getResources().getString(R.string.labels_unlabeled)));

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

@ -21,6 +21,7 @@ import java.util.Collections; @@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.OptionsItem;
@ -34,6 +35,7 @@ import org.transdroid.core.gui.lists.SimpleListItemAdapter; @@ -34,6 +35,7 @@ import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.navigation.SetLabelDialog;
import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener;
@ -85,13 +87,17 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -85,13 +87,17 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
protected ArrayList<Label> currentLabels = null;
@InstanceState
protected boolean isLoadingTorrent = false;
@InstanceState
protected boolean hasCriticalError = false;
private ServerSetting currentServerSettings = null;
// Views
@ViewById(resName = "details_container")
protected View detailsContainer;
@ViewById(resName = "details_list")
protected SherlockListView detailsList;
@ViewById
protected TextView emptyText;
protected TextView emptyText, errorText;
@ViewById
protected ProgressBar loadingProgress;
@ -102,9 +108,9 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -102,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);
}
}
@ -128,19 +134,22 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -128,19 +134,22 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
/**
* Updates the details adapter header to show the new torrent data.
* @param newTorrent The new torrent object
* @param newTorrent The new, non-null torrent object
*/
public void updateTorrent(Torrent newTorrent) {
clear();
this.torrent = newTorrent;
this.hasCriticalError = false;
((DetailsAdapter) detailsList.getAdapter()).updateTorrent(newTorrent);
// Make the list (with details header) visible
detailsList.setVisibility(View.VISIBLE);
emptyText.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
// Also update the available actions in the action bar
getActivity().supportInvalidateOptionsMenu();
// Refresh the detailed statistics (errors) and list of files
torrentDetails = null;
torrentFiles = null;
getTasksExecutor().refreshTorrentDetails(torrent);
getTasksExecutor().refreshTorrentFiles(torrent);
}
@ -208,7 +217,8 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -208,7 +217,8 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
public void clear() {
detailsList.setAdapter(new DetailsAdapter(getActivity()));
detailsList.setVisibility(View.GONE);
emptyText.setVisibility(!isLoadingTorrent ? View.VISIBLE : View.GONE);
emptyText.setVisibility(!isLoadingTorrent && !hasCriticalError ? View.VISIBLE : View.GONE);
errorText.setVisibility(!isLoadingTorrent && hasCriticalError ? View.VISIBLE : View.GONE);
loadingProgress.setVisibility(isLoadingTorrent ? View.VISIBLE : View.GONE);
// Note: this.torrent is not cleared as we need to know later what the fragment was originally bound to
torrentDetails = null;
@ -218,10 +228,13 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -218,10 +228,13 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
/**
* Updates the shown screen depending on whether the torrent is loading
* @param isLoading True if the torrent is (re)loading, false otherwise
* @param connectionErrorMessage The error message text to show to the user, or null if there was no error
*/
public void updateIsLoading(boolean isLoading) {
public void updateIsLoading(boolean isLoading, String connectionErrorMessage) {
this.isLoadingTorrent = isLoading;
if (isLoadingTorrent)
this.hasCriticalError = connectionErrorMessage != null;
errorText.setText(connectionErrorMessage);
if (isLoading || hasCriticalError)
clear();
}
@ -238,6 +251,7 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -238,6 +251,7 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
menu.findItem(R.id.action_remove_withdata).setVisible(false);
menu.findItem(R.id.action_setlabel).setVisible(false);
menu.findItem(R.id.action_updatetrackers).setVisible(false);
menu.findItem(R.id.action_changelocation).setVisible(false);
return;
}
// Update action availability
@ -330,6 +344,22 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -330,6 +344,22 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
getTasksExecutor().updateLocation(torrent, newLocation);
}
@Click
protected void emptyTextClicked() {
// Refresh the activity (that contains this fragment) when the empty view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
@Click
protected void errorTextClicked() {
// Refresh the activity (that contains this fragment) when the error view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
private MultiChoiceModeListenerCompat onDetailsSelected = new MultiChoiceModeListenerCompat() {
SelectionManagerMode selectionManagerMode;

5
core/src/org/transdroid/core/gui/TorrentTasksExecutor.java

@ -22,6 +22,11 @@ import org.transdroid.daemon.Priority; @@ -22,6 +22,11 @@ import org.transdroid.daemon.Priority;
import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentFile;
/**
* Interface to be implemented by any activity that wants containing fragments to be able to load data and execute
* commands against a torrent server.
* @author Eric Kok
*/
public interface TorrentTasksExecutor {
void resumeTorrent(Torrent torrent);
void pauseTorrent(Torrent torrent);

42
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -122,7 +122,8 @@ import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -122,7 +122,8 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/
@EActivity(resName = "activity_torrents")
@OptionsMenu(resName = "activity_torrents")
public class TorrentsActivity extends SherlockFragmentActivity implements OnNavigationListener, TorrentTasksExecutor {
public class TorrentsActivity extends SherlockFragmentActivity implements OnNavigationListener, TorrentTasksExecutor,
RefreshableActivity {
// Navigation components
@Bean
@ -143,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -143,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected ApplicationSettings applicationSettings;
@InstanceState
boolean firstStart = true;
boolean skipNextOnNavigationItemSelectedCall = false;
int skipNextOnNavigationItemSelectedCalls = 2;
private IDaemonAdapter currentConnection = null;
@InstanceState
protected NavigationFilter currentFilter = null;
@ -207,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -207,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Log messages from the server daemons using our singleton logger
DLog.setLogger(Log_.getInstance_(this));
// Connect to the last used server or a server that was supplied in the starting intent
// Connect to the last used server or a server that was explicitly supplied in the starting intent
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
if (lastUsed == null) {
// No server settings yet;
@ -229,15 +230,15 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -229,15 +230,15 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
// Set this as selection in the action bar spinner; we can use the server setting key since we have stable ids
// Note: skipNextOnNavigationItemSelectedCalls is used to prevent this event from triggering filterSelected
getSupportActionBar().setSelectedNavigationItem(lastUsed.getOrder() + 1);
skipNextOnNavigationItemSelectedCall = true;
filterSelected(lastUsed, true);
// Handle any start up intents
if (startTorrent != null) {
openDetails(startTorrent);
startTorrent = null;
} else if (firstStart && getIntent() != null) {
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName());
handleStartIntent();
}
@ -257,10 +258,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -257,10 +258,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if (lastUsed == null) {
// Still no settings
updateFragmentVisibility(false);
// There is a server know (now): forcefully select it to establish a connection
filterSelected(lastUsed, true);
return;
}
// There is a server know (now): forcefully select it to establish a connection
filterSelected(lastUsed, true);
// If we had no connection before, establish it now
if (currentConnection == null)
filterSelected(lastUsed, true);
}
@Override
@ -334,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -334,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
*/
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
if (skipNextOnNavigationItemSelectedCall) {
skipNextOnNavigationItemSelectedCall = false;
if (skipNextOnNavigationItemSelectedCalls > 0) {
skipNextOnNavigationItemSelectedCalls--;
return false;
}
Object item = navigationSpinnerAdapter.getItem(itemPosition);
@ -353,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -353,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
filtersList.setItemChecked(position, true);
filterSelected((SimpleListItem) filtersList.getAdapter().getItem(position), false);
Object item = filtersList.getAdapter().getItem(position);
if (item instanceof SimpleListItem)
filterSelected((SimpleListItem) item, false);
}
};
@ -385,6 +392,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -385,6 +392,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true);
if (fragmentDetails != null && fragmentDetails.getActivity() != null) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear();
fragmentDetails.setCurrentServerSettings(server);
}
@ -401,6 +409,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -401,6 +409,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
// Clear the details view
if (fragmentDetails != null) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear();
}
}
@ -422,6 +431,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -422,6 +431,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
supportInvalidateOptionsMenu();
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleStartIntent();
}
/**
* If required, add torrents, switch to a specific server, etc.
@ -547,7 +562,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -547,7 +562,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
@OptionsItem(resName = "action_refresh")
protected void refreshScreen() {
public void refreshScreen() {
fragmentTorrents.updateIsLoading(true);
refreshTorrents();
if (Daemon.supportsStats(currentConnection.getType()))
@ -942,8 +957,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -942,8 +957,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
Crouton.showText(this, error, NavigationHelper.CROUTON_ERROR_STYLE);
fragmentTorrents.updateIsLoading(false);
if (isCritical)
if (isCritical) {
fragmentTorrents.updateError(error);
if (fragmentDetails != null)
fragmentDetails.updateIsLoading(false, error);
}
}
@UiThread

28
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -23,6 +23,7 @@ import java.util.Locale; @@ -23,6 +23,7 @@ import java.util.Locale;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick;
@ -33,6 +34,7 @@ import org.transdroid.core.gui.lists.TorrentsAdapter; @@ -33,6 +34,7 @@ import org.transdroid.core.gui.lists.TorrentsAdapter;
import org.transdroid.core.gui.lists.TorrentsAdapter_;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.navigation.SetLabelDialog;
import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener;
@ -304,6 +306,22 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL @@ -304,6 +306,22 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
};
@Click
protected void emptyTextClicked() {
// Refresh the activity (that contains this fragment) when the empty view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
@Click
protected void errorTextClicked() {
// Refresh the activity (that contains this fragment) when the error view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
@ItemClick(resName = "torrent_list")
protected void torrentsListClicked(Torrent torrent) {
((TorrentsActivity) getActivity()).openDetails(torrent);
@ -325,6 +343,11 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL @@ -325,6 +343,11 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
this.hasAConnection = hasAConnection;
this.daemonType = daemonType;
if (!hasAConnection) {
torrentsList.setVisibility(View.GONE);
emptyText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
nosettingsText.setVisibility(View.VISIBLE);
clear(true, true); // Indirectly also calls updateViewVisibility()
} else {
updateViewVisibility();
@ -363,11 +386,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL @@ -363,11 +386,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
private void updateViewVisibility() {
if (!hasAConnection) {
torrentsList.setVisibility(View.GONE);
emptyText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
nosettingsText.setVisibility(View.VISIBLE);
return;
}
boolean isEmpty = torrents == null || torrentsList.getAdapter().isEmpty();

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);

28
core/src/org/transdroid/core/gui/navigation/RefreshableActivity.java

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
/*
* Copyright 2010-2013 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.navigation;
/**
* Interface to be implemented by any activity that allows its content to be refreshed; fragments can ask for
* user-initiated refreshes.
* @author Eric Kok
*/
public interface RefreshableActivity {
public void refreshScreen();
}

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);

5
core/src/org/transdroid/core/gui/rss/RssitemsFragment.java

@ -26,6 +26,7 @@ import org.androidannotations.annotations.InstanceState; @@ -26,6 +26,7 @@ import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item;
@ -99,7 +100,9 @@ public class RssitemsFragment extends SherlockFragment { @@ -99,7 +100,9 @@ public class RssitemsFragment extends SherlockFragment {
@ItemClick(resName = "rssitems_list")
protected void onItemClicked(Item item) {
Intent i = new Intent(Intent.ACTION_VIEW, item.getTheLinkUri());
// Don't broadcast this intent; we can safely assume this is intended for Transdroid only
Intent i = TorrentsActivity_.intent(getActivity()).get();
i.setData(item.getTheLinkUri());
i.putExtra("TORRENT_TITLE", item.getTitle());
startActivity(i);
}

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

5
core/src/org/transdroid/core/gui/search/SearchResultsFragment.java

@ -33,6 +33,7 @@ import org.transdroid.core.app.search.SearchHelper.SearchSortOrder; @@ -33,6 +33,7 @@ import org.transdroid.core.app.search.SearchHelper.SearchSortOrder;
import org.transdroid.core.app.search.SearchResult;
import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
@ -121,7 +122,9 @@ public class SearchResultsFragment extends SherlockFragment { @@ -121,7 +122,9 @@ public class SearchResultsFragment extends SherlockFragment {
@ItemClick(resName = "searchresults_list")
protected void onItemClicked(SearchResult item) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(item.getTorrentUrl()));
// Don't broadcast this intent; we can safely assume this is intended for Transdroid only
Intent i = TorrentsActivity_.intent(getActivity()).get();
i.setData(Uri.parse(item.getTorrentUrl()));
i.putExtra("TORRENT_TITLE", item.getName());
startActivity(i);
}

4
core/src/org/transdroid/core/service/ConnectivityHelper.java

@ -42,7 +42,8 @@ public class ConnectivityHelper { @@ -42,7 +42,8 @@ public class ConnectivityHelper {
return false;
// Still good? Check the current active network instead
return connectivityManager.getActiveNetworkInfo().isConnected();
return connectivityManager.getActiveNetworkInfo() != null
&& connectivityManager.getActiveNetworkInfo().isConnected();
}
public String getConnectedNetworkName() {
@ -51,4 +52,5 @@ public class ConnectivityHelper { @@ -51,4 +52,5 @@ public class ConnectivityHelper {
}
return null;
}
}

6
core/src/org/transdroid/core/widget/WidgetConfigActivity.java

@ -32,7 +32,6 @@ import org.transdroid.core.app.settings.ApplicationSettings; @@ -32,7 +32,6 @@ import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.lists.SimpleListItemSpinnerAdapter;
import org.transdroid.core.gui.lists.SortByListItem;
import org.transdroid.core.gui.lists.TorrentsAdapter;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.navigation.StatusType.StatusTypeFilter;
import org.transdroid.core.service.ConnectivityHelper;
@ -76,8 +75,6 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -76,8 +75,6 @@ public class WidgetConfigActivity extends SherlockActivity {
protected TextView filterText, serverText, errorText;
@ViewById
protected ListView torrentsList;
@Bean
protected TorrentsAdapter previewTorrentsAdapter;
private List<Torrent> previewTorrents = null;
// Settings and helpers
@ -122,7 +119,6 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -122,7 +119,6 @@ public class WidgetConfigActivity extends SherlockActivity {
sortSpinner.setAdapter(new SimpleListItemSpinnerAdapter<SortByListItem>(this, 0, sortOrders));
// TODO: Update to AndroidAnnotations 3.0 and use @CheckedChanged
reverseorderCheckBox.setOnCheckedChangeListener(reverseorderCheckedChanged);
torrentsList.setAdapter(previewTorrentsAdapter);
torrentsList.setEmptyView(errorText);
// Set up action bar with a done button
@ -215,7 +211,7 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -215,7 +211,7 @@ public class WidgetConfigActivity extends SherlockActivity {
.sort(filteredTorrents, new TorrentsComparator(serverType, sortBy, reverseorderCheckBox.isChecked()));
// Finally update the widget preview with the live, filtered and sorted torrents list
previewTorrentsAdapter.update(filteredTorrents);
torrentsList.setAdapter(new WidgetPreviewAdapter(this, 0, filteredTorrents));
torrentsList.setVisibility(View.VISIBLE);
errorText.setVisibility(View.GONE);
}

102
core/src/org/transdroid/core/widget/WidgetPreviewAdapter.java

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
/*
* Copyright 2010-2013 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.widget;
import java.util.List;
import org.transdroid.core.R;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.daemon.Torrent;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
/**
* A list list item adapter that shows torrents as simplified, widget-style list items; the light theme is always used.
* @author Eric Kok
*/
public class WidgetPreviewAdapter extends ArrayAdapter<Torrent> {
/**
* Constructs the custom array adapter that shows torrents in a widget list style for preview.
* @param context The widget configuration activity context
* @param foo Ignored parameter; the light theme widget appearance is always used
* @param torrents The already-retrieved, non-null list of torrents to show
*/
public WidgetPreviewAdapter(Context context, int foo, List<Torrent> torrents) {
super(context, R.layout.list_item_widget_light, torrents);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the views
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_widget_light, parent, false);
holder = new ViewHolder();
holder.nameText = (TextView) convertView.findViewById(R.id.name_text);
holder.progressText = (TextView) convertView.findViewById(R.id.progress_text);
holder.ratioText = (TextView) convertView.findViewById(R.id.ratio_text);
holder.statusView = convertView.findViewById(R.id.status_view);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// Bind the torrent values
Torrent torrent = getItem(position);
LocalTorrent local = LocalTorrent.fromTorrent(torrent);
int statusColour;
switch (torrent.getStatusCode()) {
case Downloading:
statusColour = R.color.torrent_downloading;
break;
case Paused:
statusColour = R.color.torrent_paused;
break;
case Seeding:
statusColour = R.color.torrent_seeding;
break;
case Error:
statusColour = R.color.torrent_error;
break;
default: // Checking, Waiting, Queued, Unknown
statusColour = R.color.torrent_other;
break;
}
holder.nameText.setText(torrent.getName());
holder.progressText.setText(local.getProgressSizeText(getContext().getResources(), false));
holder.ratioText.setText(local.getProgressEtaRatioText(getContext().getResources()));
holder.statusView.setBackgroundColor(getContext().getResources().getColor(statusColour));
return convertView;
}
protected static class ViewHolder {
public TextView nameText;
public TextView progressText;
public TextView ratioText;
public View statusView;
}
}

2
full/AndroidManifest.xml

@ -53,6 +53,7 @@ @@ -53,6 +53,7 @@
<activity
android:name="org.transdroid.core.gui.TorrentsActivity_"
android:allowTaskReparenting="true"
android:launchMode="singleTop"
android:label="@string/app_name"
android:theme="@style/TransdroidTheme"
android:uiOptions="splitActionBarWhenNarrow" >
@ -227,6 +228,7 @@ @@ -227,6 +228,7 @@
<activity
android:name="org.transdroid.core.gui.rss.RssfeedsActivity_"
android:label="@string/rss_feeds"
android:launchMode="singleTop"
android:theme="@style/TransdroidTheme" />
<activity
android:name="org.transdroid.core.gui.rss.RssitemsActivity_"

Loading…
Cancel
Save