rhodes 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -0
- data/Manifest.txt +4 -3
- data/bin/upgrade-rhodes-app +1 -0
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/rhom/rhom_object_factory.rb +16 -7
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_Rhodes.h +14 -4
- data/platform/android/Rhodes/jni/src/rhodes.cpp +7 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +7 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +6 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/{MainView.java → mainview/MainView.java} +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +286 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/{TabbedMainView.java → mainview/TabbedMainView.java} +5 -1
- data/platform/android/build/RhodesSRC_build.files +3 -3
- data/platform/android/build/android.rake +1 -0
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +22 -4
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +1 -1
- data/platform/bb/rhodes/src/rhomobile/camera/CameraScreen.java +15 -3
- data/platform/iphone/Classes/WebViewController.m +21 -7
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/rbuild/iphone.rake +36 -28
- data/platform/osx/Rhodes Launcher/launch.rb +21 -14
- data/platform/shared/common/RhodesApp.cpp +7 -0
- data/platform/shared/common/RhodesApp.h +1 -0
- data/platform/shared/ruby/wince/io_wce.c +2 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoRuby.java +2 -1
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +3 -3
- data/platform/shared/sync/SyncEngine.cpp +6 -5
- data/res/build-tools/cygwin1.dll +0 -0
- data/res/build-tools/cygz.dll +0 -0
- data/spec/framework_spec/app/spec/rhom_object_spec.rb +54 -75
- metadata +6 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SimpleMainView.java +0 -67
data/CHANGELOG
CHANGED
data/Manifest.txt
CHANGED
@@ -292,7 +292,9 @@ platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java
|
|
292
292
|
platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java
|
293
293
|
platform/android/Rhodes/src/com/rhomobile/rhodes/HttpLog.java
|
294
294
|
platform/android/Rhodes/src/com/rhomobile/rhodes/Logger.java
|
295
|
-
platform/android/Rhodes/src/com/rhomobile/rhodes/MainView.java
|
295
|
+
platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java
|
296
|
+
platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java
|
297
|
+
platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java
|
296
298
|
platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Annotation.java
|
297
299
|
platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/AnnotationsOverlay.java
|
298
300
|
platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java
|
@@ -307,13 +309,11 @@ platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java
|
|
307
309
|
platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesInstance.java
|
308
310
|
platform/android/Rhodes/src/com/rhomobile/rhodes/RhoLogConf.java
|
309
311
|
platform/android/Rhodes/src/com/rhomobile/rhodes/RingtoneManager.java
|
310
|
-
platform/android/Rhodes/src/com/rhomobile/rhodes/SimpleMainView.java
|
311
312
|
platform/android/Rhodes/src/com/rhomobile/rhodes/socket/RhoSockAddr.java
|
312
313
|
platform/android/Rhodes/src/com/rhomobile/rhodes/socket/RhoSocket.java
|
313
314
|
platform/android/Rhodes/src/com/rhomobile/rhodes/socket/RhoSocketImpl.java
|
314
315
|
platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java
|
315
316
|
platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java
|
316
|
-
platform/android/Rhodes/src/com/rhomobile/rhodes/TabbedMainView.java
|
317
317
|
platform/android/Rhodes/src/com/rhomobile/rhodes/ui/AboutDialog.java
|
318
318
|
platform/android/Rhodes/src/com/rhomobile/rhodes/ui/LogOptionsDialog.java
|
319
319
|
platform/android/Rhodes/src/com/rhomobile/rhodes/ui/LogViewDialog.java
|
@@ -3263,6 +3263,7 @@ rakefile.rb
|
|
3263
3263
|
README.textile
|
3264
3264
|
res/build-tools/build_inf.js
|
3265
3265
|
res/build-tools/cygwin1.dll
|
3266
|
+
res/build-tools/cygz.dll
|
3266
3267
|
res/build-tools/db/syncdb.schema
|
3267
3268
|
res/build-tools/db/syncdb.triggers
|
3268
3269
|
res/build-tools/insertRhoBundle2pkg.rb
|
data/bin/upgrade-rhodes-app
CHANGED
data/lib/framework/rhodes.rb
CHANGED
@@ -62,6 +62,10 @@ module Rhom
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def to_s
|
66
|
+
@vars.to_s if @vars
|
67
|
+
end
|
68
|
+
|
65
69
|
def method_missing(name, *args)
|
66
70
|
unless name == Fixnum
|
67
71
|
varname = name.to_s.gsub(/\=/,"")
|
@@ -507,7 +511,7 @@ module Rhom
|
|
507
511
|
#new_obj.vars.merge!(rowhash)
|
508
512
|
|
509
513
|
rowhash.each do |attrName, attrVal|
|
510
|
-
new_obj.vars.merge!( { attrName.to_sym()=>attrVal } )
|
514
|
+
new_obj.vars.merge!( { attrName.to_sym()=>attrVal } ) if attrVal
|
511
515
|
end
|
512
516
|
|
513
517
|
ret_list << new_obj
|
@@ -529,10 +533,6 @@ module Rhom
|
|
529
533
|
}
|
530
534
|
end
|
531
535
|
|
532
|
-
if order_attr && limit
|
533
|
-
ret_list = ret_list.slice(offset,limit)
|
534
|
-
end
|
535
|
-
|
536
536
|
return list.length if args.first == :count
|
537
537
|
if args.first == :first || args.first.is_a?(String)
|
538
538
|
return ret_list.length > 0 ? ret_list[0] : nil
|
@@ -733,8 +733,17 @@ module Rhom
|
|
733
733
|
::Rhom::RhomDbAdapter.start_transaction
|
734
734
|
|
735
735
|
result = ::Rhom::RhomDbAdapter.execute_sql("SELECT object FROM object_values WHERE object=? AND source_id=? LIMIT 1 OFFSET 0",obj,nSrcID)
|
736
|
-
|
737
|
-
|
736
|
+
if result && result.length > 0
|
737
|
+
resUpdateType = ::Rhom::RhomDbAdapter.select_from_table('changed_values', 'update_type', {"object"=>obj, "source_id"=>nSrcID, 'sent'=>0})
|
738
|
+
if resUpdateType && resUpdateType.length > 0
|
739
|
+
update_type = resUpdateType[0]['update_type']
|
740
|
+
else
|
741
|
+
update_type = self.get_update_type_by_source('update')
|
742
|
+
end
|
743
|
+
else
|
744
|
+
update_type = self.get_update_type_by_source('create')
|
745
|
+
end
|
746
|
+
|
738
747
|
self.vars.each do |key_a,value|
|
739
748
|
key = key_a.to_s
|
740
749
|
next if ::Rhom::RhomObject.method_name_reserved?(key)
|
data/lib/framework/version.rb
CHANGED
data/lib/rhodes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
3
3
|
package="com.rhomobile.rhodes"
|
4
|
-
android:versionCode="
|
5
|
-
android:versionName="1.5.
|
4
|
+
android:versionCode="22"
|
5
|
+
android:versionName="1.5.3">
|
6
6
|
<uses-sdk android:minSdkVersion="3" />
|
7
7
|
<application android:icon="@drawable/icon"
|
8
8
|
android:multiprocess="true"
|
@@ -7,10 +7,12 @@
|
|
7
7
|
#ifdef __cplusplus
|
8
8
|
extern "C" {
|
9
9
|
#endif
|
10
|
-
#undef
|
11
|
-
#define
|
12
|
-
#undef
|
13
|
-
#define
|
10
|
+
#undef com_rhomobile_rhodes_Rhodes_RHO_SPLASH_VIEW
|
11
|
+
#define com_rhomobile_rhodes_Rhodes_RHO_SPLASH_VIEW 1L
|
12
|
+
#undef com_rhomobile_rhodes_Rhodes_RHO_MAIN_VIEW
|
13
|
+
#define com_rhomobile_rhodes_Rhodes_RHO_MAIN_VIEW 2L
|
14
|
+
#undef com_rhomobile_rhodes_Rhodes_RHO_TOOLBAR_VIEW
|
15
|
+
#define com_rhomobile_rhodes_Rhodes_RHO_TOOLBAR_VIEW 3L
|
14
16
|
/*
|
15
17
|
* Class: com_rhomobile_rhodes_Rhodes
|
16
18
|
* Method: createRhodesApp
|
@@ -83,6 +85,14 @@ JNIEXPORT jstring JNICALL Java_com_rhomobile_rhodes_Rhodes_getAppBackUrl
|
|
83
85
|
JNIEXPORT jstring JNICALL Java_com_rhomobile_rhodes_Rhodes_normalizeUrl
|
84
86
|
(JNIEnv *, jobject, jstring);
|
85
87
|
|
88
|
+
/*
|
89
|
+
* Class: com_rhomobile_rhodes_Rhodes
|
90
|
+
* Method: doRequest
|
91
|
+
* Signature: (Ljava/lang/String;)V
|
92
|
+
*/
|
93
|
+
JNIEXPORT void JNICALL Java_com_rhomobile_rhodes_Rhodes_doRequest
|
94
|
+
(JNIEnv *, jobject, jstring);
|
95
|
+
|
86
96
|
/*
|
87
97
|
* Class: com_rhomobile_rhodes_Rhodes
|
88
98
|
* Method: makeLink
|
@@ -354,6 +354,13 @@ RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_Rhodes_getAppBackUrl
|
|
354
354
|
return rho_cast<jstring>(s);
|
355
355
|
}
|
356
356
|
|
357
|
+
RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_Rhodes_doRequest
|
358
|
+
(JNIEnv *env, jobject, jstring strUrl)
|
359
|
+
{
|
360
|
+
std::string const &url = rho_cast<std::string>(strUrl);
|
361
|
+
rho_net_request(url.c_str());
|
362
|
+
}
|
363
|
+
|
357
364
|
RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_Rhodes_normalizeUrl
|
358
365
|
(JNIEnv *, jobject, jstring strUrl)
|
359
366
|
{
|
@@ -22,6 +22,10 @@ package com.rhomobile.rhodes;
|
|
22
22
|
|
23
23
|
import java.util.Vector;
|
24
24
|
|
25
|
+
import com.rhomobile.rhodes.mainview.MainView;
|
26
|
+
import com.rhomobile.rhodes.mainview.SimpleMainView;
|
27
|
+
import com.rhomobile.rhodes.mainview.TabbedMainView;
|
28
|
+
|
25
29
|
public class NativeBar {
|
26
30
|
|
27
31
|
private static final String TAG = "NativeBar";
|
@@ -46,10 +50,11 @@ public class NativeBar {
|
|
46
50
|
|
47
51
|
switch (type) {
|
48
52
|
case NOBAR_TYPE:
|
49
|
-
case TOOLBAR_TYPE:
|
50
|
-
// There is no toolbar on android so TOOLBAR_TYPE means exactly NOBAR_TYPE
|
51
53
|
v = new SimpleMainView();
|
52
54
|
break;
|
55
|
+
case TOOLBAR_TYPE:
|
56
|
+
v = new SimpleMainView(params);
|
57
|
+
break;
|
53
58
|
case TABBAR_TYPE:
|
54
59
|
v = new TabbedMainView(params);
|
55
60
|
break;
|
@@ -27,6 +27,8 @@ import java.util.Locale;
|
|
27
27
|
|
28
28
|
import com.rhomobile.rhodes.Utils.AssetsSource;
|
29
29
|
import com.rhomobile.rhodes.Utils.FileSource;
|
30
|
+
import com.rhomobile.rhodes.mainview.MainView;
|
31
|
+
import com.rhomobile.rhodes.mainview.SimpleMainView;
|
30
32
|
import com.rhomobile.rhodes.ui.AboutDialog;
|
31
33
|
import com.rhomobile.rhodes.ui.LogOptionsDialog;
|
32
34
|
import com.rhomobile.rhodes.ui.LogViewDialog;
|
@@ -71,6 +73,7 @@ public class Rhodes extends Activity {
|
|
71
73
|
|
72
74
|
public static final int RHO_SPLASH_VIEW = 1;
|
73
75
|
public static final int RHO_MAIN_VIEW = 2;
|
76
|
+
public static final int RHO_TOOLBAR_VIEW = 3;
|
74
77
|
|
75
78
|
public static int WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
76
79
|
public static int WINDOW_MASK = WindowManager.LayoutParams.FLAG_FULLSCREEN;
|
@@ -111,6 +114,8 @@ public class Rhodes extends Activity {
|
|
111
114
|
|
112
115
|
public native String normalizeUrl(String url);
|
113
116
|
|
117
|
+
public native void doRequest(String url);
|
118
|
+
|
114
119
|
public native static void makeLink(String src, String dst);
|
115
120
|
|
116
121
|
private void initRootPath() {
|
@@ -539,12 +544,7 @@ public class Rhodes extends Activity {
|
|
539
544
|
}
|
540
545
|
|
541
546
|
private void goBack() {
|
542
|
-
|
543
|
-
int activeTab = mainView.activeTab();
|
544
|
-
if (backUrl == null || backUrl.length() == 0)
|
545
|
-
mainView.back(activeTab);
|
546
|
-
else
|
547
|
-
mainView.navigate(backUrl, activeTab);
|
547
|
+
mainView.back(mainView.activeTab());
|
548
548
|
}
|
549
549
|
|
550
550
|
private void goForward() {
|
data/platform/android/Rhodes/src/com/rhomobile/rhodes/{MainView.java → mainview/MainView.java}
RENAMED
@@ -18,7 +18,7 @@
|
|
18
18
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
============================================================================
|
20
20
|
*/
|
21
|
-
package com.rhomobile.rhodes;
|
21
|
+
package com.rhomobile.rhodes.mainview;
|
22
22
|
|
23
23
|
import android.view.View;
|
24
24
|
|
@@ -0,0 +1,286 @@
|
|
1
|
+
/*
|
2
|
+
============================================================================
|
3
|
+
Author : Dmitry Moskalchuk
|
4
|
+
Version : 1.5
|
5
|
+
Copyright : Copyright (C) 2008 Rhomobile. All rights reserved.
|
6
|
+
|
7
|
+
This program is free software: you can redistribute it and/or modify
|
8
|
+
it under the terms of the GNU General Public License as published by
|
9
|
+
the Free Software Foundation, either version 3 of the License, or
|
10
|
+
(at your option) any later version.
|
11
|
+
|
12
|
+
This program is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
GNU General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU General Public License
|
18
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
============================================================================
|
20
|
+
*/
|
21
|
+
package com.rhomobile.rhodes.mainview;
|
22
|
+
|
23
|
+
import java.util.Map;
|
24
|
+
import java.util.Vector;
|
25
|
+
|
26
|
+
import com.rhomobile.rhodes.AndroidR;
|
27
|
+
import com.rhomobile.rhodes.Rhodes;
|
28
|
+
import com.rhomobile.rhodes.RhodesInstance;
|
29
|
+
|
30
|
+
import android.graphics.Bitmap;
|
31
|
+
import android.graphics.BitmapFactory;
|
32
|
+
import android.graphics.Color;
|
33
|
+
import android.graphics.drawable.BitmapDrawable;
|
34
|
+
import android.graphics.drawable.Drawable;
|
35
|
+
import android.view.Gravity;
|
36
|
+
import android.view.View;
|
37
|
+
import android.view.ViewGroup;
|
38
|
+
import android.webkit.WebView;
|
39
|
+
import android.widget.Button;
|
40
|
+
import android.widget.ImageButton;
|
41
|
+
import android.widget.LinearLayout;
|
42
|
+
|
43
|
+
public class SimpleMainView implements MainView {
|
44
|
+
|
45
|
+
private static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT;
|
46
|
+
private static final int FILL_PARENT = ViewGroup.LayoutParams.FILL_PARENT;
|
47
|
+
|
48
|
+
private class ActionBack implements View.OnClickListener {
|
49
|
+
public void onClick(View v) {
|
50
|
+
back(0);
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
private class ActionForward implements View.OnClickListener {
|
55
|
+
public void onClick(View v) {
|
56
|
+
forward(0);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
private class ActionHome implements View.OnClickListener {
|
61
|
+
public void onClick(View v) {
|
62
|
+
navigate(RhodesInstance.getInstance().getStartUrl(), 0);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
private class ActionOptions implements View.OnClickListener {
|
67
|
+
public void onClick(View v) {
|
68
|
+
navigate(RhodesInstance.getInstance().getOptionsUrl(), 0);
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
private class ActionRefresh implements View.OnClickListener {
|
73
|
+
public void onClick(View v) {
|
74
|
+
reload(0);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
private class ActionCustomRunnable implements Runnable {
|
79
|
+
private boolean callback;
|
80
|
+
private String url;
|
81
|
+
public ActionCustomRunnable(boolean c, String u) {
|
82
|
+
callback = c;
|
83
|
+
url = u;
|
84
|
+
}
|
85
|
+
|
86
|
+
public void run() {
|
87
|
+
if (callback)
|
88
|
+
RhodesInstance.getInstance().doRequest(url);
|
89
|
+
else
|
90
|
+
navigate(url, 0);
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
private class ActionCustom implements View.OnClickListener {
|
95
|
+
private static final String scheme = "callback:";
|
96
|
+
private String url;
|
97
|
+
private boolean callback;
|
98
|
+
|
99
|
+
public ActionCustom(String u) {
|
100
|
+
callback = false;
|
101
|
+
url = u;
|
102
|
+
if (url.startsWith(scheme)) {
|
103
|
+
url = url.substring(scheme.length());
|
104
|
+
callback = true;
|
105
|
+
}
|
106
|
+
url = RhodesInstance.getInstance().normalizeUrl(url);
|
107
|
+
}
|
108
|
+
|
109
|
+
public void onClick(View v) {
|
110
|
+
Rhodes.performOnUiThread(new ActionCustomRunnable(callback, url), false);
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
private LinearLayout view;
|
115
|
+
private WebView webView;
|
116
|
+
|
117
|
+
public View getView() {
|
118
|
+
return view;
|
119
|
+
}
|
120
|
+
|
121
|
+
@SuppressWarnings("unchecked")
|
122
|
+
private void init(Vector<Object> params) {
|
123
|
+
Rhodes r = RhodesInstance.getInstance();
|
124
|
+
|
125
|
+
view = new LinearLayout(r);
|
126
|
+
view.setOrientation(LinearLayout.VERTICAL);
|
127
|
+
view.setGravity(Gravity.BOTTOM);
|
128
|
+
view.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT));
|
129
|
+
view.setId(Rhodes.RHO_MAIN_VIEW);
|
130
|
+
|
131
|
+
webView = r.createWebView();
|
132
|
+
view.addView(webView, new LinearLayout.LayoutParams(FILL_PARENT, 0, 1));
|
133
|
+
|
134
|
+
LinearLayout bottom = new LinearLayout(r);
|
135
|
+
bottom.setOrientation(LinearLayout.HORIZONTAL);
|
136
|
+
bottom.setBackgroundColor(Color.GRAY);
|
137
|
+
bottom.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0));
|
138
|
+
view.addView(bottom);
|
139
|
+
|
140
|
+
if (params != null) {
|
141
|
+
LinearLayout left = new LinearLayout(r);
|
142
|
+
left.setGravity(Gravity.LEFT);
|
143
|
+
left.setOrientation(LinearLayout.HORIZONTAL);
|
144
|
+
left.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 1));
|
145
|
+
bottom.addView(left);
|
146
|
+
|
147
|
+
LinearLayout right = new LinearLayout(r);
|
148
|
+
right.setGravity(Gravity.RIGHT);
|
149
|
+
right.setOrientation(LinearLayout.HORIZONTAL);
|
150
|
+
right.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT, 1));
|
151
|
+
bottom.addView(right);
|
152
|
+
|
153
|
+
LinearLayout current = left;
|
154
|
+
|
155
|
+
String rootPath = r.getRootPath() + "/apps/";
|
156
|
+
|
157
|
+
for (int i = 0, lim = params.size(); i < lim; ++i) {
|
158
|
+
Object param = params.elementAt(i);
|
159
|
+
if (!(param instanceof Map<?,?>))
|
160
|
+
throw new IllegalArgumentException("Hash expected");
|
161
|
+
|
162
|
+
Map<Object, Object> hash = (Map<Object, Object>)param;
|
163
|
+
|
164
|
+
Object actionObj = hash.get("action");
|
165
|
+
if (actionObj == null || !(actionObj instanceof String))
|
166
|
+
throw new IllegalArgumentException("'action' should be String");
|
167
|
+
|
168
|
+
String action = (String)actionObj;
|
169
|
+
if (action.length() == 0)
|
170
|
+
throw new IllegalArgumentException("'action' should not be empty");
|
171
|
+
|
172
|
+
Drawable icon = null;
|
173
|
+
String label = null;
|
174
|
+
|
175
|
+
View.OnClickListener onClick = null;
|
176
|
+
if (action.equalsIgnoreCase("back")) {
|
177
|
+
icon = r.getResources().getDrawable(AndroidR.drawable.back);
|
178
|
+
onClick = new ActionBack();
|
179
|
+
}
|
180
|
+
else if (action.equalsIgnoreCase("forward")) {
|
181
|
+
icon = r.getResources().getDrawable(AndroidR.drawable.next);
|
182
|
+
onClick = new ActionForward();
|
183
|
+
}
|
184
|
+
else if (action.equalsIgnoreCase("home")) {
|
185
|
+
icon = r.getResources().getDrawable(AndroidR.drawable.home);
|
186
|
+
onClick = new ActionHome();
|
187
|
+
}
|
188
|
+
else if (action.equalsIgnoreCase("options")) {
|
189
|
+
icon = r.getResources().getDrawable(AndroidR.drawable.options);
|
190
|
+
onClick = new ActionOptions();
|
191
|
+
}
|
192
|
+
else if (action.equalsIgnoreCase("refresh")) {
|
193
|
+
icon = r.getResources().getDrawable(AndroidR.drawable.refresh);
|
194
|
+
onClick = new ActionRefresh();
|
195
|
+
}
|
196
|
+
else if (action.equalsIgnoreCase("separator")) {
|
197
|
+
current = right;
|
198
|
+
continue;
|
199
|
+
}
|
200
|
+
|
201
|
+
Object iconObj = hash.get("icon");
|
202
|
+
if (iconObj != null) {
|
203
|
+
if (!(iconObj instanceof String))
|
204
|
+
throw new IllegalArgumentException("'icon' should be String");
|
205
|
+
String iconPath = rootPath + (String)iconObj;
|
206
|
+
Bitmap bitmap = BitmapFactory.decodeFile(iconPath);
|
207
|
+
if (bitmap != null)
|
208
|
+
icon = new BitmapDrawable(bitmap);
|
209
|
+
}
|
210
|
+
|
211
|
+
if (icon == null) {
|
212
|
+
Object labelObj = hash.get("label");
|
213
|
+
if (labelObj == null || !(labelObj instanceof String))
|
214
|
+
throw new IllegalArgumentException("'label' should be String");
|
215
|
+
label = (String)labelObj;
|
216
|
+
}
|
217
|
+
|
218
|
+
if (icon == null && label == null)
|
219
|
+
throw new IllegalArgumentException("One of 'icon' or 'label' should be specified");
|
220
|
+
|
221
|
+
View button = null;
|
222
|
+
if (icon != null) {
|
223
|
+
ImageButton btn = new ImageButton(r);
|
224
|
+
btn.setImageDrawable(icon);
|
225
|
+
button = btn;
|
226
|
+
}
|
227
|
+
else {
|
228
|
+
Button btn = new Button(r);
|
229
|
+
btn.setText(label);
|
230
|
+
button = btn;
|
231
|
+
}
|
232
|
+
|
233
|
+
if (button == null)
|
234
|
+
continue;
|
235
|
+
|
236
|
+
if (onClick == null)
|
237
|
+
onClick = new ActionCustom(action);
|
238
|
+
|
239
|
+
button.setOnClickListener(onClick);
|
240
|
+
button.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
|
241
|
+
current.addView(button);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
public SimpleMainView() {
|
247
|
+
init(null);
|
248
|
+
}
|
249
|
+
|
250
|
+
public SimpleMainView(Vector<Object> params) {
|
251
|
+
init(params);
|
252
|
+
}
|
253
|
+
|
254
|
+
public void back(int index) {
|
255
|
+
String backUrl = RhodesInstance.getInstance().getAppBackUrl();
|
256
|
+
if (backUrl == null || backUrl.length() == 0)
|
257
|
+
webView.goBack();
|
258
|
+
else
|
259
|
+
navigate(backUrl, index);
|
260
|
+
}
|
261
|
+
|
262
|
+
public void forward(int index) {
|
263
|
+
webView.goForward();
|
264
|
+
}
|
265
|
+
|
266
|
+
public void navigate(String url, int index) {
|
267
|
+
webView.loadUrl(url);
|
268
|
+
}
|
269
|
+
|
270
|
+
public void reload(int index) {
|
271
|
+
webView.reload();
|
272
|
+
}
|
273
|
+
|
274
|
+
public String currentLocation(int index) {
|
275
|
+
return webView.getUrl();
|
276
|
+
}
|
277
|
+
|
278
|
+
public void switchTab(int index) {
|
279
|
+
// Nothing
|
280
|
+
}
|
281
|
+
|
282
|
+
public int activeTab() {
|
283
|
+
return 0;
|
284
|
+
}
|
285
|
+
|
286
|
+
}
|