Browse Source

Replaced action bar with Toolbar and replaced spinner navigation with nav drawer.

material
Eric Kok 10 years ago
parent
commit
ad8c0f39ac
  1. 8
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  2. 5
      app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java
  3. 24
      app/src/main/java/org/transdroid/core/gui/ServerStatusView.java
  4. 379
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  5. 5
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java
  6. 70
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListDropDownAdapter.java
  7. 155
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java
  8. 52
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationSelectionView.java
  9. 10
      app/src/main/java/org/transdroid/core/service/ConnectivityHelper.java
  10. 8
      app/src/main/res/drawable/elevation_shadow.xml
  11. 32
      app/src/main/res/layout-w600dp/activity_torrents.xml
  12. 36
      app/src/main/res/layout-w900dp/activity_torrents.xml
  13. 44
      app/src/main/res/layout/actionbar_navigation.xml
  14. 114
      app/src/main/res/layout/actionbar_serverstatus.xml
  15. 43
      app/src/main/res/layout/activity_torrents.xml
  16. 2
      app/src/main/res/layout/list_item_filter.xml
  17. 2
      app/src/main/res/values-v16/styles.xml
  18. 17
      app/src/main/res/values-v21/styles.xml
  19. 2
      app/src/main/res/values/strings.xml
  20. 14
      app/src/main/res/values/styles.xml
  21. 2
      app/src/main/res/values/styles_transdroid_dark.xml
  22. 2
      app/src/main/res/values/styles_transdroid_light.xml

8
app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

