Browse Source

Improved layout and text sizes on large (tablet) screens.

pull/11/head
Eric Kok 11 years ago
parent
commit
3600873f3c
  1. 1
      core/res/drawable/selectable_background_transdroid.xml
  2. 1
      core/res/drawable/selectable_background_transdroid2.xml
  3. 2
      core/res/layout-w600dp/activity_torrents.xml
  4. 2
      core/res/layout-w900dp/activity_torrents.xml
  5. 19
      core/res/layout/fragment_details_header.xml
  6. 4
      core/res/layout/list_item_navigation.xml
  7. 2
      core/res/layout/list_item_simple.xml
  8. 10
      core/res/layout/list_item_torrent.xml
  9. 6
      core/res/layout/list_item_torrentfile.xml
  10. 21
      core/res/values-sw500dp/dimens.xml
  11. 14
      core/res/values/dimens.xml
  12. 4
      core/res/values/styles.xml
  13. 1
      core/src/org/transdroid/core/gui/DetailsFragment.java
  14. 32
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  15. 13
      core/src/org/transdroid/core/gui/TorrentsFragment.java

1
core/res/drawable/selectable_background_transdroid.xml

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
<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="false" android:state_checked="true" android:drawable="@drawable/list_focused_transdroid" />
<item android:state_pressed="true" android:drawable="@drawable/pressed_background_transdroid" />
<item android:drawable="@android:color/transparent" />
</selector>

1
core/res/drawable/selectable_background_transdroid2.xml

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
<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="false" android:state_checked="true" android:drawable="@drawable/list_focused_transdroid2" />
<item android:state_pressed="true" android:drawable="@drawable/pressed_background_transdroid2" />
<item android:drawable="@android:color/transparent" />
</selector>

2
core/res/layout-w600dp/activity_torrents.xml

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:listSelector="@drawable/selectable_background_transdroid" />
android:listSelector="?attr/selectable_background_transdroid" />
<fragment
android:id="@+id/torrent_list"

2
core/res/layout-w900dp/activity_torrents.xml

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:listSelector="@drawable/selectable_background_transdroid" />
android:listSelector="?attr/selectable_background_transdroid" />
<fragment
android:id="@+id/torrent_list"

19
core/res/layout/fragment_details_header.xml

@ -24,7 +24,8 @@ @@ -24,7 +24,8 @@
<View
android:id="@+id/separator"
android:layout_width="2dip"
android:layout_height="110dip"
android:layout_height="@dimen/ui_details_seperator"
android:textSize="@dimen/text_enlargednumbers"
android:layout_below="@id/dateadded_text"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin_default"
@ -40,7 +41,7 @@ @@ -40,7 +41,7 @@
android:layout_marginTop="@dimen/margin_half"
android:layout_marginLeft="@dimen/margin_half"
android:textColor="?attr/text_bright"
android:textSize="33sp"
android:textSize="@dimen/text_hugenumbers"
android:fontFamily="sans-serif-light"
android:textIsSelectable="false" />
@ -62,7 +63,7 @@ @@ -62,7 +63,7 @@
android:layout_below="@id/uploaded_text"
android:layout_toRightOf="@id/separator"
android:layout_marginLeft="@dimen/margin_half"
android:textSize="12sp"
android:textSize="@dimen/text_small"
android:textIsSelectable="false" />
<TextView
@ -73,7 +74,7 @@ @@ -73,7 +74,7 @@
android:layout_toRightOf="@id/separator"
android:layout_marginLeft="@dimen/margin_half"
android:layout_marginBottom="4dip"
android:textSize="22sp"
android:textSize="@dimen/text_enlargednumbers"
android:textColor="?attr/text_bright"
android:fontFamily="sans-serif-light"
android:textIsSelectable="false" />
@ -85,7 +86,7 @@ @@ -85,7 +86,7 @@
android:layout_below="@id/upspeed_text"
android:layout_toRightOf="@id/separator"
android:layout_marginLeft="@dimen/margin_half"
android:textSize="12sp"
android:textSize="@dimen/text_small"
android:textIsSelectable="false" />
<TextView
@ -107,7 +108,7 @@ @@ -107,7 +108,7 @@
android:layout_toLeftOf="@id/downloadedunit_text"
android:layout_marginRight="4dip"
android:textColor="?attr/text_bright"
android:textSize="33sp"
android:textSize="@dimen/text_hugenumbers"
android:fontFamily="sans-serif-light"
android:textIsSelectable="false" />
@ -118,7 +119,7 @@ @@ -118,7 +119,7 @@
android:layout_alignBaseline="@id/ratio_text"
android:layout_toLeftOf="@id/separator"
android:layout_marginRight="@dimen/margin_half"
android:textSize="12sp"
android:textSize="@dimen/text_small"
android:textIsSelectable="false" />
<TextView
@ -128,7 +129,7 @@ @@ -128,7 +129,7 @@
android:layout_alignBaseline="@id/upspeed_text"
android:layout_toLeftOf="@id/separator"
android:layout_marginRight="@dimen/margin_half"
android:textSize="22sp"
android:textSize="@dimen/text_enlargednumbers"
android:textColor="?attr/text_bright"
android:fontFamily="sans-serif-light"
android:textIsSelectable="false" />
@ -140,7 +141,7 @@ @@ -140,7 +141,7 @@
android:layout_alignBaseline="@id/seeders_text"
android:layout_toLeftOf="@id/separator"
android:layout_marginRight="@dimen/margin_half"
android:textSize="12sp"
android:textSize="@dimen/text_small"
android:textIsSelectable="false" />
<TextView

