1
0
mirror of https://gitlab.com/openlp/android.git synced 2024-12-22 03:42:48 +00:00

Migration from Bazaar to Git

This commit is contained in:
Tim 2018-08-28 20:42:34 +01:00
parent 6726146422
commit dfc89d0ab8
213 changed files with 0 additions and 6090 deletions

View File

@ -1,12 +0,0 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/app/build
/.idea
/.bzr
.apk
/.git
.gitignore

11
.gitignore vendored
View File

@ -1,11 +0,0 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/app/build
/.idea
/.bzr
.bzrignore
.apk

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="OpenLP2" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

1
app/.gitignore vendored
View File

@ -1 +0,0 @@
/build

View File

@ -1,139 +0,0 @@
<?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="fixssl" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<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/aidl/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/apt/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/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/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/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/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/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/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" 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/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/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" 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/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/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" 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/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/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/transition/25.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
<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/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<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/shaders" />
<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/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-25.0.0" level="project" />
<orderEntry type="library" exported="" name="design-25.0.0" level="project" />
<orderEntry type="library" exported="" name="classes" level="project" />
<orderEntry type="library" exported="" name="support-v4-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-media-compat-25.0.0" level="project" />
<orderEntry type="library" exported="" name="transition-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-compat-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-fragment-25.0.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-25.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-25.0.0" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-25.0.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-25.0.0" level="project" />
</component>
</module>

View File

@ -1,42 +0,0 @@
apply plugin: 'com.android.application'
project.archivesBaseName = 'OpenLP'
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
applicationId "org.openlp.android2"
minSdkVersion 16
targetSdkVersion 25
versionCode 6
versionName "2.0"
vectorDrawables.useSupportLibrary = true
}
android {
lintOptions {
ignore 'MissingTranslation'
}
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:design:25.0.0'
}
}
dependencies {
compile files('libs/classes.jar')
}

Binary file not shown.

View File

@ -1,17 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/tim/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.openlp.android2" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".OpenLP"
android:label="@string/app_name"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.SettingsActivity"
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>

View File

@ -1,302 +0,0 @@
/******************************************************************************
* 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;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity;
import android.app.ActionBar;
import android.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.support.v4.widget.DrawerLayout;
import android.view.WindowManager;
import org.openlp.android2.activities.SettingsActivity;
import org.openlp.android2.common.NavigationOptions;
import org.openlp.android2.common.OpenLPURLBuilder;
import org.openlp.android2.common.StateHolder;
import org.openlp.android2.dialogs.AlertDisplayDialog;
import org.openlp.android2.dialogs.BlankDisplayDialog;
import org.openlp.android2.fragments.AboutFragment;
import org.openlp.android2.fragments.HomeFragment;
import org.openlp.android2.fragments.LiveListFragment;
import org.openlp.android2.fragments.LiveWebFragment;
import org.openlp.android2.fragments.NavigationDrawerFragment;
import org.openlp.android2.fragments.SearchFragment;
import org.openlp.android2.fragments.ServiceListFragment;
import org.openlp.android2.fragments.StageWebFragment;
public class OpenLP extends ActionBarActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks {
/**
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
*/
private NavigationDrawerFragment mNavigationDrawerFragment;
/**
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
*/
private final String LOG_TAG = OpenLP.class.getName();
private CharSequence mTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
OpenLPURLBuilder.getInstance().setContext(this);
StateHolder.getInstance().setContext(this);
doPreferenceCheck();
mNavigationDrawerFragment = (NavigationDrawerFragment)
getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
mTitle = getTitle();
// Set up the drawer.
mNavigationDrawerFragment.setUp(
R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout));
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
/**
* Check the preferences have been set at startup and if not redirect them to be set.
*
*/
protected 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);
}
}
/**
* Handle configuration change.
*
* @param newConfig The new Config.
*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
/**
* Handle the selection of the Navigation Menu
*
* @param position Which item has been selected.
*/
@Override
public void onNavigationDrawerItemSelected(int position) {
// update the main content by replacing fragments
FragmentManager fragmentManager = getFragmentManager();
switch (position) {
case NavigationOptions.Home:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, HomeFragment.newInstance())
.commit();
mTitle = getString(R.string.home);
toggerContainer(R.id.next_button, View.GONE);
toggerContainer(R.id.prev_button, View.GONE);
break;
case NavigationOptions.ServiceList:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, ServiceListFragment.newInstance(), "servicelist")
.commit();
mTitle = getString(R.string.service_list);
toggerContainer(R.id.next_button, View.VISIBLE);
toggerContainer(R.id.prev_button, View.VISIBLE);
break;
case NavigationOptions.LiveList:
duelTab();
fragmentManager.beginTransaction()
.replace(R.id.container_left, ServiceListFragment.newInstance(), "servicelist")
.commit();
fragmentManager.beginTransaction()
.replace(R.id.container_right, LiveListFragment.newInstance(), "livelist")
.commit();
mTitle = getString(R.string.live_list);
toggerContainer(R.id.next_button, View.VISIBLE);
toggerContainer(R.id.prev_button, View.VISIBLE);
break;
case NavigationOptions.StageView:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, StageWebFragment.newInstance())
.commit();
mTitle = getString(R.string.stage_view);
toggerContainer(R.id.next_button, View.GONE);
toggerContainer(R.id.prev_button, View.GONE);
break;
case NavigationOptions.LiveView:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, LiveWebFragment.newInstance())
.commit();
mTitle = getString(R.string.live_view);
toggerContainer(R.id.next_button, View.GONE);
toggerContainer(R.id.prev_button, View.GONE);
break;
case NavigationOptions.Search:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, SearchFragment.newInstance())
.commit();
mTitle = getString(R.string.action_search);
toggerContainer(R.id.next_button, View.GONE);
toggerContainer(R.id.prev_button, View.GONE);
break;
default:
singleTab();
fragmentManager.beginTransaction()
.replace(R.id.container, HomeFragment.newInstance())
.commit();
mTitle = getString(R.string.home);
toggerContainer(R.id.next_button, View.GONE);
toggerContainer(R.id.prev_button, View.GONE);
break;
}
}
/**
* Set Display to allow for Duel Columns
*/
protected void duelTab(){
toggerContainer(R.id.container, View.GONE);
toggerContainer(R.id.container_right, View.VISIBLE);
toggerContainer(R.id.container_left, View.VISIBLE);
}
/**
* Set Display to allow for Single Columns
*/
protected void singleTab(){
toggerContainer(R.id.container_right, View.GONE);
toggerContainer(R.id.container_left, View.GONE);
toggerContainer(R.id.container, View.VISIBLE);
}
/**
*
* @param container The container id to be accesses
* @param direction What visibility to use on the container
*/
protected void toggerContainer(int container, int direction){
View cTainer = this.findViewById(container);
if (cTainer != null) {
cTainer.setVisibility(direction);
}
}
public void restoreActionBar() {
try {
ActionBar actionBar = getActionBar();
//actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
} catch (Exception e) {
//noop
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!mNavigationDrawerFragment.isDrawerOpen()) {
// Only show items in the action bar relevant to this screen
// if the drawer is not showing. Otherwise, let the drawer
// decide what to show in the action bar.
getMenuInflater().inflate(R.menu.open_l, menu);
restoreActionBar();
return true;
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
Intent intent;
switch (item.getItemId()) {
case R.id.action_preferences:
intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
case R.id.action_refresh:
if (this.mTitle.equals(getString(R.string.service_list))) {
refreshServiceFragment(R.id.container);
} else if (this.mTitle.equals(getString(R.string.live_list)) ) {
refreshServiceFragment(R.id.container_left);
refreshLiveFragment(R.id.container_right);
}
return true;
case R.id.action_blank:
new BlankDisplayDialog().show(getFragmentManager(), "BlankDialog");
return true;
case R.id.action_alert:
new AlertDisplayDialog().show(getFragmentManager(), "AlertDialog");
return true;
case R.id.action_about:
getFragmentManager().beginTransaction().replace(R.id.container,
new AboutFragment()).commit();
default:
return super.onOptionsItemSelected(item);
}
}
public void refreshLiveFragment(int container){
LiveListFragment fragment = (LiveListFragment)
getFragmentManager().findFragmentById(container);
if (fragment != null) {
fragment.refreshDisplay();
}
}
public void refreshServiceFragment(int container){
ServiceListFragment fragment = (ServiceListFragment)
getFragmentManager().findFragmentById(container);
if (fragment != null) {
fragment.refreshDisplay();
}
}
public void next(View view) {
ServiceListFragment serviceListFragment = (ServiceListFragment) getFragmentManager().findFragmentByTag("servicelist");
serviceListFragment.next();
}
public void previous(View view) {
ServiceListFragment serviceListFragment = (ServiceListFragment) getFragmentManager().findFragmentByTag("servicelist");
serviceListFragment.previous();
}
}

