Browse Source

Fix state in which no settings are know and no loading is performed.

pull/11/head
Eric Kok 12 years ago
parent
commit
cc834a7ff5
  1. 10
      core/res/drawable/loading_progress.xml
  2. 12
      core/res/layout/fragment_torrents.xml
  3. 2
      core/res/values-sw500dp/bools.xml
  4. 2
      core/res/values/bools.xml
  5. 13
      core/src/org/transdroid/core/gui/DetailsFragment.java
  6. 14
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  7. 2
      core/src/org/transdroid/core/gui/navigation/NavigationHelper.java

10
core/res/drawable/loading_progress.xml

@ -1,5 +1,13 @@ @@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@android:id/progress"
android:duration="100">
<rotate
android:drawable="@drawable/ic_empty_details"
android:pivotX="50%"
android:pivotY="50%" />
</item>
</animation-list>

12
core/res/layout/fragment_torrents.xml

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminate="true"
android:indeterminateOnly="true"
android:indeterminateDrawable="@drawable/loading_progress"
android:visibility="visible" />
@ -24,10 +26,11 @@ @@ -24,10 +26,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableTop="@drawable/ic_empty_details"
android:drawablePadding="8dip"
android:text="@string/navigation_emptytorrents"
android:drawableTop="@drawable/ic_empty_details"
android:gravity="center"
android:maxWidth="400dip"
android:text="@string/navigation_emptytorrents"
android:textIsSelectable="false"
android:visibility="gone" />
@ -36,10 +39,11 @@ @@ -36,10 +39,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableTop="@drawable/ic_empty_details"
android:drawablePadding="8dip"
android:text="@string/navigation_nosettings"
android:drawableTop="@drawable/ic_empty_details"
android:gravity="center"
android:maxWidth="400dip"
android:text="@string/navigation_nosettings"
android:textIsSelectable="false"
android:visibility="gone" />

2
core/res/values-sw500dp/bools.xml

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Used to determine if a device is 'small', i.e. a phone; for reference: a Nexus 7's smallest width is 533dip -->
<bool name="small_screen">false</bool>
<bool name="show_dialog_fullscreen">false</bool>
</resources>

2
core/res/values/bools.xml

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Used to determine if a device is 'small', i.e. a phone; for reference: a Nexus 7's smallest width is 533dip -->
<bool name="small_screen">true</bool>
<bool name="show_dialog_fullscreen">true</bool>
</resources>

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

@ -127,6 +127,7 @@ public class DetailsFragment extends SherlockFragment { @@ -127,6 +127,7 @@ public class DetailsFragment extends SherlockFragment {
torrent = null;
torrentDetails = null;
torrentFiles = null;
getActivity().supportInvalidateOptionsMenu();
}
/**
@ -143,12 +144,24 @@ public class DetailsFragment extends SherlockFragment { @@ -143,12 +144,24 @@ public class DetailsFragment extends SherlockFragment {
public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
if (torrent == null) {
menu.findItem(R.id.action_resume).setVisible(false);
menu.findItem(R.id.action_pause).setVisible(false);
menu.findItem(R.id.action_start).setVisible(false);
menu.findItem(R.id.action_stop).setVisible(false);
menu.findItem(R.id.action_remove).setVisible(false);
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);
return;
}
// Update action availability
boolean startStop = Daemon.supportsStoppingStarting(torrent.getDaemon());
menu.findItem(R.id.action_resume).setVisible(torrent.canResume());
menu.findItem(R.id.action_pause).setVisible(torrent.canPause());
menu.findItem(R.id.action_start).setVisible(startStop && torrent.canStart());
menu.findItem(R.id.action_stop).setVisible(startStop && torrent.canStop());
menu.findItem(R.id.action_remove).setVisible(true);
boolean removeWithData = Daemon.supportsRemoveWithData(torrent.getDaemon());
menu.findItem(R.id.action_remove_withdata).setVisible(removeWithData);
boolean setLabel = Daemon.supportsSetLabel(torrent.getDaemon());

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

@ -142,8 +142,10 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -142,8 +142,10 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
if (lastUsed == null) {
// Still no settings
updateFragmentVisibility(false);
return;
}
// TODO: See if this does not mean the refresh is called twice (first in onCreate)
// There is a server now: select it to establish a connection
filterSelected(lastUsed);
}
@ -254,6 +256,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -254,6 +256,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
currentConnection = server.createServerAdapter();
applicationSettings.setLastUsedServer(server);
clearScreens();
updateFragmentVisibility(true);
refreshTorrents();
return;
@ -281,6 +284,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -281,6 +284,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
return currentConnection.getSettings().getName();
}
/**
* Hides the filter list and details fragment's full view if there is no configured connection
* @param hasServerSettings Whether there are server settings available, so we can continue to connect
*/
private void updateFragmentVisibility(boolean hasServerSettings) {
if (filtersList != null)
filtersList.setVisibility(hasServerSettings? View.VISIBLE: View.GONE);
if (fragmentDetails != null)
getSupportFragmentManager().beginTransaction().hide(fragmentDetails).commit();
}
/**
* If required, add torrents, switch to a specific server, etc.
*/

2
core/src/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -38,7 +38,7 @@ public class NavigationHelper { @@ -38,7 +38,7 @@ public class NavigationHelper {
* @return True if the app runs on a small device, false otherwise
*/
public boolean isSmallScreen() {
return context.getResources().getBoolean(R.bool.small_screen);
return context.getResources().getBoolean(R.bool.show_dialog_fullscreen);
}
/**

Loading…
Cancel
Save