diff --git a/app/src/main/java/org/openlp/android2/dialogs/SearchSelectionDialog.java b/app/src/main/java/org/openlp/android2/dialogs/SearchSelectionDialog.java new file mode 100644 index 0000000..160f65c --- /dev/null +++ b/app/src/main/java/org/openlp/android2/dialogs/SearchSelectionDialog.java @@ -0,0 +1,124 @@ +/****************************************************************************** + * 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.EditText; +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; +import org.openlp.android2.common.OpenLPHttpClient; + +public class SearchSelectionDialog extends OpenLPDialog { + private final String LOG_TAG = SearchSelectionDialog.class.getName(); + public AlertDialog dialog; + private int num; + 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. + + num = getArguments().getInt("id"); + plugin = getArguments().getString("plugin"); + text = getArguments().getString("text"); + + context = getActivity(); + httpClient = new OpenLPHttpClient(context); + + 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.buttonService); + sendLive.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + triggerTextRequest(Api.DISPLAY_SHOW); + } + }); + addToService = (RadioButton) view.findViewById(R.id.buttonLive); + addToService.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + triggerTextRequest(Api.DISPLAY_BLANK); + } + }); + + 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 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(); + } + } +} diff --git a/app/src/main/java/org/openlp/android2/fragments/SearchFragment.java b/app/src/main/java/org/openlp/android2/fragments/SearchFragment.java index 47a0b69..7a28e93 100644 --- a/app/src/main/java/org/openlp/android2/fragments/SearchFragment.java +++ b/app/src/main/java/org/openlp/android2/fragments/SearchFragment.java @@ -1,5 +1,6 @@ package org.openlp.android2.fragments; +import android.app.DialogFragment; import android.app.Fragment; import android.content.Context; import android.content.SharedPreferences; @@ -40,6 +41,7 @@ import org.openlp.android2.api.Api; import org.openlp.android2.common.JsonHelpers; import org.openlp.android2.common.OpenLPHttpClient; +import org.openlp.android2.dialogs.SearchSelectionDialog; import java.util.ArrayList; import java.util.HashMap; @@ -219,6 +221,14 @@ public class SearchFragment extends Fragment { final JSONArray item = (JSONArray) parent.getItemAtPosition(position); Toast.makeText(context, "Item Pressed " + String.valueOf(position) + item, Toast.LENGTH_SHORT).show(); + Bundle args = new Bundle(); + args.putString("plugin", "plugin"); + args.putString("text", "text"); + args.putInt("id", 123); + DialogFragment newFragment = new SearchSelectionDialog(); + newFragment.setArguments(args); + newFragment.show(getFragmentManager(), "TAG"); + } }); diff --git a/app/src/main/res/layout/search_action_dialog.xml b/app/src/main/res/layout/search_action_dialog.xml new file mode 100644 index 0000000..b210efb --- /dev/null +++ b/app/src/main/res/layout/search_action_dialog.xml @@ -0,0 +1,40 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d1fd299..0d6bc72 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,6 +48,10 @@ Previous Process Service List + Search Results + Send Live + Add to Service + Showing Results for \'%s\' Stage View Select display text size Change the Service text size