View File

@ -1,219 +0,0 @@
package org.openlp.android2.activities;
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 onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setupSimplePreferencesScreen();
}
/**
* 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);
// 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"));
}
/**
* {@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);
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"));
}
}
}

View File

@ -1,125 +0,0 @@
/******************************************************************************
* 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.api;
/**
* <h1>Routes:</h1>
* <p/>
* <p/>
* <pre>
* ``/``
* Go to the web interface.
*
* ``/files/{filename}``
*
* ``/api/poll``
* {"results": {"type": "controller"}}
* Or, if there were no results, False::
* {"results": False}
*
* ``/api/display/{hide|show}``
* Blank or unblank the screen.
*
* ``/api/alert``
* {"request": {"text": "<your alert text>"}}
* ``/api/controller/{live|preview}/{action}``
* ``next``
* Load the next slide.
*
* ``previous``
* Load the previous slide.
*
* ``set``
* Set a specific slide. Requires an id return in a JSON-encoded dict like
* this::
*
* {"request": {"id": 1}}
*
* ``first``
* Load the first slide.
*
* ``last``
* Load the last slide.
*
* ``text``
* Fetches the text of the current song. The output is a JSON-encoded
* dict which looks like this::
*
* {"result": {"slides": ["...", "..."]}}
*
* ``/api/service/{action}``
* Perform ``{action}`` on the service manager (e.g. go live). Data is
* passed as a json-encoded ``data`` parameter. Valid actions are:
*
* ``next``
* Load the next item in the service.
*
* ``previous``
*
* ``set``
* Set a specific item in the service. Requires an id returned in a
* JSON-encoded dict like this::
*
* {"request": {"id": 1}}
*
* ``list``
* Request a list of items in the service. Returns a list of items in the
* current service in a JSON-encoded dict like this::
*
* {"results": {"items": [{...}, {...}]}}
* """
* </pre>
*/
public interface Api {
public final String LIVE_BASE = "/api/controller/live/";
public final String LIVE_NEXT = "/api/controller/live/next";
public final String LIVE_PREVIOUS = "/api/controller/live/previous";
public final String LIVE_TEXT = "/api/controller/live/text";
public final String LIVE_SET = "/api/controller/live/set?data=";
public final String STAGE_VIEW = "/stage";
public final String LIVE_VIEW = "/main";
public final String SERVICE_LIST = "/api/service/list";
public final String SERVICE_SET = "/api/service/set?data=";
public final String DISPLAY_SHOW = "/api/display/show";
public final String DISPLAY_BLANK = "/api/display/blank";
public final String DISPLAY_THEME = "/api/display/theme";
public final String DISPLAY_DESKTOP = "/api/display/desktop";
public final String POLL_STATUS = "/api/poll";
public final String ALERT = "/api/alert?data=";
public final String SEARCHABLE_PLUGINS = "/api/plugin/search";
/**
* This is a special string that uses the String.format() method. See
* {@link String#format(String, Object...)}
*/
public final String SEARCH_PLUGIN_FORMATTED = "/api/%s/search?data=";
/**
* Match intent extra key with regex since multiple plugins can be inserted
*/
public final String SEARCH_PLUGIN_ADD = "/api/%s/add?data=";
/**
* Match intent extra key with regex since multiple plugins can be inserted
*/
public final String SEARCH_PLUGIN_LIVE = "/api/%s/live?data=";
}

