Browse Source

Improving the general screen flow and unnecesary multiple refresh calls. Also fixes #11 and fixes #6.

pull/82/head
Eric Kok 11 years ago
parent
commit
fc2cd9be25
  1. 1
      core/src/org/transdroid/core/gui/DetailsFragment.java
  2. 28
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  3. 10
      core/src/org/transdroid/core/gui/TorrentsFragment.java
  4. 5
      core/src/org/transdroid/core/gui/rss/RssitemsFragment.java
  5. 5
      core/src/org/transdroid/core/gui/search/SearchResultsFragment.java
  6. 2
      full/AndroidManifest.xml

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

@ -249,6 +249,7 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
menu.findItem(R.id.action_remove_withdata).setVisible(false); menu.findItem(R.id.action_remove_withdata).setVisible(false);
menu.findItem(R.id.action_setlabel).setVisible(false); menu.findItem(R.id.action_setlabel).setVisible(false);
menu.findItem(R.id.action_updatetrackers).setVisible(false); menu.findItem(R.id.action_updatetrackers).setVisible(false);
menu.findItem(R.id.action_changelocation).setVisible(false);
return; return;
} }
// Update action availability // Update action availability

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

@ -144,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected ApplicationSettings applicationSettings; protected ApplicationSettings applicationSettings;
@InstanceState @InstanceState
boolean firstStart = true; boolean firstStart = true;
boolean skipNextOnNavigationItemSelectedCall = false; int skipNextOnNavigationItemSelectedCalls = 2;
private IDaemonAdapter currentConnection = null; private IDaemonAdapter currentConnection = null;
@InstanceState @InstanceState
protected NavigationFilter currentFilter = null; protected NavigationFilter currentFilter = null;
@ -208,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Log messages from the server daemons using our singleton logger // Log messages from the server daemons using our singleton logger
DLog.setLogger(Log_.getInstance_(this)); DLog.setLogger(Log_.getInstance_(this));
// Connect to the last used server or a server that was supplied in the starting intent // Connect to the last used server or a server that was explicitly supplied in the starting intent
ServerSetting lastUsed = applicationSettings.getLastUsedServer(); ServerSetting lastUsed = applicationSettings.getLastUsedServer();
if (lastUsed == null) { if (lastUsed == null) {
// No server settings yet; // No server settings yet;
@ -230,15 +230,15 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
} }
// Set this as selection in the action bar spinner; we can use the server setting key since we have stable ids // Set this as selection in the action bar spinner; we can use the server setting key since we have stable ids
// Note: skipNextOnNavigationItemSelectedCalls is used to prevent this event from triggering filterSelected
getSupportActionBar().setSelectedNavigationItem(lastUsed.getOrder() + 1); getSupportActionBar().setSelectedNavigationItem(lastUsed.getOrder() + 1);
skipNextOnNavigationItemSelectedCall = true; filterSelected(lastUsed, true);
// Handle any start up intents // Handle any start up intents
if (startTorrent != null) { if (startTorrent != null) {
openDetails(startTorrent); openDetails(startTorrent);
startTorrent = null; startTorrent = null;
} else if (firstStart && getIntent() != null) { } else if (firstStart && getIntent() != null) {
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName());
handleStartIntent(); handleStartIntent();
} }
@ -258,9 +258,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if (lastUsed == null) { if (lastUsed == null) {
// Still no settings // Still no settings
updateFragmentVisibility(false); updateFragmentVisibility(false);
// There is a server know (now): forcefully select it to establish a connection
filterSelected(lastUsed, true);
return; return;
} }
// There is a server know (now): forcefully select it to establish a connection
// If we had no connection before, establish it now
if (currentConnection == null)
filterSelected(lastUsed, true); filterSelected(lastUsed, true);
} }
@ -335,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
*/ */
@Override @Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) { public boolean onNavigationItemSelected(int itemPosition, long itemId) {
if (skipNextOnNavigationItemSelectedCall) { if (skipNextOnNavigationItemSelectedCalls > 0) {
skipNextOnNavigationItemSelectedCall = false; skipNextOnNavigationItemSelectedCalls--;
return false; return false;
} }
Object item = navigationSpinnerAdapter.getItem(itemPosition); Object item = navigationSpinnerAdapter.getItem(itemPosition);
@ -354,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
filtersList.setItemChecked(position, true); filtersList.setItemChecked(position, true);
filterSelected((SimpleListItem) filtersList.getAdapter().getItem(position), false); Object item = filtersList.getAdapter().getItem(position);
if (item instanceof SimpleListItem)
filterSelected((SimpleListItem) item, false);
} }
}; };
@ -426,6 +432,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
} }
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleStartIntent();
}
/** /**
* If required, add torrents, switch to a specific server, etc. * If required, add torrents, switch to a specific server, etc.
*/ */

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

