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. 30
      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 @@ -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_setlabel).setVisible(false);
menu.findItem(R.id.action_updatetrackers).setVisible(false);
menu.findItem(R.id.action_changelocation).setVisible(false);
return;
}
// Update action availability

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

@ -144,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -144,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected ApplicationSettings applicationSettings;
@InstanceState
boolean firstStart = true;
boolean skipNextOnNavigationItemSelectedCall = false;
int skipNextOnNavigationItemSelectedCalls = 2;
private IDaemonAdapter currentConnection = null;
@InstanceState
protected NavigationFilter currentFilter = null;
@ -208,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -208,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Log messages from the server daemons using our singleton logger
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();
if (lastUsed == null) {
// No server settings yet;
@ -230,15 +230,15 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -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
// Note: skipNextOnNavigationItemSelectedCalls is used to prevent this event from triggering filterSelected
getSupportActionBar().setSelectedNavigationItem(lastUsed.getOrder() + 1);
skipNextOnNavigationItemSelectedCall = true;
filterSelected(lastUsed, true);
// Handle any start up intents
if (startTorrent != null) {
openDetails(startTorrent);
startTorrent = null;
} else if (firstStart && getIntent() != null) {
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName());
handleStartIntent();
}
@ -258,10 +258,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -258,10 +258,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if (lastUsed == null) {
// Still no settings
updateFragmentVisibility(false);
// There is a server know (now): forcefully select it to establish a connection
filterSelected(lastUsed, true);
return;
}
// There is a server know (now): forcefully select it to establish a connection
filterSelected(lastUsed, true);
// If we had no connection before, establish it now
if (currentConnection == null)
filterSelected(lastUsed, true);
}
@Override
@ -335,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -335,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
*/
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
if (skipNextOnNavigationItemSelectedCall) {
skipNextOnNavigationItemSelectedCall = false;
if (skipNextOnNavigationItemSelectedCalls > 0) {
skipNextOnNavigationItemSelectedCalls--;
return false;
}
Object item = navigationSpinnerAdapter.getItem(itemPosition);
@ -354,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -354,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
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);
}
};
@ -425,6 +431,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -425,6 +431,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
supportInvalidateOptionsMenu();
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleStartIntent();
}
/**
* 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 @@ -343,6 +343,11 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
this.hasAConnection = hasAConnection;
this.daemonType = daemonType;
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()
} else {
updateViewVisibility();
@ -381,11 +386,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL @@ -381,11 +386,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
private void updateViewVisibility() {
if (!hasAConnection) {
torrentsList.setVisibility(View.GONE);
emptyText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
nosettingsText.setVisibility(View.VISIBLE);
return;
}
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; @@ -26,6 +26,7 @@ import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item;
@ -99,7 +100,9 @@ public class RssitemsFragment extends SherlockFragment { @@ -99,7 +100,9 @@ public class RssitemsFragment extends SherlockFragment {
@ItemClick(resName = "rssitems_list")
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());
startActivity(i);
}

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

@ -33,6 +33,7 @@ import org.transdroid.core.app.search.SearchHelper.SearchSortOrder; @@ -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.SearchSite;
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.SelectionManagerMode;
@ -121,7 +122,9 @@ public class SearchResultsFragment extends SherlockFragment { @@ -121,7 +122,9 @@ public class SearchResultsFragment extends SherlockFragment {
@ItemClick(resName = "searchresults_list")
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());
startActivity(i);
}

2
full/AndroidManifest.xml

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

Loading…
Cancel
Save