View File

@ -1,58 +0,0 @@
/******************************************************************************
* 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.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONStringer;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class JsonHelpers {
private static String LOG_TAG = JsonHelpers.class.getName();
public static String createRequestJSON(String key, String value) throws JSONHandlerException {
try {
String responseJSON;
JSONObject jo = new JSONObject();
jo.put(key, value);
responseJSON = new JSONStringer().object().key("request").value(jo)
.endObject().toString();
responseJSON = URLEncoder.encode(responseJSON, "UTF-8");
Log.d(LOG_TAG, String.format("createRequestJSON: %s : %s : %s", key, value, responseJSON));
return responseJSON;
} catch (JSONException e) {
throw new JSONHandlerException(e);
} catch (UnsupportedEncodingException e) {
throw new JSONHandlerException(e);
}
}
public static class JSONHandlerException extends Exception {
private static final long serialVersionUID = -6772307308404816615L;
public JSONHandlerException(Throwable throwable) {
super(throwable);
}
}
}

View File

@ -1,28 +0,0 @@
/******************************************************************************
* 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;
public class NavigationOptions{
public final static int Home = 0;
public final static int ServiceList = 1;
public final static int LiveList = 2;
public final static int StageView = 3;
public final static int LiveView = 4;
public final static int Search = 5;
}

View File

@ -1,124 +0,0 @@
/******************************************************************************
* 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.app.DialogFragment;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
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.api.Api;
import java.util.HashMap;
import java.util.Map;
abstract public class OpenLPDialog extends DialogFragment {
private final String LOG_TAG = OpenLPDialog.class.getName();
protected Context context;
private String urlcalled;
protected void populateDisplay(String responseString) {
}
protected void processUpdate(String responseString) {
}
protected void errorDisplay(String responseString) {
}
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());
}
};
}

View File

@ -1,138 +0,0 @@
/******************************************************************************
* 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.app.ListFragment;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
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.api.Api;
import java.util.HashMap;
import java.util.Map;
abstract public class OpenLPFragment extends ListFragment{
private String LOG_TAG = OpenLPFragment.class.getName();
public Context context;
protected String urlcalled;
protected String updateUrl;
abstract public void itemClicked(int position);
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
itemClicked(position);
}
protected void refreshDisplay(){}
protected void populateDisplay(String responseString, boolean inError) {}
protected void processUpdate(String responseString, boolean inError) {}
protected void triggerTextRequest(final String urlbase) {
String url = RequestQueueService.getInstance(this.context).getUrl(urlbase);
updateUrl = 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(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() {
Log.d(LOG_TAG, "Going to next slide");
triggerTextRequest(Api.LIVE_NEXT);
}
public void previous() {
Log.d(LOG_TAG, "Going to previous slide");
triggerTextRequest(Api.LIVE_PREVIOUS);
}
}

View File

@ -1,86 +0,0 @@
/******************************************************************************
* 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;
private static OpenLPURLBuilder ourInstance = new OpenLPURLBuilder();
public static OpenLPURLBuilder getInstance() {
return ourInstance;
}
private OpenLPURLBuilder() {
}
public void setContext(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);
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", host, port);
}
}

View File

@ -1,99 +0,0 @@
/******************************************************************************
* 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.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 RequestQueueService(Context context) {
mCtx = context;
mRequestQueue = getRequestQueue();
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", OpenLPURLBuilder.getInstance().getBaseUrl(), url );
}
public String getBasicAuth(){
return OpenLPURLBuilder.getInstance().getBasicAuth();
}
public int getConnectionTimeout(){
return OpenLPURLBuilder.getInstance().getConnectionTimeout();
}
public <T> void addToRequestQueue(Request<T> req) {
getRequestQueue().add(req);
}
public ImageLoader getImageLoader() {
return mImageLoader;
}
}

View File

@ -1,22 +0,0 @@
package org.openlp.android2.common;
import android.content.Context;
/**
* Created by tim on 14/08/16.
*/
public class StateHolder {
private static StateHolder ourInstance = new StateHolder();
private static Context context;
public static StateHolder getInstance() {
return ourInstance;
}
private StateHolder() {
}
public void setContext(Context context) {
this.context = context;
}
}

View File