4
core/res/layout/list_item_navigation.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
android:layout_height="wrap_content"
android:textColor="?attr/text_actionbar"
android:textIsSelectable="false"
android:textSize="17sp" />
android:textSize="@dimen/ui_navigation_filter" />
<TextView
android:id="@+id/server_text"
@ -20,6 +20,6 @@ @@ -20,6 +20,6 @@
android:layout_marginTop="-4dip"
android:textColor="?attr/text_actionbar"
android:textIsSelectable="false"
android:textSize="14sp" />
android:textSize="@dimen/ui_navigation_server" />
</LinearLayout>

2
core/res/layout/list_item_simple.xml

@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
android:id="@+id/item_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textSize="@dimen/text_default"
android:textIsSelectable="false"
android:autoLink="web" />

10
core/res/layout/list_item_torrent.xml

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
android:paddingTop="@dimen/margin_half"
android:textColor="?attr/text_bright"
android:textIsSelectable="false"
android:textSize="15sp" />
android:textSize="@dimen/text_enlarged" />
<TextView
android:id="@+id/ratio_text"
@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
android:layout_marginTop="4.0dip"
android:paddingBottom="@dimen/margin_half"
android:textIsSelectable="false"
android:textSize="12sp" />
android:textSize="@dimen/text_small" />
<ImageView
android:id="@+id/priority_image"
@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
android:layout_marginLeft="@dimen/margin_torrentlistleft"
android:layout_toLeftOf="@id/priority_image"
android:textIsSelectable="false"
android:textSize="12sp" />
android:textSize="@dimen/text_small" />
<org.transdroid.core.gui.lists.TorrentProgressBar
android:id="@+id/torrent_progressbar"
@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
android:layout_marginTop="@dimen/margin_half"
android:paddingBottom="@dimen/margin_half"
android:textIsSelectable="false"
android:textSize="12sp" />
android:textSize="@dimen/text_small" />
<TextView
android:id="@+id/peers_text"
@ -78,6 +78,6 @@ @@ -78,6 +78,6 @@
android:layout_toLeftOf="@id/speed_text"
android:paddingBottom="@dimen/margin_half"
android:textIsSelectable="false"
android:textSize="12sp" />
android:textSize="@dimen/text_small" />
</org.transdroid.core.gui.lists.TorrentStatusLayout>