@ -97,15 +97,15 @@ public class ApplicationSettings { @@ -97,15 +97,15 @@ public class ApplicationSettings {
* @return The server settings object, loaded from shared preferences
*/
public ServerSetting getServerSetting(int order) {
int max = getMaxNormalServer();
if (order <= max) {
int max = getMaxNormalServer() + 1;
if (order < max) {
return getNormalServerSetting(order);
}
for (SeedboxProvider provider : SeedboxProvider.values()) {
int offset = max;
max += provider.getSettings().getMaxSeedboxOrder(prefs) + 1;
if (order <= max) {
return provider.getSettings().getServerSetting(prefs, offset, order - offset - 1);
if (order < max) {
return provider.getSettings().getServerSetting(prefs, offset, order - offset);
}
}
return null;

5
app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java

@ -259,6 +259,11 @@ public class ServerSetting implements SimpleListItem { @@ -259,6 +259,11 @@ public class ServerSetting implements SimpleListItem {
return false;
}
@Override
public String toString() {
return getUniqueIdentifier();
}
/**
* Returns the appropriate daemon adapter to which tasks can be executed, in accordance with this server's settings
* @param connectedToNetwork The name of the (wifi) network we are currently connected to, or null if this could not

24
app/src/main/java/org/transdroid/core/gui/ServerStatusView.java

@ -21,9 +21,11 @@ import java.util.List; @@ -21,9 +21,11 @@ import java.util.List;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
import org.transdroid.R;
import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.SetTransferRatesDialog;
import org.transdroid.core.gui.navigation.SetTransferRatesDialog.OnRatesPickedListener;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.util.FileSizeConverter;
@ -37,7 +39,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -37,7 +39,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
public class ServerStatusView extends RelativeLayout implements OnRatesPickedListener {
@ViewById
protected TextView downcountText, upcountText, downcountSign, upcountSign, downspeedText, upspeedText;
protected TextView filterText, serverText, downcountText, upcountText, downcountSign, upcountSign, downspeedText, upspeedText;
@ViewById
protected View speedswrapperLayout;
private TorrentsActivity activity;
@ -47,17 +49,33 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis @@ -47,17 +49,33 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis
}
public ServerStatusView(TorrentsActivity activity) {
super(activity);
super(activity.getSupportActionBar().getThemedContext());
this.activity = activity;
}
/**
* Updates the name of the current connected server.
* @param currentServer The server currently connected to
*/
public void updateCurrentServer(IDaemonAdapter currentServer) {
serverText.setText(currentServer.getSettings().getName());
}
/**
* Updates the name of the selected filter.
* @param currentFilter The filter that is currently selected
*/
public void updateCurrentFilter(NavigationFilter currentFilter) {
filterText.setText(currentFilter.getName());
}
/**
* Updates the statistics as shown in the action bar through this server status view.
* @param torrents The most recently received list of torrents
* @param dormantAsInactive Whether to treat dormant (0KB/s) torrent as inactive state torrents
* @param supportsSetTransferRates Whether the connected torrent client supports setting of max transfer speeds
*/
public void update(List<Torrent> torrents, boolean dormantAsInactive, boolean supportsSetTransferRates) {
public void updateStatus(List<Torrent> torrents, boolean dormantAsInactive, boolean supportsSetTransferRates) {
if (torrents == null) {
downcountText.setText(null);

379
app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

@ -16,17 +16,28 @@ @@ -16,17 +16,28 @@
*/
package org.transdroid.core.gui;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import android.annotation.TargetApi;
import android.app.SearchManager;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SearchView;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
@ -46,17 +57,28 @@ import org.apache.http.client.methods.HttpGet; @@ -46,17 +57,28 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.transdroid.R;
import org.transdroid.core.app.search.*;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.app.search.SearchHelper_;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.app.settings.WebsearchSetting;
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.rss.*;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.log.LogUncaughtExceptionHandler;
import org.transdroid.core.gui.navigation.FilterListAdapter;
import org.transdroid.core.gui.navigation.FilterListAdapter_;
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.RefreshableActivity;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.rss.RssfeedsActivity_;
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.core.service.BootReceiver;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.core.widget.ListWidgetProvider;
@ -96,26 +118,18 @@ import org.transdroid.daemon.task.StartTask; @@ -96,26 +118,18 @@ import org.transdroid.daemon.task.StartTask;
import org.transdroid.daemon.task.StopTask;
import org.transdroid.daemon.util.HttpHelper;
import android.annotation.TargetApi;
import android.app.SearchManager;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SearchView;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import de.keyboardsurfer.android.widget.crouton.Crouton;
/**
@ -127,13 +141,16 @@ import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -127,13 +141,16 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/
@EActivity(resName = "activity_torrents")
@OptionsMenu(resName = "activity_torrents")
public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnNavigationListener, TorrentTasksExecutor,
RefreshableActivity {
public class TorrentsActivity extends ActionBarActivity implements TorrentTasksExecutor, RefreshableActivity {
private static final int RESULT_DETAILS = 0;
// Fragment uses this to pause the refresh across restarts
public boolean stopRefresh = false;
// Navigation components
@SystemService
protected SearchManager searchManager;
@Bean
protected Log log;
@Bean
@ -141,12 +158,18 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -141,12 +158,18 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Bean
protected ConnectivityHelper connectivityHelper;
@ViewById
protected Toolbar torrentsToolbar;
@ViewById
protected DrawerLayout drawerLayout;
@ViewById
protected ListView drawerList;
@ViewById
protected ListView filtersList;
protected FilterListAdapter navigationListAdapter = null;
protected FilterListDropDownAdapter navigationSpinnerAdapter = null;
protected ListView navigationList;
protected FilterListAdapter navigationListAdapter;
protected ServerStatusView serverStatusView;
@SystemService
protected SearchManager searchManager;
protected ActionBarDrawerToggle drawerToggle;
// Settings
@Bean
protected ApplicationSettings applicationSettings;
@ -167,20 +190,24 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -167,20 +190,24 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
protected DetailsFragment fragmentDetails;
@InstanceState
boolean firstStart = true;
int skipNextOnNavigationItemSelectedCalls = 2;
private MenuItem searchMenu = null;
private IDaemonAdapter currentConnection = null;
// Auto refresh task
private AsyncTask<Void, Void, Void> autoRefreshTask;
// Handles item selections on the dedicated list of filter items
/**
* Handles item selections on the dedicated list of filter items
*/
private OnItemClickListener onFilterListItemClicked = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
filtersList.setItemChecked(position, true);
Object item = filtersList.getAdapter().getItem(position);
if (item instanceof SimpleListItem)
navigationList.setItemChecked(position, true);
Object item = navigationList.getAdapter().getItem(position);
if (item instanceof SimpleListItem) {
filterSelected((SimpleListItem) item, false);
}
drawerLayout.closeDrawer(drawerList);
}
};
@Override
@ -190,50 +217,43 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -190,50 +217,43 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
setTheme(R.style.TransdroidTheme_Dark);
}
// Catch any uncaught exception to log it
Thread.setDefaultUncaughtExceptionHandler(new LogUncaughtExceptionHandler(this,
Thread.getDefaultUncaughtExceptionHandler()));
Thread.setDefaultUncaughtExceptionHandler(
new LogUncaughtExceptionHandler(this, Thread.getDefaultUncaughtExceptionHandler()));
super.onCreate(savedInstanceState);
}
@AfterViews
protected void init() {
// Set up navigation, with an action bar spinner, server status indicator and possibly (if room) with a filter
// list
// Use a custom view as action bar content, showing filter selection and current torrent counts/speeds
setSupportActionBar(torrentsToolbar);
serverStatusView = ServerStatusView_.build(this);
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(serverStatusView);
navigationSpinnerAdapter = FilterListDropDownAdapter_.getInstance_(getSupportActionBar().getThemedContext());
// Servers are always added to the action bar spinner
navigationSpinnerAdapter.updateServers(applicationSettings.getAllServerSettings());
// Check if there was room for a dedicated filter list (i.e. on tablets)
if (filtersList != null) {
// The action bar spinner doesn't have to show the 'servers' label, as it will only contain servers
navigationSpinnerAdapter.hideServersLabel();
// Create dedicated side list adapter and add the status types
torrentsToolbar.addView(serverStatusView);
// Construct the filters list, i.e. the list of servers, status types and labels
navigationListAdapter = FilterListAdapter_.getInstance_(this);
navigationListAdapter.updateServers(applicationSettings.getAllServerSettings());
navigationListAdapter.updateStatusTypes(StatusType.getAllStatusTypes(this));
// 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.setOnItemClickListener(onFilterListItemClicked);
// Apply the filters list to the navigation drawer (on phones) or the dedicated side bar (i.e. on tablets)
if (filtersList != null) {
navigationList = filtersList;
} else {
// Add status types directly to the action bar spinner
navigationSpinnerAdapter.updateStatusTypes(StatusType.getAllStatusTypes(this));
// Add an empty labels list (which will be updated later, but the adapter needs to be created now)
navigationSpinnerAdapter.updateLabels(new ArrayList<Label>());
}
navigationList = drawerList;
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_opendrawer,
R.string.navigation_closedrawer);
drawerToggle.setDrawerIndicatorEnabled(true);
drawerLayout.setDrawerListener(drawerToggle);
}
navigationList.setAdapter(navigationListAdapter);
navigationList.setOnItemClickListener(onFilterListItemClicked);
// Now that all items (or at least their adapters) have been added, ensure a filter is selected
// NOTE When this is a fresh start, it might override the filter later (based on the last user selection)
if (currentFilter == null) {
currentFilter = StatusType.getShowAllType(this);
}
actionBar.setListNavigationCallbacks(navigationSpinnerAdapter, this);
// Load the default server or a server that was explicitly supplied in the starting intent
ServerSetting defaultServer = applicationSettings.getDefaultServer();
@ -242,23 +262,20 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -242,23 +262,20 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
return;
}
Torrent openTorrent = null;
if (getIntent().getAction() != null && getIntent().getAction().equals(ListWidgetProvider.INTENT_STARTSERVER)
&& getIntent().getExtras() == null && getIntent().hasExtra(ListWidgetProvider.EXTRA_SERVER)) {
if (getIntent().getAction() != null && getIntent().getAction().equals(ListWidgetProvider.INTENT_STARTSERVER) &&
getIntent().getExtras() == null && getIntent().hasExtra(ListWidgetProvider.EXTRA_SERVER)) {
// A server settings order ID was provided in this org.transdroid.START_SERVER action intent
int serverId = getIntent().getExtras().getInt(ListWidgetProvider.EXTRA_SERVER);
if (serverId < 0 || serverId > applicationSettings.getMaxOfAllServers()) {
log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId
+ " is not an existing server order id");
log.e(this, "Tried to start with " + ListWidgetProvider.EXTRA_SERVER + " intent but " + serverId +
" is not an existing server order id");
} else {
defaultServer = applicationSettings.getServerSetting(serverId);
if (getIntent().hasExtra(ListWidgetProvider.EXTRA_TORRENT))
if (getIntent().hasExtra(ListWidgetProvider.EXTRA_TORRENT)) {
openTorrent = getIntent().getParcelableExtra(ListWidgetProvider.EXTRA_TORRENT);
}
}
// 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
actionBar.setSelectedNavigationItem(defaultServer.getOrder() + 1);
}
// Connect to the last used server or a server that was explicitly supplied in the starting intent
if (firstStart) {
@ -276,8 +293,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -276,8 +293,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
// Resume after instead of fully loading the torrents list; create connection and set action bar title
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
navigationSpinnerAdapter.updateCurrentServer(currentConnection);
navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
serverStatusView.updateCurrentServer(currentConnection);
serverStatusView.updateCurrentFilter(currentFilter);
}
firstStart = false;
@ -287,12 +304,21 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -287,12 +304,21 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred
if (drawerToggle != null) {
drawerToggle.syncState();
}
}
@Override
protected void onResume() {
super.onResume();
// Refresh server settings
navigationSpinnerAdapter.updateServers(applicationSettings.getAllServerSettings());
navigationListAdapter.updateServers(applicationSettings.getAllServerSettings());
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
if (lastUsed == null) {
// Still no settings
@ -301,10 +327,11 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -301,10 +327,11 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
}
// If we had no connection before, establish it now; otherwise just reload the settings
if (currentConnection == null)
if (currentConnection == null) {
filterSelected(lastUsed, true);
else
} else {
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
}
// Start auto refresh
startAutoRefresh();
@ -324,8 +351,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -324,8 +351,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void startAutoRefresh() {
// Check if already running
if (autoRefreshTask != null || stopRefresh || systemSettings.getRefreshIntervalMilliseconds() == 0)
if (autoRefreshTask != null || stopRefresh || systemSettings.getRefreshIntervalMilliseconds() == 0) {
return;
}
autoRefreshTask = new AsyncTask<Void, Void, Void>() {
@Override
@ -337,27 +365,27 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -337,27 +365,27 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
// Ignore
}
// Just in case it was cancelled during sleep
if (isCancelled())
if (isCancelled()) {
return null;
}
refreshTorrents();
if (Daemon.supportsStats(currentConnection.getType()))
if (Daemon.supportsStats(currentConnection.getType())) {
getAdditionalStats();
}
}
return null;
}
};
// Executes serially by default on Honeycomb, was parallel before
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
autoRefreshTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
autoRefreshTask.execute();
}
public void stopAutoRefresh() {
if (autoRefreshTask != null)
if (autoRefreshTask != null) {
autoRefreshTask.cancel(true);
}
autoRefreshTask = null;
}
@ -419,9 +447,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -419,9 +447,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
menu.findItem(R.id.action_filter).setVisible(false);
menu.findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.findItem(R.id.action_help).setVisible(true);
if (fragmentTorrents != null)
if (fragmentTorrents != null) {
fragmentTorrents.updateConnectionStatus(false, null);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
return true;
}
@ -440,30 +468,17 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -440,30 +468,17 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
menu.findItem(R.id.action_filter).setVisible(true);
menu.findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.findItem(R.id.action_help).setVisible(false);
if (fragmentTorrents != null)
if (fragmentTorrents != null) {
fragmentTorrents.updateConnectionStatus(true, currentConnection.getType());
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
}
return true;
}
/**
* Called when an item in the action bar navigation spinner was selected
*/
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
if (skipNextOnNavigationItemSelectedCalls > 0) {
skipNextOnNavigationItemSelectedCalls--;
return false;
}
Object item = navigationSpinnerAdapter.getItem(itemPosition);
if (item instanceof SimpleListItem) {
// A filter item was selected form the navigation spinner
filterSelected((SimpleListItem) item, false);
return true;
}
// A header was selected; no action
return false;
public boolean onOptionsItemSelected(MenuItem item) {
// Handle only if this is the drawer toggle; otherwise the AndroidAnnotations will be used
return drawerToggle != null && drawerToggle.onOptionsItemSelected(item);
}
/**
@ -490,9 +505,10 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -490,9 +505,10 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
// Update connection to the newly selected server and refresh
currentConnection = server.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
applicationSettings.setLastUsedServer(server);
navigationSpinnerAdapter.updateCurrentServer(currentConnection);
if (forceNewConnection)
navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
serverStatusView.updateCurrentServer(currentConnection);
if (forceNewConnection) {
serverStatusView.updateCurrentFilter(currentFilter);
}
// Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true);
@ -512,7 +528,7 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -512,7 +528,7 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
// Set new filter
currentFilter = (NavigationFilter) item;
fragmentTorrents.applyNavigationFilter(currentFilter);
navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
serverStatusView.updateCurrentFilter(currentFilter);
// Remember that the user last selected this
applicationSettings.setLastUsedNavigationFilter(currentFilter);
// Clear the details view
@ -529,14 +545,14 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -529,14 +545,14 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
* @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);
// TODO Hide hamburger icon?
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (hasServerSettings)
if (hasServerSettings) {
getFragmentManager().beginTransaction().show(fragmentDetails).commit();
else
} else {
getFragmentManager().beginTransaction().hide(fragmentDetails).commit();
}
}
invalidateOptionsMenu();
}
@ -548,8 +564,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -548,8 +564,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
protected void handleStartIntent() {
// For intents that come from out of the application, perhaps we can not directly add them
if (applicationSettings.getDefaultServerKey() == ApplicationSettings.DEFAULTSERVER_ASKONADD
&& getIntent().getData() != null) {
if (applicationSettings.getDefaultServerKey() == ApplicationSettings.DEFAULTSERVER_ASKONADD &&
getIntent().getData() != null) {
// First ask which server to use before adding any intent from the extras
ServerPickerDialog.startServerPicker(this, applicationSettings.getAllServerSettings());
return;
@ -563,8 +579,6 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -563,8 +579,6 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
ServerSetting selectedServer = applicationSettings.getAllServerSettings().get(position);
filterSelected(selectedServer, false);
addFromIntent();
skipNextOnNavigationItemSelectedCalls++; // Prevent this selection from launching filterSelected() again
getSupportActionBar().setSelectedNavigationItem(position + 1);
}
/**
@ -583,8 +597,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -583,8 +597,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
String[] titles = intent.getStringArrayExtra("TORRENT_TITLES");
if (urls != null) {
for (int i = 0; i < urls.length; i++) {
String title = (titles != null && titles.length >= i ? titles[i] : NavigationHelper
.extractNameFromUri(Uri.parse(urls[i])));
String title = (titles != null && titles.length >= i ? titles[i] :
NavigationHelper.extractNameFromUri(Uri.parse(urls[i])));
if (intent.hasExtra("PRIVATE_SOURCE")) {
// This is marked by the Search Module as being a private source site; get the url locally first
addTorrentFromPrivateSource(urls[i], title, intent.getStringExtra("PRIVATE_SOURCE"));
@ -597,8 +611,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -597,8 +611,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
}
// Add a torrent from a local or remote data URI?
if (dataUri == null)
if (dataUri == null) {
return;
}
if (dataUri.getScheme() == null) {
Crouton.showText(this, R.string.error_invalid_url_form, NavigationHelper.CROUTON_ERROR_STYLE);
return;
@ -664,8 +679,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -664,8 +679,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Override
protected void onPause() {
if (searchMenu != null)
if (searchMenu != null) {
searchMenu.collapseActionView();
}
stopAutoRefresh();
super.onPause();
}
@ -729,16 +745,17 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -729,16 +745,17 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
*/
@Override
public void addRefreshableView(View view) {
// TODO Add new style pull to refresh library
// TODO Add new style pull to refresh library (using SwipeRefreshLayout?)
}
@OptionsItem(resName = "action_refresh")
public void refreshScreen() {
fragmentTorrents.updateIsLoading(true);
refreshTorrents();
if (Daemon.supportsStats(currentConnection.getType()))
if (Daemon.supportsStats(currentConnection.getType())) {
getAdditionalStats();
}
}
@OptionsItem(resName = "action_enableturtle")
protected void enableTurtleMode() {
@ -855,8 +872,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -855,8 +872,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Background
public void refreshTorrentDetails(Torrent torrent) {
if (!Daemon.supportsFineDetails(currentConnection.getType()))
if (!Daemon.supportsFineDetails(currentConnection.getType())) {
return;
}
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = GetTorrentDetailsTask.create(currentConnection, torrent).execute(log);
if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) {
@ -872,8 +890,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -872,8 +890,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Background
public void refreshTorrentFiles(Torrent torrent) {
if (!Daemon.supportsFileListing(currentConnection.getType()))
if (!Daemon.supportsFileListing(currentConnection.getType())) {
return;
}
String startConnectionId = currentConnection.getSettings().getIdString();
DaemonTaskResult result = GetFileListTask.create(currentConnection, torrent).execute(log);
if (!startConnectionId.equals(currentConnection.getSettings().getIdString())) {
@ -1002,8 +1021,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1002,8 +1021,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
try {
// Cookies are taken from the websearchSetting that we already matched against this target URL
DefaultHttpClient httpclient = HttpHelper.createStandardHttpClient(false, null, null, true, null, 10000,
null, -1);
DefaultHttpClient httpclient =
HttpHelper.createStandardHttpClient(false, null, null, true, null, 10000, null, -1);
Map<String, String> cookies = HttpHelper.parseCookiePairs(websearchSetting.getCookies());
String domain = Uri.parse(url).getHost();
for (Entry<String, String> pair : cookies.entrySet()) {
@ -1016,11 +1035,11 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1016,11 +1035,11 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
// Download the torrent at the specified URL (which will first be written to a temporary file)
// If we get an HTTP 401, 403 or 404 response, show an error to the user
HttpResponse response = httpclient.execute(new HttpGet(url));
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED
|| response.getStatusLine().getStatusCode() == HttpStatus.SC_FORBIDDEN
|| response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
log.e(this, "Can't retrieve web torrent " + url + ": Unexpected HTTP response status code "
+ response.getStatusLine().toString());
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED ||
response.getStatusLine().getStatusCode() == HttpStatus.SC_FORBIDDEN ||
response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
log.e(this, "Can't retrieve web torrent " + url + ": Unexpected HTTP response status code " +
response.getStatusLine().toString());
Crouton.showText(this, R.string.error_401, NavigationHelper.CROUTON_ERROR_STYLE);
return;
}
@ -1043,8 +1062,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1043,8 +1062,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
try {
final byte[] buffer = new byte[1024];
int read;
while ((read = input.read(buffer)) != -1)
while ((read = input.read(buffer)) != -1) {
output.write(buffer, 0, read);
}
output.flush();
String fileName = Uri.fromFile(tempFile).toString();
addTorrentByFile(fileName, title);
@ -1056,8 +1076,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1056,8 +1076,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
Crouton.showText(this, R.string.error_torrentfile, NavigationHelper.CROUTON_ERROR_STYLE);
} finally {
try {
if (input != null)
if (input != null) {
input.close();
}
} catch (IOException e) {
log.e(this, "Error closing the input stream " + tempFile.toString() + ": " + e.toString());
Crouton.showText(this, R.string.error_torrentfile, NavigationHelper.CROUTON_ERROR_STYLE);
@ -1118,9 +1139,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1118,9 +1139,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
public void removeTorrent(Torrent torrent, boolean withData) {
DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded(
(DaemonTaskSuccessResult) result,
getString(withData ? R.string.result_removed_with_data : R.string.result_removed, torrent.getName()));
onTaskSucceeded((DaemonTaskSuccessResult) result,
getString(withData ? R.string.result_removed_with_data : R.string.result_removed,
torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -1130,13 +1151,12 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1130,13 +1151,12 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Override
public void updateLabel(Torrent torrent, String newLabel) {
torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel)
.execute(log);
DaemonTaskResult result =
SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded(
(DaemonTaskSuccessResult) result,
newLabel == null ? getString(R.string.result_labelremoved) : getString(R.string.result_labelset,
newLabel));
onTaskSucceeded((DaemonTaskSuccessResult) result,
newLabel == null ? getString(R.string.result_labelremoved) :
getString(R.string.result_labelset, newLabel));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -1180,8 +1200,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1180,8 +1200,9 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Background
@Override
public void updatePriority(Torrent torrent, List<TorrentFile> files, Priority priority) {
DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority,
new ArrayList<TorrentFile>(files)).execute(log);
DaemonTaskResult result =
SetFilePriorityTask.create(currentConnection, torrent, priority, new ArrayList<TorrentFile>(files))
.execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else {
@ -1191,8 +1212,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1191,8 +1212,8 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@Background
public void updateMaxSpeeds(Integer maxDownloadSpeed, Integer maxUploadSpeed) {
DaemonTaskResult result = SetTransferRatesTask.create(currentConnection, maxUploadSpeed, maxDownloadSpeed)
.execute(log);
DaemonTaskResult result =
SetTransferRatesTask.create(currentConnection, maxUploadSpeed, maxDownloadSpeed).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_maxspeedsset));
} else {
@ -1209,22 +1230,24 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1209,22 +1230,24 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@UiThread
protected void onCommunicationError(DaemonTaskFailureResult result, boolean isCritical) {
//noinspection ThrowableResultOfMethodCallIgnored
log.i(this, result.getException().toString());
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
Crouton.showText(this, error, NavigationHelper.CROUTON_ERROR_STYLE);
fragmentTorrents.updateIsLoading(false);
if (isCritical) {
fragmentTorrents.updateError(error);
if (fragmentDetails != null && fragmentDetails.isAdded())
if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateIsLoading(false, error);
}
}
}
@UiThread
protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) {
lastNavigationLabels = Label.convertToNavigationLabels(labels,
getResources().getString(R.string.labels_unlabeled));
lastNavigationLabels =
Label.convertToNavigationLabels(labels, getResources().getString(R.string.labels_unlabeled));
// Report the newly retrieved list of torrents to the torrents fragment
fragmentTorrents.updateIsLoading(false);
@ -1236,27 +1259,19 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1236,27 +1259,19 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
}
// Update local list of labels in the navigation
if (navigationListAdapter != null) {
// Labels are shown in the dedicated side navigation
navigationListAdapter.updateLabels(lastNavigationLabels);
} else {
// Labels are shown in the action bar spinner
navigationSpinnerAdapter.updateLabels(lastNavigationLabels);
}
if (fragmentDetails != null && fragmentDetails.isAdded())
if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateLabels(lastNavigationLabels);
}
// Perhaps we were still waiting to preselect the last used filter (on a fresh application start)
if (preselectNavigationFilter != null) {
FilterListAdapter adapter = navigationListAdapter != null ? navigationListAdapter
: navigationSpinnerAdapter;
for (int i = 0; i < adapter.getCount(); i++) {
// Regardless of the navigation style (side list or action bar spinner), we can look up the navigation
// filter item, which is represented as simple list item (and might not exist any more, such as with a
// label that is deleted on the server)
Object item = adapter.getItem(i);
if (item instanceof SimpleListItem && item instanceof NavigationFilter
&& ((NavigationFilter) item).getCode().equals(preselectNavigationFilter)) {
if (preselectNavigationFilter != null && navigationListAdapter != null) {
for (int i = 0; i < navigationListAdapter.getCount(); i++) {
// Look up the navigation filter item, which is represented as simple list item (and might not exist any
// more, such as with a label that is deleted on the server)
Object item = navigationListAdapter.getItem(i);
if (item instanceof SimpleListItem && item instanceof NavigationFilter &&
((NavigationFilter) item).getCode().equals(preselectNavigationFilter)) {
filterSelected((SimpleListItem) item, false);
break;
}
@ -1266,7 +1281,7 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1266,7 +1281,7 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
}
// Update the server status (counts and speeds) in the action bar
serverStatusView.update(torrents, systemSettings.treatDormantAsInactive(),
serverStatusView.updateStatus(torrents, systemSettings.treatDormantAsInactive(),
Daemon.supportsSetTransferRates(currentConnection.getType()));
}
@ -1274,16 +1289,18 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN @@ -1274,16 +1289,18 @@ public class TorrentsActivity extends ActionBarActivity implements ActionBar.OnN
@UiThread
protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// Update the details fragment with the new fine details for the shown torrent
if (fragmentDetails != null && fragmentDetails.isAdded())
if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateTorrentDetails(torrent, torrentDetails);
}
}
@UiThread
protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// Update the details fragment with the newly retrieved list of files
if (fragmentDetails != null && fragmentDetails.isAdded())
if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateTorrentFiles(torrent, new ArrayList<TorrentFile>(torrentFiles));
}
}
@UiThread
protected void onTurtleModeRetrieved(boolean turtleModeEnabled) {

5
app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java

@ -114,9 +114,4 @@ public class FilterListAdapter extends MergeAdapter { @@ -114,9 +114,4 @@ public class FilterListAdapter extends MergeAdapter {
notifyDataSetChanged();
}
@Override
public int getViewTypeCount() {
return 1;
}
}

70
app/src/main/java/org/transdroid/core/gui/navigation/FilterListDropDownAdapter.java

@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
/*
* Copyright 2010-2013 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.navigation;
import org.androidannotations.annotations.EBean;
import org.transdroid.daemon.IDaemonAdapter;
import android.view.View;
import android.view.ViewGroup;
/**
* List adapter that holds filter items, that is, servers, view types and labels and is displayed as content to a
* Spinner instead of a ListView.
* @author Eric Kok
*/
@EBean
public class FilterListDropDownAdapter extends FilterListAdapter {
protected NavigationSelectionView navigationSelectionView = null;
private String currentServer = null;
private String currentFilter = null;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// This returns the singleton navigation spinner view
if (navigationSelectionView == null) {
navigationSelectionView = NavigationSelectionView_.build(context);
}
navigationSelectionView.bind(currentServer, currentFilter);
return navigationSelectionView;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
// This returns the item to show in the drop down list
return super.getView(position, convertView, parent);
}
public void updateCurrentFilter(NavigationFilter currentFilter) {
this.currentFilter = currentFilter.getName();
if (navigationSelectionView != null)
navigationSelectionView.bind(this.currentServer, this.currentFilter);
}
public void updateCurrentServer(IDaemonAdapter currentConnection) {
this.currentServer = currentConnection.getSettings().getName();
if (navigationSelectionView != null)
navigationSelectionView.bind(this.currentServer, this.currentFilter);
}
public void hideServersLabel() {
serverSeparator.setViewVisibility(View.GONE);
notifyDataSetInvalidated();
}
}

155
app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -18,9 +18,6 @@ package org.transdroid.core.gui.navigation; @@ -18,9 +18,6 @@ package org.transdroid.core.gui.navigation;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.text.Spannable;
import android.text.SpannableString;
@ -53,22 +50,83 @@ import de.keyboardsurfer.android.widget.crouton.Style; @@ -53,22 +50,83 @@ import de.keyboardsurfer.android.widget.crouton.Style;
@EBean
public class NavigationHelper {
@RootContext
protected Context context;
private Boolean inDebugMode;
private static ImageLoader imageCache;
/**
* Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display error messages.
*/
public static Style CROUTON_ERROR_STYLE =
new Style.Builder().setBackgroundColor(R.color.crouton_error).setTextSize(13).build();
/**
* Use with {@link Crouton#showText(android.app.Activity, int, Style)} (and variants) to display info messages.
*/
public static Style CROUTON_INFO_STYLE =
new Style.Builder().setBackgroundColor(R.color.crouton_info).setTextSize(13).build();
private static ImageLoader imageCache;
@RootContext
protected Context context;
/**
* Converts a string into a {@link Spannable} that displays the string in the Roboto Condensed font
* @param string A plain text {@link String}
* @return A {@link Spannable} that can be applied to supporting views (such as the action bar title) so that the
* input string will be displayed using the Roboto Condensed font (if the OS has this)
*/
public static SpannableString buildCondensedFontString(String string) {
if (string == null) {
return null;
}
SpannableString s = new SpannableString(string);
s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
/**
* Analyses a torrent http or magnet URI and tries to come up with a reasonable human-readable name.
* @param rawTorrentUri The raw http:// or magnet: link to the torrent
* @return A best-guess, reasonably long name for the linked torrent
*/
public static String extractNameFromUri(Uri rawTorrentUri) {
if (rawTorrentUri.getScheme() == null) {
// Probably an incorrect URI; just return the whole thing
return rawTorrentUri.toString();
}
if (rawTorrentUri.getScheme().equals("magnet")) {
// Magnet links might have a dn (display name) parameter
String dn = getQueryParameter(rawTorrentUri, "dn");
if (dn != null && !dn.equals("")) {
return dn;
}
// If not, try to return the hash that is specified as xt (exact topci)
String xt = getQueryParameter(rawTorrentUri, "xt");
if (xt != null && !xt.equals("")) {
return xt;
}
}
if (rawTorrentUri.isHierarchical()) {
String path = rawTorrentUri.getPath();
if (path != null) {
if (path.contains("/")) {
path = path.substring(path.lastIndexOf("/"));
}
return path;
}
}
// No idea what to do with this; return as is
return rawTorrentUri.toString();
}
private static String getQueryParameter(Uri uri, String parameter) {
int start = uri.toString().indexOf(parameter + "=");
if (start >= 0) {
int begin = start + (parameter + "=").length();
int end = uri.toString().indexOf("&", begin);
return uri.toString().substring(begin, end >= 0 ? end : uri.toString().length());
}
return null;
}
/**
* Returns (and initialises, if needed) an image cache that uses memory and (1MB) local storage.
@ -100,18 +158,13 @@ public class NavigationHelper { @@ -100,18 +158,13 @@ public class NavigationHelper {
}
/**
* Whether any search-related UI components should be shown in the interface. At the moment returns false only if we
* run as Transdroid Lite version.
* @return True if search is enabled, false otherwise
* Returns the application name (like Transdroid) and version name (like 1.5.0), appended by the version code (like
* 180).
* @return The app name and version, such as 'Transdroid 1.5.0 (180)'
*/
public String getAppNameAndVersion() {
String appName = context.getString(R.string.app_name);
try {
PackageInfo m = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
return appName + " " + m.versionName + " (" + m.versionCode + ")";
} catch (NameNotFoundException e) {
return appName;
}
return context.getString(R.string.app_name) + " " + BuildConfig.VERSION_NAME + " (" +
Integer.toString(BuildConfig.VERSION_CODE) + ")";
}
/**
@ -160,68 +213,4 @@ public class NavigationHelper { @@ -160,68 +213,4 @@ public class NavigationHelper {
return context.getResources().getBoolean(R.bool.updatecheck_available);
}
/**
* Converts a string into a {@link Spannable} that displays the string in the Roboto Condensed font
* @param string A plain text {@link String}
* @return A {@link Spannable} that can be applied to supporting views (such as the action bar title) so that the
* input string will be displayed using the Roboto Condensed font (if the OS has this)
*/
public static SpannableString buildCondensedFontString(String string) {
if (string == null) {
return null;
}
SpannableString s = new SpannableString(string);
s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s;
}
/**
* Analyses a torrent http or magnet URI and tries to come up with a reasonable human-readable name.
* @param rawTorrentUri The raw http:// or magnet: link to the torrent
* @return A best-guess, reasonably long name for the linked torrent
*/
public static String extractNameFromUri(Uri rawTorrentUri) {
if (rawTorrentUri.getScheme() == null) {
// Probably an incorrect URI; just return the whole thing
return rawTorrentUri.toString();
}
if (rawTorrentUri.getScheme().equals("magnet")) {
// Magnet links might have a dn (display name) parameter
String dn = getQueryParameter(rawTorrentUri, "dn");
if (dn != null && !dn.equals("")) {
return dn;
}
// If not, try to return the hash that is specified as xt (exact topci)
String xt = getQueryParameter(rawTorrentUri, "xt");
if (xt != null && !xt.equals("")) {
return xt;
}
}
if (rawTorrentUri.isHierarchical()) {
String path = rawTorrentUri.getPath();
if (path != null) {
if (path.contains("/")) {
path = path.substring(path.lastIndexOf("/"));
}
return path;
}
}
// No idea what to do with this; return as is
return rawTorrentUri.toString();
}
private static String getQueryParameter(Uri uri, String parameter) {
int start = uri.toString().indexOf(parameter + "=");
if (start >= 0) {
int begin = start + (parameter + "=").length();
int end = uri.toString().indexOf("&", begin);
return uri.toString().substring(begin, end >= 0 ? end : uri.toString().length());
}
return null;
}
}

52
app/src/main/java/org/transdroid/core/gui/navigation/NavigationSelectionView.java

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
/*
* Copyright 2010-2013 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.navigation;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
* View that displays the user-selected server and display filter inside the action bar list navigation spinner
* @author Eric Kok
*/
@EViewGroup(resName="actionbar_navigation")
public class NavigationSelectionView extends LinearLayout {
@ViewById
protected TextView filterText;
@ViewById
protected TextView serverText;
public NavigationSelectionView(Context context) {
super(context);
}
/**
* Binds the names of the current connected server and selected filter to this navigation view.
* @param currentServer The name of the server currently connected to
* @param currentFilter The name of the filter that is currently selected
*/
public void bind(String currentServer, String currentFilter) {
serverText.setText(currentServer);
filterText.setText(currentFilter);
}
}

10
app/src/main/java/org/transdroid/core/service/ConnectivityHelper.java

@ -32,16 +32,8 @@ public class ConnectivityHelper { @@ -32,16 +32,8 @@ public class ConnectivityHelper {
@SystemService
protected WifiManager wifiManager;
public ConnectivityHelper(Context context) {
}
@SuppressWarnings("deprecation")
public boolean shouldPerformBackgroundActions() {
// First check the old background data setting (this will always be true for ICS+)
if (!connectivityManager.getBackgroundDataSetting())
return false;
// Still good? Check the current active network instead
// Check the current active network whether we are connected
return connectivityManager.getActiveNetworkInfo() != null
&& connectivityManager.getActiveNetworkInfo().isConnected();
}

8
app/src/main/res/drawable/elevation_shadow.xml

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="90"
android:endColor="#88333333"
android:startColor="@android:color/transparent"/>
</shape>

32
app/src/main/res/layout-w600dp/activity_torrents.xml

@ -1,12 +1,29 @@ @@ -1,12 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This layout is for 7" and 10" tablets in portrait and shows torrents and filters. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:orientation="vertical"
tools:context=".core.gui.TorrentsActivity_">
<android.support.v7.widget.Toolbar
android:id="@+id/torrents_toolbar"
style="@style/DefaultToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"/>
<View
style="@style/DefaultToolbarShadow"
android:layout_below="@id/torrents_toolbar"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/torrents_toolbar"
android:baselineAligned="false"
tools:context=".TorrentsActivity" >
android:orientation="horizontal">
<ListView
android:id="@+id/filters_list"
@ -14,14 +31,15 @@ @@ -14,14 +31,15 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:listSelector="?attr/activatable_background" />
tools:listitem="@layout/list_item_filter"/>
<fragment
android:id="@+id/torrents_fragment"
class="org.transdroid.core.gui.TorrentsFragment_"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="3"
class="org.transdroid.core.gui.TorrentsFragment_"
tools:layout="@layout/fragment_torrents" />
tools:layout="@layout/fragment_torrents"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

36
app/src/main/res/layout-w900dp/activity_torrents.xml

@ -1,12 +1,29 @@ @@ -1,12 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This layout is for 7" and 10" tablets in landscape shows torrents, filters and details. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:orientation="vertical"
tools:context=".core.gui.TorrentsActivity_">
<android.support.v7.widget.Toolbar
android:id="@+id/torrents_toolbar"
style="@style/DefaultToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"/>
<View
style="@style/DefaultToolbarShadow"
android:layout_below="@id/torrents_toolbar"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/torrents_toolbar"
android:baselineAligned="false"
tools:context=".TorrentsActivity" >
android:orientation="horizontal">
<ListView
android:id="@+id/filters_list"
@ -14,22 +31,23 @@ @@ -14,22 +31,23 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:listSelector="?attr/activatable_background" />
tools:listitem="@layout/list_item_filter"/>
<fragment
android:id="@+id/torrents_fragment"
class="org.transdroid.core.gui.TorrentsFragment_"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2"
class="org.transdroid.core.gui.TorrentsFragment_"
tools:layout="@layout/fragment_torrents" />
tools:layout="@layout/fragment_torrents"/>
<fragment
android:id="@+id/torrentdetails_fragment"
class="org.transdroid.core.gui.DetailsFragment_"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2"
class="org.transdroid.core.gui.DetailsFragment_"
tools:layout="@layout/fragment_details" />
tools:layout="@layout/fragment_details"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

44
app/src/main/res/layout/actionbar_navigation.xml

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2013 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:minWidth="120dp"
android:paddingRight="@dimen/margin_half" >
<TextView
android:id="@+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/text_actionbar"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter"
android:fontFamily="sans-serif-condensed" />
<TextView
android:id="@+id/server_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dip"
android:textColor="?attr/text_actionbar"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server"
android:fontFamily="sans-serif-light" />
</LinearLayout>

114
app/src/main/res/layout/actionbar_serverstatus.xml

@ -15,82 +15,106 @@ @@ -15,82 +15,106 @@
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_width="match_parent" >
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/speedswrapper_layout"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="?attr/selectableItemBackground"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?attr/activatable_background"
android:clickable="true"
android:focusable="true"
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default"
android:paddingTop="@dimen/ui_serverstatus_margin"
tools:ignore="UselessParent" >
android:orientation="vertical"
android:padding="@dimen/ui_serverstatus_margin">
<TextView
android:id="@+id/upcount_sign"
android:id="@+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-condensed"
android:textColor="?attr/text_actionbar"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter"
tools:text="Downloading"/>
<TextView
android:id="@+id/server_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↑"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server"
tools:text="XIRVIK RTORRENT"/>
</LinearLayout>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<RelativeLayout
android:id="@+id/speedswrapper_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?attr/activatable_background"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/ui_serverstatus_margin">
<TextView
android:id="@+id/upcount_text"
android:id="@+id/downcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_bignumber" />
android:textSize="@dimen/ui_serverstatus_bignumber"
tools:text="7"/>
<TextView
android:id="@+id/downcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_text"
android:layout_toRightOf="@id/downcount_text"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↓"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
tools:ignore="HardcodedText"
tools:visibility="visible"/>
<TextView
android:id="@+id/downcount_text"
android:id="@+id/upcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/downcount_sign"
android:layout_toRightOf="@id/downcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_bignumber" />
android:textSize="@dimen/ui_serverstatus_bignumber"
tools:text="128"/>
<TextView
android:id="@+id/upspeed_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:id="@+id/upcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text"
android:layout_alignParentRight="true"
android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip"
android:layout_toRightOf="@id/upcount_text"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:text="↑"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText"
tools:visibility="visible"/>
<TextView
android:id="@+id/downspeed_text"
@ -103,7 +127,23 @@ @@ -103,7 +127,23 @@
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
android:textSize="@dimen/ui_serverstatus_smallnumber"
tools:text="1.2 MB/s"/>
<TextView
android:id="@+id/upspeed_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text"
android:layout_alignRight="@id/upcount_sign"
android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_actionbar"
android:textSize="@dimen/ui_serverstatus_smallnumber"
tools:text="678 KB/s"/>
</RelativeLayout>
</FrameLayout>
</LinearLayout>

43
app/src/main/res/layout/activity_torrents.xml

@ -1,16 +1,49 @@ @@ -1,16 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This layout is for phones in portrait and shows only the torrents list. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TorrentsActivity" >
tools:context=".core.gui.TorrentsActivity_">
<!-- The main content view -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/torrents_toolbar"
style="@style/DefaultToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"/>
<View
style="@style/DefaultToolbarShadow"
android:layout_below="@id/torrents_toolbar"/>
<fragment
android:id="@+id/torrents_fragment"
class="org.transdroid.core.gui.TorrentsFragment_"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="org.transdroid.core.gui.TorrentsFragment_"
tools:layout="@layout/fragment_torrents" />
android:layout_below="@id/torrents_toolbar"
tools:layout="@layout/fragment_torrents"/>
</RelativeLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"/>
</FrameLayout>
</android.support.v4.widget.DrawerLayout>

2
app/src/main/res/layout/list_item_filter.xml

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activatable_background"
android:paddingBottom="@dimen/margin_half"

2
app/src/main/res/values-v16/styles.xml

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<!-- Taken from http://stackoverflow.com/questions/10020466/android-4-0-sub-title-section-label-styling -->
<style name="SectionHeader" parent="TextAppearance.AppCompat">
<item name="android:drawablePadding">4dp</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:layout_marginTop">@dimen/margin_default</item>
<item name="android:textColor">@color/green</item>
<item name="android:textSize">13sp</item>
<item name="android:fontFamily">sans-serif</item>

17
app/src/main/res/values-v21/styles.xml

@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
<item name="ic_action_trackers">@drawable/ic_action_trackers_light</item>
<item name="ic_action_website">@drawable/ic_action_website_light</item>
<item name="loading_progress">@drawable/loading_progress_light</item>
<item name="activatable_background">@drawable/activatable_background</item>
<item name="activatable_background">?android:attr/selectableItemBackground</item>
<item name="text_bright">@color/text_bright_light</item>
<item name="text_actionbar">@color/text_actionbar_dark</item>
<item name="text_actionbar_secondary">@color/text_actionbar_light</item>
@ -80,10 +80,23 @@ @@ -80,10 +80,23 @@
<item name="ic_action_trackers">@drawable/ic_action_trackers_dark</item>
<item name="ic_action_website">@drawable/ic_action_website_dark</item>
<item name="loading_progress">@drawable/loading_progress_dark</item>
<item name="activatable_background">@drawable/activatable_background</item>
<item name="activatable_background">?android:attr/selectableItemBackground</item>
<item name="text_bright">@color/text_bright_dark</item>
<item name="text_actionbar">@color/text_actionbar_dark</item>
<item name="text_actionbar_secondary">@color/text_actionbar_light</item>
</style>
<style name="DefaultToolbar">
<item name="android:background">?attr/colorPrimary</item>
<item name="android:elevation">3dp</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
<style name="DefaultToolbarShadow">
<item name="android:visibility">gone</item>
<item name="android:layout_height">3dp</item>
<item name="android:layout_width">match_parent</item>
</style>
</resources>

2
app/src/main/res/values/strings.xml

@ -71,6 +71,8 @@ @@ -71,6 +71,8 @@
<string name="action_visitwebsite">Visit transdroid.org</string>
<string name="action_close">Close</string>
<string name="navigation_opendrawer">Select server and filter</string>
<string name="navigation_closedrawer">Close filters list</string>
<string name="navigation_nosettings">%1$s allows you to monitor and manage the torrent client you run at home or on your seedbox. Setting things up can be a bit tricky, but we offer step-by-step guides and promise it\'ll be worth it!</string>
<string name="navigation_emptytorrents">Connected, but no torrents are active within the current filter</string>
<string name="navigation_emptydetails">Select a torrent to view its details</string>

14
app/src/main/res/values/styles.xml

@ -96,9 +96,21 @@ @@ -96,9 +96,21 @@
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="DefaultToolbar">
<item name="android:background">?attr/colorPrimary</item>
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
</style>
<style name="DefaultToolbarShadow">
<item name="android:background">@drawable/elevation_shadow</item>
<item name="android:layout_height">3dp</item>
<item name="android:layout_width">match_parent</item>
</style>
<style name="SectionHeader" parent="TextAppearance.AppCompat">
<item name="android:drawablePadding">4dp</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:layout_marginTop">@dimen/margin_default</item>
<item name="android:textColor">@color/green</item>
<item name="android:textSize">13sp</item>
</style>

2
app/src/main/res/values/styles_transdroid_dark.xml

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<resources>
<style name="Theme.Transdroid.Dark" parent="Theme.AppCompat">
<style name="Theme.Transdroid.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green_dark</item>
</style>

2
app/src/main/res/values/styles_transdroid_light.xml

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
<resources>
<style name="Theme.Transdroid.Light" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="Theme.Transdroid.Light" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green_dark</item>
<item name="colorAccent">@color/green_light</item>

Loading…
Cancel
Save