@ -1,105 +0,0 @@
/******************************************************************************
* 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.dialogs;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.OpenLPDialog;
public class AlertDisplayDialog extends OpenLPDialog {
private final String LOG_TAG = AlertDisplayDialog.class.getName();
public AlertDialog dialog;
/**
* The system calls this only when creating the layout in a dialog.
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// The only reason you might override this method when using onCreateView() is
// to modify any dialog characteristics. For example, the dialog includes a
// title by default, but your custom layout might not need it. So here you can
// remove the dialog title, but you must call the superclass to get the Dialog.
context = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
View view = inflater.inflate(R.layout.alert_display_dialog, null);
builder.setView(view);
builder.setPositiveButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
AlertDisplayDialog.this.getDialog().cancel();
}
});
builder.setNegativeButton(R.string.process, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog1, int id) {
EditText text = (EditText) dialog.findViewById(R.id.alertText);
requestAlert(text.getText().toString());
}
});
dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogI) {
Button btnNegative = dialog.getButton(Dialog.BUTTON_NEGATIVE);
btnNegative.setTextSize(20);
Button btnPositive = dialog.getButton(Dialog.BUTTON_POSITIVE);
btnPositive.setTextSize(20);
}
});
return dialog;
}
@Override
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
}
public void processUpdate(String response) {
Toast.makeText(context, "Alert Requested", Toast.LENGTH_SHORT).show();
}
public void requestAlert(String text) {
try {
String request = JsonHelpers.createRequestJSON("text", text);
triggerTextRequest(String.format("%s%s", Api.ALERT, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), text(%s)", Api.ALERT, text));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -1,159 +0,0 @@
/******************************************************************************
* 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.dialogs;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import org.json.JSONException;
import org.json.JSONObject;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.OpenLPDialog;
public class BlankDisplayDialog extends OpenLPDialog {
private final String LOG_TAG = BlankDisplayDialog.class.getName();
public AlertDialog dialog;
RadioButton desktop;
RadioButton screen;
RadioButton theme;
RadioButton reset;
/**
* The system calls this only when creating the layout in a dialog.
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// The only reason you might override this method when using onCreateView() is
// to modify any dialog characteristics. For example, the dialog includes a
// title by default, but your custom layout might not need it. So here you can
// remove the dialog title, but you must call the superclass to get the Dialog.
context = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
View view = inflater.inflate(R.layout.blank_display_dialog, null);
builder.setView(view);
reset = (RadioButton) view.findViewById(R.id.buttonReset);
reset.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
triggerTextRequest(Api.DISPLAY_SHOW);
}
});
screen = (RadioButton) view.findViewById(R.id.buttonScreen);
screen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
triggerTextRequest(Api.DISPLAY_BLANK);
}
});
theme = (RadioButton) view.findViewById(R.id.buttonTheme);
theme.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
triggerTextRequest(Api.DISPLAY_THEME);
}
});
desktop = (RadioButton) view.findViewById(R.id.buttonDesktop);
desktop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
triggerTextRequest(Api.DISPLAY_DESKTOP);
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
BlankDisplayDialog.this.getDialog().cancel();
}
});
dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogI) {
Button btnNegative = dialog.getButton(Dialog.BUTTON_NEGATIVE);
btnNegative.setTextSize(20);
}
});
return dialog;
}
@Override
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.POLL_STATUS);
Log.d(LOG_TAG, "Resumed...");
}
public void processUpdate(String response) {
triggerTextRequest(Api.POLL_STATUS);
}
public void populateDisplay(String json) {
Log.d(LOG_TAG, "populateDisplay : " + json );
reset_display();
try {
JSONObject item = new JSONObject(json).getJSONObject("results");
if (item.getString("theme").equals("true")){
theme.setChecked(true);
} else {
if (item.getString("blank").equals("true")){
screen.setChecked(true);
} else{
if (item.getString("display").equals("true")){
desktop.setChecked(true);
} else{
reset.setChecked(true);
}
}
}
} catch (JSONException e) {
Log.e(LOG_TAG, "Exception with Json = " + json);
e.printStackTrace();
}
}
public void errorDisplay(String responseString) {
Log.d(LOG_TAG, String.format("URL Error text %s", responseString));
reset_display();
}
private void reset_display(){
screen.setChecked(false);
theme.setChecked(false);
desktop.setChecked(false);
reset.setChecked(false);
}
}

View File

@ -1,135 +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.dialogs;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.Toast;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.OpenLPDialog;
public class SearchSelectionDialog extends OpenLPDialog {
private final String LOG_TAG = SearchSelectionDialog.class.getName();
public AlertDialog dialog;
private String key;
private String plugin;
private String text;
private RadioButton sendLive;
private RadioButton addToService;
/**
* The system calls this only when creating the layout in a dialog.
*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// The only reason you might override this method when using onCreateView() is
// to modify any dialog characteristics. For example, the dialog includes a
// title by default, but your custom layout might not need it. So here you can
// remove the dialog title, but you must call the superclass to get the Dialog.
key = getArguments().getString("key");
plugin = getArguments().getString("plugin");
text = getArguments().getString("text");
Log.d(LOG_TAG, String.format("onCreateDialog %s : %s : %s", key, plugin, text));
context = getActivity();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
View view = inflater.inflate(R.layout.search_action_dialog, null);
builder.setView(view);
sendLive = (RadioButton) view.findViewById(R.id.buttonLive);
sendLive.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createLive();
SearchSelectionDialog.this.getDialog().cancel();
}
});
addToService = (RadioButton) view.findViewById(R.id.buttonService);
addToService.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createService();
SearchSelectionDialog.this.getDialog().cancel();
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SearchSelectionDialog.this.getDialog().cancel();
}
});
dialog = builder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogI) {
Button btnNegative = dialog.getButton(Dialog.BUTTON_NEGATIVE);
btnNegative.setTextSize(20);
}
});
return dialog;
}
@Override
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
}
public void createLive() {
try {
String request = JsonHelpers.createRequestJSON("id", text);
String url = String.format(Api.SEARCH_PLUGIN_LIVE, plugin.toLowerCase());
triggerTextRequest(String.format("%s%s", url, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), text(%s)", Api.SEARCH_PLUGIN_LIVE, request));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
}
}
public void createService() {
try {
String request = JsonHelpers.createRequestJSON("id", text);
String url = String.format(Api.SEARCH_PLUGIN_ADD, plugin.toLowerCase());
triggerTextRequest(String.format("%s%s", url, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), text(%s)", Api.SEARCH_PLUGIN_ADD, text));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -1,70 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.openlp.android2.R;
import java.text.SimpleDateFormat;
import java.util.Date;
public class AboutFragment extends Fragment {
public AboutFragment() {
// Empty constructor required for fragment subclasses
}
public static AboutFragment newInstance() {
return new AboutFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_about, container, false);
String date = new SimpleDateFormat("yyyy").format(new Date());
StringBuilder html = new StringBuilder();
html.append(getString(R.string.about_display_1));
html.append("\n");
html.append(getString(R.string.about_display_2));
html.append(" http://www.openlp.org");
html.append("\n\n\n");
html.append(getString(R.string.about_display_4));
html.append(" © 2004-").append(date).append(" Raoul Snyman\n");
html.append(getString(R.string.about_display_5));
html.append(" © 2004-").append(date);
html.append("\nTim Bentley, Tomas Groth, Johan Mynhardt");
html.append("\n\n\n");
html.append(getString(R.string.about_display_6));
html.append("\n");
html.append(getString(R.string.about_display_7));
html.append("\n");
html.append(getString(R.string.about_display_8));
((TextView) view.findViewById(R.id.about_text)).setText(html);
return view;
}
}

View File

@ -1,58 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import org.openlp.android2.R;
public class HomeFragment extends Fragment {
private View displayView;
public HomeFragment() {
// Empty constructor required for fragment subclasses
}
public static HomeFragment newInstance() {
return new HomeFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
displayView = inflater.inflate(R.layout.fragment_home, container, false);
displayIcon();
return displayView;
}
@Override
public void onResume() {
super.onResume();
displayIcon();
}
private void displayIcon(){
int imageId = getResources().getIdentifier("openlp_splash_screen","drawable", getActivity().getPackageName());
((ImageView) displayView.findViewById(R.id.home_image)).setImageResource(imageId);
}
}

View File

@ -1,189 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.Html;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
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;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.OpenLPFragment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class LiveListFragment extends OpenLPFragment {
private int selected = 0;
private String LOG_TAG = LiveListFragment.class.getName();
public static LiveListFragment newInstance() {
return new LiveListFragment();
}
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public LiveListFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context = getActivity();
urlcalled = Api.LIVE_TEXT;
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void populateDisplay(String json, boolean notInError) {
Log.i(LOG_TAG, "populate_display - entry");
List<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
selected = 0;
if (notInError) {
try {
JSONArray items = new JSONObject(json).getJSONObject("results").getJSONArray("slides");
for (int i = 0; i < items.length(); ++i) {
JSONObject item = items.getJSONObject(i);
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("tag", item.getString("tag"));
if (item.getString("selected").equals("true")) {
selected = i;
}
hm.put("liveListNormal", Html.fromHtml(item.getString("html")).toString());
aList.add(hm);
}
} catch (JSONException e) {
Log.e(LOG_TAG,json);
e.printStackTrace();
}
}
// Keys used in Hashmap
String[] from = {"line", "tag", "liveListNormal", "liveListSelected"};
// Ids of views in live_list_fragment
int[] to = {R.id.line, R.id.tag, R.id.liveListNormal, R.id.liveListSelected};
SharedPreferences prefs = context.getSharedPreferences(
context.getString(R.string.key_shared_preferences),
Context.MODE_PRIVATE);
final int size = Integer.parseInt(prefs.getString(
context.getString(R.string.key_text_size),
String.valueOf(context.getResources().getInteger(
R.integer.textSizeDefaultValue))));
// Instantiating an adapter to store each items
ListAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList,
R.layout.fragment_livelist, from, to) {
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
// TextView line = (TextView) view.findViewById(R.id.line);
TextView text1 = (TextView) view.findViewById(R.id.tag);
if (text1 != null) {
text1.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
}
TextView text2 = (TextView) view.findViewById(R.id.liveListNormal);
if (text2 != null) {
text2.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
if (selected == position) {
text2.setTypeface(null, Typeface.BOLD_ITALIC);
// line.setBackgroundColor(0xffffff);
} else {
text2.setTypeface(null, Typeface.NORMAL);
// line.setBackgroundColor(0xffffff);
}
}
return view;
}
};
setListAdapter(adapter);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Boolean autoscroll =
sharedPrefs.getBoolean(context.getString(R.string.key_auto_scroll), false);
if (autoscroll){
getListView().setSelection(selected - 1);
}
Log.i(LOG_TAG, "populate_display - exit");
}
@Override
public void refreshDisplay() {
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.LIVE_TEXT);
}
@Override
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.LIVE_TEXT);
Log.d(LOG_TAG, "Resumed...");
}
public void processUpdate(String response, boolean inError) {
triggerTextRequest(Api.LIVE_TEXT);
}
public void itemClicked(int position) {
try {
String request = JsonHelpers.createRequestJSON("id", Integer.toString(position));
triggerTextRequest(String.format("%s%s", Api.LIVE_SET, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), position(%s)",
Api.LIVE_SET, position));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(getActivity().getBaseContext(), "Request Failed", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -1,33 +0,0 @@
/******************************************************************************
* 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.fragments;
import org.openlp.android2.api.Api;
public class LiveWebFragment extends WebFragment {
public LiveWebFragment() {
super();
curURL = Api.LIVE_VIEW;
}
public static LiveWebFragment newInstance() {
return new LiveWebFragment();
}
}

View File

@ -1,344 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import org.openlp.android2.R;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* Fragment used for managing interactions for and presentation of a navigation drawer.
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
* design guidelines</a> for a complete explanation of the behaviors implemented here.
*/
public class NavigationDrawerFragment extends Fragment {
/**
* Remember the position of the selected item.
*/
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
/**
* Per the design guidelines, you should show the drawer on launch until the user manually
* expands it. This shared preference tracks this.
*/
private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
/**
* A pointer to the current callbacks instance (the Activity).
*/
private NavigationDrawerCallbacks mCallbacks;
/**
* Helper component that ties the action bar to the navigation drawer.
*/
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private ListView mDrawerListView;
private View mFragmentContainerView;
private int mCurrentSelectedPosition = 0;
private boolean mFromSavedInstanceState;
private boolean mUserLearnedDrawer;
public NavigationDrawerFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Read in the flag indicating whether or not the user has demonstrated awareness of the
// drawer. See PREF_USER_LEARNED_DRAWER for details.
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
if (savedInstanceState != null) {
mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
mFromSavedInstanceState = true;
}
// Select either the default item (0) or the last selected item.
selectItem(mCurrentSelectedPosition);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Indicate that this fragment would like to influence the set of actions in the action bar.
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mDrawerListView = (ListView) inflater.inflate(
R.layout.fragment_navigation_drawer, container, false);
mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
}
});
List<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> hm = new HashMap<String, String>();
hm.put("title", getString(R.string.home));
hm.put("icon", Integer.toString(R.drawable.ic_home_black));
aList.add(hm);
HashMap<String, String> hm1 = new HashMap<String, String>();
hm1.put("title", getString(R.string.service_list));
hm1.put("icon", Integer.toString(R.drawable.ic_view_list_black));
aList.add(hm1);
HashMap<String, String> hm2 = new HashMap<String, String>();
hm2.put("title", getString(R.string.live_list));
hm2.put("icon", Integer.toString(R.drawable.ic_list_black));
aList.add(hm2);
HashMap<String, String> hm3 = new HashMap<String, String>();
hm3.put("title", getString(R.string.stage_view));
hm3.put("icon", Integer.toString(R.drawable.ic_live_tv_black));
aList.add(hm3);
HashMap<String, String> hm4 = new HashMap<String, String>();
hm4.put("title", getString(R.string.live_view));
hm4.put("icon", Integer.toString(R.drawable.ic_ondemand_video_black));
aList.add(hm4);
HashMap<String, String> hm5 = new HashMap<String, String>();
hm5.put("title", getString(R.string.action_search));
hm5.put("icon", Integer.toString(R.drawable.ic_search_black));
aList.add(hm5);
// Keys used in Hashmap
String[] from = {"icon", "title"};
// Ids of views in service_list_fragment
int[] to = {R.id.drawer_icon, R.id.drawer_text};
ListAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList,
R.layout.fragment_navigation_drawer_list, from, to);
mDrawerListView.setAdapter(adapter);
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
return mDrawerListView;
}
public boolean isDrawerOpen() {
return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView);
}
/**
* Users of this fragment must call this method to set up the navigation drawer interactions.
*
* @param fragmentId The android:id of this fragment in its activity's layout.
* @param drawerLayout The DrawerLayout containing this fragment's UI.
*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
mFragmentContainerView = getActivity().findViewById(fragmentId);
mDrawerLayout = drawerLayout;
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
// OpenLP Blue
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4d7bd8")));
getActionBar().setDisplayHomeAsUpEnabled(true); // also required
if (Build.VERSION.SDK_INT >= 18) {
getActionBar().setHomeAsUpIndicator(
getResources().getDrawable(R.drawable.ic_menu_white));
}
// ActionBarDrawerToggle ties together the the proper interactions
// between the navigation drawer and the action bar app icon.
mDrawerToggle = new ActionBarDrawerToggle(
getActivity(), /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_menu_white, /* nav drawer image to replace 'Up' caret */
R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
R.string.navigation_drawer_close /* "close drawer" description for accessibility */
) {
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if (!isAdded()) {
return;
}
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if (!isAdded()) {
return;
}
if (!mUserLearnedDrawer) {
// The user manually opened the drawer; store this flag to prevent auto-showing
// the navigation drawer automatically in the future.
mUserLearnedDrawer = true;
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(getActivity());
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
}
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
}
};
// If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
// per the navigation drawer design guidelines.
if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
mDrawerLayout.openDrawer(mFragmentContainerView);
}
// Defer code dependent on restoration of previous instance state.
mDrawerLayout.post(new Runnable() {
@Override
public void run() {
mDrawerToggle.syncState();
}
});
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
private void selectItem(int position) {
mCurrentSelectedPosition = position;
if (mDrawerListView != null) {
mDrawerListView.setItemChecked(position, true);
}
if (mDrawerLayout != null) {
mDrawerLayout.closeDrawer(mFragmentContainerView);
}
if (mCallbacks != null) {
mCallbacks.onNavigationDrawerItemSelected(position);
}
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mCallbacks = (NavigationDrawerCallbacks) activity;
} catch (ClassCastException e) {
throw new ClassCastException("Activity must implement NavigationDrawerCallbacks.");
}
}
@Override
public void onDetach() {
super.onDetach();
mCallbacks = null;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Forward the new configuration the drawer toggle component.
mDrawerToggle.onConfigurationChanged(newConfig);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// If the drawer is open, show the global app actions in the action bar. See also
// showGlobalContextActionBar, which controls the top-left area of the action bar.
if (mDrawerLayout != null && isDrawerOpen()) {
inflater.inflate(R.menu.global, menu);
showGlobalContextActionBar();
}
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* Per the navigation drawer design guidelines, updates the action bar to show the global app
* 'context', rather than just what's in the current screen.
*/
private void showGlobalContextActionBar() {
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setTitle(R.string.app_name);
}
private ActionBar getActionBar() {
return ((ActionBarActivity) getActivity()).getSupportActionBar();
}
/**
* Callbacks interface that all activities using this fragment must implement.
*/
public static interface NavigationDrawerCallbacks {
/**
* Called when an item in the navigation drawer is selected.
*/
void onNavigationDrawerItemSelected(int position);
}
}

