mirror of
https://gitlab.com/openlp/android.git
synced 2024-12-22 11:52:49 +00:00
Clean up and settings fix
This commit is contained in:
parent
13bb8ca00e
commit
47164004b1
@ -1,5 +1,7 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
project.archivesBaseName = 'OpenLP'
|
||||
|
||||
android {
|
||||
compileSdkVersion 21
|
||||
buildToolsVersion "21.1.2"
|
||||
|
@ -20,10 +20,6 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".fragments.SettingsActivity"
|
||||
android:label="@string/title_activity_settings" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
@ -32,14 +28,7 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="org.openlp.android2.OpenLP" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.ConnectionActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
android:parentActivityName=".OpenLP" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="org.openlp.android2.OpenLP" />
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -20,12 +20,15 @@ package org.openlp.android2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.app.ActionBar;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -57,6 +60,7 @@ public class OpenLP extends ActionBarActivity
|
||||
/**
|
||||
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
|
||||
*/
|
||||
private final String LOG_TAG = OpenLP.class.getName();
|
||||
private CharSequence mTitle;
|
||||
private boolean backArrowActive = false;
|
||||
private Menu dropdownMenu;
|
||||
@ -66,6 +70,8 @@ public class OpenLP extends ActionBarActivity
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
doPreferenceCheck();
|
||||
|
||||
mNavigationDrawerFragment = (NavigationDrawerFragment)
|
||||
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
|
||||
mTitle = getTitle();
|
||||
@ -76,6 +82,19 @@ public class OpenLP extends ActionBarActivity
|
||||
(DrawerLayout) findViewById(R.id.drawer_layout));
|
||||
}
|
||||
|
||||
private void doPreferenceCheck() {
|
||||
SharedPreferences sharedPrefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(this);
|
||||
if (sharedPrefs.getString(getString(R.string.key_host), "NONE").equals("NONE")
|
||||
|| sharedPrefs.getString(getString(R.string.key_host), null).equals(null)) {
|
||||
Log.d(LOG_TAG,
|
||||
"URL preference not set. Starting preference activity...");
|
||||
Intent preferenceIntent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(preferenceIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onNavigationDrawerItemSelected(int position) {
|
||||
// update the main content by replacing fragments
|
||||
@ -123,7 +142,7 @@ public class OpenLP extends ActionBarActivity
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setTitle(mTitle);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//noop
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,8 +245,7 @@ public class OpenLP extends ActionBarActivity
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
|
||||
return rootView;
|
||||
return inflater.inflate(R.layout.fragment_main, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,427 +0,0 @@
|
||||
/******************************************************************************
|
||||
* OpenLP - Open Source Lyrics Projection *
|
||||
* --------------------------------------------------------------------------- *
|
||||
* Copyright (c) 2011-2015 OpenLP Android Developers *
|
||||
* --------------------------------------------------------------------------- *
|
||||
* This program 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; version 2 of the License. *
|
||||
* *
|
||||
* This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 *
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
*******************************************************************************/
|
||||
package org.openlp.android2.activities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.*;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import org.openlp.android2.R;
|
||||
|
||||
public class ConnectionActivity extends PreferenceActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(android.R.id.content, new ConnectionFragment())
|
||||
.commit();
|
||||
}
|
||||
|
||||
public static class ConnectionFragment extends PreferenceFragment {
|
||||
private final String KEY_PREFERENCE_DISPLAY = "preferenceDisplay";
|
||||
private final String KEY_SERVER_ID = "keyServerId";
|
||||
private final String PREFERENCE_DISPLAY_SERVER = "displayServer";
|
||||
private final String LOG_TAG = ConnectionFragment.class.getName();
|
||||
|
||||
private PreferenceScreen preferenceScreen = null;
|
||||
private boolean resume = true;
|
||||
|
||||
private static String getHostConfigTitleKey(int id) {
|
||||
return HostConfig.KEY_PREFIX + id + ".title";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.empty_preferences);
|
||||
getPreferenceManager()
|
||||
.setSharedPreferencesName(getString(R.string.keySharedPreferences));
|
||||
preferenceScreen = getPreferenceScreen() == null
|
||||
? getPreferenceManager().createPreferenceScreen(getActivity())
|
||||
: getPreferenceScreen();
|
||||
preferenceScreen.removeAll();
|
||||
String preferenceDisplay = getActivity().getIntent().getStringExtra(KEY_PREFERENCE_DISPLAY);
|
||||
if (preferenceDisplay != null
|
||||
&& preferenceDisplay.equalsIgnoreCase(PREFERENCE_DISPLAY_SERVER)) {
|
||||
constructServerView(getActivity().getIntent().getIntExtra(KEY_SERVER_ID, 1));
|
||||
} else {
|
||||
resume = false;
|
||||
constructOverviewScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void constructOverviewScreen() {
|
||||
getPreferenceScreen().removeAll();
|
||||
Log.i(LOG_TAG, "constructOverviewScreen");
|
||||
Preference configPref = new Preference(getActivity());
|
||||
configPref.setTitle(getString(R.string.connection_available_configurations));
|
||||
configPref.setSummary(getString(R.string.connection_add_by_menu));
|
||||
configPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
int nextId = getNextPrefId(
|
||||
getHostConfigMap(
|
||||
getPreferenceManager()
|
||||
.getSharedPreferences().getAll()
|
||||
)
|
||||
);
|
||||
Preference newPreference = simpleClickablePreferenceFromHostConfig(
|
||||
new HostConfig(
|
||||
getString(R.string.connection_profile_server),
|
||||
nextId));
|
||||
newPreference.setTitle(getString(R.string.connection_profile_new_server));
|
||||
newPreference.setSummary(getString(R.string.connection_profile_not_saved));
|
||||
preferenceScreen.addPreference(newPreference);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
preferenceScreen.addPreference(configPref);
|
||||
List<HostConfig> hostConfigs = getHostConfigs();
|
||||
if (!hostConfigs.isEmpty()) {
|
||||
for (final HostConfig config : getHostConfigs()) {
|
||||
preferenceScreen.addPreference(
|
||||
simpleClickablePreferenceFromHostConfig(config));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void constructServerView(int hostId) {
|
||||
HostConfig hostConfig = hostConfigFromPreferencesForHostId(
|
||||
hostId,
|
||||
getHostConfigMap(
|
||||
getPreferenceManager()
|
||||
.getSharedPreferences()
|
||||
.getAll()
|
||||
)
|
||||
);
|
||||
addPreferenceCategory(preferenceScreen, hostConfig);
|
||||
}
|
||||
|
||||
private Preference simpleClickablePreferenceFromHostConfig(final HostConfig config) {
|
||||
final Preference serverConfig = new Preference(getActivity());
|
||||
serverConfig.setTitle(config.title.getSummary());
|
||||
|
||||
Boolean useSsl = getPreferenceManager()
|
||||
.getSharedPreferences()
|
||||
.getBoolean(config.useSsl.getKey(), false);
|
||||
|
||||
serverConfig.setSummary(String.format(
|
||||
"%s:%s %s",
|
||||
config.hostAddress.getText(),
|
||||
config.hostPort.getText(),
|
||||
useSsl ? "(SSL)" : "")
|
||||
);
|
||||
serverConfig.setOnPreferenceClickListener(
|
||||
new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent serverConfigIntent = new Intent(
|
||||
getActivity(),
|
||||
ConnectionActivity.class
|
||||
);
|
||||
serverConfigIntent.putExtra(KEY_PREFERENCE_DISPLAY,
|
||||
PREFERENCE_DISPLAY_SERVER);
|
||||
serverConfigIntent.putExtra(KEY_SERVER_ID, config.id);
|
||||
startActivity(serverConfigIntent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return serverConfig;
|
||||
}
|
||||
|
||||
private List<HostConfig> getHostConfigs() {
|
||||
return hostConfigsFromPreferences(
|
||||
getHostConfigMap(
|
||||
getPreferenceManager()
|
||||
.getSharedPreferences()
|
||||
.getAll()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private Map<String, ?> getHostConfigMap(Map<String, ?> preferences) {
|
||||
Map<String, Object> configMap = new TreeMap<String, Object>();
|
||||
|
||||
List<String> sortedKeys = new ArrayList<String>(preferences.keySet());
|
||||
Collections.sort(sortedKeys);
|
||||
for (String key : sortedKeys) {
|
||||
if (key.startsWith(HostConfig.KEY_PREFIX)) {
|
||||
configMap.put(key, preferences.get(key));
|
||||
}
|
||||
}
|
||||
return configMap;
|
||||
}
|
||||
|
||||
private List<HostConfig> hostConfigsFromPreferences(Map<String, ?> preferences) {
|
||||
List<Integer> hostIds = getHostIds(preferences);
|
||||
List<HostConfig> hostConfigs = new ArrayList<HostConfig>();
|
||||
for (Integer id : hostIds) {
|
||||
hostConfigs.add(hostConfigFromPreferencesForHostId(id, preferences));
|
||||
}
|
||||
return hostConfigs;
|
||||
}
|
||||
|
||||
private HostConfig hostConfigFromPreferencesForHostId(int hostId, Map<String, ?> preferences) {
|
||||
Object titleValue = preferences.get(getHostConfigTitleKey(hostId));
|
||||
String hostTitle = titleValue == null ? getString(R.string.connection_profile_server) : titleValue.toString();
|
||||
HostConfig hostConfig = new HostConfig(
|
||||
hostTitle, hostId
|
||||
);
|
||||
Object hostValueObject = preferences.get(hostConfig.hostAddress.getKey());
|
||||
String hostValue = hostValueObject == null
|
||||
? getString(R.string.hostDefaultValue) : hostValueObject.toString();
|
||||
hostConfig.hostAddress.setText(hostValue);
|
||||
hostConfig.hostAddress.setSummary(hostValue);
|
||||
|
||||
Object portValueObject = preferences.get(hostConfig.hostPort.getKey());
|
||||
String portValue = portValueObject == null
|
||||
? getString(R.string.portDefaultValue) : portValueObject.toString();
|
||||
hostConfig.hostPort.setText(portValue);
|
||||
hostConfig.hostPort.setSummary(portValue);
|
||||
|
||||
Object useridValueObject = preferences.get(hostConfig.userid.getKey());
|
||||
String useridValue = useridValueObject == null
|
||||
? getString(R.string.useridDefaultValue) : useridValueObject.toString();
|
||||
hostConfig.userid.setText(useridValue);
|
||||
hostConfig.userid.setSummary(useridValue);
|
||||
|
||||
Object passwordValueObject = preferences.get(hostConfig.password.getKey());
|
||||
String passwordValue = passwordValueObject == null
|
||||
? getString(R.string.passwordDefaultValue) : passwordValueObject.toString();
|
||||
hostConfig.password.setText(passwordValue);
|
||||
hostConfig.password.setSummary(passwordValue);
|
||||
return hostConfig;
|
||||
}
|
||||
|
||||
private int getNextPrefId(Map<String, ?> preferences) {
|
||||
int max = 0;
|
||||
for (String key : preferences.keySet()) {
|
||||
int prefValue = Integer.valueOf(key.split("\\.")[2]);
|
||||
max = prefValue > max ? prefValue : max;
|
||||
}
|
||||
return max + 1;
|
||||
}
|
||||
|
||||
private List<Integer> getHostIds(Map<String, ?> preferences) {
|
||||
Set<Integer> hashSet = new HashSet<Integer>();
|
||||
for (String key : preferences.keySet()) {
|
||||
hashSet.add(Integer.valueOf(key.split("\\.")[2]));
|
||||
}
|
||||
List<Integer> hostIds = new ArrayList<Integer>(hashSet);
|
||||
Collections.sort(hostIds);
|
||||
Log.i(LOG_TAG, "Got HostIds: " + hostIds);
|
||||
return hostIds;
|
||||
}
|
||||
|
||||
private boolean addPreferenceCategory(PreferenceScreen preferenceScreen, HostConfig hostConfig) {
|
||||
PreferenceCategory preferenceCategory = new PreferenceCategory(getActivity());
|
||||
preferenceCategory.setTitle(hostConfig.title.getSummary());
|
||||
preferenceCategory.setKey("key.preference.category");
|
||||
preferenceScreen.addPreference(preferenceCategory);
|
||||
preferenceCategory.addPreference(hostConfig.title);
|
||||
preferenceCategory.addPreference(hostConfig.hostAddress);
|
||||
preferenceCategory.addPreference(hostConfig.hostPort);
|
||||
preferenceCategory.addPreference(hostConfig.useSsl);
|
||||
preferenceCategory.addPreference(hostConfig.userid);
|
||||
preferenceCategory.addPreference(hostConfig.password);
|
||||
preferenceCategory.addPreference(hostConfig.remove);
|
||||
preferenceCategory.addPreference(hostConfig.activate);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (resume) {
|
||||
Log.i(LOG_TAG, "Resuming...");
|
||||
} else {
|
||||
constructOverviewScreen();
|
||||
Log.i(LOG_TAG, "Not resuming...");
|
||||
}
|
||||
}
|
||||
|
||||
private class HostConfig {
|
||||
static final String KEY_PREFIX = "host.config.";
|
||||
final int id;
|
||||
final EditTextPreference title;
|
||||
final EditTextPreference hostAddress;
|
||||
final EditTextPreference hostPort;
|
||||
final CheckBoxPreference useSsl;
|
||||
final EditTextPreference userid;
|
||||
final EditTextPreference password;
|
||||
final Preference remove;
|
||||
final Preference activate;
|
||||
Preference.OnPreferenceChangeListener onPreferenceChangeListener =
|
||||
new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
preference.setSummary("" + o);
|
||||
if (preference.getKey().endsWith(".title")) {
|
||||
preferenceScreen
|
||||
.findPreference("key.preference.category")
|
||||
.setTitle("" + o);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
HostConfig(String sTitle, int id) {
|
||||
this.id = id;
|
||||
title = new EditTextPreference(getActivity());
|
||||
title.setSummary(getString(R.string.url));
|
||||
title.getEditText().setHint(getString(R.string.url));
|
||||
title.setTitle(getString(R.string.connection_profile_title));
|
||||
title.setKey(KEY_PREFIX + id + ".title");
|
||||
title.setDefaultValue(getString(R.string.url));
|
||||
title.setSummary(sTitle);
|
||||
title.setDialogTitle(getString(R.string.connection_profile_title));
|
||||
title.setOnPreferenceChangeListener(onPreferenceChangeListener);
|
||||
|
||||
hostAddress = new EditTextPreference(getActivity());
|
||||
hostAddress.setTitle(getString(R.string.url_hint));
|
||||
hostAddress.setKey(KEY_PREFIX + id + ".address");
|
||||
hostAddress.getEditText().setHint(R.string.url_hint);
|
||||
hostAddress.setSummary(getString(R.string.url_hint));
|
||||
hostAddress.setDialogTitle(getString(R.string.url_hint));
|
||||
hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
|
||||
hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener);
|
||||
|
||||
hostPort = new EditTextPreference(getActivity());
|
||||
hostPort.setTitle(getString(R.string.port));
|
||||
hostPort.setKey(KEY_PREFIX + id + ".port");
|
||||
hostPort.setSummary(getString(R.string.port));
|
||||
hostPort.setDialogTitle(getString(R.string.port));
|
||||
hostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
hostPort.setDefaultValue(getString(R.string.portDefaultValue));
|
||||
hostPort.setOnPreferenceChangeListener(onPreferenceChangeListener);
|
||||
|
||||
useSsl = new CheckBoxPreference(getActivity());
|
||||
useSsl.setTitle(getString(R.string.connection_profile_ssl_use));
|
||||
useSsl.setSummary(getString(R.string.connection_profile_ssl_summary));
|
||||
useSsl.setKey(KEY_PREFIX + id + ".usessl");
|
||||
|
||||
userid = new EditTextPreference(getActivity());
|
||||
userid.setSummary(getString(R.string.connection_userid));
|
||||
userid.getEditText().setHint(getString(R.string.connection_userid));
|
||||
userid.setTitle(getString(R.string.connection_userid));
|
||||
userid.setKey(KEY_PREFIX + id + ".userid");
|
||||
userid.setDefaultValue(getString(R.string.useridDefaultValue));
|
||||
userid.setSummary(getString(R.string.useridDefaultValue));
|
||||
userid.setDialogTitle(getString(R.string.connection_userid));
|
||||
userid.setOnPreferenceChangeListener(onPreferenceChangeListener);
|
||||
|
||||
password = new EditTextPreference(getActivity());
|
||||
password.setSummary(getString(R.string.connection_password));
|
||||
password.getEditText().setHint(getString(R.string.connection_password));
|
||||
password.setTitle(getString(R.string.connection_password));
|
||||
password.setKey(KEY_PREFIX + id + ".password");
|
||||
password.setDefaultValue(getString(R.string.passwordDefaultValue));
|
||||
password.setSummary(getString(R.string.passwordDefaultValue));
|
||||
password.setDialogTitle(getString(R.string.connection_password));
|
||||
password.setOnPreferenceChangeListener(onPreferenceChangeListener);
|
||||
|
||||
remove = new Preference(getActivity());
|
||||
remove.setTitle(getString(R.string.connection_profile_remove));
|
||||
remove.setSummary(getString(R.string.connection_profile_remove_summary));
|
||||
remove.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.remove(hostAddress.getKey());
|
||||
editor.remove(hostPort.getKey());
|
||||
editor.remove(title.getKey());
|
||||
editor.remove(useSsl.getKey());
|
||||
editor.remove(userid.getKey());
|
||||
editor.remove(password.getKey());
|
||||
editor.commit();
|
||||
getActivity().onBackPressed();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
activate = new Preference(getActivity());
|
||||
activate.setTitle(getString(R.string.connection_profile_activate));
|
||||
activate.setSummary(getString(R.string.connection_profile_summary_activate));
|
||||
activate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SharedPreferences preferences = getPreferenceManager().getSharedPreferences();
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
String host = preferences.getString(hostAddress.getKey(),
|
||||
getString(R.string.hostDefaultValue));
|
||||
editor.putString(getString(R.string.keyHost), host);
|
||||
String port = preferences.getString(hostPort.getKey(),
|
||||
getString(R.string.portDefaultValue));
|
||||
editor.putString(getString(R.string.keyPort), port);
|
||||
Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false);
|
||||
editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl);
|
||||
String suserid = preferences.getString(userid.getKey(), getString(R.string.useridDefaultValue));
|
||||
editor.putString(getString(R.string.key_userid), suserid);
|
||||
String spassword = preferences.getString(password.getKey(),
|
||||
getString(R.string.passwordDefaultValue));
|
||||
editor.putString(getString(R.string.key_password), spassword);
|
||||
|
||||
editor.putString(
|
||||
getString(R.string.key_profile_selected_title),
|
||||
preferences.getString(
|
||||
title.getKey(),
|
||||
getString(R.string.url)));
|
||||
|
||||
editor.commit();
|
||||
Toast.makeText(getActivity(),
|
||||
String.format(
|
||||
"%s: %s\n[%s:%s] %s",
|
||||
getString(R.string.connection_profile_active_toast),
|
||||
HostConfig.this.title.getText(),
|
||||
host,
|
||||
port,
|
||||
useSsl.isChecked() ? "(SSL)" : ""
|
||||
),
|
||||
Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HostConfig{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", hostAddress=" + hostAddress.getKey() +
|
||||
", hostPort=" + hostPort.getKey() +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,88 +1,220 @@
|
||||
/******************************************************************************
|
||||
* OpenLP - Open Source Lyrics Projection *
|
||||
* --------------------------------------------------------------------------- *
|
||||
* Copyright (c) 2011-2015 OpenLP Android Developers *
|
||||
* --------------------------------------------------------------------------- *
|
||||
* This program 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; version 2 of the License. *
|
||||
* *
|
||||
* This program 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 this program; if not, write to the Free Software Foundation, Inc., 59 *
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
*******************************************************************************/
|
||||
package org.openlp.android2.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.openlp.android2.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A {@link PreferenceActivity} that presents a set of application settings. On
|
||||
* handset devices, settings are presented as a single list. On tablets,
|
||||
* settings are split by category, with category headers shown to the left of
|
||||
* the list of settings.
|
||||
* <p/>
|
||||
* See <a href="http://developer.android.com/design/patterns/settings.html">
|
||||
* Android Design: Settings</a> for design guidelines and the <a
|
||||
* href="http://developer.android.com/guide/topics/ui/settings.html">Settings
|
||||
* API Guide</a> for more information on developing a Settings UI.
|
||||
*/
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
/**
|
||||
* Determines whether to always show the simplified settings UI, where
|
||||
* settings are presented in a single list. When false, settings are shown
|
||||
* as a master/detail two-pane view on tablets. When true, a single pane is
|
||||
* shown on tablets.
|
||||
*/
|
||||
private static final boolean ALWAYS_SIMPLE_PREFS = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
//todo fix this code to work with fragments but not now!
|
||||
//getFragmentManager().beginTransaction()
|
||||
// .replace(android.R.id.content, new SettingsFragment())
|
||||
// .commit();
|
||||
setupSimplePreferencesScreen();
|
||||
}
|
||||
|
||||
getPreferenceManager()
|
||||
.setSharedPreferencesName(getString(R.string.keySharedPreferences));
|
||||
/**
|
||||
* Shows the simplified settings UI if the device configuration if the
|
||||
* device configuration dictates that a simplified, single-pane UI should be
|
||||
* shown.
|
||||
*/
|
||||
private void setupSimplePreferencesScreen() {
|
||||
if (!isSimplePreferences(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// In the simplified UI, fragments are not used at all and we instead
|
||||
// use the older PreferenceActivity APIs.
|
||||
|
||||
// Add 'general' preferences.
|
||||
addPreferencesFromResource(R.xml.pref_general);
|
||||
final SharedPreferences sharedPreferences = getPreferenceManager()
|
||||
.getSharedPreferences();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(sharedPreferences.getString(
|
||||
getString(R.string.keyHost),
|
||||
getString(R.string.not_set)));
|
||||
stringBuilder.append(":");
|
||||
|
||||
Boolean useSsl = sharedPreferences.getBoolean(
|
||||
getString(R.string.key_ssl_use), false);
|
||||
stringBuilder.append(
|
||||
String.format("%s %s",
|
||||
sharedPreferences.getString(
|
||||
getString(R.string.keyPort),
|
||||
getString(R.string.not_set)), useSsl ? "(SSL)" : ""));
|
||||
|
||||
final Preference hostPreference = findPreference(getString(R.string.keyHost));
|
||||
hostPreference.setTitle(
|
||||
getPreferenceManager().getSharedPreferences()
|
||||
.getString(
|
||||
getString(R.string.key_profile_selected_title),
|
||||
getString(R.string.url)
|
||||
)
|
||||
);
|
||||
hostPreference.setSummary(stringBuilder.toString());
|
||||
|
||||
Preference preference = findPreference(getString(R.string.keyHost));
|
||||
preference.setIntent(new Intent(this, ConnectionActivity.class));
|
||||
// Add 'notifications' preferences, and a corresponding header.
|
||||
PreferenceCategory fakeHeader = new PreferenceCategory(this);
|
||||
fakeHeader.setTitle(R.string.connection_configuration);
|
||||
getPreferenceScreen().addPreference(fakeHeader);
|
||||
addPreferencesFromResource(R.xml.pref_notification);
|
||||
|
||||
// Bind the summaries of EditText/List/Dialog/Ringtone preferences to
|
||||
// their values. When their values change, their summaries are updated
|
||||
// to reflect the new value, per the Android Design guidelines.
|
||||
bindPreferenceSummaryToValue(findPreference("key_text_size"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_connection_timeout"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_host"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_port"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_userid"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_password"));
|
||||
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragment {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean onIsMultiPane() {
|
||||
return isXLargeTablet(this) && !isSimplePreferences(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to determine if the device has an extra-large screen. For
|
||||
* example, 10" tablets are extra-large.
|
||||
*/
|
||||
private static boolean isXLargeTablet(Context context) {
|
||||
return (context.getResources().getConfiguration().screenLayout
|
||||
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the simplified settings UI should be shown. This is
|
||||
* true if this is forced via {@link #ALWAYS_SIMPLE_PREFS}, or the device
|
||||
* doesn't have newer APIs like {@link PreferenceFragment}, or the device
|
||||
* doesn't have an extra-large screen. In these cases, a single-pane
|
||||
* "simplified" settings UI should be shown.
|
||||
*/
|
||||
private static boolean isSimplePreferences(Context context) {
|
||||
return ALWAYS_SIMPLE_PREFS
|
||||
|| Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
|
||||
|| !isXLargeTablet(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public void onBuildHeaders(List<Header> target) {
|
||||
if (!isSimplePreferences(this)) {
|
||||
loadHeadersFromResource(R.xml.pref_headers, target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidFragment (String fragmentName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A preference value change listener that updates the preference's summary
|
||||
* to reflect its new value.
|
||||
*/
|
||||
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object value) {
|
||||
String stringValue = value.toString();
|
||||
|
||||
if (preference instanceof ListPreference) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
int index = listPreference.findIndexOfValue(stringValue);
|
||||
|
||||
// Set the summary to reflect the new value.
|
||||
preference.setSummary(
|
||||
index >= 0
|
||||
? listPreference.getEntries()[index]
|
||||
: null);
|
||||
|
||||
} else {
|
||||
// For all other preferences, set the summary to the value's
|
||||
// simple string representation.
|
||||
preference.setSummary(stringValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds a preference's summary to its value. More specifically, when the
|
||||
* preference's value is changed, its summary (line of text below the
|
||||
* preference title) is updated to reflect the value. The summary is also
|
||||
* immediately updated upon calling this method. The exact display format is
|
||||
* dependent on the type of preference.
|
||||
*
|
||||
* @see #sBindPreferenceSummaryToValueListener
|
||||
*/
|
||||
private static void bindPreferenceSummaryToValue(Preference preference) {
|
||||
// Set the listener to watch for value changes.
|
||||
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
|
||||
|
||||
// Trigger the listener immediately with the preference's
|
||||
// current value.
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
PreferenceManager
|
||||
.getDefaultSharedPreferences(preference.getContext())
|
||||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* This fragment shows general preferences only. It is used when the
|
||||
* activity is showing a two-pane settings UI.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public static class GeneralPreferenceFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getPreferenceManager().setSharedPreferencesName(getString(R.string.keySharedPreferences));
|
||||
// Load the preferences from an XML resource
|
||||
addPreferencesFromResource(R.xml.pref_general);
|
||||
}
|
||||
|
||||
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
|
||||
// to their values. When their values change, their summaries are
|
||||
// updated to reflect the new value, per the Android Design
|
||||
// guidelines.
|
||||
bindPreferenceSummaryToValue(findPreference("key_text_size"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This fragment shows notification preferences only. It is used when the
|
||||
* activity is showing a two-pane settings UI.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public static class NotificationPreferenceFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_notification);
|
||||
|
||||
// Bind the summaries of EditText/List/Dialog/Ringtone preferences
|
||||
// to their values. When their values change, their summaries are
|
||||
// updated to reflect the new value, per the Android Design
|
||||
// guidelines.
|
||||
bindPreferenceSummaryToValue(findPreference("key_connection_timeout"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_host"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_port"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_userid"));
|
||||
bindPreferenceSummaryToValue(findPreference("key_password"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,11 @@ package org.openlp.android2.common;
|
||||
|
||||
|
||||
import java.security.KeyStore;
|
||||
import java.util.*;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import com.loopj.android.http.AsyncHttpClient;
|
||||
import org.apache.http.auth.Credentials;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.openlp.android2.R;
|
||||
|
||||
/**
|
||||
@ -42,56 +41,29 @@ public class OpenLPHttpClient {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private String getPreference(Map preferences, String key, String defaultValue) {
|
||||
if (preferences.containsKey(key)) {
|
||||
return preferences.get(key).toString();
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getPreference(Map preferences, String key, Integer defaultValue) {
|
||||
if (preferences.containsKey(key)) {
|
||||
return Integer.valueOf(preferences.get(key).toString());
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean getPreference(Map preferences, String key, Boolean defaultValue) {
|
||||
if (preferences.containsKey(key)) {
|
||||
return Boolean.valueOf(preferences.get(key).toString());
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public String getAbsoluteUrl(AsyncHttpClient client) {
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
String urlBase = getBaseUrl();
|
||||
|
||||
Map<String, ?> preferences = context.getSharedPreferences(context.getString(R.string.keySharedPreferences),
|
||||
Context.MODE_PRIVATE).getAll();
|
||||
Log.d(LOG_TAG, "Base Url set to " + urlBase);
|
||||
|
||||
String userid = getPreference(preferences, context.getString(R.string.key_userid), "openlp");
|
||||
String userid = sharedPrefs.getString(context.getString(R.string.key_userid), "openlp");
|
||||
|
||||
String password = getPreference(preferences, context.getString(R.string.key_password), "password");
|
||||
String password = sharedPrefs.getString(context.getString(R.string.key_password), "password");
|
||||
|
||||
Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password);
|
||||
client.setBasicAuth(userid,password);
|
||||
|
||||
Credentials creds = new UsernamePasswordCredentials(userid, password);
|
||||
|
||||
int connectionTimeout = context.getResources().getInteger(
|
||||
R.integer.connectionTimeoutDefaultValue);
|
||||
|
||||
if (getPreference(preferences, context.getString(R.string.keyEnableCustomTimeout), false)) {
|
||||
if (sharedPrefs.getBoolean(context.getString(R.string.key_enable_custom_timeout), false)) {
|
||||
Log.d(LOG_TAG, "Overriding Connection and Socket timeouts");
|
||||
|
||||
connectionTimeout = getPreference(preferences,
|
||||
context.getString(R.string.keyConnectionTimeout),
|
||||
context.getResources().getInteger(
|
||||
R.integer.connectionTimeoutDefaultValue)
|
||||
connectionTimeout = sharedPrefs.getInt(context.getString(R.string.key_connection_timeout),
|
||||
context.getResources().getInteger(R.integer.connectionTimeoutDefaultValue)
|
||||
);
|
||||
}
|
||||
client.setTimeout(connectionTimeout);
|
||||
@ -104,18 +76,19 @@ public class OpenLPHttpClient {
|
||||
client.setSSLSocketFactory(sf);
|
||||
}
|
||||
catch (Exception e){
|
||||
//
|
||||
}
|
||||
}
|
||||
return urlBase;
|
||||
}
|
||||
|
||||
public String getBaseUrl(){
|
||||
Map<String, ?> preferences = context.getSharedPreferences(context.getString(R.string.keySharedPreferences), Context.MODE_PRIVATE).getAll();
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
useSSL = getPreference(preferences, context.getString(R.string.key_ssl_use), false);
|
||||
String host = getPreference(preferences, context.getString(R.string.keyHost),
|
||||
context.getString(R.string.hostDefaultValue));
|
||||
String port = getPreference(preferences, context.getString(R.string.keyPort), "4316");
|
||||
useSSL =sharedPrefs.getBoolean(context.getString(R.string.key_ssl_use), false);
|
||||
String host = sharedPrefs.getString(context.getString(R.string.key_host),
|
||||
context.getString(R.string.host_default_value));
|
||||
String port = sharedPrefs.getString(context.getString(R.string.key_port), "4316");
|
||||
|
||||
return String.format("http%s://%s:%s", useSSL ? "s" : "", host, port);
|
||||
|
||||
|
@ -36,8 +36,7 @@ public class AboutFragment extends Fragment {
|
||||
}
|
||||
|
||||
public static AboutFragment newInstance() {
|
||||
AboutFragment fragment = new AboutFragment();
|
||||
return fragment;
|
||||
return new AboutFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,8 +35,7 @@ public class HomeFragment extends Fragment {
|
||||
}
|
||||
|
||||
public static HomeFragment newInstance() {
|
||||
HomeFragment fragment = new HomeFragment();
|
||||
return fragment;
|
||||
return new HomeFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,7 @@ import android.widget.ListAdapter;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@ -54,8 +55,7 @@ public class LiveListFragment extends OpenLPFragment {
|
||||
private String LOG_TAG = LiveListFragment.class.getName();
|
||||
|
||||
public static LiveListFragment newInstance() {
|
||||
LiveListFragment fragment = new LiveListFragment();
|
||||
return fragment;
|
||||
return new LiveListFragment();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,11 +108,11 @@ public class LiveListFragment extends OpenLPFragment {
|
||||
int[] to = {R.id.tag, R.id.liveListNormal, R.id.liveListSelected};
|
||||
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
context.getString(R.string.keySharedPreferences),
|
||||
context.getString(R.string.key_shared_preferences),
|
||||
Context.MODE_PRIVATE);
|
||||
|
||||
final int size = Integer.parseInt(prefs.getString(
|
||||
context.getString(R.string.keyTextSize),
|
||||
context.getString(R.string.key_text_size),
|
||||
String.valueOf(context.getResources().getInteger(
|
||||
R.integer.textSizeDefaultValue))));
|
||||
|
||||
@ -131,7 +131,7 @@ public class LiveListFragment extends OpenLPFragment {
|
||||
}
|
||||
return view;
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
setListAdapter(adapter);
|
||||
getListView().setSelection(selected - 1);
|
||||
|
@ -27,8 +27,7 @@ public class LiveWebFragment extends WebFragment {
|
||||
}
|
||||
|
||||
public static LiveWebFragment newInstance() {
|
||||
LiveWebFragment fragment = new LiveWebFragment();
|
||||
return fragment;
|
||||
return new LiveWebFragment();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*******************************************************************************/
|
||||
package org.openlp.android2.fragments;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.app.Activity;
|
||||
import android.support.v7.app.ActionBar;
|
||||
@ -184,6 +185,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(0xFF000000));
|
||||
|
||||
// ActionBarDrawerToggle ties together the the proper interactions
|
||||
// between the navigation drawer and the action bar app icon.
|
||||
@ -300,11 +302,6 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getItemId() == R.id.action_example) {
|
||||
Toast.makeText(getActivity(), "Example action.", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
@ -161,11 +161,11 @@ public class ServiceListFragment extends OpenLPFragment {
|
||||
int[] to = {R.id.icon, R.id.serviceListText};
|
||||
|
||||
SharedPreferences prefs = context.getSharedPreferences(
|
||||
context.getString(R.string.keySharedPreferences),
|
||||
context.getString(R.string.key_shared_preferences),
|
||||
Context.MODE_PRIVATE);
|
||||
|
||||
final int size = Integer.parseInt(prefs.getString(
|
||||
context.getString(R.string.keyTextSize),
|
||||
context.getString(R.string.key_text_size),
|
||||
String.valueOf(context.getResources().getInteger(
|
||||
R.integer.textSizeDefaultValue))));
|
||||
|
||||
|
@ -29,7 +29,6 @@ public class StageWebFragment extends WebFragment {
|
||||
|
||||
|
||||
public static StageWebFragment newInstance() {
|
||||
StageWebFragment fragment = new StageWebFragment();
|
||||
return fragment;
|
||||
return new StageWebFragment();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<!-- As the main content view, the view below consumes the entire
|
||||
space available using match_parent in both dimensions. -->
|
||||
<FrameLayout android:id="@+id/container" android:layout_width="match_parent"
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- android:layout_gravity="start" tells DrawerLayout to treat
|
||||
@ -16,9 +20,12 @@
|
||||
android:layout_gravity="left" instead. -->
|
||||
<!-- The drawer is given a fixed width in dp and extends the full height of
|
||||
the container. -->
|
||||
<fragment android:id="@+id/navigation_drawer"
|
||||
android:layout_width="@dimen/navigation_drawer_width" android:layout_height="match_parent"
|
||||
android:layout_gravity="start" android:name="org.openlp.android2.fragments.NavigationDrawerFragment"
|
||||
<fragment
|
||||
android:id="@+id/navigation_drawer"
|
||||
android:name="org.openlp.android2.fragments.NavigationDrawerFragment"
|
||||
android:layout_width="@dimen/navigation_drawer_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
tools:layout="@layout/fragment_navigation_drawer" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
|
@ -13,10 +13,11 @@
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/enter_alert_text"
|
||||
android:id="@+id/textView"
|
||||
android:autoText="true"
|
||||
android:inputType="textLongMessage"
|
||||
android:textStyle="bold|italic"
|
||||
android:textSize="40px"
|
||||
android:height="45dp"/>
|
||||
android:height="45px"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/alertText"
|
||||
android:layout_width="290dp"
|
||||
|
@ -13,10 +13,9 @@
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/display_blank_summary"
|
||||
android:id="@+id/textView"
|
||||
android:autoText="true"
|
||||
android:textStyle="bold|italic"
|
||||
android:textSize="40px"
|
||||
android:height="45dp"/>
|
||||
android:height="45px"/>
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -1,8 +0,0 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
|
||||
<item android:id="@+id/action_example" android:title="@string/action_settings"
|
||||
app:showAsAction="withText|ifRoom" />
|
||||
<item android:id="@+id/action_settings" android:title="@string/action_settings"
|
||||
android:orderInCategory="100" app:showAsAction="never" />
|
||||
</menu>
|
@ -5,23 +5,23 @@
|
||||
android:visible="false"
|
||||
android:icon="@drawable/ic_arrow_back"
|
||||
android:title="@string/action_back"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
<item android:id="@+id/action_blank"
|
||||
android:checkable="true"
|
||||
android:visible="true"
|
||||
android:icon="@drawable/ic_settings_display"
|
||||
android:title="@string/action_blank"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
<item android:id="@+id/action_alert"
|
||||
android:checkable="true"
|
||||
android:visible="true"
|
||||
android:icon="@drawable/ic_alarm_add"
|
||||
android:title="@string/action_alert"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
<item android:id="@+id/action_refresh"
|
||||
android:icon="@drawable/ic_refresh"
|
||||
android:title="@string/action_refresh"
|
||||
app:showAsAction="never|withText" />
|
||||
app:showAsAction="ifRoom" />
|
||||
<item android:id="@+id/action_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/action_search"
|
||||
|
@ -1,10 +1,9 @@
|
||||
<resources>
|
||||
<!-- STRING -->
|
||||
<string name="hostDefaultValue">192.168.1.1</string>
|
||||
<string name="portDefaultValue">4316</string>
|
||||
<string name="ssl.port.default">4317</string>
|
||||
<string name="useridDefaultValue">userid</string>
|
||||
<string name="passwordDefaultValue">password</string>
|
||||
<string name="host_default_value">192.168.0.1</string>
|
||||
<string name="port_default_value">4316</string>
|
||||
<string name="userid_default_value">userid</string>
|
||||
<string name="password_default_value">password</string>
|
||||
|
||||
<!-- INTEGER -->
|
||||
<integer name="connectionTimeoutDefaultValue">3000</integer>
|
||||
|
@ -1,15 +1,12 @@
|
||||
<resources>
|
||||
<string name="keyEnableCustomTimeout">enableCustomTimeout</string>
|
||||
<string name="keyBackgroundService">backgroundService</string>
|
||||
<string name="keyConnectionTimeout">connectionTimeout</string>
|
||||
<string name="keyDisplayBlankType">blankType</string>
|
||||
<string name="keyTextSize">textSize</string>
|
||||
<string name="keySocketTimeout">socketTimeout</string>
|
||||
<string name="keyHost">keyHost</string>
|
||||
<string name="keyPort">keyPort</string>
|
||||
<string name="key.userid">key.userid</string>
|
||||
<string name="key.password">key.password</string>
|
||||
<string name="keySharedPreferences">keySharedPreferences</string>
|
||||
<string name="key.ssl.use">ssl.use</string>
|
||||
<string name="key.profile.selected.title">key.profile.selected.title</string>
|
||||
<string name="key_enable_custom_timeout">key_enable_custom_timeout</string>
|
||||
<string name="key_connection_timeout">key_connection_timeout</string>
|
||||
<string name="key_text_size">key_text_size</string>
|
||||
<string name="key_host">key_host</string>
|
||||
<string name="key_port">key_port</string>
|
||||
<string name="key_userid">key_userid</string>
|
||||
<string name="key_password">key_password</string>
|
||||
<string name="key_shared_preferences">key_shared_preferences</string>
|
||||
<string name="key_ssl_use">key_ssl_use</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="about_text">Version</string>
|
||||
<string name="about_display_1">OpenLP is free church presentation software</string>
|
||||
<string name="about_display_2">Find out more about visit the OpenLP website_</string>
|
||||
<string name="about_display_4">Copyright</string>
|
||||
@ -14,33 +13,20 @@
|
||||
<string name="action_alert">Alert</string>
|
||||
<string name="action_back">Back</string>
|
||||
<string name="action_blank">Toggle Display</string>
|
||||
<string name="action_connections">Connections</string>
|
||||
<string name="action_preferences">Preferences</string>
|
||||
<string name="action_refresh">Refresh</string>
|
||||
<string name="action_search">Search</string>
|
||||
<string name="app_name">OpenLP</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="connection_add_by_menu">Tap to add a new profile</string>
|
||||
<string name="connection_available_configurations">List of available profiles</string>
|
||||
<string name="connection_configuration">Configure Network</string>
|
||||
<string name="connection_password">Password</string>
|
||||
<string name="connection_profile_activate">Save and Activate</string>
|
||||
<string name="connection_profile_active_toast">Active Profile</string>
|
||||
<string name="connection_profile_active">Active Profile - Tap to manage</string>
|
||||
<string name="connection_profile_not_saved">Tap to edit properties</string>
|
||||
<string name="connection_profile_new_server">New Server</string>
|
||||
<string name="connection_profile_remove">Remove</string>
|
||||
<string name="connection_profile_remove_summary">Remove this configuration</string>
|
||||
<string name="connection_profile_server">Server</string>
|
||||
<string name="connection_profile">Server Details</string>
|
||||
<string name="connection_profile_ssl_use">Use HTTPS</string>
|
||||
<string name="connection_profile_ssl_summary">Specify whether HTTPS should be used</string>
|
||||
<string name="connection_profile_summary_activate">Tap to set active</string>
|
||||
<string name="connection_profile_title">Profile Title</string>
|
||||
<string name="connection_timeout">Connection Timeout</string>
|
||||
<string name="connection_timedout">Connection timed out</string>
|
||||
<string name="connection_timeout_summary">Select a value (milliseconds)</string>
|
||||
<string name="connection_userid">Userid</string>
|
||||
<string name="custom_timeout">Set Custom Timeout</string>
|
||||
<string name="custom_timeouts_summary">Check to modify timeout settings</string>
|
||||
<string name="display_blank_summary">Select the required blank type</string>
|
||||
<string name="display_desktop">Blank display to Desktop</string>
|
||||
<string name="display_reset">Reset Display</string>
|
||||
@ -55,15 +41,14 @@
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="none">None</string>
|
||||
<string name="not_set">Not set</string>
|
||||
<string name="port">Port</string>
|
||||
<string name="process">Process</string>
|
||||
<string name="service_list">Service List</string>
|
||||
<string name="stage_view">Stage View</string>
|
||||
<string name="text_size_type">Set Display Text Size</string>
|
||||
<string name="text_size_type">Display Text Size</string>
|
||||
<string name="text_size">Select display text size</string>
|
||||
<string name="text_size_summary">Change the Service text size</string>
|
||||
<string name="url">Server</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
<string name="url_hint">Hostname or IP</string>
|
||||
<string name="unable">Unable to process request - check network settings</string>
|
||||
</resources>
|
||||
|
@ -1,61 +0,0 @@
|
||||
<resources>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
|
||||
<!-- Example General settings -->
|
||||
<string name="pref_header_general">General</string>
|
||||
|
||||
<string name="pref_title_social_recommendations">Enable social recommendations</string>
|
||||
<string name="pref_description_social_recommendations">Recommendations for people to contact
|
||||
based on your message history
|
||||
</string>
|
||||
|
||||
<string name="pref_title_display_name">Display name</string>
|
||||
<string name="pref_default_display_name">John Smith</string>
|
||||
|
||||
<string name="pref_title_add_friends_to_messages">Add friends to messages</string>
|
||||
<string-array name="pref_example_list_titles">
|
||||
<item>Always</item>
|
||||
<item>When possible</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_example_list_values">
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Example settings for Data & Sync -->
|
||||
<string name="pref_header_data_sync">Data & sync</string>
|
||||
|
||||
<string name="pref_title_sync_frequency">Sync frequency</string>
|
||||
<string-array name="pref_sync_frequency_titles">
|
||||
<item>15 minutes</item>
|
||||
<item>30 minutes</item>
|
||||
<item>1 hour</item>
|
||||
<item>3 hours</item>
|
||||
<item>6 hours</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_sync_frequency_values">
|
||||
<item>15</item>
|
||||
<item>30</item>
|
||||
<item>60</item>
|
||||
<item>180</item>
|
||||
<item>360</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
|
||||
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||
|
||||
<!-- Example settings for Notifications -->
|
||||
<string name="pref_header_notifications">Notifications</string>
|
||||
|
||||
<string name="pref_title_new_message_notifications">New message notifications</string>
|
||||
|
||||
<string name="pref_title_ringtone">Ringtone</string>
|
||||
<string name="pref_ringtone_silent">Silent</string>
|
||||
|
||||
<string name="pref_title_vibrate">Vibrate</string>
|
||||
</resources>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
</PreferenceScreen>
|
@ -1,21 +0,0 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
|
||||
dismiss it. -->
|
||||
<!-- NOTE: ListPreference's summary should be set to its value by the activity code. -->
|
||||
<ListPreference
|
||||
android:key="sync_frequency"
|
||||
android:title="@string/pref_title_sync_frequency"
|
||||
android:entries="@array/pref_sync_frequency_titles"
|
||||
android:entryValues="@array/pref_sync_frequency_values"
|
||||
android:defaultValue="180"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null" />
|
||||
|
||||
<!-- This preference simply launches an intent when selected. Use this UI sparingly, per
|
||||
design guidelines. -->
|
||||
<Preference android:title="@string/pref_title_system_sync_settings">
|
||||
<intent android:action="android.settings.SYNC_SETTINGS" />
|
||||
</Preference>
|
||||
|
||||
</PreferenceScreen>
|
@ -1,41 +1,11 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:title="@string/connection_profile_active"
|
||||
android:key="category.server">
|
||||
<Preference
|
||||
android:title="@string/url"
|
||||
android:key="@string/keyHost"
|
||||
android:hint="@string/url_hint"
|
||||
android:inputType="textUri"
|
||||
android:editable="false"
|
||||
android:name="@string/url"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_test_size_setting"
|
||||
android:title="@string/text_size_type">
|
||||
|
||||
<ListPreference
|
||||
android:key="key_text_size"
|
||||
android:defaultValue="@integer/textSizeDefaultValue"
|
||||
android:entries="@array/textSizeValueEntries"
|
||||
android:entryValues="@array/textSizeValues"
|
||||
android:key="@string/keyTextSize"
|
||||
android:summary="@string/text_size_summary"
|
||||
android:title="@string/text_size" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_custom_timeout_setting"
|
||||
android:title="@string/custom_timeout">
|
||||
<CheckBoxPreference
|
||||
android:key="@string/keyEnableCustomTimeout"
|
||||
android:summary="@string/custom_timeouts_summary"
|
||||
android:title="@string/enable_custom_timeouts" />
|
||||
<ListPreference
|
||||
android:defaultValue="@integer/connectionTimeoutDefaultValue"
|
||||
android:dependency="@string/keyEnableCustomTimeout"
|
||||
android:entries="@array/socketValueEntries"
|
||||
android:entryValues="@array/socketValues"
|
||||
android:key="@string/keyConnectionTimeout"
|
||||
android:summary="@string/connection_timeout_summary"
|
||||
android:title="@string/connection_timeout" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@ -3,15 +3,12 @@
|
||||
<!-- These settings headers are only used on tablets. -->
|
||||
|
||||
<header
|
||||
android:fragment="org.openlp.android2.fragments.SettingsActivity$GeneralPreferenceFragment"
|
||||
android:title="@string/pref_header_general" />
|
||||
android:fragment="org.openlp.android2.activities.SettingsActivity$GeneralPreferenceFragment"
|
||||
android:title="@string/text_size_type" />
|
||||
|
||||
<header
|
||||
android:fragment="org.openlp.android2.fragments.SettingsActivity$NotificationPreferenceFragment"
|
||||
android:title="@string/pref_header_notifications" />
|
||||
android:fragment="org.openlp.android2.activities.SettingsActivity$NotificationPreferenceFragment"
|
||||
android:title="@string/connection_configuration" />
|
||||
|
||||
<header
|
||||
android:fragment="org.openlp.android2.fragments.SettingsActivity$DataSyncPreferenceFragment"
|
||||
android:title="@string/pref_header_data_sync" />
|
||||
|
||||
</preference-headers>
|
||||
|
@ -1,27 +1,59 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- A 'parent' preference, which enables/disables child preferences (below)
|
||||
when checked/unchecked. -->
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_custom_timeout_setting"
|
||||
android:title="@string/custom_timeout">
|
||||
<CheckBoxPreference
|
||||
android:key="notifications_new_message"
|
||||
android:title="@string/pref_title_new_message_notifications"
|
||||
android:defaultValue="true" />
|
||||
android:key="@string/key_enable_custom_timeout"
|
||||
android:title="@string/enable_custom_timeouts" />
|
||||
<ListPreference
|
||||
android:key="@string/key_connection_timeout"
|
||||
android:defaultValue="@integer/connectionTimeoutDefaultValue"
|
||||
android:dependency="@string/key_enable_custom_timeout"
|
||||
android:entries="@array/socketValueEntries"
|
||||
android:entryValues="@array/socketValues"
|
||||
android:summary="@string/connection_timeout_summary"
|
||||
android:title="@string/connection_timeout" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<!-- Allows the user to choose a ringtone in the 'notification' category. -->
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<!-- NOTE: RingtonePreference's summary should be set to its value by the activity code. -->
|
||||
<RingtonePreference
|
||||
android:dependency="notifications_new_message"
|
||||
android:key="notifications_new_message_ringtone"
|
||||
android:title="@string/pref_title_ringtone"
|
||||
android:ringtoneType="notification"
|
||||
android:defaultValue="content://settings/system/notification_sound" />
|
||||
<PreferenceCategory
|
||||
android:title="@string/connection_profile">
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/key_host"
|
||||
android:title="@string/url_hint"
|
||||
android:summary="@string/url_hint"
|
||||
android:defaultValue="@string/host_default_value"
|
||||
android:inputType="textUri" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/key_port"
|
||||
android:title="@string/port"
|
||||
android:summary="@string/port"
|
||||
android:defaultValue="@string/port_default_value"
|
||||
android:inputType="number" />
|
||||
|
||||
<!-- NOTE: This preference will be enabled only when the checkbox above is checked. -->
|
||||
<CheckBoxPreference
|
||||
android:dependency="notifications_new_message"
|
||||
android:key="notifications_new_message_vibrate"
|
||||
android:title="@string/pref_title_vibrate"
|
||||
android:defaultValue="true" />
|
||||
android:key="@string/key_ssl_use"
|
||||
android:title="@string/connection_profile_ssl_use"
|
||||
android:summary="@string/connection_profile_ssl_summary"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/key_userid"
|
||||
android:title="@string/connection_userid"
|
||||
android:summary="@string/userid_default_value"
|
||||
android:defaultValue="@string/userid_default_value"
|
||||
android:inputType="textNoSuggestions" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="@string/key_password"
|
||||
android:title="@string/connection_password"
|
||||
android:summary="@string/password_default_value"
|
||||
android:defaultValue="@string/password_default_value"
|
||||
android:inputType="textVisiblePassword" />
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user