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 cc8306dd..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" /> + + diff --git a/core/res/layout/fragment_filters.xml b/core/res/layout/fragment_filters.xml index 191fec36..7bd32786 100644 --- a/core/res/layout/fragment_filters.xml +++ b/core/res/layout/fragment_filters.xml @@ -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" /> 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/DetailsActivity.java b/core/src/org/transdroid/core/gui/DetailsActivity.java index 3f6e1bd0..0f3c816d 100644 --- a/core/src/org/transdroid/core/gui/DetailsActivity.java +++ b/core/src/org/transdroid/core/gui/DetailsActivity.java @@ -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; */ @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 } @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 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 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 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 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 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 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 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 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 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 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 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 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 } @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 @UiThread protected void onTorrentsRetrieved(List torrents, List 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))); diff --git a/core/src/org/transdroid/core/gui/DetailsFragment.java b/core/src/org/transdroid/core/gui/DetailsFragment.java index 2697335b..d38c26d2 100644 --- a/core/src/org/transdroid/core/gui/DetailsFragment.java +++ b/core/src/org/transdroid/core/gui/DetailsFragment.java @@ -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; 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 protected ArrayList