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. 75
      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' @@ -2,14 +2,15 @@ apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 22
buildToolsVersion '21.1.2'
compileSdkVersion 23
buildToolsVersion '23.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 222
versionName '2.5.2'
targetSdkVersion 23
versionCode 223
versionName '2.5.3'
}
buildTypes {
release {
@ -37,8 +38,8 @@ dependencies { @@ -37,8 +38,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.2.0'
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-annotations:23.0.0'
compile 'com.getbase:floatingactionbutton:1.8.0'
compile 'com.afollestad:material-dialogs:0.6.3.3'
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; @@ -27,6 +27,8 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.afollestad.materialdialogs.Theme;
/**
* Allows instantiation of the settings specified in R.xml.pref_system.
* @author Eric Kok
@ -62,6 +64,10 @@ public class SystemSettings { @@ -62,6 +64,10 @@ public class SystemSettings {
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.
* @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; @@ -30,6 +30,7 @@ import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
import java.util.Iterator;
import java.util.List;
@ -71,7 +72,7 @@ public class SetLabelDialog { @@ -71,7 +72,7 @@ public class SetLabelDialog {
public void onNeutral(MaterialDialog dialog) {
onLabelPickedListener.onLabelPicked(null);
}
}).build();
}).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).build();
if (currentLabels.size() == 0) {
// Hide the list (and its label) if there are no labels yet
@ -93,7 +94,7 @@ public class SetLabelDialog { @@ -93,7 +94,7 @@ public class SetLabelDialog {
}
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; @@ -24,6 +24,7 @@ import android.widget.EditText;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
public class SetStorageLocationDialog {
@ -44,11 +45,11 @@ public class SetStorageLocationDialog { @@ -44,11 +45,11 @@ public class SetStorageLocationDialog {
// User is done editing and requested to update given the text input
onStorageLocationUpdatedListener.onStorageLocationUpdated(locationText.getText().toString());
}
}).show();
}).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).show();
}
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; @@ -25,6 +25,7 @@ import android.widget.EditText;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
import java.util.Arrays;
import java.util.List;
@ -48,11 +49,11 @@ public class SetTrackersDialog extends DialogFragment { @@ -48,11 +49,11 @@ public class SetTrackersDialog extends DialogFragment {
// User is done editing and requested to update given the text input
onTrackersUpdatedListener.onTrackersUpdated(Arrays.asList(trackersText.getText().toString().split("\n")));
}
}).show();
}).theme(SystemSettings_.getInstance_(context).getMaterialDialogtheme()).show();
}
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; @@ -26,6 +26,7 @@ import android.widget.TextView;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_;
public class SetTransferRatesDialog {
@ -62,7 +63,7 @@ public class SetTransferRatesDialog { @@ -62,7 +63,7 @@ public class SetTransferRatesDialog {
public void onNeutral(MaterialDialog dialog) {
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,
R.id.down6Button, R.id.down7Button, R.id.down8Button, R.id.down9Button, R.id.down0Button);
@ -98,11 +99,11 @@ public class SetTransferRatesDialog { @@ -98,11 +99,11 @@ public class SetTransferRatesDialog {
* Listener interface to the user having picked or wanting to resets the current maximum transfer speeds;
*/
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();
}
}

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

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

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

@ -26,7 +26,14 @@ @@ -26,7 +26,14 @@
style="@style/DefaultToolbar"
android:layout_width="match_parent"
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
android:layout_width="match_parent"

2
build.gradle

@ -3,7 +3,7 @@ buildscript { @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
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'
}
}

Loading…
Cancel
Save