Browse Source

Fixed verious UI issues, such as details screen loading and text sizes.

pull/11/head
Eric Kok 12 years ago
parent
commit
6fe27396f3
  1. 17
      core/res/layout/list_item_simple.xml
  2. 11
      core/src/org/transdroid/core/app/search/SearchHelper.java
  3. 5
      core/src/org/transdroid/core/gui/DetailsActivity.java
  4. 13
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  5. 2
      core/src/org/transdroid/core/gui/lists/SimpleListItemAdapter.java
  6. 2
      core/src/org/transdroid/core/gui/lists/SimpleListItemView.java
  7. 4
      core/src/org/transdroid/core/gui/log/ErrorLogSender.java
  8. 13
      core/src/org/transdroid/core/gui/navigation/FilterListAdapter.java
  9. 60
      core/src/org/transdroid/core/gui/navigation/FilterListItemAdapter.java
  10. 29
      core/src/org/transdroid/core/gui/navigation/FilterListItemView.java
  11. 2
      core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

17
core/res/layout/list_item_simple.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/margin_half"
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default"
android:paddingTop="@dimen/margin_half" >
<TextView
android:id="@+id/item_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textIsSelectable="false" />
</FrameLayout>

11
core/src/org/transdroid/core/app/search/SearchHelper.java

@ -7,6 +7,7 @@ import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.EBean.Scope; import org.androidannotations.annotations.EBean.Scope;
import org.androidannotations.annotations.RootContext; import org.androidannotations.annotations.RootContext;
import android.content.ContentProviderClient;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
@ -49,8 +50,15 @@ public class SearchHelper {
*/ */
public List<SearchSite> getAvailableSites() { public List<SearchSite> getAvailableSites() {
// Try to access the TorrentSitesProvider to retrieve all available in-app torrent search sites // Try to access the TorrentSitesProvider of the Torrent Search app
Uri uri = Uri.parse("content://org.transdroid.search.torrentsitesprovider/sites"); Uri uri = Uri.parse("content://org.transdroid.search.torrentsitesprovider/sites");
ContentProviderClient test = context.getContentResolver().acquireContentProviderClient(uri);
if (test == null) {
// Torrent Search package is not yet installed
return null;
}
// Query the available in-app torrent search sites
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
List<SearchSite> sites = new ArrayList<SearchSite>(); List<SearchSite> sites = new ArrayList<SearchSite>();
@ -63,7 +71,6 @@ public class SearchHelper {
return sites; return sites;
} }
// Torrent Search package is not yet installed
return null; return null;
} }

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

@ -101,6 +101,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@OptionsItem(resName = "action_refresh") @OptionsItem(resName = "action_refresh")
protected void refreshScreen() { protected void refreshScreen() {
fragmentDetails.updateIsLoading(true);
refreshTorrent(); refreshTorrent();
refreshTorrentDetails(); refreshTorrentDetails();
refreshTorrentFiles(); refreshTorrentFiles();
@ -108,9 +109,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@Background @Background
protected void refreshTorrent() { protected void refreshTorrent() {
fragmentDetails.updateIsLoading(true);
DaemonTaskResult result = RetrieveTask.create(currentConnection).execute(); DaemonTaskResult result = RetrieveTask.create(currentConnection).execute();
fragmentDetails.updateIsLoading(false);
if (result instanceof RetrieveTaskSuccessResult) { if (result instanceof RetrieveTaskSuccessResult) {
onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(), onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(),
((RetrieveTaskSuccessResult) result).getLabels()); ((RetrieveTaskSuccessResult) result).getLabels());
@ -246,6 +245,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread @UiThread
protected void onCommunicationError(DaemonTaskFailureResult result) { protected void onCommunicationError(DaemonTaskFailureResult result) {
Log.i(this, result.getException().toString()); Log.i(this, result.getException().toString());
fragmentDetails.updateIsLoading(false);
Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())), Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())),
navigationHelper.CROUTON_ERROR_STYLE); navigationHelper.CROUTON_ERROR_STYLE);
} }
@ -253,6 +253,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread @UiThread
protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) { protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) {
// Update the details fragment // Update the details fragment
fragmentDetails.updateIsLoading(false);
fragmentDetails.perhapsUpdateTorrent(torrents); fragmentDetails.perhapsUpdateTorrent(torrents);
} }

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

