Browse Source

Prepared for #7 auto refresh by adding a system setting (and moving help options to a separate screen).

pull/148/merge
Eric Kok 11 years ago
parent
commit
df030db62a
  1. 4
      core/res/values/changelog.xml
  2. 18
      core/res/values/strings.xml
  3. 37
      core/res/xml/pref_help.xml
  4. 4
      core/res/xml/pref_main.xml
  5. 33
      core/res/xml/pref_system.xml
  6. 10
      core/src/org/transdroid/core/app/settings/SystemSettings.java
  7. 124
      core/src/org/transdroid/core/gui/settings/HelpSettingsActivity.java
  8. 9
      core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java
  9. 52
      core/src/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  10. 1
      full/AndroidManifest.xml
  11. 1
      lite/AndroidManifest.xml

4
core/res/values/changelog.xml

@ -17,6 +17,10 @@ @@ -17,6 +17,10 @@
-->
<resources>
<string name="system_changelog">
Transdroid 2.1.2\n
- Support for new Torrent Search\'s private sites\n
- Added optional auto refresh\n
\n
Transdroid 2.1.1\n
- Improved handling of RSS feed read state\n
- Fixes Xirvik seedbox configuration\n

18
core/res/values/strings.xml

@ -279,6 +279,22 @@ @@ -279,6 +279,22 @@
<string name="pref_adw_info">Show torrent counter in ADW Launcher</string>
<string name="pref_system">System</string>
<string name="pref_autorefresh">Automatic refreshing</string>
<string name="pref_autorefresh_info">Interval-based refresh of the main screen</string>
<string-array name="pref_autorefresh_intervals">
<item>Disabled</item>
<item>2 seconds</item>
<item>5 seconds</item>
<item>10 seconds</item>
<item>30 seconds</item>
</string-array>
<string-array name="pref_autorefresh_intervalvalues" translatable="false">
<item>0</item>
<item>2</item>
<item>5</item>
<item>10</item>
<item>30</item>
</string-array>
<string name="pref_dormantasinactive">Treat dormant torrents as inactive</string>
<string name="pref_dormantasinactive_info">Torrents at 0KB/s (no data transfer) will be filtered as being inactive</string>
<string name="pref_checkupdates">Check for updates</string>
@ -293,6 +309,8 @@ @@ -293,6 +309,8 @@
<string name="pref_export">Export settings</string>
<string name="pref_export_dialog">%1$s will export server (including passwords), web search, RSS and system settings to the following plain text JSON file: %2$s</string>
<string name="pref_export_success">Settings successfully exported</string>
<string name="pref_help">Transdroid help</string>
<string name="pref_sendlog">Send error log</string>
<string name="pref_sendlog_info">Get support or report a bug</string>
<string name="pref_installhelp">View install guides</string>

37
core/res/xml/pref_help.xml

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2013 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<Preference
android:key="system_sendlog"
android:title="@string/pref_sendlog"
android:summary="@string/pref_sendlog_info" />
<Preference
android:key="system_installhelp"
android:title="@string/pref_installhelp"
android:summary="@string/pref_installhelp_info" />
<Preference
android:key="system_changelog"
android:title="@string/pref_changelog" />
<Preference
android:key="system_about" />
</PreferenceScreen>

4
core/res/xml/pref_main.xml

@ -63,6 +63,10 @@ @@ -63,6 +63,10 @@
android:key="header_system"
android:title="@string/pref_system"
android:order="302" />
<Preference
android:key="header_help"
android:title="@string/pref_help"
android:order="303" />
</PreferenceCategory>
</PreferenceScreen>

33
core/res/xml/pref_system.xml

