/*
============================================================================
Author : Dmitry Moskalchuk
Version : 1.5
Copyright : Copyright (C) 2008 Rhomobile. All rights reserved.
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, either version 3 of the License, or
(at your option) any later version.
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, see .
============================================================================
*/
package com.rhomobile.rhodes.alert;
import java.io.File;
import java.io.FileInputStream;
import java.util.Map;
import java.util.Vector;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Vibrator;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.rhomobile.rhodes.AndroidR;
import com.rhomobile.rhodes.Capabilities;
import com.rhomobile.rhodes.Logger;
import com.rhomobile.rhodes.RhodesService;
import com.rhomobile.rhodes.file.RhoFileApi;
import com.rhomobile.rhodes.util.PerformOnUiThread;
public class Alert {
private static final String TAG = "Alert";
private static Dialog currentAlert = null;
private static TextView s_textView = null;
private static MediaPlayer currentMP = null;
private static native void doCallback(String url, String id, String title);
private static class CustomButton {
public String id;
public String title;
public CustomButton(String t) {
id = t;
title = t;
}
public CustomButton(String i, String t) {
id = i;
title = t;
}
};
private static class ShowDialogListener implements OnClickListener {
private String callback;
private String id;
private String title;
private Dialog dialog;
public ShowDialogListener(String c, String i, String t, Dialog d) {
callback = c;
id = i;
title = t;
dialog = d;
}
public void onClick(View arg0) {
if (callback != null) {
doCallback(callback, Uri.encode(id), Uri.encode(title));
}
dialog.dismiss();
currentAlert = null;
}
};
private static class ShowStatusDialog implements Runnable
{
private String m_strMessage;
private String m_strHide;
public ShowStatusDialog(String strMessage, String strHide)
{
m_strMessage = strMessage;
m_strHide = strHide;
}
@SuppressWarnings("unchecked")
public void run()
{
if ( currentAlert != null )
{
s_textView.setText(m_strMessage);
return;
}
Vector buttons = new Vector();
buttons.addElement(new CustomButton(m_strHide));
makeDialog( "", m_strMessage, null, buttons, null);
}
}
private static class ShowDialog implements Runnable {
private Object params;
public ShowDialog(Object p) {
params = p;
}
@SuppressWarnings("unchecked")
public void run() {
String title = "";//"Alert";
String message = null;
Drawable icon = null;
String callback = null;
Vector buttons = new Vector();
Context ctx = RhodesService.getInstance().getContext();
if (params instanceof String)
{
message = (String)params;
buttons.addElement(new CustomButton("OK"));
}
else if (params instanceof Map,?>) {
Map