mirror of
https://gitlab.com/openlp/android.git
synced 2024-12-22 03:42:48 +00:00
fixed code
This commit is contained in:
parent
4f6ab320fa
commit
b75b563e9d
53
app/app.iml
53
app/app.iml
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="OpenLP2" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="fixssl" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||||
<component name="FacetManager">
|
<component name="FacetManager">
|
||||||
<facet type="android-gradle" name="Android-Gradle">
|
<facet type="android-gradle" name="Android-Gradle">
|
||||||
<configuration>
|
<configuration>
|
||||||
@ -12,10 +12,7 @@
|
|||||||
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
|
|
||||||
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
|
|
||||||
<afterSyncTasks>
|
<afterSyncTasks>
|
||||||
<task>generateDebugAndroidTestSources</task>
|
|
||||||
<task>generateDebugSources</task>
|
<task>generateDebugSources</task>
|
||||||
</afterSyncTasks>
|
</afterSyncTasks>
|
||||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||||
@ -28,7 +25,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
|
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||||
@ -36,13 +33,13 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||||
@ -50,6 +47,15 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||||
@ -57,6 +63,7 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||||
@ -64,35 +71,47 @@
|
|||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.1/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.1/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
|
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="android-async-http-1.4.6" level="project" />
|
<orderEntry type="library" exported="" name="classes" level="project" />
|
||||||
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
|
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="design-22.2.1" level="project" />
|
<orderEntry type="library" exported="" name="design-22.2.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
|
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
project.archivesBaseName = 'OpenLP'
|
project.archivesBaseName = 'OpenLP'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 22
|
||||||
buildToolsVersion "21.1.2"
|
buildToolsVersion "21.1.2"
|
||||||
@ -26,20 +24,15 @@ android {
|
|||||||
}
|
}
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests.returnDefaultValues = true
|
unitTests.returnDefaultValues = true
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
compile 'com.android.support:appcompat-v7:22.2.1'
|
compile 'com.android.support:appcompat-v7:22.2.1'
|
||||||
compile 'com.android.support:support-v4:22.2.1'
|
compile 'com.android.support:support-v4:22.2.1'
|
||||||
compile 'com.android.support:design:22.2.1'
|
compile 'com.android.support:design:22.2.1'
|
||||||
compile 'com.loopj.android:android-async-http:1.4.6'
|
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
testCompile 'org.easytesting:fest:1.0.16'
|
|
||||||
testCompile 'com.squareup:fest-android:1.0.8'
|
|
||||||
testCompile('org.robolectric:robolectric:3.0-rc2') {
|
|
||||||
exclude group: 'commons-logging', module: 'commons-logging'
|
|
||||||
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dependencies {
|
||||||
|
compile files('libs/classes.jar')
|
||||||
}
|
}
|
BIN
app/libs/classes.jar
Normal file
BIN
app/libs/classes.jar
Normal file
Binary file not shown.
@ -35,6 +35,7 @@ import android.view.WindowManager;
|
|||||||
|
|
||||||
import org.openlp.android2.activities.SettingsActivity;
|
import org.openlp.android2.activities.SettingsActivity;
|
||||||
import org.openlp.android2.common.NavigationOptions;
|
import org.openlp.android2.common.NavigationOptions;
|
||||||
|
import org.openlp.android2.common.NukeSSLCerts;
|
||||||
import org.openlp.android2.dialogs.AlertDisplayDialog;
|
import org.openlp.android2.dialogs.AlertDisplayDialog;
|
||||||
import org.openlp.android2.dialogs.BlankDisplayDialog;
|
import org.openlp.android2.dialogs.BlankDisplayDialog;
|
||||||
import org.openlp.android2.fragments.AboutFragment;
|
import org.openlp.android2.fragments.AboutFragment;
|
||||||
@ -64,6 +65,7 @@ public class OpenLP extends ActionBarActivity
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
new NukeSSLCerts().nuke();
|
||||||
|
|
||||||
doPreferenceCheck();
|
doPreferenceCheck();
|
||||||
|
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.common;
|
||||||
|
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSession;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
|
||||||
|
public class NukeSSLCerts {
|
||||||
|
protected static final String TAG = "NukeSSLCerts";
|
||||||
|
|
||||||
|
public static void nuke() {
|
||||||
|
try {
|
||||||
|
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
|
new X509TrustManager() {
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
X509Certificate[] myTrustedAnchors = new X509Certificate[0];
|
||||||
|
return myTrustedAnchors;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SSLContext sc = null;
|
||||||
|
try {
|
||||||
|
sc = SSLContext.getInstance("TLS");
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||||
|
// Create all-trusting host name verifier
|
||||||
|
HostnameVerifier allHostsValid = new HostnameVerifier() {
|
||||||
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Install the all-trusting host verifier
|
||||||
|
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,12 @@
|
|||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* under the terms of the GNU General Public License as published by the Free *
|
||||||
* Software Foundation; version 2 of the License. *
|
* Software Foundation; version 2 of the License. *
|
||||||
* *
|
* *
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT *
|
* This program is distributed in the hope that it will be useful, but WITHOUT *
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
|
||||||
* more details. *
|
* more details. *
|
||||||
* *
|
* *
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* 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 *
|
* with this program; if not, write to the Free Software Foundation, Inc., 59 *
|
||||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
@ -22,54 +22,103 @@ import android.app.DialogFragment;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.loopj.android.http.AsyncHttpClient;
|
|
||||||
import com.loopj.android.http.TextHttpResponseHandler;
|
import com.android.volley.AuthFailureError;
|
||||||
import org.apache.http.Header;
|
import com.android.volley.ClientError;
|
||||||
|
import com.android.volley.DefaultRetryPolicy;
|
||||||
|
import com.android.volley.NetworkError;
|
||||||
|
import com.android.volley.NoConnectionError;
|
||||||
|
import com.android.volley.ParseError;
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.ServerError;
|
||||||
|
import com.android.volley.TimeoutError;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
|
||||||
import org.openlp.android2.R;
|
import org.openlp.android2.R;
|
||||||
import org.openlp.android2.api.Api;
|
import org.openlp.android2.api.Api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
abstract public class OpenLPDialog extends DialogFragment {
|
abstract public class OpenLPDialog extends DialogFragment {
|
||||||
|
|
||||||
private final String LOG_TAG = OpenLPDialog.class.getName();
|
private final String LOG_TAG = OpenLPDialog.class.getName();
|
||||||
protected String calledURL;
|
|
||||||
protected OpenLPHttpClient httpClient;
|
|
||||||
protected Context context;
|
protected Context context;
|
||||||
|
private String urlcalled;
|
||||||
|
|
||||||
private static AsyncHttpClient client = new AsyncHttpClient();
|
protected void populateDisplay(String responseString) {
|
||||||
|
|
||||||
protected void populateDisplay(String responseString) {}
|
|
||||||
protected void processUpdate(String responseString) {}
|
|
||||||
protected void errorDisplay(int statusCode, String responseString) {}
|
|
||||||
|
|
||||||
protected void triggerTextRequest(String url) {
|
|
||||||
calledURL = url;
|
|
||||||
Log.d(LOG_TAG, "Trigger Request for url " + url);
|
|
||||||
String callurl = String.format("%s%s", httpClient.getAbsoluteUrl(client), url );
|
|
||||||
client.get(callurl, null, new TextHttpResponseHandler() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(int statusCode, Header[] headers, String responseString) {
|
|
||||||
// called when response HTTP status is "200 OK"
|
|
||||||
manageResponse(responseString);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
|
||||||
// called when response HTTP status is "4XX" (eg. 401, 403, 404)
|
|
||||||
if (statusCode == 401) {
|
|
||||||
Toast.makeText(context, R.string.httpreturn_unauthorised, Toast.LENGTH_LONG).show();
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, R.string.unable, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
errorDisplay(statusCode, responseString);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manageResponse(String response) {
|
protected void processUpdate(String responseString) {
|
||||||
if (calledURL.equals(Api.POLL_STATUS)) {
|
}
|
||||||
populateDisplay(response);
|
|
||||||
}else {
|
protected void errorDisplay(String responseString) {
|
||||||
processUpdate(response);
|
}
|
||||||
|
|
||||||
|
protected void triggerTextRequest(final String urlbase) {
|
||||||
|
String url = RequestQueueService.getInstance(this.context).getUrl(urlbase);
|
||||||
|
urlcalled = urlbase;
|
||||||
|
|
||||||
|
StringRequest request = new StringRequest(
|
||||||
|
Request.Method.GET,
|
||||||
|
url,
|
||||||
|
listener,
|
||||||
|
errorListener) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||||
|
return createBasicAuthHeader("user", "passwd");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//Set a retry policy in case of SocketTimeout & ConnectionTimeout Exceptions.
|
||||||
|
// Volley does retry for you if you have specified the policy.
|
||||||
|
request.setRetryPolicy(new DefaultRetryPolicy(
|
||||||
|
RequestQueueService.getInstance(this.context).getConnectionTimeout(),
|
||||||
|
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
|
||||||
|
request.setTag("OpenLP");
|
||||||
|
RequestQueueService.getInstance(this.context).addToRequestQueue(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, String> createBasicAuthHeader(String username, String password) {
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("Authorization", RequestQueueService.getInstance(context).getBasicAuth());
|
||||||
|
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
Response.Listener<String> listener = new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
if (urlcalled.equals(Api.POLL_STATUS)) {
|
||||||
|
populateDisplay(response);
|
||||||
|
} else {
|
||||||
|
processUpdate(response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.d(LOG_TAG, String.format("Call response error = %s", error.toString()));
|
||||||
|
if (error instanceof NetworkError) {
|
||||||
|
} else if (error instanceof ClientError) {
|
||||||
|
} else if (error instanceof ServerError) {
|
||||||
|
} else if (error instanceof AuthFailureError) {
|
||||||
|
Toast.makeText(context, R.string.httpreturn_unauthorised,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
} else if (error instanceof ParseError) {
|
||||||
|
} else if (error instanceof NoConnectionError) {
|
||||||
|
} else if (error instanceof TimeoutError) {
|
||||||
|
}
|
||||||
|
Toast.makeText(context, R.string.unable,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
errorDisplay(error.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,30 @@ import android.view.View;
|
|||||||
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.loopj.android.http.AsyncHttpClient;
|
|
||||||
import com.loopj.android.http.TextHttpResponseHandler;
|
import com.android.volley.AuthFailureError;
|
||||||
import org.apache.http.Header;
|
import com.android.volley.ClientError;
|
||||||
|
import com.android.volley.DefaultRetryPolicy;
|
||||||
|
import com.android.volley.NetworkError;
|
||||||
|
import com.android.volley.NoConnectionError;
|
||||||
|
import com.android.volley.ParseError;
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.Response;
|
||||||
|
import com.android.volley.ServerError;
|
||||||
|
import com.android.volley.TimeoutError;
|
||||||
|
import com.android.volley.VolleyError;
|
||||||
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import org.openlp.android2.R;
|
import org.openlp.android2.R;
|
||||||
import org.openlp.android2.api.Api;
|
import org.openlp.android2.api.Api;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
abstract public class OpenLPFragment extends ListFragment{
|
abstract public class OpenLPFragment extends ListFragment{
|
||||||
|
|
||||||
private String LOG_TAG = OpenLPFragment.class.getName();
|
private String LOG_TAG = OpenLPFragment.class.getName();
|
||||||
public Context context;
|
public Context context;
|
||||||
protected String calledURL;
|
protected String urlcalled;
|
||||||
protected OpenLPHttpClient httpClient;
|
|
||||||
protected String updateUrl;
|
protected String updateUrl;
|
||||||
|
|
||||||
abstract public void itemClicked(int position);
|
abstract public void itemClicked(int position);
|
||||||
@ -48,43 +60,72 @@ abstract public class OpenLPFragment extends ListFragment{
|
|||||||
itemClicked(position);
|
itemClicked(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AsyncHttpClient client = new AsyncHttpClient();
|
|
||||||
|
|
||||||
protected void refreshDisplay(){}
|
protected void refreshDisplay(){}
|
||||||
protected void populateDisplay(String responseString, boolean inError) {}
|
protected void populateDisplay(String responseString, boolean inError) {}
|
||||||
protected void processUpdate(String responseString, boolean inError) {}
|
protected void processUpdate(String responseString, boolean inError) {}
|
||||||
|
|
||||||
protected void triggerTextRequest(String url) {
|
protected void triggerTextRequest(final String urlbase) {
|
||||||
calledURL = url;
|
String url = RequestQueueService.getInstance(this.context).getUrl(urlbase);
|
||||||
Log.d(LOG_TAG, "Trigger Request for url " + url);
|
updateUrl = urlbase;
|
||||||
String callurl = String.format("%s%s", httpClient.getAbsoluteUrl(client), url );
|
|
||||||
client.get(callurl, null, new TextHttpResponseHandler() {
|
StringRequest request = new StringRequest(
|
||||||
|
Request.Method.GET,
|
||||||
|
url,
|
||||||
|
listener,
|
||||||
|
errorListener) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int statusCode, Header[] headers, String responseString) {
|
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||||
// called when response HTTP status is "200 OK"
|
return createBasicAuthHeader("user", "passwd");
|
||||||
manageResponse(responseString, true);
|
|
||||||
}
|
}
|
||||||
@Override
|
};
|
||||||
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
|
//Set a retry policy in case of SocketTimeout & ConnectionTimeout Exceptions.
|
||||||
// called when response HTTP status is "4XX" (eg. 401, 403, 404)
|
// Volley does retry for you if you have specified the policy.
|
||||||
if (statusCode == 401) {
|
request.setRetryPolicy(new DefaultRetryPolicy(
|
||||||
Toast.makeText(context, R.string.httpreturn_unauthorised, Toast.LENGTH_LONG).show();
|
RequestQueueService.getInstance(this.context).getConnectionTimeout(),
|
||||||
} else {
|
DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
|
||||||
Toast.makeText(context, R.string.unable, Toast.LENGTH_LONG).show();
|
request.setTag("OpenLP");
|
||||||
}
|
RequestQueueService.getInstance(this.context).addToRequestQueue(request);
|
||||||
manageResponse(responseString, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manageResponse(String response, boolean notInError) {
|
Map<String, String> createBasicAuthHeader(String username, String password) {
|
||||||
if (calledURL.equals(updateUrl)) {
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
populateDisplay(response, notInError);
|
headers.put("Authorization", RequestQueueService.getInstance(context).getBasicAuth());
|
||||||
}else {
|
|
||||||
processUpdate(response, notInError);
|
return headers;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Response.Listener<String> listener = new Response.Listener<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
if (urlcalled.equals(updateUrl)) {
|
||||||
|
populateDisplay(response, true);
|
||||||
|
} else {
|
||||||
|
processUpdate(response, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.d(LOG_TAG, String.format("Call response error = %s", error.toString()));
|
||||||
|
if (error instanceof NetworkError) {
|
||||||
|
} else if (error instanceof ClientError) {
|
||||||
|
} else if (error instanceof ServerError) {
|
||||||
|
} else if (error instanceof AuthFailureError) {
|
||||||
|
Toast.makeText(context, R.string.httpreturn_unauthorised,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
} else if (error instanceof ParseError) {
|
||||||
|
} else if (error instanceof NoConnectionError) {
|
||||||
|
} else if (error instanceof TimeoutError) {
|
||||||
|
}
|
||||||
|
Toast.makeText(context, R.string.unable,
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public void next() {
|
public void next() {
|
||||||
Log.d(LOG_TAG, "Going to next slide");
|
Log.d(LOG_TAG, "Going to next slide");
|
||||||
triggerTextRequest(Api.LIVE_NEXT);
|
triggerTextRequest(Api.LIVE_NEXT);
|
||||||
|
@ -1,97 +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.common;
|
|
||||||
|
|
||||||
|
|
||||||
import java.security.KeyStore;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.util.Log;
|
|
||||||
import com.loopj.android.http.AsyncHttpClient;
|
|
||||||
import org.openlp.android2.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Personalised HttpClient to be used throughout OpenLP with customisable
|
|
||||||
* parameters.
|
|
||||||
*/
|
|
||||||
public class OpenLPHttpClient {
|
|
||||||
|
|
||||||
private final String LOG_TAG = OpenLPHttpClient.class.getName();
|
|
||||||
private Context context;
|
|
||||||
private Boolean useSSL = Boolean.FALSE;
|
|
||||||
|
|
||||||
public OpenLPHttpClient(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbsoluteUrl(AsyncHttpClient client) {
|
|
||||||
|
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
|
|
||||||
String urlBase = getBaseUrl();
|
|
||||||
|
|
||||||
Log.d(LOG_TAG, "Base Url set to " + urlBase);
|
|
||||||
|
|
||||||
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);
|
|
||||||
client.setBasicAuth(userid,password);
|
|
||||||
|
|
||||||
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))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
client.setTimeout(connectionTimeout);
|
|
||||||
if (useSSL){
|
|
||||||
try {
|
|
||||||
KeyStore trustStore = KeyStore.getInstance((KeyStore.getDefaultType()));
|
|
||||||
trustStore.load(null, null);
|
|
||||||
OpenLPSSLSocketFactory sf = new OpenLPSSLSocketFactory(trustStore);
|
|
||||||
sf.setHostnameVerifier((OpenLPSSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER));
|
|
||||||
client.setSSLSocketFactory(sf);
|
|
||||||
}
|
|
||||||
catch (Exception e){
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return urlBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBaseUrl(){
|
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,61 +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.common;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import org.openlp.android2.R;
|
|
||||||
|
|
||||||
public class OpenLPHttpReturn {
|
|
||||||
private int return_code = 0;
|
|
||||||
private String data = null;
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public OpenLPHttpReturn() {
|
|
||||||
this.return_code = -1;
|
|
||||||
this.data = "";
|
|
||||||
this.context = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenLPHttpReturn(int return_code, String data, Context context) {
|
|
||||||
this.return_code = return_code;
|
|
||||||
this.data = data;
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return this.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isError() {
|
|
||||||
return return_code != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSecurityError() {
|
|
||||||
return return_code == 401;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getErrorMessage(String message) {
|
|
||||||
return return_code == 401 ? this.context.getString(R.string.httpreturn_unauthorised) : message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "HttpReturn{" + "data='" + data + '\'' + ", return code=" + return_code + '}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +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.common;
|
|
||||||
|
|
||||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.security.*;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by tim on 14/11/14.
|
|
||||||
*/
|
|
||||||
public class OpenLPSSLSocketFactory extends SSLSocketFactory {
|
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
||||||
|
|
||||||
public OpenLPSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
|
|
||||||
super(truststore);
|
|
||||||
|
|
||||||
TrustManager tm = new X509TrustManager() {
|
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
|
||||||
}
|
|
||||||
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
sslContext.init(null, new TrustManager[] { tm }, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
|
|
||||||
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Socket createSocket() throws IOException {
|
|
||||||
return sslContext.getSocketFactory().createSocket();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,101 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.common;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.util.Base64;
|
||||||
|
import android.util.LruCache;
|
||||||
|
|
||||||
|
import com.android.volley.AuthFailureError;
|
||||||
|
import com.android.volley.Request;
|
||||||
|
import com.android.volley.RequestQueue;
|
||||||
|
import com.android.volley.toolbox.HurlStack;
|
||||||
|
import com.android.volley.toolbox.ImageLoader;
|
||||||
|
import com.android.volley.toolbox.Volley;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class RequestQueueService {
|
||||||
|
|
||||||
|
private static RequestQueueService mInstance;
|
||||||
|
private RequestQueue mRequestQueue;
|
||||||
|
private ImageLoader mImageLoader;
|
||||||
|
private static Context mCtx;
|
||||||
|
private OpenLPURLBuilder urlbuilder;
|
||||||
|
|
||||||
|
private RequestQueueService(Context context) {
|
||||||
|
mCtx = context;
|
||||||
|
mRequestQueue = getRequestQueue();
|
||||||
|
urlbuilder = new OpenLPURLBuilder(context);
|
||||||
|
|
||||||
|
mImageLoader = new ImageLoader(mRequestQueue,
|
||||||
|
new ImageLoader.ImageCache() {
|
||||||
|
private final LruCache<String, Bitmap> cache = new LruCache<String, Bitmap>(20);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Bitmap getBitmap(String url) {
|
||||||
|
return cache.get(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putBitmap(String url, Bitmap bitmap) {
|
||||||
|
cache.put(url, bitmap);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized RequestQueueService getInstance(Context context) {
|
||||||
|
if (mInstance == null) {
|
||||||
|
mInstance = new RequestQueueService(context);
|
||||||
|
}
|
||||||
|
return mInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestQueue getRequestQueue() {
|
||||||
|
if (mRequestQueue == null) {
|
||||||
|
// getApplicationContext() is key, it keeps you from leaking the
|
||||||
|
// Activity or BroadcastReceiver if someone passes one in.
|
||||||
|
mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());
|
||||||
|
}
|
||||||
|
return mRequestQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl(String url){
|
||||||
|
return String.format("%s%s", urlbuilder.getBaseUrl(), url );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBasicAuth(){
|
||||||
|
return urlbuilder.getBasicAuth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getConnectionTimeout(){
|
||||||
|
return urlbuilder.getConnectionTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> void addToRequestQueue(Request<T> req) {
|
||||||
|
getRequestQueue().add(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageLoader getImageLoader() {
|
||||||
|
return mImageLoader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,7 +32,6 @@ import org.openlp.android2.R;
|
|||||||
import org.openlp.android2.api.Api;
|
import org.openlp.android2.api.Api;
|
||||||
import org.openlp.android2.common.JsonHelpers;
|
import org.openlp.android2.common.JsonHelpers;
|
||||||
import org.openlp.android2.common.OpenLPDialog;
|
import org.openlp.android2.common.OpenLPDialog;
|
||||||
import org.openlp.android2.common.OpenLPHttpClient;
|
|
||||||
|
|
||||||
public class AlertDisplayDialog extends OpenLPDialog {
|
public class AlertDisplayDialog extends OpenLPDialog {
|
||||||
private final String LOG_TAG = AlertDisplayDialog.class.getName();
|
private final String LOG_TAG = AlertDisplayDialog.class.getName();
|
||||||
@ -49,7 +48,6 @@ public class AlertDisplayDialog extends OpenLPDialog {
|
|||||||
// remove the dialog title, but you must call the superclass to get the Dialog.
|
// remove the dialog title, but you must call the superclass to get the Dialog.
|
||||||
|
|
||||||
context = getActivity();
|
context = getActivity();
|
||||||
httpClient = new OpenLPHttpClient(context);
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
// Get the layout inflater
|
// Get the layout inflater
|
||||||
|
@ -35,10 +35,10 @@ import org.openlp.android2.R;
|
|||||||
import org.openlp.android2.api.Api;
|
import org.openlp.android2.api.Api;
|
||||||
|
|
||||||
import org.openlp.android2.common.OpenLPDialog;
|
import org.openlp.android2.common.OpenLPDialog;
|
||||||
import org.openlp.android2.common.OpenLPHttpClient;
|
|
||||||
|
|
||||||
public class BlankDisplayDialog extends OpenLPDialog {
|
public class BlankDisplayDialog extends OpenLPDialog {
|
||||||
private final String LOG_TAG = BlankDisplayDialog.class.getName();
|
private final String LOG_TAG = BlankDisplayDialog.class.getName();
|
||||||
|
|
||||||
public AlertDialog dialog;
|
public AlertDialog dialog;
|
||||||
RadioButton desktop;
|
RadioButton desktop;
|
||||||
RadioButton screen;
|
RadioButton screen;
|
||||||
@ -56,8 +56,6 @@ public class BlankDisplayDialog extends OpenLPDialog {
|
|||||||
// remove the dialog title, but you must call the superclass to get the Dialog.
|
// remove the dialog title, but you must call the superclass to get the Dialog.
|
||||||
|
|
||||||
context = getActivity();
|
context = getActivity();
|
||||||
httpClient = new OpenLPHttpClient(context);
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
// Get the layout inflater
|
// Get the layout inflater
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
@ -147,8 +145,8 @@ public class BlankDisplayDialog extends OpenLPDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void errorDisplay(int statusCode, String responseString) {
|
public void errorDisplay(String responseString) {
|
||||||
Log.d(LOG_TAG, String.format("URL Error status code %d text %s", statusCode, responseString));
|
Log.d(LOG_TAG, String.format("URL Error text %s", responseString));
|
||||||
reset_display();
|
reset_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ import org.openlp.android2.R;
|
|||||||
import org.openlp.android2.api.Api;
|
import org.openlp.android2.api.Api;
|
||||||
import org.openlp.android2.common.JsonHelpers;
|
import org.openlp.android2.common.JsonHelpers;
|
||||||
import org.openlp.android2.common.OpenLPFragment;
|
import org.openlp.android2.common.OpenLPFragment;
|
||||||
import org.openlp.android2.common.OpenLPHttpClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -73,8 +72,7 @@ public class LiveListFragment extends OpenLPFragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
context = getActivity();
|
context = getActivity();
|
||||||
updateUrl = Api.LIVE_TEXT;
|
urlcalled = Api.LIVE_TEXT;
|
||||||
httpClient = new OpenLPHttpClient(context);
|
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +40,10 @@ import org.openlp.android2.R;
|
|||||||
import org.openlp.android2.api.Api;
|
import org.openlp.android2.api.Api;
|
||||||
import org.openlp.android2.common.JsonHelpers;
|
import org.openlp.android2.common.JsonHelpers;
|
||||||
import org.openlp.android2.common.OpenLPFragment;
|
import org.openlp.android2.common.OpenLPFragment;
|
||||||
import org.openlp.android2.common.OpenLPHttpClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
public class ServiceListFragment extends OpenLPFragment {
|
public class ServiceListFragment extends OpenLPFragment {
|
||||||
@ -64,8 +62,7 @@ public class ServiceListFragment extends OpenLPFragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
context = getActivity();
|
context = getActivity();
|
||||||
updateUrl = Api.SERVICE_LIST;
|
urlcalled = Api.SERVICE_LIST;
|
||||||
httpClient = new OpenLPHttpClient(context);
|
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,12 +28,10 @@ import android.webkit.SslErrorHandler;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import org.openlp.android2.R;
|
import org.openlp.android2.R;
|
||||||
import org.openlp.android2.common.OpenLPHttpClient;
|
|
||||||
|
|
||||||
public class WebFragment extends Fragment {
|
public class WebFragment extends Fragment {
|
||||||
|
|
||||||
protected String curURL;
|
protected String curURL;
|
||||||
private OpenLPHttpClient httpClient;
|
|
||||||
private WebView webview;
|
private WebView webview;
|
||||||
|
|
||||||
public WebFragment(){
|
public WebFragment(){
|
||||||
@ -47,7 +45,7 @@ public class WebFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
||||||
httpClient = new OpenLPHttpClient(getActivity());
|
|
||||||
View view = inflater.inflate(R.layout.fragment_web, container, false);
|
View view = inflater.inflate(R.layout.fragment_web, container, false);
|
||||||
|
|
||||||
if (curURL != null) {
|
if (curURL != null) {
|
||||||
@ -59,7 +57,7 @@ public class WebFragment extends Fragment {
|
|||||||
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
|
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
|
||||||
webview.setScrollbarFadingEnabled(true);
|
webview.setScrollbarFadingEnabled(true);
|
||||||
webview.setWebViewClient(new webClient());
|
webview.setWebViewClient(new webClient());
|
||||||
webview.loadUrl(String.format("%s%s", httpClient.getBaseUrl(), curURL));
|
//webview.loadUrl(String.format("%s%s", httpClient.getBaseUrl(), curURL));
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 62 KiB |
@ -16,10 +16,6 @@
|
|||||||
android:icon="@drawable/ic_refresh_white"
|
android:icon="@drawable/ic_refresh_white"
|
||||||
android:title="@string/action_refresh"
|
android:title="@string/action_refresh"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom" />
|
||||||
<item android:id="@+id/action_search"
|
|
||||||
android:icon="@drawable/ic_search_white"
|
|
||||||
android:title="@string/action_search"
|
|
||||||
app:showAsAction="never|withText" />
|
|
||||||
<item android:id="@+id/action_preferences"
|
<item android:id="@+id/action_preferences"
|
||||||
android:icon="@android:drawable/ic_menu_preferences"
|
android:icon="@android:drawable/ic_menu_preferences"
|
||||||
android:title="@string/action_preferences"
|
android:title="@string/action_preferences"
|
||||||
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Wed Apr 10 15:27:10 PDT 2013
|
#Sat May 14 10:36:56 BST 2016
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user