@ -23,11 +23,13 @@ @@ -23,11 +23,13 @@
android:summary="@string/pref_dormantasinactive_info"
android:defaultValue="false" />
<CheckBoxPreference
android:key="system_checkupdates"
android:title="@string/pref_checkupdates"
android:summary="@string/pref_checkupdates_info"
android:defaultValue="true" />
<ListPreference
android:key="system_autorefresh"
android:title="@string/pref_autorefresh"
android:summary="@string/pref_autorefresh_info"
android:entries="@array/pref_autorefresh_intervals"
android:entryValues="@array/pref_autorefresh_intervalvalues"
android:defaultValue="0" />
<CheckBoxPreference
android:key="system_usedarktheme"
@ -35,15 +37,11 @@ @@ -35,15 +37,11 @@
android:summary="@string/pref_usedarktheme_info"
android:defaultValue="false" />
<Preference
android:key="system_sendlog"
android:title="@string/pref_sendlog"
android:summary="@string/pref_sendlog_info" />
<Preference
android:key="system_installhelp"
android:title="@string/pref_installhelp"
android:summary="@string/pref_installhelp_info" />
<CheckBoxPreference
android:key="system_checkupdates"
android:title="@string/pref_checkupdates"
android:summary="@string/pref_checkupdates_info"
android:defaultValue="true" />
<Preference
android:key="system_clearsearch"
@ -57,11 +55,4 @@ @@ -57,11 +55,4 @@
android:key="system_exportsettings"
android:title="@string/pref_export" />
<Preference
android:key="system_changelog"
android:title="@string/pref_changelog" />
<Preference
android:key="system_about" />
</PreferenceScreen>

10
core/src/org/transdroid/core/app/settings/SystemSettings.java

