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. 11
      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 @@ @@ -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; @@ -7,6 +7,7 @@ import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.EBean.Scope;
import org.androidannotations.annotations.RootContext;
import android.content.ContentProviderClient;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
@ -49,8 +50,15 @@ public class SearchHelper { @@ -49,8 +50,15 @@ public class SearchHelper {
*/
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");
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);
if (cursor.moveToFirst()) {
List<SearchSite> sites = new ArrayList<SearchSite>();
@ -63,7 +71,6 @@ public class SearchHelper { @@ -63,7 +71,6 @@ public class SearchHelper {
return sites;
}
// Torrent Search package is not yet installed
return null;
}

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

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

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

@ -331,7 +331,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -331,7 +331,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
String data = intent.getDataString();
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
String[] urls = intent.getStringArrayExtra("TORRENT_URLS");
String[] titles = intent.getStringArrayExtra("TORRENT_TITLES");
@ -343,11 +344,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -343,11 +344,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
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)) {
addTorrentFromDownloads(dataUri);
return;
}
// Adding a torrent from http or https URL
if (dataUri.getScheme().equals("http") || dataUri.getScheme().equals("https")) {
String title = data.substring(data.lastIndexOf("/"));
if (intent.hasExtra("TORRENT_TITLE")) {
@ -357,11 +364,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -357,11 +364,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
return;
}
// Adding a torrent from magnet URL
if (dataUri.getScheme().equals("magnet")) {
addTorrentByMagnetUrl(data);
return;
}
// Adding a local .torrent file
if (dataUri.getScheme().equals("file")) {
String title = data.substring(data.lastIndexOf("/"));
addTorrentByFile(data, title);

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

@ -20,7 +20,7 @@ public class SimpleListItemAdapter extends BaseAdapter { @@ -20,7 +20,7 @@ public class SimpleListItemAdapter extends BaseAdapter {
/**
* 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) {
this.items = newItems;

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

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

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

@ -34,9 +34,13 @@ public class ErrorLogSender { @@ -34,9 +34,13 @@ public class ErrorLogSender {
body.append("\n");
body.append(navigationHelper.getAppNameAndVersion());
body.append("\n");
if (serverSetting == null) {
body.append("(No server settings)");
} else {
body.append(serverSetting.getType().toString());
body.append(" settings: ");
body.append(serverSetting.getHumanReadableIdentifier());
}
body.append("\n\nConnection and error log:");
// 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; @@ -6,7 +6,6 @@ import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.navigation.StatusType.StatusTypeFilter;
import android.content.Context;
@ -24,9 +23,9 @@ public class FilterListAdapter extends MergeAdapter { @@ -24,9 +23,9 @@ public class FilterListAdapter extends MergeAdapter {
@RootContext
protected Context context;
private SimpleListItemAdapter serverItems = null;
private SimpleListItemAdapter statusTypeItems = null;
private SimpleListItemAdapter labelItems = null;
private FilterListItemAdapter serverItems = null;
private FilterListItemAdapter statusTypeItems = null;
private FilterListItemAdapter labelItems = null;
private FilterSeparatorView statusTypeSeparator;
private FilterSeparatorView labelSeperator;
private FilterSeparatorView serverSeparator;
@ -40,7 +39,7 @@ public class FilterListAdapter extends MergeAdapter { @@ -40,7 +39,7 @@ public class FilterListAdapter extends MergeAdapter {
serverSeparator = FilterSeparatorView_.build(context).setText(context.getString(R.string.navigation_servers));
serverSeparator.setVisibility(servers.isEmpty()? View.GONE: View.VISIBLE);
addView(serverSeparator, false);
this.serverItems = new SimpleListItemAdapter(context, servers);
this.serverItems = new FilterListItemAdapter(context, servers);
addAdapter(serverItems);
} else if (this.serverItems != null && servers != null) {
serverSeparator.setVisibility(serverItems.isEmpty()? View.GONE: View.VISIBLE);
@ -61,7 +60,7 @@ public class FilterListAdapter extends MergeAdapter { @@ -61,7 +60,7 @@ public class FilterListAdapter extends MergeAdapter {
context.getString(R.string.navigation_status));
statusTypeSeparator.setVisibility(statusTypes.isEmpty()? View.GONE: View.VISIBLE);
addView(statusTypeSeparator, false);
this.statusTypeItems = new SimpleListItemAdapter(context, statusTypes);
this.statusTypeItems = new FilterListItemAdapter(context, statusTypes);
addAdapter(statusTypeItems);
} else if (this.statusTypeItems != null && statusTypes != null) {
statusTypeSeparator.setVisibility(statusTypeItems.isEmpty()? View.GONE: View.VISIBLE);
@ -81,7 +80,7 @@ public class FilterListAdapter extends MergeAdapter { @@ -81,7 +80,7 @@ public class FilterListAdapter extends MergeAdapter {
labelSeperator = FilterSeparatorView_.build(context).setText(context.getString(R.string.navigation_labels));
labelSeperator.setVisibility(labels.isEmpty()? View.GONE: View.VISIBLE);
addView(labelSeperator, false);
this.labelItems = new SimpleListItemAdapter(context, labels);
this.labelItems = new FilterListItemAdapter(context, labels);
addAdapter(labelItems);
} else if (this.labelItems != null && labels != null) {
labelSeperator.setVisibility(labelItems.isEmpty()? View.GONE: View.VISIBLE);

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

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

Loading…
Cancel
Save