From e710f18be28b22914f88ffcbac76593023afc755 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 1 Jun 2015 11:46:48 +0200 Subject: [PATCH] Adding action bar to the preference activities. --- app/build.gradle | 2 +- .../transdroid/core/gui/TorrentsActivity.java | 6 +- .../gui/settings/HelpSettingsActivity.java | 4 +- .../settings/KeyBoundPreferencesActivity.java | 5 +- .../gui/settings/MainSettingsActivity.java | 81 +++++------- .../NotificationSettingsActivity.java | 28 ++-- .../core/gui/settings/OverflowPreference.java | 121 ------------------ .../settings/PreferenceCompatActivity.java | 65 ++++++++++ .../gui/settings/RssfeedSettingsActivity.java | 7 +- .../gui/settings/ServerSettingsActivity.java | 7 +- .../gui/settings/SystemSettingsActivity.java | 4 +- .../gui/settings/WebsearchPreference.java | 14 +- .../settings/WebsearchSettingsActivity.java | 11 +- .../seedbox/SeedstuffSettingsActivity.java | 2 +- .../seedbox/XirvikDediSettingsActivity.java | 2 +- .../seedbox/XirvikSemiSettingsActivity.java | 2 +- .../seedbox/XirvikSharedSettingsActivity.java | 2 +- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_main.xml | 2 +- 19 files changed, 151 insertions(+), 215 deletions(-) delete mode 100644 app/src/main/java/org/transdroid/core/gui/settings/OverflowPreference.java create mode 100644 app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java diff --git a/app/build.gradle b/app/build.gradle index cfafe69e..4abc11c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ 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.0.0' + compile 'com.android.support:appcompat-v7:22.1.0' compile 'com.android.support:support-annotations:20.0.0' compile 'com.getbase:floatingactionbutton:1.8.0' compile 'com.afollestad:material-dialogs:0.6.3.3' 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 978edcc4..65c257e6 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -472,7 +472,8 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE } // There is a connection (read: settings to some server known) - torrentsToolbar.setNavigationIcon(R.drawable.ic_action_drawer); + if (drawerToggle != null) + torrentsToolbar.setNavigationIcon(R.drawable.ic_action_drawer); addmenuButton.setVisibility(View.VISIBLE); actionsToolbar.setVisibility(View.VISIBLE); boolean addByFile = Daemon.supportsAddByFile(currentConnection.getType()); @@ -513,7 +514,8 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE if (item instanceof SimpleListItem) { filterSelected((SimpleListItem) item, false); } - drawerLayout.closeDrawer(drawerContainer); + if (drawerLayout != null) + drawerLayout.closeDrawer(drawerContainer); } }; diff --git a/app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java index 62561437..3c68c8f7 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java @@ -37,7 +37,7 @@ import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; @EActivity -public class HelpSettingsActivity extends PreferenceActivity { +public class HelpSettingsActivity extends PreferenceCompatActivity { protected static final int DIALOG_CHANGELOG = 0; protected static final int DIALOG_ABOUT = 1; @@ -57,7 +57,7 @@ public class HelpSettingsActivity extends PreferenceActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Just load the system-related preferences from XML addPreferencesFromResource(R.xml.pref_help); diff --git a/app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java index 1f89a390..800bd7c6 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java @@ -28,7 +28,6 @@ import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; -import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.text.method.PasswordTransformationMethod; @@ -43,13 +42,13 @@ import android.text.method.PasswordTransformationMethod; * @author Eric Kok */ @EActivity -public abstract class KeyBoundPreferencesActivity extends PreferenceActivity { +public abstract class KeyBoundPreferencesActivity extends PreferenceCompatActivity { @Extra protected int key = -1; private SharedPreferences sharedPrefs; - private Map originalSummaries = new HashMap(); + private Map originalSummaries = new HashMap<>(); /** * Should be called during the activity {@link #onCreate(android.os.Bundle)} (but after super.onCreate(Bundle)) to diff --git a/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java index 10e635fa..81f0aec9 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java @@ -28,8 +28,6 @@ import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; -import android.preference.PreferenceActivity; -import android.view.View; import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.EActivity; @@ -41,9 +39,8 @@ import org.transdroid.core.app.settings.ApplicationSettings; import org.transdroid.core.app.settings.RssfeedSetting; import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.WebsearchSetting; -import org.transdroid.core.gui.*; +import org.transdroid.core.gui.TorrentsActivity_; import org.transdroid.core.gui.navigation.NavigationHelper; -import org.transdroid.core.gui.settings.OverflowPreference.OnOverflowClicked; import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener; import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener; import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener; @@ -55,21 +52,14 @@ import java.util.ArrayList; import java.util.List; /** - * The main activity that provides access to all application settings. It shows the configured serves, web search sites - * and RSS feeds along with other general settings. + * The main activity that provides access to all application settings. It shows the configured serves, web search sites and RSS feeds along with other + * general settings. * @author Eric Kok */ @EActivity -public class MainSettingsActivity extends PreferenceActivity { +public class MainSettingsActivity extends PreferenceCompatActivity { protected static final int DIALOG_ADDSEEDBOX = 0; - private OnOverflowClicked onOverflowClicked = new OnOverflowClicked() { - @SuppressWarnings("deprecation") - @Override - public void onOverflowClicked(View overflowButton) { - showDialog(DIALOG_ADDSEEDBOX); - } - }; @Bean protected NavigationHelper navigationHelper; @Bean @@ -78,9 +68,13 @@ public class MainSettingsActivity extends PreferenceActivity { protected SearchHelper searchHelper; protected SharedPreferences prefs; private OnPreferenceClickListener onAddServer = new OnPreferenceClickListener() { + @SuppressWarnings("deprecation") @Override public boolean onPreferenceClick(Preference preference) { - ServerSettingsActivity_.intent(MainSettingsActivity.this).start(); + if (navigationHelper.enableSeedboxes()) + showDialog(DIALOG_ADDSEEDBOX); + else + ServerSettingsActivity_.intent(MainSettingsActivity.this).start(); return true; } }; @@ -130,8 +124,7 @@ public class MainSettingsActivity extends PreferenceActivity { public void onSeedboxClicked(ServerSetting serverSetting, SeedboxProvider provider, int seedboxOffset) { // NOTE: The seedboxOffset is the seedbox type-unique order that we need to supply uin the Extras bundle to // edit this specific seedbox - startActivity(provider.getSettings().getSettingsActivityIntent(MainSettingsActivity.this) - .putExtra("key", seedboxOffset)); + startActivity(provider.getSettings().getSettingsActivityIntent(MainSettingsActivity.this).putExtra("key", seedboxOffset)); } }; private OnWebsearchClickedListener onWebsearchClicked = new OnWebsearchClickedListener() { @@ -150,8 +143,10 @@ public class MainSettingsActivity extends PreferenceActivity { @Override public void onClick(DialogInterface dialog, int which) { // Start the configuration activity for this specific chosen seedbox - startActivity( - SeedboxProvider.values()[which].getSettings().getSettingsActivityIntent(MainSettingsActivity.this)); + if (which == 0) + ServerSettingsActivity_.intent(MainSettingsActivity.this).start(); + else + startActivity(SeedboxProvider.values()[which - 1].getSettings().getSettingsActivityIntent(MainSettingsActivity.this)); } }; @@ -166,7 +161,7 @@ public class MainSettingsActivity extends PreferenceActivity { protected void onResume() { super.onResume(); - //TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); prefs = getPreferenceManager().getSharedPreferences(); if (getPreferenceScreen() != null) { @@ -178,13 +173,7 @@ public class MainSettingsActivity extends PreferenceActivity { // Load the preference menu and attach actions addPreferencesFromResource(R.xml.pref_main); - OverflowPreference addServerPrefernce = (OverflowPreference) findPreference("header_addserver"); - addServerPrefernce.setOnPreferenceClickListener(onAddServer); - if (navigationHelper.enableSeedboxes()) { - addServerPrefernce.setOnOverflowClickedListener(onOverflowClicked); - } else { - addServerPrefernce.hideOverflowButton(); - } + findPreference("header_addserver").setOnPreferenceClickListener(onAddServer); if (enableSearchUi) { findPreference("header_addwebsearch").setOnPreferenceClickListener(onAddWebsearch); } @@ -196,8 +185,8 @@ public class MainSettingsActivity extends PreferenceActivity { findPreference("header_help").setOnPreferenceClickListener(onHelpSettings); // Keep a list of the server codes and names (for default server selection) - List serverCodes = new ArrayList(); - List serverNames = new ArrayList(); + List serverCodes = new ArrayList<>(); + List serverNames = new ArrayList<>(); serverCodes.add(Integer.toString(ApplicationSettings.DEFAULTSERVER_LASTUSED)); serverCodes.add(Integer.toString(ApplicationSettings.DEFAULTSERVER_ASKONADD)); serverNames.add(getString(R.string.pref_defaultserver_lastused)); @@ -206,8 +195,8 @@ public class MainSettingsActivity extends PreferenceActivity { // Add existing servers List servers = applicationSettings.getNormalServerSettings(); for (ServerSetting serverSetting : servers) { - getPreferenceScreen().addPreference(new ServerPreference(this).setServerSetting(serverSetting) - .setOnServerClickedListener(onServerClicked)); + getPreferenceScreen() + .addPreference(new ServerPreference(this).setServerSetting(serverSetting).setOnServerClickedListener(onServerClicked)); if (serverSetting.getUniqueIdentifier() != null) { serverCodes.add(Integer.toString(serverSetting.getOrder())); serverNames.add(serverSetting.getName()); @@ -219,9 +208,8 @@ public class MainSettingsActivity extends PreferenceActivity { for (SeedboxProvider provider : SeedboxProvider.values()) { int seedboxOffset = 0; for (ServerSetting seedbox : provider.getSettings().getAllServerSettings(prefs, orderOffset)) { - getPreferenceScreen().addPreference( - new SeedboxPreference(this).setProvider(provider).setServerSetting(seedbox) - .setOnSeedboxClickedListener(onSeedboxClicked, seedboxOffset)); + getPreferenceScreen().addPreference(new SeedboxPreference(this).setProvider(provider).setServerSetting(seedbox) + .setOnSeedboxClickedListener(onSeedboxClicked, seedboxOffset)); orderOffset++; seedboxOffset++; if (seedbox.getUniqueIdentifier() != null) { @@ -242,8 +230,8 @@ public class MainSettingsActivity extends PreferenceActivity { } else { List rssfeeds = applicationSettings.getRssfeedSettings(); for (RssfeedSetting rssfeedSetting : rssfeeds) { - getPreferenceScreen().addPreference(new RssfeedPreference(this).setRssfeedSetting(rssfeedSetting) - .setOnRssfeedClickedListener(onRssfeedClicked)); + getPreferenceScreen() + .addPreference(new RssfeedPreference(this).setRssfeedSetting(rssfeedSetting).setOnRssfeedClickedListener(onRssfeedClicked)); } } @@ -256,8 +244,8 @@ public class MainSettingsActivity extends PreferenceActivity { // Add existing websearch sites List websearches = applicationSettings.getWebsearchSettings(); for (WebsearchSetting websearchSetting : websearches) { - getPreferenceScreen().addPreference(new WebsearchPreference(this).setWebsearchSetting(websearchSetting) - .setOnWebsearchClickedListener(onWebsearchClicked)); + getPreferenceScreen().addPreference( + new WebsearchPreference(this).setWebsearchSetting(websearchSetting).setOnWebsearchClickedListener(onWebsearchClicked)); } // Construct list of all available search sites, in-app and web @@ -265,10 +253,10 @@ public class MainSettingsActivity extends PreferenceActivity { // Retrieve the available in-app search sites (using the Torrent Search package) List searchsites = searchHelper.getAvailableSites(); if (searchsites == null) { - searchsites = new ArrayList(); + searchsites = new ArrayList<>(); } - List siteNames = new ArrayList(websearches.size() + searchsites.size()); - List siteValues = new ArrayList(websearches.size() + searchsites.size()); + List siteNames = new ArrayList<>(websearches.size() + searchsites.size()); + List siteValues = new ArrayList<>(websearches.size() + searchsites.size()); for (SearchSite searchSite : searchsites) { siteNames.add(searchSite.getName()); siteValues.add(searchSite.getKey()); @@ -295,14 +283,15 @@ public class MainSettingsActivity extends PreferenceActivity { super.onBuildHeaders(target); } + @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ADDSEEDBOX: - // Open dialog to pick one of the supported seedbox providers - String[] seedboxes = new String[SeedboxProvider.values().length]; - for (int i = 0; i < seedboxes.length; i++) { - seedboxes[i] = getString(R.string.pref_seedbox_addseedbox, - SeedboxProvider.values()[i].getSettings().getName()); + // Open dialog to pick one of the supported seedbox providers (or a normal server) + String[] seedboxes = new String[SeedboxProvider.values().length + 1]; + seedboxes[0] = getString(R.string.pref_addserver_normal); + for (int i = 0; i < seedboxes.length - 1; i++) { + seedboxes[i + 1] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.values()[i].getSettings().getName()); } return new AlertDialog.Builder(this).setItems(seedboxes, onAddSeedbox).create(); } diff --git a/app/src/main/java/org/transdroid/core/gui/settings/NotificationSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/NotificationSettingsActivity.java index 66a57dcb..f2717f04 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/NotificationSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/NotificationSettingsActivity.java @@ -16,24 +16,22 @@ */ package org.transdroid.core.gui.settings; -import org.androidannotations.annotations.Bean; -import org.androidannotations.annotations.EActivity; -import org.androidannotations.annotations.OptionsItem; -import org.transdroid.R; -import org.transdroid.core.app.settings.NotificationSettings; -import org.transdroid.core.service.BootReceiver; - import android.annotation.TargetApi; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Build; import android.os.Bundle; -import android.preference.PreferenceActivity; + +import org.androidannotations.annotations.Bean; +import org.androidannotations.annotations.EActivity; +import org.androidannotations.annotations.OptionsItem; +import org.transdroid.R; +import org.transdroid.core.app.settings.NotificationSettings; +import org.transdroid.core.service.BootReceiver; @EActivity -public class NotificationSettingsActivity extends PreferenceActivity implements - OnSharedPreferenceChangeListener { +public class NotificationSettingsActivity extends PreferenceCompatActivity implements OnSharedPreferenceChangeListener { @Bean protected NotificationSettings notificationSettings; @@ -43,13 +41,13 @@ public class NotificationSettingsActivity extends PreferenceActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the notification-related preferences from XML and update availability thereof addPreferencesFromResource(R.xml.pref_notifications); boolean disabled = !notificationSettings.isEnabledForRss() && !notificationSettings.isEnabledForTorrents(); updatePrefsEnabled(disabled); - + } @SuppressWarnings("deprecation") @@ -59,7 +57,7 @@ public class NotificationSettingsActivity extends PreferenceActivity implements // Start/stop the background service appropriately getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); } - + @SuppressWarnings("deprecation") @Override protected void onPause() { @@ -78,8 +76,8 @@ public class NotificationSettingsActivity extends PreferenceActivity implements boolean disabled = !notificationSettings.isEnabledForRss() && !notificationSettings.isEnabledForTorrents(); updatePrefsEnabled(disabled); - - if (disabled ) { + + if (disabled) { // Disabled all background notifications; disable the alarms that start the service BootReceiver.cancelBackgroundServices(getApplicationContext()); } diff --git a/app/src/main/java/org/transdroid/core/gui/settings/OverflowPreference.java b/app/src/main/java/org/transdroid/core/gui/settings/OverflowPreference.java deleted file mode 100644 index 0a79ccec..00000000 --- a/app/src/main/java/org/transdroid/core/gui/settings/OverflowPreference.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.transdroid.core.gui.settings; - -import org.transdroid.R; - -import android.content.Context; -import android.content.res.TypedArray; -import android.os.Build; -import android.preference.Preference; -import android.util.AttributeSet; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.ImageButton; - -/** - * A {@link Preference} item that shows an extra overflow button at the right side of the screen. The action attached to - * this button is set using {@link #setOnOverflowClickedListener(OnOverflowClicked)}. Normal clicks on this preference - * are handled in the standard way. - * @author Eric Kok - */ -public class OverflowPreference extends Preference { - - private OnPreferenceClickListener onPreferenceClickListener = null; - private OnOverflowClicked onOverflowClickedListener = null; - private ImageButton overflowButton = null; - - public OverflowPreference(Context context) { - super(context); - init(); - } - - public OverflowPreference(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - public OverflowPreference(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - init(); - } - - @Override - protected View onCreateView(ViewGroup parent) { - View layout = super.onCreateView(parent); - // Since the Preference layout is now created, we can attach the proper click listeners - layout.setClickable(true); - layout.setFocusable(true); - // When setting the background drawable the padding on this Preference layout disappears, so add it again - int bottom = layout.getPaddingBottom(); - int top = layout.getPaddingTop(); - int right = layout.getPaddingRight(); - int left = layout.getPaddingLeft(); - TypedArray ta = getContext().obtainStyledAttributes(new int[] { android.R.attr.selectableItemBackground }); - layout.setBackgroundDrawable(ta.getDrawable(0)); - ta.recycle(); - layout.setPadding(left, top, right, bottom); - layout.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (onPreferenceClickListener != null) - onPreferenceClickListener.onPreferenceClick(OverflowPreference.this); - } - }); - overflowButton = (ImageButton) layout.findViewById(R.id.overflow_button); - overflowButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (onOverflowClickedListener != null) - onOverflowClickedListener.onOverflowClicked(v); - } - }); - return layout; - } - - public void init() { - // Load an overflow-style image button as custom widget in the right of this Preference layout - setWidgetLayoutResource(R.layout.pref_withoverflow); - } - - /** - * Hides the overflow button (on the right side of the Preference) from the UI. - */ - public void hideOverflowButton() { - if (overflowButton != null) { - overflowButton.setVisibility(View.GONE); - } - } - - /** - * Shows (after hiding it) the overflow button (on the right side of the Preference) in the UI. - */ - public void showOverflowButton() { - if (overflowButton != null) { - overflowButton.setVisibility(View.VISIBLE); - } - } - - @Override - public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener) { - // Instead of the build-in list item click behaviour, we have to manually assign the click listener to this - // Preference item, as we stole the focus behaviour when we added a Button to the Preference layout - this.onPreferenceClickListener = onPreferenceClickListener; - } - - /** - * Registers the listener for clicks on the overflow button contained in this preference. - * @param onOverflowClickedListener The overflow button click listener - */ - public void setOnOverflowClickedListener(OnOverflowClicked onOverflowClickedListener) { - this.onOverflowClickedListener = onOverflowClickedListener; - } - - /** - * An interface to be implemented by any activity (or otherwise) that wants to handle events when the contained - * overflow button is clicked. - */ - public interface OnOverflowClicked { - public void onOverflowClicked(View overflowButton); - } - -} diff --git a/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java new file mode 100644 index 00000000..a25ba166 --- /dev/null +++ b/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java @@ -0,0 +1,65 @@ +package org.transdroid.core.gui.settings; + +import android.content.res.Configuration; +import android.os.Bundle; +import android.preference.PreferenceActivity; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatCallback; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.view.ActionMode; + +public class PreferenceCompatActivity extends PreferenceActivity implements AppCompatCallback { + + private AppCompatDelegate acd; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + acd = AppCompatDelegate.create(this, this); + acd.onCreate(savedInstanceState); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + acd.onPostCreate(savedInstanceState); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + acd.onConfigurationChanged(newConfig); + } + + @Override + public void setTitle(CharSequence title) { + super.setTitle(title); + acd.setTitle(title); + } + + @Override + protected void onStop() { + super.onStop(); + acd.onStop(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + acd.onDestroy(); + } + + public ActionBar getSupportActionBar() { + return acd.getSupportActionBar(); + } + + @Override + public void onSupportActionModeStarted(ActionMode actionMode) { + + } + + @Override + public void onSupportActionModeFinished(ActionMode actionMode) { + + } +} diff --git a/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java index c302cde6..ae911641 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java @@ -37,7 +37,7 @@ import android.os.Bundle; * @author Eric Kok */ @EActivity -@OptionsMenu(resName = "activity_deleteableprefs") +@OptionsMenu(R.menu.activity_deleteableprefs) public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity { private static final int DIALOG_CONFIRMREMOVE = 0; @@ -46,7 +46,7 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the raw preferences to show in this screen init(R.xml.pref_rssfeed, ApplicationSettings_.getInstance_(this).getMaxRssfeed()); @@ -65,11 +65,12 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity { } @SuppressWarnings("deprecation") - @OptionsItem(resName = "action_removesettings") + @OptionsItem(R.id.action_removesettings) protected void removeSettings() { showDialog(DIALOG_CONFIRMREMOVE); } + @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_CONFIRMREMOVE: diff --git a/app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java index 8c36f0bf..72725a92 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java @@ -41,7 +41,7 @@ import android.preference.PreferenceManager; * @author Eric Kok */ @EActivity -@OptionsMenu(resName = "activity_deleteableprefs") +@OptionsMenu(R.menu.activity_deleteableprefs) public class ServerSettingsActivity extends KeyBoundPreferencesActivity { private static final int DIALOG_CONFIRMREMOVE = 0; @@ -52,7 +52,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the raw preferences to show in this screen init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxNormalServer()); @@ -89,11 +89,12 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { } @SuppressWarnings("deprecation") - @OptionsItem(resName = "action_removesettings") + @OptionsItem(R.id.action_removesettings) protected void removeSettings() { showDialog(DIALOG_CONFIRMREMOVE); } + @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_CONFIRMREMOVE: 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 c1b16934..add9e506 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 @@ -53,7 +53,7 @@ import java.io.FileNotFoundException; import java.io.IOException; @EActivity -public class SystemSettingsActivity extends PreferenceActivity { +public class SystemSettingsActivity extends PreferenceCompatActivity { protected static final int DIALOG_IMPORTSETTINGS = 0; private OnPreferenceClickListener onImportSettingsClick = new OnPreferenceClickListener() { @@ -154,7 +154,7 @@ public class SystemSettingsActivity extends PreferenceActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Just load the system-related preferences from XML addPreferencesFromResource(R.xml.pref_system); diff --git a/app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java b/app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java index dec0f098..ea999b6a 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java @@ -16,11 +16,11 @@ */ package org.transdroid.core.gui.settings; -import org.transdroid.core.app.settings.WebsearchSetting; - import android.content.Context; import android.preference.Preference; +import org.transdroid.core.app.settings.WebsearchSetting; + /** * Represents a {@link WebsearchSetting} in a preferences screen. * @author Eric Kok @@ -31,7 +31,7 @@ public class WebsearchPreference extends Preference { private WebsearchSetting websearchSetting; private OnWebsearchClickedListener onWebsearchClickedListener = null; - + public WebsearchPreference(Context context) { super(context); setOnPreferenceClickListener(onPreferenceClicked); @@ -49,7 +49,7 @@ public class WebsearchPreference extends Preference { setOrder(ORDER_START + websearchSetting.getOrder()); return this; } - + /** * Set a listener that will be notified of click events on this preference * @param onWebsearchClickedListener The click listener to register @@ -68,9 +68,9 @@ public class WebsearchPreference extends Preference { return true; } }; - + public interface OnWebsearchClickedListener { - public void onWebsearchClicked(WebsearchSetting serverSetting); + void onWebsearchClicked(WebsearchSetting serverSetting); } - + } diff --git a/app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java index 1b94f9c8..4cf11ee8 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java @@ -37,7 +37,7 @@ import android.os.Bundle; * @author Eric Kok */ @EActivity -@OptionsMenu(resName="activity_deleteableprefs") +@OptionsMenu(R.menu.activity_deleteableprefs) public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity { private static final int DIALOG_CONFIRMREMOVE = 0; @@ -46,8 +46,8 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); - + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + // Load the raw preferences to show in this screen init(R.xml.pref_websearch, ApplicationSettings_.getInstance_(this).getMaxWebsearch()); initTextPreference("websearch_name"); @@ -63,11 +63,12 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity { } @SuppressWarnings("deprecation") - @OptionsItem(resName = "action_removesettings") + @OptionsItem(R.id.action_removesettings) protected void removeSettings() { showDialog(DIALOG_CONFIRMREMOVE); } - + + @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_CONFIRMREMOVE: diff --git a/app/src/main/java/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java b/app/src/main/java/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java index 9b266942..ffccd56a 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/seedbox/SeedstuffSettingsActivity.java @@ -42,7 +42,7 @@ public class SeedstuffSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the raw preferences to show in this screen init(R.xml.pref_seedbox_seedstuff, diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java index b220bfe8..ac54df3f 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikDediSettingsActivity.java @@ -42,7 +42,7 @@ public class XirvikDediSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the raw preferences to show in this screen init(R.xml.pref_seedbox_xirvikdedi, diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java index 5fd42862..fe8f0849 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSemiSettingsActivity.java @@ -42,7 +42,7 @@ public class XirvikSemiSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the raw preferences to show in this screen init(R.xml.pref_seedbox_xirviksemi, diff --git a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java index d8c9c6ed..92ed970a 100644 --- a/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java +++ b/app/src/main/java/org/transdroid/core/seedbox/XirvikSharedSettingsActivity.java @@ -60,7 +60,7 @@ public class XirvikSharedSettingsActivity extends KeyBoundPreferencesActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // TODO getActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Load the raw preferences to show in this screen init(R.xml.pref_seedbox_xirvikshared, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 55edda18..6d47642e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -222,6 +222,7 @@ Servers Add new server + Add normal, custom server Add seedbox Default server Last used diff --git a/app/src/main/res/xml/pref_main.xml b/app/src/main/res/xml/pref_main.xml index 584b1cab..3555ea98 100644 --- a/app/src/main/res/xml/pref_main.xml +++ b/app/src/main/res/xml/pref_main.xml @@ -21,7 +21,7 @@ android:key="header_servers" android:title="@string/pref_servers" android:order="0"> -