@ -46,6 +46,14 @@ public class SystemSettings { @@ -46,6 +46,14 @@ public class SystemSettings {
return prefs.getBoolean("system_dormantasinactive", false);
}
/**
* Returns the interval in which automatic screen refreshes should be scheduled.
* @return The selected refresh interval in milliseconds or 0 if automatic refreshes should be disabled
*/
public int getRefreshIntervalMilliseconds() {
return Integer.parseInt(prefs.getString("system_autorefresh", "0"));
}
public boolean checkForUpdates() {
return prefs.getBoolean("system_checkupdates", true);
}
@ -70,5 +78,5 @@ public class SystemSettings { @@ -70,5 +78,5 @@ public class SystemSettings {
public void setLastCheckedForAppUpdates(Date lastChecked) {
prefs.edit().putLong("system_lastappupdatecheck", lastChecked == null ? -1L : lastChecked.getTime()).commit();
}
}

124
core/src/org/transdroid/core/gui/settings/HelpSettingsActivity.java

@ -0,0 +1,124 @@ @@ -0,0 +1,124 @@
/*
* Copyright 2010-2013 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.settings;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.SettingsPersistence;
import org.transdroid.core.gui.log.ErrorLogSender;
import org.transdroid.core.gui.navigation.DialogHelper;
import org.transdroid.core.gui.navigation.NavigationHelper;
import android.annotation.TargetApi;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
@EActivity
public class HelpSettingsActivity extends SherlockPreferenceActivity {
protected static final int DIALOG_CHANGELOG = 0;
protected static final int DIALOG_ABOUT = 1;
protected static final String INSTALLHELP_URI = "http://www.transdroid.org/download/";
@Bean
protected NavigationHelper navigationHelper;
@Bean
protected ApplicationSettings applicationSettings;
@Bean
protected ErrorLogSender errorLogSender;
@Bean
protected SettingsPersistence settingsPersistence;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Just load the system-related preferences from XML
addPreferencesFromResource(R.xml.pref_help);
// Handle outgoing links and preference changes
findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick);
findPreference("system_installhelp").setOnPreferenceClickListener(onInstallHelpClick);
findPreference("system_changelog").setOnPreferenceClickListener(onChangeLogClick);
findPreference("system_about").setTitle(getString(R.string.pref_about, getString(R.string.app_name)));
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() {
@Override
public boolean onPreferenceClick(Preference preference) {
errorLogSender.collectAndSendLog(HelpSettingsActivity.this, applicationSettings.getLastUsedServer());
return true;
}
};
private OnPreferenceClickListener onInstallHelpClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(INSTALLHELP_URI)));
return true;
}
};
private OnPreferenceClickListener onChangeLogClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation")
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_CHANGELOG);
return true;
}
};
private OnPreferenceClickListener onAboutClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation")
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_ABOUT);
return true;
}
};
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CHANGELOG:
return DialogHelper.showDialog(this, new ChangelogDialog());
case DIALOG_ABOUT:
return DialogHelper.showDialog(this, new AboutDialog());
}
return null;
}
}

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

@ -107,6 +107,7 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { @@ -107,6 +107,7 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
findPreference("header_addrssfeed").setOnPreferenceClickListener(onAddRssfeed);
findPreference("header_background").setOnPreferenceClickListener(onBackgroundSettings);
findPreference("header_system").setOnPreferenceClickListener(onSystemSettings);
findPreference("header_help").setOnPreferenceClickListener(onHelpSettings);
// Add existing servers
List<ServerSetting> servers = applicationSettings.getNormalServerSettings();
@ -238,6 +239,14 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { @@ -238,6 +239,14 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
}
};
private OnPreferenceClickListener onHelpSettings = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
HelpSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
}
};
private OnServerClickedListener onServerClicked = new OnServerClickedListener() {
@Override
public void onServerClicked(ServerSetting serverSetting) {

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

@ -27,7 +27,6 @@ import org.transdroid.core.R; @@ -27,7 +27,6 @@ import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.SettingsPersistence;
import org.transdroid.core.gui.log.ErrorLogSender;
import org.transdroid.core.gui.navigation.DialogHelper;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.search.SearchHistoryProvider;
import org.transdroid.core.service.BootReceiver;
@ -39,7 +38,6 @@ import android.content.DialogInterface; @@ -39,7 +38,6 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@ -54,11 +52,8 @@ import de.keyboardsurfer.android.widget.crouton.Crouton; @@ -54,11 +52,8 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
@EActivity
public class SystemSettingsActivity extends SherlockPreferenceActivity {
protected static final int DIALOG_CHANGELOG = 0;
protected static final int DIALOG_ABOUT = 1;
protected static final int DIALOG_IMPORTSETTINGS = 2;
protected static final int DIALOG_EXPORTSETTINGS = 3;
protected static final String INSTALLHELP_URI = "http://www.transdroid.org/download/";
protected static final int DIALOG_IMPORTSETTINGS = 0;
protected static final int DIALOG_EXPORTSETTINGS = 1;
@Bean
protected NavigationHelper navigationHelper;
@ -85,14 +80,9 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -85,14 +80,9 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
} else {
getPreferenceScreen().removePreference(findPreference("system_checkupdates"));
}
findPreference("system_sendlog").setOnPreferenceClickListener(onSendLogClick);
findPreference("system_installhelp").setOnPreferenceClickListener(onInstallHelpClick);
findPreference("system_changelog").setOnPreferenceClickListener(onChangeLogClick);
findPreference("system_clearsearch").setOnPreferenceClickListener(onClearSearchClick);
findPreference("system_importsettings").setOnPreferenceClickListener(onImportSettingsClick);
findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick);
findPreference("system_about").setTitle(getString(R.string.pref_about, getString(R.string.app_name)));
findPreference("system_about").setOnPreferenceClickListener(onAboutClick);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -112,22 +102,6 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -112,22 +102,6 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
}
};
private OnPreferenceClickListener onSendLogClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
errorLogSender.collectAndSendLog(SystemSettingsActivity.this, applicationSettings.getLastUsedServer());
return true;
}
};
private OnPreferenceClickListener onInstallHelpClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(INSTALLHELP_URI)));
return true;
}
};
private OnPreferenceClickListener onImportSettingsClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation")
@Override
@ -146,15 +120,6 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -146,15 +120,6 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
}
};
private OnPreferenceClickListener onChangeLogClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation")
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_CHANGELOG);
return true;
}
};
private OnPreferenceClickListener onClearSearchClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
@ -165,21 +130,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity { @@ -165,21 +130,8 @@ public class SystemSettingsActivity extends SherlockPreferenceActivity {
}
};
private OnPreferenceClickListener onAboutClick = new OnPreferenceClickListener() {
@SuppressWarnings("deprecation")
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_ABOUT);
return true;
}
};
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CHANGELOG:
return DialogHelper.showDialog(this, new ChangelogDialog());
case DIALOG_ABOUT:
return DialogHelper.showDialog(this, new AboutDialog());
case DIALOG_IMPORTSETTINGS:
// @formatter:off
return new AlertDialog.Builder(this)

1
full/AndroidManifest.xml

@ -190,6 +190,7 @@ @@ -190,6 +190,7 @@
<activity android:name="org.transdroid.core.gui.settings.RssfeedSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.settings.NotificationSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.settings.HelpSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" />
<!-- Seedbox settings -->

1
lite/AndroidManifest.xml

@ -181,6 +181,7 @@ @@ -181,6 +181,7 @@
<activity android:name="org.transdroid.core.gui.settings.ServerSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.settings.NotificationSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.settings.HelpSettingsActivity_" />
<activity android:name="org.transdroid.core.gui.navigation.DialogHelper_" />
<!-- Seedbox settings -->

Loading…
Cancel
Save