/*
============================================================================
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.mainview;
import java.util.Map;
import java.util.Vector;
import com.rhomobile.rhodes.AndroidR;
import com.rhomobile.rhodes.Rhodes;
import com.rhomobile.rhodes.RhodesInstance;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
public class SimpleMainView implements MainView {
private static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT;
private static final int FILL_PARENT = ViewGroup.LayoutParams.FILL_PARENT;
private class ActionBack implements View.OnClickListener {
public void onClick(View v) {
back(0);
}
};
private class ActionForward implements View.OnClickListener {
public void onClick(View v) {
forward(0);
}
};
private class ActionHome implements View.OnClickListener {
public void onClick(View v) {
navigate(RhodesInstance.getInstance().getStartUrl(), 0);
}
};
private class ActionOptions implements View.OnClickListener {
public void onClick(View v) {
navigate(RhodesInstance.getInstance().getOptionsUrl(), 0);
}
};
private class ActionRefresh implements View.OnClickListener {
public void onClick(View v) {
reload(0);
}
};
private class ActionCustomRunnable implements Runnable {
private boolean callback;
private String url;
public ActionCustomRunnable(boolean c, String u) {
callback = c;
url = u;
}
public void run() {
if (callback)
RhodesInstance.getInstance().doRequest(url);
else
navigate(url, 0);
}
};
private class ActionCustom implements View.OnClickListener {
private static final String scheme = "callback:";
private String url;
private boolean callback;
public ActionCustom(String u) {
callback = false;
url = u;
if (url.startsWith(scheme)) {
url = url.substring(scheme.length());
callback = true;
}
url = RhodesInstance.getInstance().normalizeUrl(url);
}
public void onClick(View v) {
Rhodes.performOnUiThread(new ActionCustomRunnable(callback, url), false);
}
};
private LinearLayout view;
private WebView webView;
public View getView() {
return view;
}
@SuppressWarnings("unchecked")
private void init(Vector