@ -343,6 +343,11 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
this.hasAConnection = hasAConnection; this.hasAConnection = hasAConnection;
this.daemonType = daemonType; this.daemonType = daemonType;
if (!hasAConnection) { if (!hasAConnection) {
torrentsList.setVisibility(View.GONE);
emptyText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
nosettingsText.setVisibility(View.VISIBLE);
clear(true, true); // Indirectly also calls updateViewVisibility() clear(true, true); // Indirectly also calls updateViewVisibility()
} else { } else {
updateViewVisibility(); updateViewVisibility();
@ -381,11 +386,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
private void updateViewVisibility() { private void updateViewVisibility() {
if (!hasAConnection) { if (!hasAConnection) {
torrentsList.setVisibility(View.GONE);
emptyText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
nosettingsText.setVisibility(View.VISIBLE);
return; return;
} }
boolean isEmpty = torrents == null || torrentsList.getAdapter().isEmpty(); boolean isEmpty = torrents == null || torrentsList.getAdapter().isEmpty();

5
core/src/org/transdroid/core/gui/rss/RssitemsFragment.java

@ -26,6 +26,7 @@ import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick; import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.rssparser.Channel; import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item; import org.transdroid.core.rssparser.Item;
@ -99,7 +100,9 @@ public class RssitemsFragment extends SherlockFragment {
@ItemClick(resName = "rssitems_list") @ItemClick(resName = "rssitems_list")
protected void onItemClicked(Item item) { protected void onItemClicked(Item item) {
Intent i = new Intent(Intent.ACTION_VIEW, item.getTheLinkUri()); // Don't broadcast this intent; we can safely assume this is intended for Transdroid only
Intent i = TorrentsActivity_.intent(getActivity()).get();
i.setData(item.getTheLinkUri());
i.putExtra("TORRENT_TITLE", item.getTitle()); i.putExtra("TORRENT_TITLE", item.getTitle());
startActivity(i); startActivity(i);
} }

5
core/src/org/transdroid/core/gui/search/SearchResultsFragment.java

@ -33,6 +33,7 @@ import org.transdroid.core.app.search.SearchHelper.SearchSortOrder;
import org.transdroid.core.app.search.SearchResult; import org.transdroid.core.app.search.SearchResult;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.SystemSettings_; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper_; import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
@ -121,7 +122,9 @@ public class SearchResultsFragment extends SherlockFragment {
@ItemClick(resName = "searchresults_list") @ItemClick(resName = "searchresults_list")
protected void onItemClicked(SearchResult item) { protected void onItemClicked(SearchResult item) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(item.getTorrentUrl())); // Don't broadcast this intent; we can safely assume this is intended for Transdroid only
Intent i = TorrentsActivity_.intent(getActivity()).get();
i.setData(Uri.parse(item.getTorrentUrl()));
i.putExtra("TORRENT_TITLE", item.getName()); i.putExtra("TORRENT_TITLE", item.getName());
startActivity(i); startActivity(i);
} }

2
full/AndroidManifest.xml

@ -53,6 +53,7 @@
<activity <activity
android:name="org.transdroid.core.gui.TorrentsActivity_" android:name="org.transdroid.core.gui.TorrentsActivity_"
android:allowTaskReparenting="true" android:allowTaskReparenting="true"
android:launchMode="singleTop"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/TransdroidTheme" android:theme="@style/TransdroidTheme"
android:uiOptions="splitActionBarWhenNarrow" > android:uiOptions="splitActionBarWhenNarrow" >
@ -227,6 +228,7 @@
<activity <activity
android:name="org.transdroid.core.gui.rss.RssfeedsActivity_" android:name="org.transdroid.core.gui.rss.RssfeedsActivity_"
android:label="@string/rss_feeds" android:label="@string/rss_feeds"
android:launchMode="singleTop"
android:theme="@style/TransdroidTheme" /> android:theme="@style/TransdroidTheme" />
<activity <activity
android:name="org.transdroid.core.gui.rss.RssitemsActivity_" android:name="org.transdroid.core.gui.rss.RssitemsActivity_"

Loading…
Cancel
Save