6
core/res/layout/list_item_torrentfile.xml

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/file_checkbox"
android:textColor="?attr/text_bright"
android:textSize="15sp"
android:textSize="@dimen/text_enlarged"
android:textIsSelectable="false"
android:focusable="false" />
@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/margin_half"
android:layout_marginTop="4dip"
android:textSize="12sp"
android:textSize="@dimen/text_small"
android:textIsSelectable="false"
android:focusable="false" />
@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
android:layout_alignBottom="@+id/progress_text"
android:layout_toRightOf="@+id/priority_image"
android:textIsSelectable="false"
android:textSize="12sp"
android:textSize="@dimen/text_small"
android:focusable="false" />
<ImageView

21
core/res/values-sw500dp/dimens.xml

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<resources>
<!-- Margins -->
<dimen name="margin_default">16dp</dimen>
<dimen name="margin_half">8dp</dimen>
<dimen name="margin_torrentlistleft">16dp</dimen>
<!-- Text sizes -->
<dimen name="text_small">14sp</dimen>
<dimen name="text_default">17sp</dimen>
<dimen name="text_enlarged">18sp</dimen>
<dimen name="text_enlargednumbers">27sp</dimen>
<dimen name="text_hugenumbers">40sp</dimen>
<dimen name="text_label">14sp</dimen>
<!-- UI elements -->
<dimen name="ui_navigation_filter">18sp</dimen>
<dimen name="ui_navigation_server">15sp</dimen>
<dimen name="ui_details_seperator">125dp</dimen>
</resources>

14
core/res/values/dimens.xml

@ -1,7 +1,21 @@ @@ -1,7 +1,21 @@
<resources>
<!-- Margins -->
<dimen name="margin_default">16dp</dimen>
<dimen name="margin_half">8dp</dimen>
<dimen name="margin_torrentlistleft">16dp</dimen>
<!-- Text sizes -->
<dimen name="text_small">12sp</dimen>
<dimen name="text_default">15sp</dimen>
<dimen name="text_enlarged">15sp</dimen>
<dimen name="text_enlargednumbers">22sp</dimen>
<dimen name="text_hugenumbers">33sp</dimen>
<dimen name="text_label">12sp</dimen>
<!-- UI elements -->
<dimen name="ui_navigation_filter">17sp</dimen>
<dimen name="ui_navigation_server">14sp</dimen>
<dimen name="ui_details_seperator">110dp</dimen>
</resources>

4
core/res/values/styles.xml

@ -59,11 +59,11 @@ @@ -59,11 +59,11 @@
</style>
<style name="DefaultTextView" parent="android:Widget.Holo.Light.TextView">
<item name="android:textSize">15sp</item>
<item name="android:textSize">@dimen/text_default</item>
</style>
<style name="LabelTextView" parent="android:Widget.Holo.Light.TextView">
<item name="android:textSize">12sp</item>
<item name="android:textSize">@dimen/text_label</item>
<item name="android:background">#333</item>
<item name="android:textColor">#fff</item>
<item name="android:paddingLeft">4dip</item>

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