View File

@ -1,357 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.AuthFailureError;
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.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.RequestQueueService;
import org.openlp.android2.dialogs.SearchSelectionDialog;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*/
public class SearchFragment extends Fragment {
private final String LOG_TAG = SearchFragment.class.getName();
private Spinner spinner;
public Context context;
protected String calledURL;
protected String updateUrl;
protected String searchedPlugin;
protected Map<String, String> pluginMap = new HashMap<String, String>();
public SearchFragment() {
Log.d(LOG_TAG, "Constructor");
}
public static SearchFragment newInstance() {
SearchFragment fragment = new SearchFragment();
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context = getActivity();
updateUrl = Api.SEARCHABLE_PLUGINS;
View view = inflater.inflate(R.layout.fragment_search, container, false);
spinner = (Spinner) view.findViewById(R.id.search_spinner);
triggerTextRequest(Api.SEARCHABLE_PLUGINS);
// Add search listener to text field
final EditText editText = (EditText) view.findViewById(R.id.search_text);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView tv, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
// Now close the keyboard as finished with
View view = getActivity().getCurrentFocus();
if (view != null) {
InputMethodManager imm =
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
searchedPlugin = pluginMap.get(spinner.getSelectedItem().toString());
requestSearch(tv.getText().toString());
return true;
}
return false;
}
});
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
/**
* Called when a new item is selected (in the Spinner)
*/
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
editText.setText("");
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing, just another required interface callback
}
});
return view;
}
@Override
public void onDetach() {
super.onDetach();
}
private void populatePluginList(String response, Boolean notInError) {
Log.i(LOG_TAG, "populatePluginList - entry");
List<String> categories = new ArrayList<String>();
pluginMap.clear();
if (notInError) {
try {
JSONArray items = new JSONObject(response).getJSONObject("results").getJSONArray("items");
for (int i = 0; i < items.length(); ++i) {
JSONArray item = items.getJSONArray(i);
categories.add(item.get(1).toString());
pluginMap.put(item.get(1).toString(), item.get(0).toString());
}
} catch (JSONException e) {
Log.e(LOG_TAG, response);
e.printStackTrace();
}
ArrayAdapter<String> LTRadapter = new ArrayAdapter<String>(getActivity(),
R.layout.spinner_list_item, categories);
LTRadapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
spinner.setAdapter(LTRadapter);
Log.i(LOG_TAG, "populatePluginList - exit");
}
}
protected void triggerTextRequest(String urlbase) {
Log.d(LOG_TAG, "Trigger Request for url " + urlbase);
String url = RequestQueueService.getInstance(this.context).getUrl(urlbase);
calledURL = 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 (calledURL.equals(updateUrl)) {
populatePluginList(response, true);
} else {
populateListDisplay(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 requestSearch(String text) {
updateUrl = Api.SEARCH_PLUGIN_FORMATTED;
try {
String request = JsonHelpers.createRequestJSON("text", text);
String url = String.format(Api.SEARCH_PLUGIN_FORMATTED, searchedPlugin);
triggerTextRequest(String.format("%s%s", url, request));
Log.d(LOG_TAG, String.format("Search request. apiBase(%s), text(%s)", searchedPlugin, text));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(context, "Search Request Failed", Toast.LENGTH_SHORT).show();
}
}
public void populateListDisplay(String json, boolean notInError) {
Log.i(LOG_TAG, "populateListDisplay - entry");
ListView list = (ListView) getActivity().findViewById(R.id.searchListView);
final ArrayList<JSONArray> listitems = new ArrayList<JSONArray>();
if (notInError) {
try {
JSONArray items = new JSONObject(json).getJSONObject("results").getJSONArray("items");
Log.d(LOG_TAG,items.toString());
for (int i = 0; i < items.length(); ++i) {
JSONArray item = items.getJSONArray(i);
listitems.add(item);
}
} catch (JSONException e) {
Log.e(LOG_TAG, json);
e.printStackTrace();
}
}
final StableArrayAdapter adapter = new StableArrayAdapter(context,
android.R.layout.simple_list_item_1,
listitems);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view,
int position, long id) {
final JSONArray item = (JSONArray) parent.getItemAtPosition(position);
//Toast.makeText(context, "Item Pressed " + String.valueOf(position) + item,
// Toast.LENGTH_SHORT).show();
String it = "";
try {
Log.i(LOG_TAG, "list.setOnItemClickListener" + item);
it = item.get(0).toString();
} catch (JSONException e) {
e.printStackTrace();
}
Bundle args = new Bundle();
args.putString("plugin", searchedPlugin);
args.putString("text", it);
args.putString("key", Long.toString(id));
DialogFragment SSDFragment = new SearchSelectionDialog();
SSDFragment.setArguments(args);
SSDFragment.show(getFragmentManager(), "TAG");
}
});
Log.i(LOG_TAG, "populateListDisplay - exit");
}
public class StableArrayAdapter extends ArrayAdapter<JSONArray> {
HashMap<String, Integer> mIdMap = new HashMap<String, Integer>();
public StableArrayAdapter(Context context,
int textViewResourceId,
List<JSONArray> objects) {
super(context, textViewResourceId, objects);
for (int i = 0; i < objects.size(); ++i) {
JSONArray item = objects.get(i);
try {
mIdMap.put(item.get(1).toString(), i);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Get the data item for this position
//User user = getItem(position);
String item = null;
try {
item = getItem(position).get(1).toString();
} catch (JSONException e) {
e.printStackTrace();
}
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.search_result_row,
parent, false);
}
// Lookup view for data population
TextView tvItem = (TextView) convertView.findViewById(R.id.searchListRow);
// Populate the data into the template view using the data object
tvItem.setText(item);
// Return the completed view to render on screen
return convertView;
}
@Override
public long getItemId(int position) {
String item = null;
try {
item = getItem(position).get(1).toString();
} catch (JSONException e) {
e.printStackTrace();
}
return mIdMap.get(item);
}
@Override
public boolean hasStableIds() {
return true;
}
}
}

