summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/RPCRequestFactory.java70
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/AlertDialog.java168
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/PlaceholderFragment.java106
-rw-r--r--mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java15
4 files changed, 224 insertions, 135 deletions
diff --git a/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/RPCRequestFactory.java b/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/RPCRequestFactory.java
index 73a912de97..0123ceeea1 100644
--- a/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/RPCRequestFactory.java
+++ b/mobile/android/SyncProxyAndroid/src/main/java/com/ford/syncV4/proxy/RPCRequestFactory.java
@@ -179,52 +179,48 @@ public class RPCRequestFactory {
return addSubMenu;
}
-
- public static Alert buildAlert(String ttsText, Boolean playTone,
- Integer correlationID) {
- Vector<TTSChunk> chunks = TTSChunkFactory
- .createSimpleTTSChunks(ttsText);
- Alert msg = buildAlert(chunks, null, null, playTone, null,
- correlationID);
- return msg;
+
+ /**
+ * Alert section
+ */
+
+ public static Alert buildAlert() {
+ return new Alert();
+ }
+
+ public static Alert buildAlert(String ttsText, Boolean playTone, Integer correlationId) {
+ Vector<TTSChunk> chunks = TTSChunkFactory.createSimpleTTSChunks(ttsText);
+ return buildAlert(chunks, null, null, playTone, null, correlationId);
}
- public static Alert buildAlert(String alertText1, String alertText2,
- Integer duration, Integer correlationID) {
- Alert msg = buildAlert((Vector<TTSChunk>) null, alertText1, alertText2,
- null, duration, correlationID);
- return msg;
+ public static Alert buildAlert(String alertText1, String alertText2, Integer duration,
+ Integer correlationId) {
+ return buildAlert((Vector<TTSChunk>) null, alertText1, alertText2, null, duration,
+ correlationId);
}
- public static Alert buildAlert(String ttsText, String alertText1,
- String alertText2, Boolean playTone, Integer duration,
- Integer correlationID) {
- Vector<TTSChunk> chunks = TTSChunkFactory
- .createSimpleTTSChunks(ttsText);
- Alert msg = buildAlert(chunks, alertText1, alertText2, playTone,
- duration, correlationID);
- return msg;
+ public static Alert buildAlert(String ttsText, String alertText1, String alertText2,
+ Boolean playTone, Integer duration, Integer correlationId) {
+ Vector<TTSChunk> chunks = TTSChunkFactory.createSimpleTTSChunks(ttsText);
+ return buildAlert(chunks, alertText1, alertText2, playTone, duration, correlationId);
}
public static Alert buildAlert(Vector<TTSChunk> chunks, Boolean playTone,
- Integer correlationID) {
- Alert msg = buildAlert(chunks, null, null, playTone, null,
- correlationID);
- return msg;
+ Integer correlationId) {
+ return buildAlert(chunks, null, null, playTone, null, correlationId);
}
- public static Alert buildAlert(Vector<TTSChunk> ttsChunks,
- String alertText1, String alertText2, Boolean playTone,
- Integer duration, Integer correlationID) {
- Alert msg = new Alert();
- msg.setCorrelationId(correlationID);
- msg.setAlertText1(alertText1);
- msg.setAlertText2(alertText2);
- msg.setDuration(duration);
- msg.setPlayTone(playTone);
- msg.setTtsChunks(ttsChunks);
-
- return msg;
+ public static Alert buildAlert(Vector<TTSChunk> ttsChunks, String alertText1,
+ String alertText2, Boolean playTone, Integer duration,
+ Integer correlationId) {
+ Alert alert = buildAlert();
+ alert.setCorrelationId(correlationId);
+ alert.setAlertText1(alertText1);
+ alert.setAlertText2(alertText2);
+ alert.setDuration(duration);
+ alert.setPlayTone(playTone);
+ alert.setTtsChunks(ttsChunks);
+ return alert;
}
/**
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/AlertDialog.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/AlertDialog.java
index 63478be70e..5918686282 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/AlertDialog.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/AlertDialog.java
@@ -1,11 +1,177 @@
package com.ford.syncV4.android.activity;
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+
+import com.ford.syncV4.android.R;
+import com.ford.syncV4.android.constants.Const;
+import com.ford.syncV4.proxy.RPCRequestFactory;
+import com.ford.syncV4.proxy.TTSChunkFactory;
+import com.ford.syncV4.proxy.rpc.Alert;
+import com.ford.syncV4.proxy.rpc.SoftButton;
+import com.ford.syncV4.proxy.rpc.TTSChunk;
+import com.ford.syncV4.proxy.rpc.enums.SoftButtonType;
+import com.ford.syncV4.proxy.rpc.enums.SystemAction;
+import com.ford.syncV4.util.logger.Logger;
+
+import java.util.Vector;
+
/**
* Created with Android Studio.
* Author: Chernyshov Yuriy - Mobile Development
* Date: 05.08.14
* Time: 9:50
*/
-public class AlertDialog {
+public class AlertDialog extends BaseDialogFragment {
+
+ private static final String LOG_TAG = AlertDialog.class.getSimpleName();
+
+ /**
+ * START
+ * These field must be refactored with
+ * https://adc.luxoft.com/jira/browse/APPLINK-8099
+ */
+
+ /**
+ * The Include Soft Buttons checkbox in the current dialog. Kept here to
+ * check it when the user has explicitly set the soft buttons.
+ */
+ private CheckBox chkIncludeSoftButtons;
+
+ /**
+ * List of soft buttons for current function. Passed between
+ * {@link SoftButtonsListActivity} and this activity.
+ */
+ private Vector<SoftButton> currentSoftButtons;
+
+ private static final int ALERT_MAXSOFTBUTTONS = 4;
+
+ /**
+ * END
+ */
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Context context = getActivity();
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ View layout = inflater.inflate(R.layout.alert,
+ (ViewGroup) getActivity().findViewById(R.id.itemRoot));
+
+ final EditText txtSpeak = (EditText) layout.findViewById(R.id.txtSpeak);
+ final EditText txtAlertField1 = (EditText) layout.findViewById(R.id.txtAlertField1);
+ final EditText txtAlertField2 = (EditText) layout.findViewById(R.id.txtAlertField2);
+ final EditText txtAlertField3 = (EditText) layout.findViewById(R.id.txtAlertField3);
+ final EditText txtDuration = (EditText) layout.findViewById(R.id.txtDuration);
+ final CheckBox chkPlayTone = (CheckBox) layout.findViewById(R.id.chkPlayTone);
+ final CheckBox useProgressIndicator = (CheckBox) layout.findViewById(R.id.alert_useProgressIndicator);
+ final CheckBox useDuration = (CheckBox) layout.findViewById(R.id.alert_useDuration);
+ final CheckBox doEncryptView = (CheckBox) layout.findViewById(R.id.alert_do_encrypt_view);
+ chkIncludeSoftButtons = (CheckBox) layout.findViewById(R.id.chkIncludeSBs);
+
+ SoftButton sb1 = new SoftButton();
+ sb1.setSoftButtonID(SyncProxyTester.getNewSoftButtonId());
+ sb1.setText("ReRoute");
+ sb1.setType(SoftButtonType.SBT_TEXT);
+ sb1.setIsHighlighted(false);
+ sb1.setSystemAction(SystemAction.STEAL_FOCUS);
+ SoftButton sb2 = new SoftButton();
+ sb2.setSoftButtonID(SyncProxyTester.getNewSoftButtonId());
+ sb2.setText("Close");
+ sb2.setType(SoftButtonType.SBT_TEXT);
+ sb2.setIsHighlighted(false);
+ sb2.setSystemAction(SystemAction.DEFAULT_ACTION);
+ currentSoftButtons = new Vector<SoftButton>();
+ currentSoftButtons.add(sb1);
+ currentSoftButtons.add(sb2);
+
+ Button btnSoftButtons = (Button) layout.findViewById(R.id.alert_btnSoftButtons);
+ btnSoftButtons.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ IntentHelper.addObjectForKey(currentSoftButtons, Const.INTENTHELPER_KEY_OBJECTSLIST);
+ Intent intent = new Intent(getActivity(), SoftButtonsListActivity.class);
+ intent.putExtra(Const.INTENT_KEY_OBJECTS_MAXNUMBER, ALERT_MAXSOFTBUTTONS);
+ startActivityForResult(intent, PlaceholderFragment.REQUEST_LIST_SOFTBUTTONS);
+ }
+ });
+
+ return new android.app.AlertDialog.Builder(context)
+ .setTitle("RPC Request - Alert")
+ .setPositiveButton(getString(R.string.ok_string),
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ try {
+ Alert alert = RPCRequestFactory.buildAlert();
+ alert.setCorrelationId(((SyncProxyTester) getActivity())
+ .getNextCorrelationIdForCurrentFragment());
+ alert.setAlertText1(txtAlertField1.getText().toString());
+ alert.setAlertText2(txtAlertField2.getText().toString());
+ alert.setAlertText3(txtAlertField3.getText().toString());
+ if (useDuration.isChecked()) {
+ alert.setDuration(Integer.parseInt(txtDuration.getText().toString()));
+ }
+ alert.setPlayTone(chkPlayTone.isChecked());
+ alert.setProgressIndicator(useProgressIndicator.isChecked());
+
+ String toSpeak = txtSpeak.getText().toString();
+ if (toSpeak.length() > 0) {
+ Vector<TTSChunk> ttsChunks = TTSChunkFactory
+ .createSimpleTTSChunks(toSpeak);
+ alert.setTtsChunks(ttsChunks);
+ }
+ alert.setDoEncryption(doEncryptView.isChecked());
+ if (chkIncludeSoftButtons.isChecked() &&
+ (currentSoftButtons != null) &&
+ (currentSoftButtons.size() > 0)) {
+ alert.setSoftButtons(currentSoftButtons);
+ }
+ ((SyncProxyTester) getActivity()).onAlertDialogResult(
+ getArguments().getString(APP_ID_KEY), alert);
+ } catch (NumberFormatException e) {
+ SafeToast.showToastAnyThread("Couldn't parse number");
+ }
+ currentSoftButtons = null;
+ chkIncludeSoftButtons = null;
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ currentSoftButtons = null;
+ chkIncludeSoftButtons = null;
+ dialog.cancel();
+ }
+ }).setView(layout).show();
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ Logger.i(LOG_TAG + " OnActivityResult, request:" + requestCode + ", result:" + resultCode +
+ ", data:" + data);
+
+ switch (requestCode) {
+ case PlaceholderFragment.REQUEST_LIST_SOFTBUTTONS:
+ if (resultCode == Activity.RESULT_OK) {
+ currentSoftButtons = (Vector<SoftButton>) IntentHelper.
+ getObjectForKey(Const.INTENTHELPER_KEY_OBJECTSLIST);
+ if (chkIncludeSoftButtons != null) {
+ chkIncludeSoftButtons.setChecked(true);
+ }
+ }
+ IntentHelper.removeObjectForKey(Const.INTENTHELPER_KEY_OBJECTSLIST);
+ break;
+ }
+ }
} \ No newline at end of file
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/PlaceholderFragment.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/PlaceholderFragment.java
index 6bbf29e77a..5c9c9eb9ae 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/PlaceholderFragment.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/PlaceholderFragment.java
@@ -144,6 +144,7 @@ public class PlaceholderFragment extends Fragment {
private final static String REGISTER_APP_INTERFACE_DIALOG_TAG = "RegisterAppInterfaceDialogTag";
private final static String HASH_ID_SET_UP_DIALOG_TAG = "HashIdSetUpDialogTag";
private final static String FEEDBACK_DIALOG_TAG = "FeedbackDialogTag";
+ private final static String ALERT_DIALOG_TAG = "AlertDialogTag";
private static final String MSC_PREFIX = "msc_";
private static final int ALERT_MAXSOFTBUTTONS = 4;
@@ -1031,11 +1032,17 @@ public class PlaceholderFragment extends Fragment {
((SyncProxyTester) getActivity()).getImageTypeAdapter();
new AlertDialog.Builder(getActivity())
- .setTitle("Pick a Function")
+ .setTitle("Select RPC Request")
.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (adapter.getItem(which).equals(Names.Alert)) {
- sendAlert();
+ // Create and show dialog for the RPC Request - Alert
+ BaseDialogFragment alertDialogFragment =
+ BaseDialogFragment.newInstance(
+ com.ford.syncV4.android.activity.AlertDialog.class.getName(),
+ getAppId());
+ alertDialogFragment.show(getActivity().getFragmentManager(),
+ ALERT_DIALOG_TAG);
} else if (adapter.getItem(which).equals(Names.Speak)) {
//something
AlertDialog.Builder builder;
@@ -1534,101 +1541,6 @@ public class PlaceholderFragment extends Fragment {
}
/**
- * Sends Alert message.
- */
- private void sendAlert() {
- final Context mContext = adapter.getContext();
- LayoutInflater inflater = (LayoutInflater) mContext
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View layout = inflater.inflate(R.layout.alert, null);
- final EditText txtSpeak = (EditText) layout.findViewById(R.id.txtSpeak);
- final EditText txtAlertField1 = (EditText) layout.findViewById(R.id.txtAlertField1);
- final EditText txtAlertField2 = (EditText) layout.findViewById(R.id.txtAlertField2);
- final EditText txtAlertField3 = (EditText) layout.findViewById(R.id.txtAlertField3);
- final EditText txtDuration = (EditText) layout.findViewById(R.id.txtDuration);
- final CheckBox chkPlayTone = (CheckBox) layout.findViewById(R.id.chkPlayTone);
- final CheckBox useProgressIndicator = (CheckBox) layout.findViewById(R.id.alert_useProgressIndicator);
- final CheckBox useDuration = (CheckBox) layout.findViewById(R.id.alert_useDuration);
- final CheckBox doEncryptView = (CheckBox) layout.findViewById(R.id.alert_do_encrypt_view);
- chkIncludeSoftButtons = (CheckBox) layout.findViewById(R.id.chkIncludeSBs);
-
- SoftButton sb1 = new SoftButton();
- sb1.setSoftButtonID(
- SyncProxyTester.getNewSoftButtonId());
- sb1.setText("ReRoute");
- sb1.setType(SoftButtonType.SBT_TEXT);
- sb1.setIsHighlighted(false);
- sb1.setSystemAction(SystemAction.STEAL_FOCUS);
- SoftButton sb2 = new SoftButton();
- sb2.setSoftButtonID(SyncProxyTester.getNewSoftButtonId());
- sb2.setText("Close");
- sb2.setType(SoftButtonType.SBT_TEXT);
- sb2.setIsHighlighted(false);
- sb2.setSystemAction(SystemAction.DEFAULT_ACTION);
- currentSoftButtons = new Vector<SoftButton>();
- currentSoftButtons.add(sb1);
- currentSoftButtons.add(sb2);
-
- Button btnSoftButtons = (Button) layout.findViewById(R.id.alert_btnSoftButtons);
- btnSoftButtons.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- IntentHelper
- .addObjectForKey(currentSoftButtons,
- Const.INTENTHELPER_KEY_OBJECTSLIST);
- Intent intent = new Intent(mContext, SoftButtonsListActivity.class);
- intent.putExtra(Const.INTENT_KEY_OBJECTS_MAXNUMBER, ALERT_MAXSOFTBUTTONS);
- startActivityForResult(intent, REQUEST_LIST_SOFTBUTTONS);
- }
- });
-
- AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
- builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- try {
- Alert msg = new Alert();
- msg.setCorrelationId(getCorrelationId());
- msg.setAlertText1(txtAlertField1.getText().toString());
- msg.setAlertText2(txtAlertField2.getText().toString());
- msg.setAlertText3(txtAlertField3.getText().toString());
- if (useDuration.isChecked()) {
- msg.setDuration(Integer.parseInt(txtDuration.getText().toString()));
- }
- msg.setPlayTone(chkPlayTone.isChecked());
- msg.setProgressIndicator(useProgressIndicator.isChecked());
-
- String toSpeak = txtSpeak.getText().toString();
- if (toSpeak.length() > 0) {
- Vector<TTSChunk> ttsChunks = TTSChunkFactory
- .createSimpleTTSChunks(toSpeak);
- msg.setTtsChunks(ttsChunks);
- }
- msg.setDoEncryption(doEncryptView.isChecked());
- if (chkIncludeSoftButtons.isChecked() &&
- (currentSoftButtons != null) &&
- (currentSoftButtons.size() > 0)) {
- msg.setSoftButtons(currentSoftButtons);
- }
- sendRPCRequestToProxy(msg);
- } catch (NumberFormatException e) {
- SafeToast.showToastAnyThread("Couldn't parse number");
- }
- currentSoftButtons = null;
- chkIncludeSoftButtons = null;
- }
- });
- builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- currentSoftButtons = null;
- chkIncludeSoftButtons = null;
- dialog.cancel();
- }
- });
- builder.setView(layout);
- builder.show();
- }
-
- /**
* Sends UnregisterAppInterface message.
*/
private void sendUnregisterAppInterface() {
diff --git a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java
index 4008c78102..5e961ba91c 100644
--- a/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java
+++ b/mobile/android/SyncProxyTester/src/main/java/com/ford/syncV4/android/activity/SyncProxyTester.java
@@ -57,6 +57,7 @@ import com.ford.syncV4.proxy.constants.Names;
import com.ford.syncV4.proxy.constants.ProtocolConstants;
import com.ford.syncV4.proxy.rpc.AddCommand;
import com.ford.syncV4.proxy.rpc.AddSubMenu;
+import com.ford.syncV4.proxy.rpc.Alert;
import com.ford.syncV4.proxy.rpc.OnAudioPassThru;
import com.ford.syncV4.proxy.rpc.OnKeyboardInput;
import com.ford.syncV4.proxy.rpc.OnTouchEvent;
@@ -1022,6 +1023,20 @@ public class SyncProxyTester extends ActionBarActivity implements ActionBar.TabL
/**
* This is a callback function for the result of the
+ * {@link com.ford.syncV4.android.activity.AlertDialog}
+ *
+ * @param appId Application Id
+ * @param alert {@link com.ford.syncV4.proxy.rpc.Alert} request
+ */
+ public void onAlertDialogResult(String appId, Alert alert) {
+ if (mBoundProxyService == null) {
+ return;
+ }
+ mBoundProxyService.syncProxySendRPCRequest(appId, alert);
+ }
+
+ /**
+ * This is a callback function for the result of the
* {@link com.ford.syncV4.android.activity.PolicyFilesSetUpDialog}
*/
public void onPolicyFilesSetUpDialogResult_SendUpdate(String appId, FileType fileType,