@ -58,6 +58,7 @@ public class DetailsFragment extends SherlockFragment { @@ -58,6 +58,7 @@ public class DetailsFragment extends SherlockFragment {
protected void init() {
detailsList.setAdapter(new DetailsAdapter(getActivity()));
detailsList.setFastScrollEnabled(true);
if (torrent != null)
updateTorrent(torrent);
if (torrentDetails != null)

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

@ -25,12 +25,20 @@ import org.transdroid.core.app.settings.ServerSetting; @@ -25,12 +25,20 @@ import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.log.*;
import org.transdroid.core.gui.navigation.*;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.log.Log_;
import org.transdroid.core.gui.navigation.FilterListAdapter;
import org.transdroid.core.gui.navigation.FilterListAdapter_;
import org.transdroid.core.gui.navigation.FilterListDropDownAdapter;
import org.transdroid.core.gui.navigation.FilterListDropDownAdapter_;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog;
import org.transdroid.core.gui.settings.*;
import org.transdroid.core.gui.settings.MainSettingsActivity_;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Torrent;
@ -71,7 +79,7 @@ import android.os.Build; @@ -71,7 +79,7 @@ import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.AdapterView.OnItemClickListener;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
@ -146,7 +154,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -146,7 +154,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Add an empty labels list (which will be updated later, but the adapter needs to be created now)
navigationListAdapter.updateLabels(new ArrayList<Label>());
filtersList.setAdapter(navigationListAdapter);
filtersList.setOnItemSelectedListener(onFilterListItemSelected);
filtersList.setOnItemClickListener(onFilterListItemClicked);
} else {
// Add status types directly to the action bar spinner
navigationSpinnerAdapter.updateStatusTypes(StatusType.getAllStatusTypes(this));
@ -270,19 +278,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -270,19 +278,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
return false;
}
// Handles clicks (selections) on the dedicated list of filter items (if it exists)
// NOTE: Unfortunately we cannot use the @ItemSelect(R.id.filters_list) annotation as it throws NPE exceptions when
// the list doesn't exist (read: on small screens)
protected OnItemSelectedListener onFilterListItemSelected = new OnItemSelectedListener() {
// Handles item selections on the dedicated list of filter items
private OnItemClickListener onFilterListItemClicked = new OnItemClickListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
filtersList.setItemChecked(position, true);
filterSelected((SimpleListItem) filtersList.getAdapter().getItem(position), false);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO: Check if this happens
}
};
/**

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

@ -74,6 +74,7 @@ public class TorrentsFragment extends SherlockFragment { @@ -74,6 +74,7 @@ public class TorrentsFragment extends SherlockFragment {
this.currentSortDescending = applicationSettings.getLastUsedSortDescending();
torrentsList.setAdapter(TorrentsAdapter_.getInstance_(getActivity()));
torrentsList.setMultiChoiceModeListener(onTorrentsSelected);
torrentsList.setFastScrollEnabled(true);
if (torrents != null)
updateTorrents(torrents);
}
@ -142,17 +143,17 @@ public class TorrentsFragment extends SherlockFragment { @@ -142,17 +143,17 @@ public class TorrentsFragment extends SherlockFragment {
Daemon serverType = (this.torrents.size() > 0 ? this.torrents.get(0).getDaemon() : Daemon.Transmission);
// Filter the list of torrents to show according to navigation and text filters
ArrayList<Torrent> filteredTorrents = torrents;
if (torrents != null && currentNavigationFilter != null) {
ArrayList<Torrent> filteredTorrents = new ArrayList<Torrent>(torrents);
if (filteredTorrents != null && currentNavigationFilter != null) {
// Remove torrents that do not match the selected navigation filter
for (Iterator<Torrent> torrentIter = torrents.iterator(); torrentIter.hasNext();) {
for (Iterator<Torrent> torrentIter = filteredTorrents.iterator(); torrentIter.hasNext();) {
if (!currentNavigationFilter.matches(torrentIter.next()))
torrentIter.remove();
}
}
if (torrents != null && currentTextFilter != null) {
if (filteredTorrents != null && currentTextFilter != null) {
// Remove torrent that do not contain the text filter string
for (Iterator<Torrent> torrentIter = torrents.iterator(); torrentIter.hasNext();) {
for (Iterator<Torrent> torrentIter = filteredTorrents.iterator(); torrentIter.hasNext();) {
if (!torrentIter.next().getName().toLowerCase(Locale.getDefault())
.contains(currentTextFilter.toLowerCase(Locale.getDefault())))
torrentIter.remove();
@ -160,7 +161,7 @@ public class TorrentsFragment extends SherlockFragment { @@ -160,7 +161,7 @@ public class TorrentsFragment extends SherlockFragment {
}
// Sort the list of filtered torrents
Collections.sort(this.torrents, new TorrentsComparator(serverType, this.currentSortOrder,
Collections.sort(filteredTorrents, new TorrentsComparator(serverType, this.currentSortOrder,
this.currentSortDescending));
((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents);

Loading…
Cancel
Save