@ -331,23 +331,30 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
String data = intent.getDataString(); String data = intent.getDataString();
String action = intent.getAction(); String action = intent.getAction();
if (action.equals("org.transdroid.ADD_MULTIPLE")) { // Adding multiple torrents at the same time (as found in the Intent extras Bundle)
if (action != null && action.equals("org.transdroid.ADD_MULTIPLE")) {
// Intent should have some extras pointing to possibly multiple torrents // Intent should have some extras pointing to possibly multiple torrents
String[] urls = intent.getStringArrayExtra("TORRENT_URLS"); String[] urls = intent.getStringArrayExtra("TORRENT_URLS");
String[] titles = intent.getStringArrayExtra("TORRENT_TITLES"); String[] titles = intent.getStringArrayExtra("TORRENT_TITLES");
if (urls != null) { if (urls != null) {
for (int i = 0; i < urls.length; i++) { for (int i = 0; i < urls.length; i++) {
addTorrentByUrl(urls[i], (titles != null && titles.length >= i? titles[i]: "Torrent")); addTorrentByUrl(urls[i], (titles != null && titles.length >= i ? titles[i] : "Torrent"));
} }
} }
return; return;
} }
// Add a torrent from a local or remote data URI?
if (dataUri == null)
return;
// Adding a torrent from the Android downloads manager
if (dataUri.getScheme() != null && dataUri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) { if (dataUri.getScheme() != null && dataUri.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
addTorrentFromDownloads(dataUri); addTorrentFromDownloads(dataUri);
return; return;
} }
// Adding a torrent from http or https URL
if (dataUri.getScheme().equals("http") || dataUri.getScheme().equals("https")) { if (dataUri.getScheme().equals("http") || dataUri.getScheme().equals("https")) {
String title = data.substring(data.lastIndexOf("/")); String title = data.substring(data.lastIndexOf("/"));
if (intent.hasExtra("TORRENT_TITLE")) { if (intent.hasExtra("TORRENT_TITLE")) {
@ -357,11 +364,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
return; return;
} }
// Adding a torrent from magnet URL
if (dataUri.getScheme().equals("magnet")) { if (dataUri.getScheme().equals("magnet")) {
addTorrentByMagnetUrl(data); addTorrentByMagnetUrl(data);
return; return;
} }
// Adding a local .torrent file
if (dataUri.getScheme().equals("file")) { if (dataUri.getScheme().equals("file")) {
String title = data.substring(data.lastIndexOf("/")); String title = data.substring(data.lastIndexOf("/"));
addTorrentByFile(data, title); addTorrentByFile(data, title);

2
core/src/org/transdroid/core/gui/lists/SimpleListItemAdapter.java

@ -20,7 +20,7 @@ public class SimpleListItemAdapter extends BaseAdapter {
/** /**
* Allows updating of the full data list underlying this adapter, replacing all items * Allows updating of the full data list underlying this adapter, replacing all items
* @param newItems The new list of filter items to display * @param newItems The new list of simple list items to display
*/ */
public void update(List<? extends SimpleListItem> newItems) { public void update(List<? extends SimpleListItem> newItems) {
this.items = newItems; this.items = newItems;

2
core/src/org/transdroid/core/gui/lists/SimpleListItemView.java

@ -11,7 +11,7 @@ import android.widget.TextView;
* View that represents some {@link SimpleListItem} object and simple prints out the text (in proper style) * View that represents some {@link SimpleListItem} object and simple prints out the text (in proper style)
* @author Eric Kok * @author Eric Kok
*/ */
@EViewGroup(resName="list_item_filter") @EViewGroup(resName="list_item_simple")
public class SimpleListItemView extends FrameLayout { public class SimpleListItemView extends FrameLayout {
@ViewById @ViewById

4
core/src/org/transdroid/core/gui/log/ErrorLogSender.java

@ -34,9 +34,13 @@ public class ErrorLogSender {
body.append("\n"); body.append("\n");
body.append(navigationHelper.getAppNameAndVersion()); body.append(navigationHelper.getAppNameAndVersion());
body.append("\n"); body.append("\n");
if (serverSetting == null) {
body.append("(No server settings)");
} else {
body.append(serverSetting.getType().toString()); body.append(serverSetting.getType().toString());
body.append(" settings: "); body.append(" settings: ");
body.append(serverSetting.getHumanReadableIdentifier()); body.append(serverSetting.getHumanReadableIdentifier());
}
body.append("\n\nConnection and error log:"); body.append("\n\nConnection and error log:");
// Print the individual error log messages as stored in the database // Print the individual error log messages as stored in the database

13
core/src/org/transdroid/core/gui/navigation/FilterListAdapter.java

@ -6,7 +6,6 @@ import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext; import org.androidannotations.annotations.RootContext;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.navigation.StatusType.StatusTypeFilter; import org.transdroid.core.gui.navigation.StatusType.StatusTypeFilter;
import android.content.Context; import android.content.Context;
@ -24,9 +23,9 @@ public class FilterListAdapter extends MergeAdapter {
@RootContext @RootContext
protected Context context; protected Context context;
private SimpleListItemAdapter serverItems = null; private FilterListItemAdapter serverItems = null;
private SimpleListItemAdapter statusTypeItems = null; private FilterListItemAdapter statusTypeItems = null;
private SimpleListItemAdapter labelItems = null; private FilterListItemAdapter labelItems = null;
private FilterSeparatorView statusTypeSeparator; private FilterSeparatorView statusTypeSeparator;
private FilterSeparatorView labelSeperator; private FilterSeparatorView labelSeperator;
private FilterSeparatorView serverSeparator; private FilterSeparatorView serverSeparator;
@ -40,7 +39,7 @@ public class FilterListAdapter extends MergeAdapter {
serverSeparator = FilterSeparatorView_.build(context).setText(context.getString(R.string.navigation_servers)); serverSeparator = FilterSeparatorView_.build(context).setText(context.getString(R.string.navigation_servers));
serverSeparator.setVisibility(servers.isEmpty()? View.GONE: View.VISIBLE); serverSeparator.setVisibility(servers.isEmpty()? View.GONE: View.VISIBLE);
addView(serverSeparator, false); addView(serverSeparator, false);
this.serverItems = new SimpleListItemAdapter(context, servers); this.serverItems = new FilterListItemAdapter(context, servers);
addAdapter(serverItems); addAdapter(serverItems);
} else if (this.serverItems != null && servers != null) { } else if (this.serverItems != null && servers != null) {
serverSeparator.setVisibility(serverItems.isEmpty()? View.GONE: View.VISIBLE); serverSeparator.setVisibility(serverItems.isEmpty()? View.GONE: View.VISIBLE);
@ -61,7 +60,7 @@ public class FilterListAdapter extends MergeAdapter {
context.getString(R.string.navigation_status)); context.getString(R.string.navigation_status));
statusTypeSeparator.setVisibility(statusTypes.isEmpty()? View.GONE: View.VISIBLE); statusTypeSeparator.setVisibility(statusTypes.isEmpty()? View.GONE: View.VISIBLE);
addView(statusTypeSeparator, false); addView(statusTypeSeparator, false);
this.statusTypeItems = new SimpleListItemAdapter(context, statusTypes); this.statusTypeItems = new FilterListItemAdapter(context, statusTypes);
addAdapter(statusTypeItems); addAdapter(statusTypeItems);
} else if (this.statusTypeItems != null && statusTypes != null) { } else if (this.statusTypeItems != null && statusTypes != null) {
statusTypeSeparator.setVisibility(statusTypeItems.isEmpty()? View.GONE: View.VISIBLE); statusTypeSeparator.setVisibility(statusTypeItems.isEmpty()? View.GONE: View.VISIBLE);
@ -81,7 +80,7 @@ public class FilterListAdapter extends MergeAdapter {
labelSeperator = FilterSeparatorView_.build(context).setText(context.getString(R.string.navigation_labels)); labelSeperator = FilterSeparatorView_.build(context).setText(context.getString(R.string.navigation_labels));
labelSeperator.setVisibility(labels.isEmpty()? View.GONE: View.VISIBLE); labelSeperator.setVisibility(labels.isEmpty()? View.GONE: View.VISIBLE);
addView(labelSeperator, false); addView(labelSeperator, false);
this.labelItems = new SimpleListItemAdapter(context, labels); this.labelItems = new FilterListItemAdapter(context, labels);
addAdapter(labelItems); addAdapter(labelItems);
} else if (this.labelItems != null && labels != null) { } else if (this.labelItems != null && labels != null) {
labelSeperator.setVisibility(labelItems.isEmpty()? View.GONE: View.VISIBLE); labelSeperator.setVisibility(labelItems.isEmpty()? View.GONE: View.VISIBLE);

60
core/src/org/transdroid/core/gui/navigation/FilterListItemAdapter.java

@ -0,0 +1,60 @@
package org.transdroid.core.gui.navigation;
import java.util.List;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.lists.SimpleListItemView;
import org.transdroid.core.gui.lists.SimpleListItemView_;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class FilterListItemAdapter extends BaseAdapter {
private final Context context;
private List<? extends SimpleListItem> items;
public FilterListItemAdapter(Context context, List<? extends SimpleListItem> items) {
this.context = context;
this.items = items;
}
/**
* Allows updating of the full data list underlying this adapter, replacing all items
* @param newItems The new list of filter items to display
*/
public void update(List<? extends SimpleListItem> newItems) {
this.items = newItems;
notifyDataSetChanged();
}
@Override
public int getCount() {
return items.size();
}
@Override
public SimpleListItem getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
SimpleListItemView filterItemView;
if (convertView == null || !(convertView instanceof SimpleListItemView)) {
filterItemView = SimpleListItemView_.build(context);
} else {
filterItemView = (SimpleListItemView) convertView;
}
filterItemView.bind(getItem(position));
return filterItemView;
}
}

29
core/src/org/transdroid/core/gui/navigation/FilterListItemView.java

@ -0,0 +1,29 @@
package org.transdroid.core.gui.navigation;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
import org.transdroid.core.gui.lists.SimpleListItem;
import android.content.Context;
import android.widget.FrameLayout;
import android.widget.TextView;
/**
* View that represents some {@link SimpleListItem} object used to represent a navigation filter item
* @author Eric Kok
*/
@EViewGroup(resName="list_item_filter")
public class FilterListItemView extends FrameLayout {
@ViewById
protected TextView itemText;
public FilterListItemView(Context context) {
super(context);
}
public void bind(SimpleListItem filterItem) {
itemText.setText(filterItem.getName());
}
}

2
core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -86,6 +86,8 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
ListPreference setSite = (ListPreference) findPreference("header_setsearchsite"); ListPreference setSite = (ListPreference) findPreference("header_setsearchsite");
// Retrieve the available in-app search sites (using the Torrent Search package) // Retrieve the available in-app search sites (using the Torrent Search package)
List<SearchSite> searchsites = searchHelper.getAvailableSites(); List<SearchSite> searchsites = searchHelper.getAvailableSites();
if (searchsites == null)
searchsites = new ArrayList<SearchSite>();
List<String> siteNames = new ArrayList<String>(websearches.size() + searchsites.size()); List<String> siteNames = new ArrayList<String>(websearches.size() + searchsites.size());
List<String> siteValues = new ArrayList<String>(websearches.size() + searchsites.size()); List<String> siteValues = new ArrayList<String>(websearches.size() + searchsites.size());
for (SearchSite searchSite : searchsites) { for (SearchSite searchSite : searchsites) {

Loading…
Cancel
Save