1
0
mirror of https://gitlab.com/openlp/android.git synced 2024-10-31 16:54:41 +00:00
This commit is contained in:
Tim Bentley 2016-05-15 17:51:14 +01:00
parent b75b563e9d
commit 94c6b998bb
19 changed files with 96 additions and 18 deletions

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -0,0 +1,78 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2016 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.common;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Base64;
import android.util.Log;
import org.openlp.android2.R;
public class OpenLPURLBuilder {
private final String LOG_TAG = OpenLPURLBuilder.class.getName();
private Context context;
public OpenLPURLBuilder(Context context) {
this.context = context;
}
public int getConnectionTimeout() {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
int connectionTimeout = context.getResources().getInteger(
R.integer.connectionTimeoutDefaultValue);
if (sharedPrefs.getBoolean(context.getString(R.string.key_enable_custom_timeout), false)) {
Log.d(LOG_TAG, "Overriding Connection and Socket timeouts");
connectionTimeout = Integer.parseInt(sharedPrefs.getString(context.getString(R.string.key_connection_timeout),
String.valueOf(context.getResources().getInteger(R.integer.connectionTimeoutDefaultValue))
));
}
return connectionTimeout;
}
public String getBasicAuth(){
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
String userid = sharedPrefs.getString(context.getString(R.string.key_userid), "openlp");
String password = sharedPrefs.getString(context.getString(R.string.key_password), "password");
Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password);
String credentials = userid + ":" + password;
return "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.DEFAULT);
}
public String getBaseUrl(){
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Boolean 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);
}
}

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *

View File

@ -1,7 +1,7 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
* Copyright (c) 2011-2015 OpenLP Android Developers *
* Copyright (c) 2011-2016 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 *