From d55019f8bee9adee1e51917165e50bce69f27bb4 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 3 Oct 2018 19:34:11 -0400 Subject: [PATCH 1/5] ios: remove extra blank lines --- src/ios/CDVNotification.m | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m index 89f3d5d2..3b26fe86 100644 --- a/src/ios/CDVNotification.m +++ b/src/ios/CDVNotification.m @@ -39,15 +39,12 @@ @implementation CDVNotification */ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType { - int count = (int)[buttons count]; #ifdef __IPHONE_8_0 if (NSClassFromString(@"UIAlertController")) { - UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.3) { - CGRect alertFrame = [UIScreen mainScreen].applicationFrame; if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { @@ -101,7 +98,6 @@ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons: if ([alertList count]==1) { [self presentAlertcontroller]; } - } else { @@ -116,8 +112,6 @@ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons: alertView.callbackId = callbackId; - - for (int n = 0; n < count; n++) { [alertView addButtonWithTitle:[buttons objectAtIndex:n]]; } @@ -132,7 +126,6 @@ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons: #ifdef __IPHONE_8_0 } #endif - } - (void)alert:(CDVInvokedUrlCommand*)command @@ -239,7 +232,6 @@ -(UIViewController *)getTopPresentedViewController { } -(void)presentAlertcontroller { - __weak CDVNotification* weakNotif = self; [self.getTopPresentedViewController presentViewController:[alertList firstObject] animated:YES completion:^{ [alertList removeObject:[alertList firstObject]]; @@ -247,7 +239,6 @@ -(void)presentAlertcontroller { [weakNotif presentAlertcontroller]; } }]; - } @end From 1ac63b62036e2818a3c6ba740da4d519a58ee71f Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 3 Oct 2018 19:35:02 -0400 Subject: [PATCH 2/5] ios: remove trailing whitespace --- src/ios/CDVNotification.m | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m index 3b26fe86..1ae36356 100644 --- a/src/ios/CDVNotification.m +++ b/src/ios/CDVNotification.m @@ -43,17 +43,17 @@ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons: #ifdef __IPHONE_8_0 if (NSClassFromString(@"UIAlertController")) { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; - + if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.3) { CGRect alertFrame = [UIScreen mainScreen].applicationFrame; - + if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { // swap the values for the app frame since it is now in landscape CGFloat temp = alertFrame.size.width; alertFrame.size.width = alertFrame.size.height; alertFrame.size.height = temp; } - + alertController.view.frame = alertFrame; } @@ -83,18 +83,18 @@ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons: [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId]; }]]; } - + if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) { - + [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.text = defaultText; }]; } - + if(!alertList) alertList = [[NSMutableArray alloc] init]; [alertList addObject:alertController]; - + if ([alertList count]==1) { [self presentAlertcontroller]; } @@ -109,19 +109,19 @@ - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons: delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; - + alertView.callbackId = callbackId; - + for (int n = 0; n < count; n++) { [alertView addButtonWithTitle:[buttons objectAtIndex:n]]; } - + if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) { alertView.alertViewStyle = UIAlertViewStylePlainTextInput; UITextField* textField = [alertView textFieldAtIndex:0]; textField.text = defaultText; } - + [alertView show]; #ifdef __IPHONE_8_0 } From 234611fd7eea7833895c39adf33c41c4629e458b Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 3 Oct 2018 19:47:00 -0400 Subject: [PATCH 3/5] android: remove extra blank line --- src/android/Notification.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/android/Notification.java b/src/android/Notification.java index f19bc888..09ba5bcc 100644 --- a/src/android/Notification.java +++ b/src/android/Notification.java @@ -281,7 +281,6 @@ public void onCancel(DialogInterface dialog) * @param callbackContext The callback context. */ public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final CallbackContext callbackContext) { - final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { From 53c6a34500e807415795570e66978118714743ee Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 3 Oct 2018 19:47:53 -0400 Subject: [PATCH 4/5] android: remove trailing whitespace --- src/android/Notification.java | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/android/Notification.java b/src/android/Notification.java index 09ba5bcc..4c188071 100644 --- a/src/android/Notification.java +++ b/src/android/Notification.java @@ -43,7 +43,7 @@ Licensed to the Apache Software Foundation (ASF) under one /** * This class provides access to notifications on the device. * - * Be aware that this implementation gets called on + * Be aware that this implementation gets called on * navigator.notification.{alert|confirm|prompt}, and that there is a separate * implementation in org.apache.cordova.CordovaChromeClient that gets * called on a simple window.{alert|confirm|prompt}. @@ -51,7 +51,7 @@ Licensed to the Apache Software Foundation (ASF) under one public class Notification extends CordovaPlugin { private static final String LOG_TAG = "Notification"; - + public int confirmResult = -1; public ProgressDialog spinnerDialog = null; public ProgressDialog progressDialog = null; @@ -78,7 +78,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo * be returned in the event of an invalid action. */ if(this.cordova.getActivity().isFinishing()) return true; - + if (action.equals("beep")) { this.beep(args.getLong(0)); } @@ -282,13 +282,13 @@ public void onCancel(DialogInterface dialog) */ public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; - + Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); - - /* CB-11677 - By default, prompt input text color is set according current theme. - But for some android versions is not visible (for example 5.1.1). + + /* CB-11677 - By default, prompt input text color is set according current theme. + But for some android versions is not visible (for example 5.1.1). android.R.color.primary_text_light will make text visible on all versions. */ Resources resources = cordova.getActivity().getResources(); int promptInputTextColor = resources.getColor(android.R.color.primary_text_light); @@ -298,11 +298,11 @@ But for some android versions is not visible (for example 5.1.1). dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(true); - + dlg.setView(promptInput); - + final JSONObject result = new JSONObject(); - + // First button if (buttonLabels.length() > 0) { try { @@ -312,7 +312,7 @@ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex",1); - result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText()); + result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText()); } catch (JSONException e) { LOG.d(LOG_TAG,"JSONException on first button.", e); } @@ -355,7 +355,7 @@ public void onClick(DialogInterface dialog, int which) { try { result.put("buttonIndex",3); result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText()); - } catch (JSONException e) { + } catch (JSONException e) { LOG.d(LOG_TAG,"JSONException on third button.", e); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); @@ -478,7 +478,7 @@ public synchronized void progressStop() { this.progressDialog = null; } } - + @SuppressLint("NewApi") private AlertDialog.Builder createDialog(CordovaInterface cordova) { int currentapiVersion = android.os.Build.VERSION.SDK_INT; @@ -498,7 +498,7 @@ private ProgressDialog createProgressDialog(CordovaInterface cordova) { return new ProgressDialog(cordova.getActivity()); } } - + @SuppressLint("NewApi") private void changeTextDirection(Builder dlg){ int currentapiVersion = android.os.Build.VERSION.SDK_INT; From 3f675af8e8fac8048218be14734faf7abca02acc Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 3 Oct 2018 19:54:41 -0400 Subject: [PATCH 5/5] android: convert tabs to spaces (and space after an if statement) --- src/android/Notification.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/android/Notification.java b/src/android/Notification.java index 4c188071..0a97af0a 100644 --- a/src/android/Notification.java +++ b/src/android/Notification.java @@ -71,13 +71,13 @@ public Notification() { * @return True when the action was valid, false otherwise. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - /* - * Don't run any of these if the current activity is finishing - * in order to avoid android.view.WindowManager$BadTokenException - * crashing the app. Just return true here since false should only - * be returned in the event of an invalid action. - */ - if(this.cordova.getActivity().isFinishing()) return true; + /* + * Don't run any of these if the current activity is finishing + * in order to avoid android.view.WindowManager$BadTokenException + * crashing the app. Just return true here since false should only + * be returned in the event of an invalid action. + */ + if (this.cordova.getActivity().isFinishing()) return true; if (action.equals("beep")) { this.beep(args.getLong(0)); @@ -160,7 +160,7 @@ public void run() { * @param callbackContext The callback context */ public synchronized void alert(final String message, final String title, final String buttonLabel, final CallbackContext callbackContext) { - final CordovaInterface cordova = this.cordova; + final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { @@ -201,7 +201,7 @@ public void onCancel(DialogInterface dialog) * @param callbackContext The callback context. */ public synchronized void confirm(final String message, final String title, final JSONArray buttonLabels, final CallbackContext callbackContext) { - final CordovaInterface cordova = this.cordova; + final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { @@ -272,8 +272,8 @@ public void onCancel(DialogInterface dialog) * Builds and shows a native Android prompt dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The following results are returned to the JavaScript callback identified by callbackId: - * buttonIndex Index number of the button selected - * input1 The text entered in the prompt dialog box + * buttonIndex Index number of the button selected + * input1 The text entered in the prompt dialog box * * @param message The message the dialog should display * @param title The title of the dialog