mirror of
https://gitlab.com/openlp/android.git
synced 2024-12-22 20:02:50 +00:00
add About / Home / Stage Web and Live Web
This commit is contained in:
parent
a8689e84ed
commit
f2d2656cc6
@ -35,11 +35,10 @@ import android.view.ViewGroup;
|
|||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import org.openlp.android2.activities.ConnectionActivity;
|
import org.openlp.android2.activities.ConnectionActivity;
|
||||||
import org.openlp.android2.activities.SettingsActivity;
|
import org.openlp.android2.activities.SettingsActivity;
|
||||||
|
import org.openlp.android2.common.NavigationOptions;
|
||||||
import org.openlp.android2.dialogs.AlertDisplayDialog;
|
import org.openlp.android2.dialogs.AlertDisplayDialog;
|
||||||
import org.openlp.android2.dialogs.BlankDisplayDialog;
|
import org.openlp.android2.dialogs.BlankDisplayDialog;
|
||||||
import org.openlp.android2.fragments.LiveListFragment;
|
import org.openlp.android2.fragments.*;
|
||||||
import org.openlp.android2.fragments.NavigationDrawerFragment;
|
|
||||||
import org.openlp.android2.fragments.ServiceListFragment;
|
|
||||||
|
|
||||||
|
|
||||||
public class OpenLP extends Activity
|
public class OpenLP extends Activity
|
||||||
@ -75,27 +74,33 @@ public class OpenLP extends Activity
|
|||||||
// update the main content by replacing fragments
|
// update the main content by replacing fragments
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case NavigationOptions.Home:
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.replace(R.id.container, HomeFragment.newInstance())
|
||||||
|
.commit();
|
||||||
|
mTitle = getString(R.string.service_list);
|
||||||
|
break;
|
||||||
|
case NavigationOptions.ServiceList:
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.container, ServiceListFragment.newInstance())
|
.replace(R.id.container, ServiceListFragment.newInstance())
|
||||||
.commit();
|
.commit();
|
||||||
mTitle = getString(R.string.service_list);
|
mTitle = getString(R.string.service_list);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case NavigationOptions.LiveList:
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.container, LiveListFragment.newInstance())
|
.replace(R.id.container, LiveListFragment.newInstance())
|
||||||
.commit();
|
.commit();
|
||||||
mTitle = getString(R.string.live_list);
|
mTitle = getString(R.string.live_list);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case NavigationOptions.StageView:
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
|
.replace(R.id.container, StageWebFragment.newInstance())
|
||||||
.commit();
|
.commit();
|
||||||
mTitle = getString(R.string.stage_view);
|
mTitle = getString(R.string.stage_view);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case NavigationOptions.LiveView:
|
||||||
fragmentManager.beginTransaction()
|
fragmentManager.beginTransaction()
|
||||||
.replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
|
.replace(R.id.container, LiveWebFragment.newInstance())
|
||||||
.commit();
|
.commit();
|
||||||
mTitle = getString(R.string.live_view);
|
mTitle = getString(R.string.live_view);
|
||||||
break;
|
break;
|
||||||
@ -104,6 +109,9 @@ public class OpenLP extends Activity
|
|||||||
|
|
||||||
public void onSectionAttached(int number) {
|
public void onSectionAttached(int number) {
|
||||||
switch (number) {
|
switch (number) {
|
||||||
|
case 0:
|
||||||
|
mTitle = getString(R.string.service_list);
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mTitle = getString(R.string.service_list);
|
mTitle = getString(R.string.service_list);
|
||||||
break;
|
break;
|
||||||
@ -145,27 +153,31 @@ public class OpenLP extends Activity
|
|||||||
// Handle action bar item clicks here. The action bar will
|
// Handle action bar item clicks here. The action bar will
|
||||||
// automatically handle clicks on the Home/Up button, so long
|
// automatically handle clicks on the Home/Up button, so long
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
int id = item.getItemId();
|
Intent intent;
|
||||||
if (id == R.id.action_preferences) {
|
switch (item.getItemId()) {
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
|
||||||
|
case R.id.action_preferences:
|
||||||
|
intent = new Intent(this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
case R.id.action_connections:
|
||||||
if (id == R.id.action_connections) {
|
intent = new Intent(this, ConnectionActivity.class);
|
||||||
Intent intent = new Intent(this, ConnectionActivity.class);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
case R.id.action_blank:
|
||||||
if (id == R.id.action_blank) {
|
|
||||||
new BlankDisplayDialog().show(getFragmentManager(), "BlankDialog");
|
new BlankDisplayDialog().show(getFragmentManager(), "BlankDialog");
|
||||||
return true;
|
return true;
|
||||||
}
|
case R.id.action_alert:
|
||||||
if (id == R.id.action_alert) {
|
|
||||||
new AlertDisplayDialog().show(getFragmentManager(), "AlertDialog");
|
new AlertDisplayDialog().show(getFragmentManager(), "AlertDialog");
|
||||||
return true;
|
return true;
|
||||||
}
|
case R.id.action_about:
|
||||||
|
getFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.container, AboutFragment.newInstance())
|
||||||
|
.commit();
|
||||||
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A placeholder fragment containing a simple view.
|
* A placeholder fragment containing a simple view.
|
||||||
|
@ -70,24 +70,10 @@ public class OpenLPHttpClient {
|
|||||||
|
|
||||||
public String getAbsoluteUrl(AsyncHttpClient client) {
|
public String getAbsoluteUrl(AsyncHttpClient client) {
|
||||||
|
|
||||||
if (useSSL){
|
String urlBase = getBaseUrl();
|
||||||
try {
|
|
||||||
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
|
||||||
trustStore.load(null, null);
|
|
||||||
MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
|
|
||||||
sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
|
||||||
client.setSSLSocketFactory(sf);
|
|
||||||
}
|
|
||||||
catch (Exception e) {;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Map<String, ?> preferences = context.getSharedPreferences(context.getString(R.string.keySharedPreferences), Context.MODE_PRIVATE).getAll();
|
|
||||||
|
|
||||||
useSSL = getPreference(preferences, context.getString(R.string.key_ssl_use), false);
|
|
||||||
String host = getPreference(preferences, context.getString(R.string.keyHost),
|
|
||||||
context.getString(R.string.hostDefaultValue));
|
|
||||||
String port = getPreference(preferences, context.getString(R.string.keyPort), "4316");
|
|
||||||
|
|
||||||
|
Map<String, ?> preferences = context.getSharedPreferences(context.getString(R.string.keySharedPreferences),
|
||||||
|
Context.MODE_PRIVATE).getAll();
|
||||||
|
|
||||||
String userid = getPreference(preferences, context.getString(R.string.key_userid), "openlp");
|
String userid = getPreference(preferences, context.getString(R.string.key_userid), "openlp");
|
||||||
|
|
||||||
@ -98,8 +84,6 @@ public class OpenLPHttpClient {
|
|||||||
|
|
||||||
Credentials creds = new UsernamePasswordCredentials(userid, password);
|
Credentials creds = new UsernamePasswordCredentials(userid, password);
|
||||||
|
|
||||||
String urlBase = String.format("http%s://%s:%s", useSSL ? "s" : "", host, port);
|
|
||||||
|
|
||||||
int connectionTimeout = context.getResources().getInteger(
|
int connectionTimeout = context.getResources().getInteger(
|
||||||
R.integer.connectionTimeoutDefaultValue);
|
R.integer.connectionTimeoutDefaultValue);
|
||||||
|
|
||||||
@ -127,31 +111,16 @@ public class OpenLPHttpClient {
|
|||||||
return urlBase;
|
return urlBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getBaseUrl(){
|
||||||
|
Map<String, ?> preferences = context.getSharedPreferences(context.getString(R.string.keySharedPreferences), Context.MODE_PRIVATE).getAll();
|
||||||
|
|
||||||
/* public OpenLPHttpReturn handleExecute() throws IOException {
|
useSSL = getPreference(preferences, context.getString(R.string.key_ssl_use), false);
|
||||||
//HttpResponse response = this.execute();
|
String host = getPreference(preferences, context.getString(R.string.keyHost),
|
||||||
|
context.getString(R.string.hostDefaultValue));
|
||||||
|
String port = getPreference(preferences, context.getString(R.string.keyPort), "4316");
|
||||||
|
|
||||||
Log.d(LOG_TAG, "Http response code " + String.valueOf(response.getStatusLine().getStatusCode()));
|
return String.format("http%s://%s:%s", useSSL ? "s" : "", host, port);
|
||||||
|
|
||||||
if (response.getStatusLine().getStatusCode() == 200) {
|
|
||||||
BufferedReader bufferedReader;
|
|
||||||
HttpEntity entity = response.getEntity();
|
|
||||||
|
|
||||||
if (entity != null) {
|
|
||||||
bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
String line = bufferedReader.readLine();
|
|
||||||
while (line != null) {
|
|
||||||
stringBuilder.append(line);
|
|
||||||
line = bufferedReader.readLine();
|
|
||||||
}
|
}
|
||||||
bufferedReader.close();
|
|
||||||
return new OpenLPHttpReturn(0, stringBuilder.toString(), this.context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new OpenLPHttpReturn(response.getStatusLine().getStatusCode(), null, this.context);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* OpenLP - Open Source Lyrics Projection *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2011-2014 Raoul Snyman *
|
||||||
|
* Portions copyright (c) 2011-2014 Tim Bentley, Johan Mynhardt *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* 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() {
|
||||||
|
AboutFragment fragment = new AboutFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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, 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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* OpenLP - Open Source Lyrics Projection *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2011-2014 Raoul Snyman *
|
||||||
|
* Portions copyright (c) 2011-2014 Tim Bentley, Johan Mynhardt *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* 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() {
|
||||||
|
HomeFragment fragment = new HomeFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* OpenLP - Open Source Lyrics Projection *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2011-2014 Raoul Snyman *
|
||||||
|
* Portions copyright (c) 2011-2014 Tim Bentley, Johan Mynhardt *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* 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() {
|
||||||
|
LiveWebFragment fragment = new LiveWebFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -102,6 +102,7 @@ public class NavigationDrawerFragment extends Fragment {
|
|||||||
R.layout.fragment_navigation_drawer_list,
|
R.layout.fragment_navigation_drawer_list,
|
||||||
android.R.id.text1,
|
android.R.id.text1,
|
||||||
new String[]{
|
new String[]{
|
||||||
|
getString(R.string.home),
|
||||||
getString(R.string.service_list),
|
getString(R.string.service_list),
|
||||||
getString(R.string.live_list),
|
getString(R.string.live_list),
|
||||||
getString(R.string.stage_view),
|
getString(R.string.stage_view),
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* OpenLP - Open Source Lyrics Projection *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2011-2014 Raoul Snyman *
|
||||||
|
* Portions copyright (c) 2011-2014 Tim Bentley, Johan Mynhardt *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* 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() {
|
||||||
|
StageWebFragment fragment = new StageWebFragment();
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* OpenLP - Open Source Lyrics Projection *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* Copyright (c) 2011-2014 Raoul Snyman *
|
||||||
|
* Portions copyright (c) 2011-2014 Tim Bentley, Johan Mynhardt *
|
||||||
|
* --------------------------------------------------------------------------- *
|
||||||
|
* 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.net.http.SslError;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.SslErrorHandler;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
import org.openlp.android2.R;
|
||||||
|
import org.openlp.android2.common.OpenLPHttpClient;
|
||||||
|
|
||||||
|
public class WebFragment extends Fragment {
|
||||||
|
|
||||||
|
protected String curURL;
|
||||||
|
private OpenLPHttpClient httpClient;
|
||||||
|
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) {
|
||||||
|
httpClient = new OpenLPHttpClient(getActivity());
|
||||||
|
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", httpClient.getBaseUrl(), curURL));
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
if (webview != null) {
|
||||||
|
webview.destroy();
|
||||||
|
}
|
||||||
|
super.onDestroyView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class webClient extends WebViewClient {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||||
|
handler.proceed(); // Ignore SSL certificate errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
app/src/main/res/layout/fragment_about.xml
Normal file
8
app/src/main/res/layout/fragment_about.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/about_text"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:background="#000000"
|
||||||
|
android:gravity="center"
|
||||||
|
android:linksClickable="true"
|
||||||
|
android:padding="32dp" />
|
22
app/src/main/res/layout/fragment_home.xml
Normal file
22
app/src/main/res/layout/fragment_home.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<!--
|
||||||
|
Copyright 2013 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/home_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="32dp"/>
|
11
app/src/main/res/layout/fragment_web.xml
Normal file
11
app/src/main/res/layout/fragment_web.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:baselineAligned="false">
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/webPage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -46,6 +46,7 @@
|
|||||||
<string name="display_theme">Blank display to Theme</string>
|
<string name="display_theme">Blank display to Theme</string>
|
||||||
<string name="enable_custom_timeouts">Enable Custom Timeouts</string>
|
<string name="enable_custom_timeouts">Enable Custom Timeouts</string>
|
||||||
<string name="enter_alert_text">Enter Alert Text</string>
|
<string name="enter_alert_text">Enter Alert Text</string>
|
||||||
|
<string name="home">Home</string>
|
||||||
<string name="httpreturn_unauthorised">Unauthorised Access, please enter valid userid and password</string>
|
<string name="httpreturn_unauthorised">Unauthorised Access, please enter valid userid and password</string>
|
||||||
<string name="live_list">Live List</string>
|
<string name="live_list">Live List</string>
|
||||||
<string name="live_view">LiveView</string>
|
<string name="live_view">LiveView</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user