cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: [Android] Unbreak API level < 14
Date Tue, 07 Oct 2014 20:01:09 GMT
Repository: cordova-plugin-dialogs
Updated Branches:
  refs/heads/master 81339a61d -> 4cfe290b2


[Android] Unbreak API level < 14

< API 11 for AlertDialog.Builder
< API 14 for ProgressDialog

github: close #31


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/4cfe290b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/4cfe290b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/4cfe290b

Branch: refs/heads/master
Commit: 4cfe290b2a3e8f0aafb71a1ff4fbee4b710c8749
Parents: 81339a6
Author: miqmago <miqmago@users.noreply.github.com>
Authored: Thu Sep 4 18:41:38 2014 +0200
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Oct 7 15:59:59 2014 -0400

----------------------------------------------------------------------
 src/android/Notification.java | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/4cfe290b/src/android/Notification.java
----------------------------------------------------------------------
diff --git a/src/android/Notification.java b/src/android/Notification.java
index 1b05dba..d3e3ba4 100755
--- a/src/android/Notification.java
+++ b/src/android/Notification.java
@@ -25,6 +25,8 @@ import org.apache.cordova.PluginResult;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
+
+import android.annotation.SuppressLint;
 import android.app.AlertDialog;
 import android.app.ProgressDialog;
 import android.content.DialogInterface;
@@ -157,7 +159,7 @@ public class Notification extends CordovaPlugin {
         Runnable runnable = new Runnable() {
             public void run() {
 
-                AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
+                AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
                 dlg.setMessage(message);
                 dlg.setTitle(title);
                 dlg.setCancelable(true);
@@ -200,7 +202,7 @@ public class Notification extends CordovaPlugin {
 
         Runnable runnable = new Runnable() {
             public void run() {
-                AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
+                AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
                 dlg.setMessage(message);
                 dlg.setTitle(title);
                 dlg.setCancelable(true);
@@ -280,7 +282,7 @@ public class Notification extends CordovaPlugin {
             public void run() {
                 final EditText promptInput =  new EditText(cordova.getActivity());
                 promptInput.setHint(defaultText);
-                AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
+                AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
                 dlg.setMessage(message);
                 dlg.setTitle(title);
                 dlg.setCancelable(true);
@@ -409,7 +411,7 @@ public class Notification extends CordovaPlugin {
         final CordovaInterface cordova = this.cordova;
         Runnable runnable = new Runnable() {
             public void run() {
-                notification.progressDialog = new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
+                notification.progressDialog = createProgressDialog(cordova); // new ProgressDialog(cordova.getActivity(),
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
                 notification.progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                 notification.progressDialog.setTitle(title);
                 notification.progressDialog.setMessage(message);
@@ -448,4 +450,24 @@ public class Notification extends CordovaPlugin {
             this.progressDialog = null;
         }
     }
+    
+    @SuppressLint("NewApi")
+    private AlertDialog.Builder createDialog(CordovaInterface cordova) {
+        int currentapiVersion = android.os.Build.VERSION.SDK_INT;
+        if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
+            return new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
+        } else {
+            return new AlertDialog.Builder(cordova.getActivity());
+        }
+    }
+
+    @SuppressLint("InlinedApi")
+    private ProgressDialog createProgressDialog(CordovaInterface cordova) {
+        int currentapiVersion = android.os.Build.VERSION.SDK_INT;
+        if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+            return new ProgressDialog(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
+        } else {
+            return new ProgressDialog(cordova.getActivity());
+        }
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message