cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mrbil...@apache.org
Subject git commit: Check for setTextDirection API level
Date Thu, 16 Oct 2014 19:03:40 GMT
Repository: cordova-plugin-dialogs
Updated Branches:
  refs/heads/master 27abe2857 -> 23bebf96f


Check for setTextDirection API level


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/23bebf96
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/23bebf96
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/23bebf96

Branch: refs/heads/master
Commit: 23bebf96f7a3388c7483afc0091faecf943692d3
Parents: 27abe28
Author: mbillau <mike.billau@gmail.com>
Authored: Thu Oct 16 14:28:52 2014 -0400
Committer: mbillau <mike.billau@gmail.com>
Committed: Thu Oct 16 14:28:52 2014 -0400

----------------------------------------------------------------------
 src/android/Notification.java | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/23bebf96/src/android/Notification.java
----------------------------------------------------------------------
diff --git a/src/android/Notification.java b/src/android/Notification.java
index c01f35e..3bc3cee 100755
--- a/src/android/Notification.java
+++ b/src/android/Notification.java
@@ -28,6 +28,7 @@ import org.json.JSONObject;
 
 import android.annotation.SuppressLint;
 import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
 import android.app.ProgressDialog;
 import android.content.DialogInterface;
 import android.media.Ringtone;
@@ -178,10 +179,7 @@ public class Notification extends CordovaPlugin {
                     }
                 });
 
-                dlg.create();
-                AlertDialog dialog =  dlg.show();
-                TextView messageview = (TextView)dialog.findViewById(android.R.id.message);
-                messageview.setTextDirection(android.view.View.TEXT_DIRECTION_LOCALE);
+                changeTextDirection(dlg);
             };
         };
         this.cordova.getActivity().runOnUiThread(runnable);
@@ -253,10 +251,7 @@ public class Notification extends CordovaPlugin {
                     }
                 });
 
-                dlg.create();
-                AlertDialog dialog =  dlg.show();
-                TextView messageview = (TextView)dialog.findViewById(android.R.id.message);
-                messageview.setTextDirection(android.view.View.TEXT_DIRECTION_LOCALE);
+                changeTextDirection(dlg);
             };
         };
         this.cordova.getActivity().runOnUiThread(runnable);
@@ -352,10 +347,7 @@ public class Notification extends CordovaPlugin {
                     }
                 });
 
-                dlg.create();
-                AlertDialog dialog =  dlg.show();
-                TextView messageview = (TextView)dialog.findViewById(android.R.id.message);
-                messageview.setTextDirection(android.view.View.TEXT_DIRECTION_LOCALE);
+                changeTextDirection(dlg);
             };
         };
         this.cordova.getActivity().runOnUiThread(runnable);
@@ -477,4 +469,15 @@ public class Notification extends CordovaPlugin {
             return new ProgressDialog(cordova.getActivity());
         }
     }
+    
+    @SuppressLint("NewApi")
+    private void changeTextDirection(Builder dlg){
+        int currentapiVersion = android.os.Build.VERSION.SDK_INT;
+        dlg.create();
+        AlertDialog dialog =  dlg.show();
+        if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
+            TextView messageview = (TextView)dialog.findViewById(android.R.id.message);
+            messageview.setTextDirection(android.view.View.TEXT_DIRECTION_LOCALE);
+        }
+    }
 }


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


Mime
View raw message