Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Android: introduce common IRhoConfig and move RE config to separate e…

…xtension
  • Loading branch information...
commit f1bf511e2022cd8a0df63b74d8945f5db17fa60c 1 parent 5bfd2cd
Alexey Tikhvinsky lexis-t authored
5 Rakefile
View
@@ -466,7 +466,10 @@ namespace "config" do
$invalid_license = false
- if $rhoelements_features.length() > 0
+ if $rhoelements_features.length() > 0
+
+ $app_config['extensions'] << 'rhoelements-license'
+
#check for RhoElements gem and license
begin
require "rhoelements"
4 platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java
View
@@ -112,4 +112,8 @@ public boolean onAuthRequired(IRhoExtManager extManager, String type, String url
return res;
}
+ @Override
+ public boolean onNewConfig(IRhoExtManager extManager, IRhoConfig config, String name, boolean res) {
+ return res;
+ }
}
28 platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java
View
@@ -13,22 +13,23 @@
void addRhoListener(IRhoListener listener);
/**
- *
+ * Handler to notify RhoExtManager about new configuration
+ * @param config - IRhoConfig implementation
+ * @param name - configuration name used to identify the config like 'rhoelements' od 'rhoconfig'
*/
+ void setConfig(String name, IRhoConfig config);
+ IRhoConfig getConfig(String name);
+
Context getContext();
-
- /**
- * Web view getter. In case of Motorola WebKit is used it returns object which may be directly casted to NeonEkihView
- * @return Current web view instance from MainView
- */
+
IRhoWebView getWebView();
-
+
/**
* RhodesActivity top level View getter
* @return RhodesActivity top level View
*/
View getTopView();
-
+
/**
*
* @param name - build configuration item name
@@ -54,18 +55,9 @@
void setFullScreen(boolean fullScreen);
void minimizeApp();
void restoreApp();
- //void resizeBrowserWindow(RECT rc);
void zoomPage(float fZoom);
void zoomText(int nZoom);
-
- /**
- * Handler to notify RhoExtManager about new configuration value
- * @param name - configuration parameter name
- * @param value - configuration parameter value
- * @return true if value is processed by RhoExtManager
- */
- boolean onNewConfigValue(String name, String value);
-
+
/**
* Handler to notify RhoExtManager that new configuration is going to apply
* @return true if it is allowed for extension to navigate start page itself
2  platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java
View
@@ -31,5 +31,7 @@
boolean startLocationUpdates(IRhoExtManager extManager, boolean highAccuracy, IRhoWebView ext, boolean res);
boolean stopLocationUpdates(IRhoExtManager extManager, IRhoWebView ext, boolean res);
+ boolean onNewConfig(IRhoExtManager extManager, IRhoConfig config, String name, boolean res);
+
}
42 platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java
View
@@ -3,6 +3,8 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.Map;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -25,7 +27,8 @@
public class RhoExtManagerImpl implements IRhoExtManager {
private static final String TAG = RhoExtManagerImpl.class.getSimpleName();
- private Hashtable<String, IRhoExtension> mExtensions = new Hashtable<String, IRhoExtension>();
+ private LinkedHashMap <String, IRhoExtension> mExtensions = new LinkedHashMap<String, IRhoExtension>();
+ private Map<String, IRhoConfig> mConfigs = new LinkedHashMap<String, IRhoConfig>();
private ArrayList<IRhoListener> mListeners = new ArrayList<IRhoListener>();
private boolean mLogError = false;
private boolean mLogWarning = false;
@@ -61,10 +64,6 @@ public IRhoExtension getExtByName(String strName) {
public void registerExtension(String strName, IRhoExtension ext) {
Logger.T(TAG, "Registering extension: " + strName);
synchronized (mExtensions) {
- if (mExtensions.containsKey(strName)) {
- mExtensions.remove(strName);
- }
-
mExtensions.put(strName, ext);
}
}
@@ -75,7 +74,28 @@ public void addRhoListener(IRhoListener listener) {
mListeners.add(listener);
}
}
-
+
+ @Override
+ public void setConfig(String name, IRhoConfig config) {
+ Logger.T(TAG, "Adding new config: " + name);
+ synchronized(mExtensions) {
+ boolean res = false;
+ for(IRhoExtension ext: mExtensions.values()) {
+ ext.onNewConfig(this, config, name, res);
+ }
+ }
+ synchronized(mConfigs) {
+ mConfigs.put(name, config);
+ }
+ }
+
+ @Override
+ public IRhoConfig getConfig(String name) {
+ synchronized(mConfigs) {
+ return mConfigs.get(name);
+ }
+ }
+
@Override
public Context getContext() {
return ContextFactory.getUiContext();
@@ -212,16 +232,6 @@ public boolean onStartNewConfig() {
return Capabilities.SHARED_RUNTIME_ENABLED;
}
- /**
- * @param name - parameter name
- * @param value - parameter value
- * @return is parameter accepted by rhodes platform
- */
- @Override
- public boolean onNewConfigValue(String name, String value) {
- return false;
- }
-
private String mLicenseToken;
private String mLicenseCompany;
private String mAppName;
1  platform/android/build/RhodesSRC_build.files
View
@@ -100,6 +100,7 @@ platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java
platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java
platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java
platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoListener.java
+platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoConfig.java
platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java
platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java
platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoListener.java
6 platform/android/build/android.rake
View
@@ -1488,12 +1488,7 @@ namespace "build" do
mkdir_p File.join($tmpdir, ext)
- #puts '$$$$$$$$$$$$$$$$$$ START'
- #currentdir = Dir.pwd()
- #Dir.chdir extpath
java_compile(File.join($tmpdir, ext), classpath, [srclist.path])
- #Dir.chdir currentdir
- #puts '$$$$$$$$$$$$$$$$$$ FINISH'
extjar = File.join $app_builddir,'extensions',ext,ext + '.jar'
args = ["cf", extjar, '.']
@@ -1502,6 +1497,7 @@ namespace "build" do
raise "Error creating #{extjar}"
end
$android_jars << extjar
+ classpath += $path_separator + extjar
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.