Browse Source

Add up (home) button in action bar of all settings related activities.

pull/11/head
Eric Kok 12 years ago
parent
commit
98c743f83b
  1. 2
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  2. 10
      core/src/org/transdroid/core/gui/navigation/DialogHelper.java
  3. 13
      core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java
  4. 14
      core/src/org/transdroid/core/gui/settings/NotificationSettingsActivity.java
  5. 11
      core/src/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  6. 11
      core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  7. 12
      core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  8. 11
      core/src/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java

2
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -297,7 +297,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Clear the currently shown list of torrents and perhaps the details // Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(); fragmentTorrents.clear();
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.getActivity() != null) {
fragmentDetails.clear(); fragmentDetails.clear();
} }
fragmentTorrents.updateIsLoading(true); fragmentTorrents.updateIsLoading(true);

10
core/src/org/transdroid/core/gui/navigation/DialogHelper.java

@ -4,10 +4,12 @@ import java.io.Serializable;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra; import org.androidannotations.annotations.Extra;
import org.transdroid.core.gui.TorrentsActivity_;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Window; import android.view.Window;
@ -32,6 +34,7 @@ public class DialogHelper extends SherlockActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(dialog.getDialogLayoutId()); setContentView(dialog.getDialogLayoutId());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
@ -40,9 +43,14 @@ public class DialogHelper extends SherlockActivity {
menuInflater.inflate(dialog.getDialogMenuId(), menu); menuInflater.inflate(dialog.getDialogMenuId(), menu);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
// Action bar up button clicked; navigate up all the way back to the torrents activity
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
return true;
}
return dialog.onMenuItemSelected(this, item.getItemId()); return dialog.onMenuItemSelected(this, item.getItemId());
} }

13
core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -5,6 +5,7 @@ import java.util.List;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.search.SearchHelper; import org.transdroid.core.app.search.SearchHelper;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
@ -12,10 +13,14 @@ import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.RssfeedSetting; import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.WebsearchSetting; import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener; import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener;
import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener; import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener;
import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener; import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
@ -46,6 +51,8 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getPreferenceScreen() != null) if (getPreferenceScreen() != null)
getPreferenceScreen().removeAll(); getPreferenceScreen().removeAll();
@ -104,6 +111,12 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
@Override @Override
public void onBuildHeaders(List<Header> target) { public void onBuildHeaders(List<Header> target) {
// TODO: Add two-pane support in settings // TODO: Add two-pane support in settings

14
core/src/org/transdroid/core/gui/settings/NotificationSettingsActivity.java

@ -2,9 +2,13 @@ package org.transdroid.core.gui.settings;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings; import org.transdroid.core.app.settings.ApplicationSettings;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import com.actionbarsherlock.app.SherlockPreferenceActivity; import com.actionbarsherlock.app.SherlockPreferenceActivity;
@ -20,9 +24,17 @@ public class NotificationSettingsActivity extends SherlockPreferenceActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Just load the notification-related preferences from XML // Just load the notification-related preferences from XML
addPreferencesFromResource(R.xml.pref_notifications); addPreferencesFromResource(R.xml.pref_notifications);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
} }

11
core/src/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java

@ -6,6 +6,9 @@ import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings_; import org.transdroid.core.app.settings.ApplicationSettings_;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
/** /**
@ -20,6 +23,8 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Load the raw preferences to show in this screen // Load the raw preferences to show in this screen
init(R.xml.pref_rssfeed, ApplicationSettings_.getInstance_(this).getMaxRssfeed()); init(R.xml.pref_rssfeed, ApplicationSettings_.getInstance_(this).getMaxRssfeed());
@ -29,6 +34,12 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeRssfeedSettings(key); ApplicationSettings_.getInstance_(this).removeRssfeedSettings(key);

11
core/src/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -7,7 +7,10 @@ import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings_; import org.transdroid.core.app.settings.ApplicationSettings_;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Daemon;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -27,6 +30,8 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Load the raw preferences to show in this screen // Load the raw preferences to show in this screen
init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxServer()); init(R.xml.pref_server, ApplicationSettings_.getInstance_(this).getMaxServer());
initTextPreference("server_name"); initTextPreference("server_name");
@ -52,6 +57,12 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeServerSettings(key); ApplicationSettings_.getInstance_(this).removeServerSettings(key);

12
core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java

@ -2,14 +2,17 @@ package org.transdroid.core.gui.settings;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings; import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.gui.log.ErrorLogSender; import org.transdroid.core.gui.log.ErrorLogSender;
import org.transdroid.core.gui.navigation.DialogHelper; import org.transdroid.core.gui.navigation.DialogHelper;
import android.annotation.TargetApi;
import android.app.Dialog; import android.app.Dialog;
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.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
@ -33,6 +36,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Just load the system-related preferences from XML // Just load the system-related preferences from XML
addPreferencesFromResource(R.xml.pref_system); addPreferencesFromResource(R.xml.pref_system);
@ -45,6 +50,12 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
findPreference("system_about").setOnPreferenceClickListener(onAboutClick); findPreference("system_about").setOnPreferenceClickListener(onAboutClick);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
private OnPreferenceClickListener onSendLogClick = new OnPreferenceClickListener() { private OnPreferenceClickListener onSendLogClick = new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
@ -104,4 +115,5 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
} }
return null; return null;
}; };
} }

11
core/src/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java

@ -6,6 +6,9 @@ import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings_; import org.transdroid.core.app.settings.ApplicationSettings_;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
/** /**
@ -21,6 +24,8 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Load the raw preferences to show in this screen // Load the raw preferences to show in this screen
init(R.xml.pref_websearch, ApplicationSettings_.getInstance_(this).getMaxWebsearch()); init(R.xml.pref_websearch, ApplicationSettings_.getInstance_(this).getMaxWebsearch());
initTextPreference("websearch_name"); initTextPreference("websearch_name");
@ -28,6 +33,12 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
@OptionsItem(resName = "action_removesettings") @OptionsItem(resName = "action_removesettings")
protected void removeSettings() { protected void removeSettings() {
ApplicationSettings_.getInstance_(this).removeWebsearchSettings(key); ApplicationSettings_.getInstance_(this).removeWebsearchSettings(key);

Loading…
Cancel
Save