From 25f741260f2e721c596e17b96c85fe037bc34cb7 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Wed, 24 Jun 2015 18:01:23 +0200 Subject: [PATCH] Fixes in tablet and dark version of the new UI. --- app/build.gradle | 8 +++---- .../transdroid/core/gui/TorrentsActivity.java | 10 +++++++++ .../core/gui/search/SearchActivity.java | 21 +++++++++---------- .../gui/search/SearchResultsFragment.java | 5 +++++ .../gui/settings/SystemSettingsActivity.java | 2 ++ .../daemon/Rtorrent/RtorrentAdapter.java | 6 +++--- app/src/main/res/layout/activity_torrents.xml | 2 +- app/src/main/res/values-v21/styles.xml | 6 ++++-- app/src/main/res/values/attrs.xml | 7 ++++--- app/src/main/res/values/changelog.xml | 4 ++++ app/src/main/res/values/styles.xml | 2 ++ 11 files changed, 49 insertions(+), 24 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5c69f6a4..9bc9c833 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { defaultConfig { minSdkVersion 15 targetSdkVersion 22 - versionCode 219 - versionName '2.5.0-beta2' + versionCode 221 + versionName '2.5.1' } buildTypes { release { @@ -37,8 +37,8 @@ dependencies { compile 'com.j256.ormlite:ormlite-core:4.48' compile 'com.j256.ormlite:ormlite-android:4.48' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' - compile 'com.android.support:appcompat-v7:22.1.0' - compile 'com.android.support:support-annotations:20.0.0' + compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:support-annotations:22.1.1' compile 'com.getbase:floatingactionbutton:1.8.0' compile 'com.afollestad:material-dialogs:0.6.3.3' compile 'com.nispok:snackbar:2.10.6' diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java index 2272364b..151d1345 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -455,8 +455,13 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE // No connection yet; hide all menu options except settings if (currentConnection == null) { torrentsToolbar.setNavigationIcon(null); + if (selectionToolbar != null) + selectionToolbar.setVisibility(View.GONE); addmenuButton.setVisibility(View.GONE); actionsToolbar.setVisibility(View.GONE); + if (filtersList != null) + filtersList.setVisibility(View.GONE); + filterSearch.setVisibility(View.GONE); torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); @@ -474,8 +479,13 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE // There is a connection (read: settings to some server known) if (drawerToggle != null) torrentsToolbar.setNavigationIcon(R.drawable.ic_action_drawer); + if (selectionToolbar != null) + selectionToolbar.setVisibility(View.VISIBLE); addmenuButton.setVisibility(View.VISIBLE); actionsToolbar.setVisibility(View.VISIBLE); + if (filtersList != null) + filtersList.setVisibility(View.VISIBLE); + filterSearch.setVisibility(View.VISIBLE); boolean addByFile = Daemon.supportsAddByFile(currentConnection.getType()); addmenuFileButton.setVisibility(addByFile ? View.VISIBLE : View.GONE); // Primary toolbar menu diff --git a/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java b/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java index e59279c7..23e3f183 100644 --- a/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java @@ -23,6 +23,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.provider.SearchRecentSuggestions; +import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.Toolbar; @@ -74,8 +75,6 @@ public class SearchActivity extends ActionBarActivity implements ActionBar.OnNav @Bean protected ApplicationSettings applicationSettings; @Bean - protected NavigationHelper navigationHelper; - @Bean protected SearchHelper searchHelper; @SystemService protected SearchManager searchManager; @@ -159,15 +158,15 @@ public class SearchActivity extends ActionBarActivity implements ActionBar.OnNav @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - if (navigationHelper.enableSearchUi()) { - // Add an expandable SearchView to the action bar - MenuItem item = menu.findItem(R.id.action_search); - final SearchView searchView = new SearchView(searchToolbar.getContext()); - searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); - searchView.setQueryRefinementEnabled(true); - item.setActionView(searchView); - searchMenu = item; - } + // Add an expandable SearchView to the action bar + MenuItem item = menu.findItem(R.id.action_search); + final SearchView searchView = new SearchView(searchToolbar.getContext()); + searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); + searchView.setQueryRefinementEnabled(true); + //searchView.setIconified(false); + searchView.setIconifiedByDefault(false); + MenuItemCompat.setActionView(item, searchView); + searchMenu = item; return true; } diff --git a/app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java b/app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java index 0f119b35..65ff59f7 100644 --- a/app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.support.v7.app.ActionBarActivity; +import android.text.TextUtils; import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; @@ -198,6 +199,10 @@ public class SearchResultsFragment extends Fragment { if (checked.size() > 1) { Toast.makeText(getActivity(), getString(R.string.search_openingdetails, first.getName()), Toast.LENGTH_LONG).show(); } + if (TextUtils.isEmpty(first.getDetailsUrl())) { + Toast.makeText(getActivity(), getString(R.string.error_invalid_url_form, first.getName()), Toast.LENGTH_LONG).show(); + return false; + } startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(first.getDetailsUrl()))); return true; } else { diff --git a/app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java index add9e506..1c46164b 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java @@ -179,6 +179,8 @@ public class SystemSettingsActivity extends PreferenceCompatActivity { @OnActivityResult(BarcodeHelper.ACTIVITY_BARCODE_QRSETTINGS) public void onQrCodeScanned(int resultCode, Intent data) { // We should have received Intent extras with the QR-decoded data representing Transdroid settings + if (data == null || !data.hasExtra("SCAN_RESULT")) + return; // Cancelled scan; ignore SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SystemSettingsActivity.this); String contents = data.getStringExtra("SCAN_RESULT"); String formatName = data.getStringExtra("SCAN_RESULT_FORMAT"); diff --git a/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java b/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java index 721f0ba3..e2d9f660 100644 --- a/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java +++ b/app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java @@ -178,7 +178,7 @@ public class RtorrentAdapter implements IDaemonAdapter { byte[] bytes = baos.toByteArray(); int size = (int) file.length() * 2; final int XMLRPC_EXTRA_PADDING = 1280; - if (version >= 904) { + if (version >= 907) { makeRtorrentCall(log, "network.xmlrpc.size_limit.set", new Object[]{size + XMLRPC_EXTRA_PADDING}); makeRtorrentCall(log, "load.raw_start", new Object[]{bytes}); } else { @@ -191,7 +191,7 @@ public class RtorrentAdapter implements IDaemonAdapter { // Request to add a torrent by URL String url = ((AddByUrlTask) task).getUrl(); - if (version >= 904) { + if (version >= 907) { makeRtorrentCall(log, "load.start", new String[]{"", url}); } else { makeRtorrentCall(log, "load_start", new String[]{url}); @@ -202,7 +202,7 @@ public class RtorrentAdapter implements IDaemonAdapter { // Request to add a magnet link by URL String magnet = ((AddByMagnetUrlTask) task).getUrl(); - if (version >= 904) { + if (version >= 907) { makeRtorrentCall(log, "load.start", new String[]{"", magnet}); } else { makeRtorrentCall(log, "load_start", new String[]{magnet}); diff --git a/app/src/main/res/layout/activity_torrents.xml b/app/src/main/res/layout/activity_torrents.xml index 50743180..384d2032 100644 --- a/app/src/main/res/layout/activity_torrents.xml +++ b/app/src/main/res/layout/activity_torrents.xml @@ -95,7 +95,7 @@ android:layout_width="@dimen/ui_filters_list" android:layout_height="match_parent" android:layout_gravity="start" - android:background="@android:color/white" + android:background="?attr/drawer_background" android:orientation="vertical">