From 1063eeec53734dd4d75b0a55fb555bf782e8b7ed Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 15 Nov 2014 17:22:08 +0000 Subject: [PATCH] Alert Dialog and string cleanups --- .../main/java/org/openlp/android2/OpenLP.java | 7 +- .../activities/ConnectionActivity.java | 8 +- .../common/OpenLPSSLSocketFactory.java | 19 ++++ .../android2/dialogs/AlertDisplayDialog.java | 30 ++----- .../android2/dialogs/BlankDisplayDialog.java | 1 - .../main/res/layout/alert_display_dialog.xml | 2 +- .../main/res/layout/blank_display_dialog.xml | 10 +-- app/src/main/res/menu/open_l.xml | 8 +- app/src/main/res/values/strings.xml | 90 ++++++++++--------- app/src/main/res/xml/pref_general.xml | 12 +-- 10 files changed, 101 insertions(+), 86 deletions(-) diff --git a/app/src/main/java/org/openlp/android2/OpenLP.java b/app/src/main/java/org/openlp/android2/OpenLP.java index 067b0b8..66dde80 100644 --- a/app/src/main/java/org/openlp/android2/OpenLP.java +++ b/app/src/main/java/org/openlp/android2/OpenLP.java @@ -35,6 +35,7 @@ import android.view.ViewGroup; import android.support.v4.widget.DrawerLayout; import org.openlp.android2.activities.ConnectionActivity; import org.openlp.android2.activities.SettingsActivity; +import org.openlp.android2.dialogs.AlertDisplayDialog; import org.openlp.android2.dialogs.BlankDisplayDialog; import org.openlp.android2.fragments.LiveListFragment; import org.openlp.android2.fragments.NavigationDrawerFragment; @@ -155,10 +156,14 @@ public class OpenLP extends Activity startActivity(intent); return true; } - if (id == R.id.action_alert) { + if (id == R.id.action_blank) { new BlankDisplayDialog().show(getFragmentManager(), "BlankDialog"); return true; } + if (id == R.id.action_alert) { + new AlertDisplayDialog().show(getFragmentManager(), "AlertDialog"); + return true; + } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/org/openlp/android2/activities/ConnectionActivity.java b/app/src/main/java/org/openlp/android2/activities/ConnectionActivity.java index 600f5bf..246e53f 100644 --- a/app/src/main/java/org/openlp/android2/activities/ConnectionActivity.java +++ b/app/src/main/java/org/openlp/android2/activities/ConnectionActivity.java @@ -308,11 +308,11 @@ public class ConnectionActivity extends PreferenceActivity { title.setOnPreferenceChangeListener(onPreferenceChangeListener); hostAddress = new EditTextPreference(getActivity()); - hostAddress.setTitle(getString(R.string.urlHint)); + hostAddress.setTitle(getString(R.string.url_hint)); hostAddress.setKey(KEY_PREFIX + id + ".address"); - hostAddress.getEditText().setHint(R.string.urlHint); - hostAddress.setSummary(getString(R.string.urlHint)); - hostAddress.setDialogTitle(getString(R.string.urlHint)); + hostAddress.getEditText().setHint(R.string.url_hint); + hostAddress.setSummary(getString(R.string.url_hint)); + hostAddress.setDialogTitle(getString(R.string.url_hint)); hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI); hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener); diff --git a/app/src/main/java/org/openlp/android2/common/OpenLPSSLSocketFactory.java b/app/src/main/java/org/openlp/android2/common/OpenLPSSLSocketFactory.java index 4dd8416..89dec57 100644 --- a/app/src/main/java/org/openlp/android2/common/OpenLPSSLSocketFactory.java +++ b/app/src/main/java/org/openlp/android2/common/OpenLPSSLSocketFactory.java @@ -1,3 +1,22 @@ +/****************************************************************************** + * 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.common; import org.apache.http.conn.ssl.SSLSocketFactory; diff --git a/app/src/main/java/org/openlp/android2/dialogs/AlertDisplayDialog.java b/app/src/main/java/org/openlp/android2/dialogs/AlertDisplayDialog.java index 0933ddd..5f55360 100644 --- a/app/src/main/java/org/openlp/android2/dialogs/AlertDisplayDialog.java +++ b/app/src/main/java/org/openlp/android2/dialogs/AlertDisplayDialog.java @@ -21,7 +21,6 @@ package org.openlp.android2.dialogs; import android.app.AlertDialog; import android.app.Dialog; -import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.util.Log; @@ -30,13 +29,11 @@ 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; - -import org.openlp.android2.common.OpenLPHttpReturn; +import org.openlp.android2.common.OpenLPHttpClient; public class AlertDisplayDialog extends OpenLPDialog { private final String LOG_TAG = AlertDisplayDialog.class.getName(); @@ -53,6 +50,7 @@ public class AlertDisplayDialog extends OpenLPDialog { // remove the dialog title, but you must call the superclass to get the Dialog. context = getActivity(); + httpClient = new OpenLPHttpClient(context); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // Get the layout inflater @@ -91,34 +89,20 @@ public class AlertDisplayDialog extends OpenLPDialog { public void onResume() { super.onResume(); Log.d(LOG_TAG, "Resuming..."); - triggerRequest(Api.POLL_STATUS); - Log.d(LOG_TAG, "Resumed..."); } - private void triggerRequest(String url) { - //ExecuteHttpRequestTask task = new ExecuteHttpRequestTask(); - //task.execute(new String[]{url}); - } - - public void populateDisplay(OpenLPHttpReturn response) { - Log.d(LOG_TAG, "populateDisplay"); - if (response.isSecurityError()) { - Toast.makeText(context, R.string.httpreturn_unauthorised, Toast.LENGTH_LONG).show(); - } else if (response.isError()) { - Toast.makeText(context, R.string.unable, Toast.LENGTH_LONG).show(); - } + 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); - triggerRequest(String.format("%s%s", Api.ALERT, request)); - Log.d(LOG_TAG, String.format("Setting list data. apiBase(%s), text(%s)", - Api.ALERT, text)); - Toast.makeText(getActivity().getBaseContext(), "Alert Requested", Toast.LENGTH_SHORT).show(); + 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(getActivity().getBaseContext(), "Request Failed", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "Request Failed", Toast.LENGTH_SHORT).show(); } } } diff --git a/app/src/main/java/org/openlp/android2/dialogs/BlankDisplayDialog.java b/app/src/main/java/org/openlp/android2/dialogs/BlankDisplayDialog.java index 6fe85ed..a86d12b 100644 --- a/app/src/main/java/org/openlp/android2/dialogs/BlankDisplayDialog.java +++ b/app/src/main/java/org/openlp/android2/dialogs/BlankDisplayDialog.java @@ -124,7 +124,6 @@ public class BlankDisplayDialog extends OpenLPDialog { } public void populateDisplay(String json) { - Log.d(LOG_TAG, "populateDisplay"); try { JSONObject item = new JSONObject(json).getJSONObject("results"); diff --git a/app/src/main/res/layout/alert_display_dialog.xml b/app/src/main/res/layout/alert_display_dialog.xml index 69e39d9..c4cc68d 100644 --- a/app/src/main/res/layout/alert_display_dialog.xml +++ b/app/src/main/res/layout/alert_display_dialog.xml @@ -11,7 +11,7 @@ android:layout_width="294dp" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/enterAlertText" + android:text="@string/enter_alert_text" android:id="@+id/textView" android:autoText="true" android:textStyle="bold|italic" diff --git a/app/src/main/res/layout/blank_display_dialog.xml b/app/src/main/res/layout/blank_display_dialog.xml index ec3aaa3..b0cea2c 100644 --- a/app/src/main/res/layout/blank_display_dialog.xml +++ b/app/src/main/res/layout/blank_display_dialog.xml @@ -11,7 +11,7 @@ android:layout_width="294dp" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" - android:text="@string/displayBlankSummary" + android:text="@string/display_blank_summary" android:id="@+id/textView" android:autoText="true" android:textStyle="bold|italic" @@ -20,7 +20,7 @@