Browse Source

Fixed UI issues due to dark theme and appcompat. Corrects dialog colors on dark theme, fixes #224. Corrects display of contextual action bar and search entry box.

pull/256/head
Eric Kok 9 years ago
parent
commit
edce58ab03
  1. 15
      app/build.gradle
  2. 6
      app/src/main/java/org/transdroid/core/app/settings/SystemSettings.java
  3. 5
      app/src/main/java/org/transdroid/core/gui/navigation/SetLabelDialog.java
  4. 5
      app/src/main/java/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java
  5. 5
      app/src/main/java/org/transdroid/core/gui/navigation/SetTrackersDialog.java
  6. 9
      app/src/main/java/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java
  7. 83
      app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java
  8. 4
      app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java
  9. 9
      app/src/main/res/layout/activity_search.xml
  10. 2
      build.gradle

15
app/build.gradle

@ -2,14 +2,15 @@ apply plugin: 'com.android.application'
apply plugin: 'android-apt' apply plugin: 'android-apt'
android { android {
compileSdkVersion 22 compileSdkVersion 23
buildToolsVersion '21.1.2' buildToolsVersion '23.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig { defaultConfig {
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 22 targetSdkVersion 23
versionCode 222 versionCode 223
versionName '2.5.2' versionName '2.5.3'
} }
buildTypes { buildTypes {
release { release {
@ -37,8 +38,8 @@ dependencies {
compile 'com.j256.ormlite:ormlite-core:4.48' compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48' compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-annotations:22.2.0' compile 'com.android.support:support-annotations:23.0.0'
compile 'com.getbase:floatingactionbutton:1.8.0' compile 'com.getbase:floatingactionbutton:1.8.0'
compile 'com.afollestad:material-dialogs:0.6.3.3' compile 'com.afollestad:material-dialogs:0.6.3.3'
compile 'com.nispok:snackbar:2.10.6' compile 'com.nispok:snackbar:2.10.6'

6
app/src/main/java/org/transdroid/core/app/settings/SystemSettings.java

@ -27,6 +27,8 @@ import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import com.afollestad.materialdialogs.Theme;
/** /**
* Allows instantiation of the settings specified in R.xml.pref_system. * Allows instantiation of the settings specified in R.xml.pref_system.
* @author Eric Kok * @author Eric Kok
@ -62,6 +64,10 @@ public class SystemSettings {
return prefs.getBoolean("system_usedarktheme", false); return prefs.getBoolean("system_usedarktheme", false);
} }
public Theme getMaterialDialogtheme() {
return useDarkTheme() ? Theme.DARK: Theme.LIGHT;
}
/** /**
* Returns the date when we last checked transdroid.org for the latest app version. * Returns the date when we last checked transdroid.org for the latest app version.
* @return The date/time when the {@link AppUpdateService} checked on the server for updates * @return The date/time when the {@link AppUpdateService} checked on the server for updates

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

@ -30,6 +30,7 @@ import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager; import com.nispok.snackbar.SnackbarManager;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -71,7 +72,7 @@ public class SetLabelDialog {
public void onNeutral(MaterialDialog dialog) { public void onNeutral(MaterialDialog dialog) {
onLabelPickedListener.onLabelPicked(null); onLabelPickedListener.onLabelPicked(null);
} }
}).build(); }).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).build();
if (currentLabels.size() == 0) { if (currentLabels.size() == 0) {
// Hide the list (and its label) if there are no labels yet // Hide the list (and its label) if there are no labels yet
@ -93,7 +94,7 @@ public class SetLabelDialog {
} }
public interface OnLabelPickedListener { public interface OnLabelPickedListener {
public void onLabelPicked(String newLabel); void onLabelPicked(String newLabel);
} }
} }

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

@ -24,6 +24,7 @@ import android.widget.EditText;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
public class SetStorageLocationDialog { public class SetStorageLocationDialog {
@ -44,11 +45,11 @@ public class SetStorageLocationDialog {
// User is done editing and requested to update given the text input // User is done editing and requested to update given the text input
onStorageLocationUpdatedListener.onStorageLocationUpdated(locationText.getText().toString()); onStorageLocationUpdatedListener.onStorageLocationUpdated(locationText.getText().toString());
} }
}).show(); }).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).show();
} }
public interface OnStorageLocationUpdatedListener { public interface OnStorageLocationUpdatedListener {
public void onStorageLocationUpdated(String newLocation); void onStorageLocationUpdated(String newLocation);
} }
} }

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

@ -25,6 +25,7 @@ import android.widget.EditText;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -48,11 +49,11 @@ public class SetTrackersDialog extends DialogFragment {
// User is done editing and requested to update given the text input // User is done editing and requested to update given the text input
onTrackersUpdatedListener.onTrackersUpdated(Arrays.asList(trackersText.getText().toString().split("\n"))); onTrackersUpdatedListener.onTrackersUpdated(Arrays.asList(trackersText.getText().toString().split("\n")));
} }
}).show(); }).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).show();
} }
public interface OnTrackersUpdatedListener { public interface OnTrackersUpdatedListener {
public void onTrackersUpdated(List<String> updatedTrackers); void onTrackersUpdated(List<String> updatedTrackers);
} }
} }

9
app/src/main/java/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java

@ -26,6 +26,7 @@ import android.widget.TextView;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
public class SetTransferRatesDialog { public class SetTransferRatesDialog {
@ -62,7 +63,7 @@ public class SetTransferRatesDialog {
public void onNeutral(MaterialDialog dialog) { public void onNeutral(MaterialDialog dialog) {
onRatesPickedListener.resetRates(); onRatesPickedListener.resetRates();
} }
}).build(); }).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).build();
bindButtons(dialog.getCustomView(), maxSpeedDown, R.id.down1Button, R.id.down2Button, R.id.down3Button, R.id.down4Button, R.id.down5Button, bindButtons(dialog.getCustomView(), maxSpeedDown, R.id.down1Button, R.id.down2Button, R.id.down3Button, R.id.down4Button, R.id.down5Button,
R.id.down6Button, R.id.down7Button, R.id.down8Button, R.id.down9Button, R.id.down0Button); R.id.down6Button, R.id.down7Button, R.id.down8Button, R.id.down9Button, R.id.down0Button);
@ -98,11 +99,11 @@ public class SetTransferRatesDialog {
* Listener interface to the user having picked or wanting to resets the current maximum transfer speeds; * Listener interface to the user having picked or wanting to resets the current maximum transfer speeds;
*/ */
public interface OnRatesPickedListener { public interface OnRatesPickedListener {
public void onRatesPicked(int maxDownloadSpeed, int maxUploadSpeed); void onRatesPicked(int maxDownloadSpeed, int maxUploadSpeed);
public void resetRates(); void resetRates();
public void onInvalidNumber(); void onInvalidNumber();
} }
} }

83
app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java

@ -16,16 +16,12 @@
*/ */
package org.transdroid.core.gui.search; package org.transdroid.core.gui.search;
import android.annotation.TargetApi;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.SearchRecentSuggestions; import android.provider.SearchRecentSuggestions;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
@ -35,6 +31,7 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SearchView; import android.widget.SearchView;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.AfterViews;
@ -42,7 +39,6 @@ import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FragmentById; import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.SystemService; import org.androidannotations.annotations.SystemService;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.R; import org.transdroid.R;
@ -62,11 +58,12 @@ import java.util.List;
* @author Eric Kok * @author Eric Kok
*/ */
@EActivity(R.layout.activity_search) @EActivity(R.layout.activity_search)
@OptionsMenu(R.menu.activity_search) public class SearchActivity extends AppCompatActivity {
public class SearchActivity extends AppCompatActivity implements ActionBar.OnNavigationListener {
@ViewById @ViewById
protected Toolbar searchToolbar; protected Toolbar searchToolbar;
@ViewById
protected Spinner sitesSpinner;
@FragmentById(R.id.searchresults_fragment) @FragmentById(R.id.searchresults_fragment)
protected SearchResultsFragment fragmentResults; protected SearchResultsFragment fragmentResults;
@ViewById @ViewById
@ -84,14 +81,6 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
private List<SearchSetting> searchSites; private List<SearchSetting> searchSites;
private SearchSetting lastUsedSite; private SearchSetting lastUsedSite;
private OnItemClickListener onSearchSiteClicked = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lastUsedSite = searchSites.get(position);
refreshSearch();
}
};
private String lastUsedQuery; private String lastUsedQuery;
@Override @Override
@ -106,8 +95,14 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
@AfterViews @AfterViews
protected void init() { protected void init() {
searchToolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
searchToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TorrentsActivity_.intent(SearchActivity.this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
});
setSupportActionBar(searchToolbar); setSupportActionBar(searchToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Get the user query, as coming from the standard SearchManager // Get the user query, as coming from the standard SearchManager
handleIntent(getIntent()); handleIntent(getIntent());
@ -133,6 +128,7 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
// Allow site selection via list (on large screens) or action bar spinner // Allow site selection via list (on large screens) or action bar spinner
if (searchsitesList != null) { if (searchsitesList != null) {
// The current layout has a dedicated list view to select the search site // The current layout has a dedicated list view to select the search site
sitesSpinner.setVisibility(View.GONE);
SearchSitesAdapter searchSitesAdapter = SearchSitesAdapter_.getInstance_(this); SearchSitesAdapter searchSitesAdapter = SearchSitesAdapter_.getInstance_(this);
searchSitesAdapter.update(searchSites); searchSitesAdapter.update(searchSites);
searchsitesList.setAdapter(searchSitesAdapter); searchsitesList.setAdapter(searchSitesAdapter);
@ -145,26 +141,31 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
} }
} else { } else {
// Use the action bar spinner to select sites // Use the action bar spinner to select sites
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); sitesSpinner.setVisibility(View.VISIBLE);
getSupportActionBar().setDisplayShowTitleEnabled(false); sitesSpinner.setAdapter(new SearchSettingsDropDownAdapter(searchToolbar.getContext(), searchSites));
getSupportActionBar().setListNavigationCallbacks(new SearchSettingsDropDownAdapter(searchToolbar.getContext(), searchSites), this); sitesSpinner.setOnItemSelectedListener(onSearchSiteSelected);
// Select the last used site; this also starts the search! // Select the last used site; this also starts the search!
if (lastUsedPosition >= 0) { if (lastUsedPosition >= 0) {
getSupportActionBar().setSelectedNavigationItem(lastUsedPosition); sitesSpinner.setSelection(lastUsedPosition);
lastUsedSite = searchSites.get(lastUsedPosition);
refreshSearch();
} }
} }
invalidateOptionsMenu();
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
// Manually insert the actions into the main torrent and secondary actions toolbars
searchToolbar.inflateMenu(R.menu.activity_search);
// Add an expandable SearchView to the action bar // Add an expandable SearchView to the action bar
MenuItem item = menu.findItem(R.id.action_search); MenuItem item = menu.findItem(R.id.action_search);
final SearchView searchView = new SearchView(searchToolbar.getContext()); final SearchView searchView = new SearchView(searchToolbar.getContext());
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true); searchView.setQueryRefinementEnabled(true);
//searchView.setIconified(false); searchView.setIconified(false);
searchView.setIconifiedByDefault(false); searchView.setIconifiedByDefault(false);
MenuItemCompat.setActionView(item, searchView); MenuItemCompat.setActionView(item, searchView);
searchMenu = item; searchMenu = item;
@ -176,9 +177,9 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
boolean searchInstalled = searchHelper.isTorrentSearchInstalled(); boolean searchInstalled = searchHelper.isTorrentSearchInstalled();
menu.findItem(R.id.action_search).setVisible(searchInstalled); searchToolbar.getMenu().findItem(R.id.action_search).setVisible(searchInstalled);
menu.findItem(R.id.action_refresh).setVisible(searchInstalled); searchToolbar.getMenu().findItem(R.id.action_refresh).setVisible(searchInstalled);
menu.findItem(R.id.action_downloadsearch).setVisible(!searchInstalled); searchToolbar.getMenu().findItem(R.id.action_downloadsearch).setVisible(!searchInstalled);
if (searchsitesList != null) { if (searchsitesList != null) {
searchsitesList.setVisibility(searchInstalled ? View.VISIBLE : View.GONE); searchsitesList.setVisibility(searchInstalled ? View.VISIBLE : View.GONE);
} }
@ -222,18 +223,25 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
return true; return true;
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private OnItemClickListener onSearchSiteClicked = new OnItemClickListener() {
@OptionsItem(android.R.id.home)
protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
@Override @Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
lastUsedSite = searchSites.get(itemPosition); lastUsedSite = searchSites.get(position);
refreshSearch(); refreshSearch();
return true; }
} };
private AdapterView.OnItemSelectedListener onSearchSiteSelected = new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
lastUsedSite = searchSites.get(position);
refreshSearch();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
/** /**
* Extracts the query string from the search {@link Intent} * Extracts the query string from the search {@link Intent}
@ -278,8 +286,9 @@ public class SearchActivity extends AppCompatActivity implements ActionBar.OnNav
// Save the search site currently used to search for future usage // Save the search site currently used to search for future usage
applicationSettings.setLastUsedSearchSite(lastUsedSite); applicationSettings.setLastUsedSearchSite(lastUsedSite);
// Update the activity title (only shown on large devices) // Update the activity title (only shown on large devices)
getSupportActionBar().setTitle( if (sitesSpinner.getVisibility() == View.GONE)
NavigationHelper.buildCondensedFontString(getString(R.string.search_queryonsite, lastUsedQuery, lastUsedSite.getName()))); searchToolbar.setTitle(
NavigationHelper.buildCondensedFontString(getString(R.string.search_queryonsite, lastUsedQuery, lastUsedSite.getName())));
// Ask the results fragment to start a search for the specified query // Ask the results fragment to start a search for the specified query
fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite); fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite);

4
app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java

@ -20,7 +20,7 @@ import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.Menu; import android.view.Menu;
@ -153,7 +153,7 @@ public class SearchResultsFragment extends Fragment {
public boolean onCreateActionMode(ActionMode mode, Menu menu) { public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Show contextual action bar to add items in batch mode // Show contextual action bar to add items in batch mode
mode.getMenuInflater().inflate(R.menu.fragment_searchresults_cab, menu); mode.getMenuInflater().inflate(R.menu.fragment_searchresults_cab, menu);
Context themedContext = ((ActionBarActivity) getActivity()).getSupportActionBar().getThemedContext(); Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
selectionManagerMode = new SelectionManagerMode(themedContext, resultsList, R.plurals.search_resutlsselected); selectionManagerMode = new SelectionManagerMode(themedContext, resultsList, R.plurals.search_resutlsselected);
selectionManagerMode.onCreateActionMode(mode, menu); selectionManagerMode.onCreateActionMode(mode, menu);
return true; return true;

9
app/src/main/res/layout/activity_search.xml

@ -26,7 +26,14 @@
style="@style/DefaultToolbar" style="@style/DefaultToolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" /> android:minHeight="?attr/actionBarSize">
<Spinner
android:id="@+id/sites_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"

2
build.gradle

@ -3,7 +3,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
} }
} }

Loading…
Cancel
Save