View File

@ -1,201 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.openlp.android2.OpenLP;
import org.openlp.android2.R;
import org.openlp.android2.api.Api;
import org.openlp.android2.common.JsonHelpers;
import org.openlp.android2.common.OpenLPFragment;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ServiceListFragment extends OpenLPFragment {
private final String LOG_TAG = ServiceListFragment.class.getName();
private int selected = 0;
public ServiceListFragment() {
}
public static ServiceListFragment newInstance() {
ServiceListFragment fragment = new ServiceListFragment();
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
context = getActivity();
urlcalled = Api.SERVICE_LIST;
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void refreshDisplay() {
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.SERVICE_LIST);
}
@Override
public void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resuming...");
triggerTextRequest(Api.SERVICE_LIST);
Log.d(LOG_TAG, "Resumed...");
}
public void processUpdate(String response, boolean inError) {
triggerTextRequest(Api.SERVICE_LIST);
((OpenLP) getActivity()).refreshLiveFragment(R.id.container_right);
}
@Override
public void populateDisplay(String json, boolean notInError) {
Log.i(LOG_TAG, "populate_display - entry");
List<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
if (notInError) {
try {
JSONArray items = new JSONObject(json).getJSONObject("results").getJSONArray("items");
for (int i = 0; i < items.length(); ++i) {
JSONObject item = items.getJSONObject(i);
HashMap<String, String> hm = new HashMap<String, String>();
if (item.getString("plugin").equals("songs")) {
hm.put("icon", Integer.toString(R.drawable.ic_my_library_music));
} else if (item.getString("plugin").equals("bibles")) {
hm.put("icon", Integer.toString(R.drawable.ic_my_library_books));
} else if (item.getString("plugin").equals("media")) {
hm.put("icon", Integer.toString(R.drawable.ic_local_movies));
} else if (item.getString("plugin").equals("presentations")) {
hm.put("icon", Integer.toString(R.drawable.ic_video_collection));
} else if (item.getString("plugin").equals("images")) {
hm.put("icon", Integer.toString(R.drawable.ic_image));
} else {
hm.put("icon", Integer.toString(R.drawable.ic_edit));
}
if (item.getString("selected").equals("true")) {
selected = i;
}
hm.put("title", item.getString("title"));
aList.add(hm);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
// Keys used in Hashmap
String[] from = {"line","icon", "title"};
// Ids of views in service_list_fragment
int[] to = {R.id.servicelistLine, R.id.icon, R.id.serviceListText};
SharedPreferences prefs = context.getSharedPreferences(
context.getString(R.string.key_shared_preferences),
Context.MODE_PRIVATE);
final int size = Integer.parseInt(prefs.getString(
context.getString(R.string.key_text_size),
String.valueOf(context.getResources().getInteger(
R.integer.textSizeDefaultValue))));
// Instantiating an adapter to store each items
ListAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList,
R.layout.fragment_service_list, from, to) {
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView line = (TextView) view.findViewById(R.id.servicelistLine);
TextView text1 = (TextView) view.findViewById(R.id.serviceListText);
text1.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
if (selected == position) {
text1.setTextColor(Color.parseColor("#000000"));
text1.setTypeface(null, Typeface.BOLD_ITALIC);
line.setBackgroundColor(0xffffff);
} else{
text1.setTypeface(null, Typeface.NORMAL);
line.setBackgroundColor(0xffffff);
}
return view;
}
};
setListAdapter(adapter);
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Boolean autoscroll =
sharedPrefs.getBoolean(context.getString(R.string.key_auto_scroll), false);
if (autoscroll){
getListView().setSelection(selected - 1);
}
Log.i(LOG_TAG, "populate_display - exit");
}
public void itemClicked(int position) {
try {
String request = JsonHelpers.createRequestJSON("id", Integer.toString(position));
triggerTextRequest(String.format("%s%s", Api.SERVICE_SET, request));
Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), position(%s)",
Api.SERVICE_SET, position));
} catch (JsonHelpers.JSONHandlerException e) {
e.printStackTrace();
Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -1,34 +0,0 @@
/******************************************************************************
* 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.fragments;
import org.openlp.android2.api.Api;
public class StageWebFragment extends WebFragment {
public StageWebFragment(){
super();
curURL = Api.STAGE_VIEW;
}
public static StageWebFragment newInstance() {
return new StageWebFragment();
}
}

View File

@ -1,78 +0,0 @@
/******************************************************************************
* 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.fragments;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import org.openlp.android2.R;
import org.openlp.android2.common.OpenLPURLBuilder;
public class WebFragment extends Fragment {
protected String curURL;
private WebView webview;
public WebFragment(){
super();
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_web, container, false);
if (curURL != null) {
webview = (WebView) view.findViewById(R.id.webPage);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(true);
webview.setWebViewClient(new webClient());
webview.loadUrl(String.format("%s%s", OpenLPURLBuilder.getInstance().getBaseUrl(), curURL));
}
return view;
}
@Override
public void onDestroyView() {
if (webview != null) {
webview.destroy();
}
super.onDestroyView();
}
public class webClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 629 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 B

Some files were not shown because too many files have changed in this diff Show More