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

Do somthings with search

This commit is contained in:
Tim Bentley 2016-01-03 15:02:30 +00:00
parent 586b269311
commit e193bf3496
4 changed files with 178 additions and 0 deletions

View File

@ -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();
}
}
}

View File

@ -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");
}
});

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1">
<TextView
android:layout_width="315dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/searchResults"
android:id="@+id/textView"
android:textStyle="bold|italic"
android:textSize="40px"
android:height="70px"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/searchSendLive"
android:id="@+id/buttonLive"
android:textSize="20sp"
android:height="30dp"
android:clickable="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"/>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/searchAddToService"
android:id="@+id/buttonService"
android:textSize="20sp"
android:height="40dp"
android:clickable="true"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"/>
</LinearLayout>

View File

@ -48,6 +48,10 @@
<string name="previous">Previous</string>
<string name="process">Process</string>
<string name="service_list">Service List</string>
<string name="searchResults">Search Results</string>
<string name="searchSendLive">Send Live</string>
<string name="searchAddToService">Add to Service</string>
<string name="showingResults">Showing Results for \'%s\'</string>
<string name="stage_view">Stage View</string>
<string name="text_size">Select display text size</string>
<string name="text_size_summary">Change the Service text size</string>