initialxy / cordova-plugin-themeablebrowser

Fork of org.apache.cordova.inappbrowser in an attempt to make it a bit more themeable and configurable to add some custom actions.
Apache License 2.0
294 stars 221 forks source link

about the "Life Circle" problem #32

Closed bau720123 closed 8 years ago

bau720123 commented 8 years ago

hi @initialxy I am using Android 4.4.2 and iOS 8.3 with your latest plugin version in npm about the "Life Circle" problem I don't know how to explain it anyway,see the code first,you can directly use it

function checkThemeablebrowser() 
{
 cordova.ThemeableBrowser.open('http://yourdomain', '_blank',
 {
  statusbar: 
  {
  color: '#000'
  },
  toolbar: 
  {
  height: 44,
  color: '#f0f0f0ff',
  //image: ''
  },
  title:
  {
  color: '#003264ff',
  //staticText: 'a text',
  showPageTitle: true
  },
  closeButton: 
  {
  wwwImage: 'images/close.png',
  wwwImagePressed: 'images/close_pressed.png',
  wwwImageDensity: 2,
  align: 'left',
  event: 'closePressed'
  },
  backButton: 
  {
  wwwImage: 'images/back.png',
  wwwImagePressed: 'images/back_pressed.png',
  wwwImageDensity: 2,
  align: 'left',
  event: 'backPressed'
  },
  backButtonCanClose: false, 
  forwardButton: 
  {
  wwwImage: 'images/forward.png',
  wwwImagePressed: 'images/forward_pressed.png',
  wwwImageDensity: 2,
  align: 'left',
  event: 'forwardPressed'
  },
  customButtons: 
  [
   {
   wwwImage: 'images/share.png',
   wwwImagePressed: 'images/share_pressed.png',
   wwwImageDensity: 2,
   align: 'right',
   event: 'sharePressed'
   }
  ],
  menu: 
  {
  title: 'title',
  cancel: 'cancel',
  wwwImage: 'images/menu.png',
  wwwImagePressed: 'images/menu_pressed.png',
  wwwImageDensity: 2,
  align: 'right',
   items: 
   [
    {
    event: 'helloPressed',
    label: 'helloWorld!'
    },
    {
    event: 'testPressed',
    label: 'test!'
    }
   ]
  }
})
  .addEventListener('closePressed', function(e)
  {
  alert('closePressed!');
  navigator.notification.alert("closePressed!", null, 'title', 'ok');
  })
  .addEventListener('backPressed', function(e)
  {
  alert('backPressed!');
  navigator.notification.alert("backPressed!", null, 'title', 'ok');
  })
  .addEventListener('forwardPressed', function(e)
  {
  alert('forwardPressed!');
  navigator.notification.alert("forwardPressed!", null, 'title', 'ok');
  })
  .addEventListener('sharePressed', function(e)
  {
  alert(e.url);
  navigator.notification.alert(e.url, null, 'title', 'ok');
  })
  .addEventListener('helloPressed', function(e)
  {
  alert('helloPressed!');
  navigator.notification.alert("helloPressed!", null, 'title', 'ok');
  })
  .addEventListener(cordova.ThemeableBrowser.EVT_ERR, function(e)
  {
  alert('EVT_ERR:' + e.message);
  navigator.notification.alert(e.message, null, endMessage_title, 'title', 'ok');
  })
  .addEventListener(cordova.ThemeableBrowser.EVT_WRN, function(e)
  {
  alert('EVT_WRN:' + e.message);
  navigator.notification.alert(e.message, null, endMessage_title, 'title', 'ok');
  });
}

these are my testing Process

when the "closePressed" trigger
in iOS:the "alert" and the "navigator.notification.alert" can also trigger
in Android:never trigger One of them

when the "backPressed" trigger
in iOS:only "alert" can be trigger
in Android:never trigger One of them

when the "forwardPressed" trigger
in iOS:only "alert" can be trigger
in Android:never trigger One of them

when the "sharePressed" trigger
in iOS:only "alert" can be trigger
in Android:the "alert" and the "navigator.notification.alert" can also trigger

when I click the "menu" icon,the "menu" will show,at the moment...
in iOS:only the "alert" with "EVT_WRN" can be trigger
in Android:never trigger One of them

when the "menu" shown,for example that I click the "hello world" item
in iOS:only "alert" can be trigger
in Android:the "alert" and the "navigator.notification.alert" can also trigger

when the "menu" shown
the menu will in the screen bottom position (ipad mini)
is it normal ? (iphone not try yet)
maybe the center position is more a correct "default position" ?

I know the "navigator.notification.alert" seem phonegap's problem but really don't know,why the pure "alert" and phonegap's "navigator.notification.alert" sometimes in A situation but sometimes in B situation ?? @_@

initialxy commented 8 years ago

Thanks for reporting this. There is a bug with event emitter on Android and the menu dialog is supposed to be aligned directly under the menu button. I will investigate these.

However navigator.notification.alert works fine for me. Did you make sure to install Cordova's org.apache.cordova.dialogs plugin?

bau720123 commented 8 years ago

hi @initialxy thanks for your reply well... I do not use "org.apache.cordova.dialogs" for a long time ago,it is deprecated in fact,org.* is all drprecated maybe you can see this http://cordova.apache.org/announcements/2015/04/21/plugins-release-and-move-to-npm.html

for now I am using "cordova-plugin-dialogs" 1.1.1 latest verison from npm https://www.npmjs.com/package/cordova-plugin-dialogs https://github.com/apache/cordova-plugin-dialogs

I am very sure "cordova-plugin-dialogs" work well (if I just only "cordova-plugin-dialogs") but just when use "cordova-plugin-dialogs" + your plugin => will have some problem (Just like those described above testing process) not only navigator.notification.alert but also alert

initialxy commented 8 years ago

Please try latest version 0.2.12, and let me know if that fixes this problem.

bau720123 commented 8 years ago

hi @initialxy problem solved perfect in Android,but still have some problem in iOS 8.4 (it seem like the same issue)

when the "backPressed" and "forwardPressed" trigger
the "navigator.notification.alert" not trigger in iOS

when the "sharePressed" trigger
the "navigator.notification.alert" not trigger in iOS

when I click the "menu" icon,the "menu" will show,at the moment...
the "navigator.notification.alert" and "EVT_WRN" not trigger in iOS

when the "menu" shown,for example that I click the "hello world" item...
the "navigator.notification.alert" and "EVT_WRN" not trigger in iOS
initialxy commented 8 years ago

After some debugging, I can conclude that this is a bug on cordova-plugin-dialogs. What's happening here is that iOS only allows you to stack a new UIViewController on top of the top most UIViewController. But cordova-plugin-dialogs does not check for the top most UIViewController and just stacks on top of the app. So when themeable browser is being displayed, themeable browser is now on top of the app and is the top most UIViewController, therefore iOS did not allow cordova-plugin-dialog to be displayed.

There is already a pull request on cordova-plugin-dialogs' repo that could fix this case. We have to wait for an update on their end.

initialxy commented 8 years ago

I have opened a separate issue on Cordova's JIRA tracker for this use case. https://issues.apache.org/jira/browse/CB-9441

bau720123 commented 8 years ago

thnaks @initialxy let us to waiting for the official's reply

bau720123 commented 8 years ago

hi @initialxy seem "CM-9441" have some jcesarmobile's reply is it useful for you ?

bau720123 commented 8 years ago

hi @initialxy any idea about "CB-9441" ?

initialxy commented 8 years ago

Sorry I've been extremely busy since the last couple of month. Yes, @jcesarmobile generously tested his pull request for this issue, and he claims it will solve this issue along with it, which I agree. This issue is entirely on cordova-plugin-dialogs. Please keep track of the above mentioned pull request, the related issue on their bug tracker as well as their release.

Judging by what I can see, unfortunately Cordova devs haven't accepted the pull request yet.

bau720123 commented 8 years ago

thanks @initialxy reply ok...let us still keep track

jcesarmobile commented 8 years ago

It's waiting for review

bau720123 commented 8 years ago

thanks @jcesarmobile reply

jcesarmobile commented 8 years ago

my pull request has been merged, but you still have to wait for a plugin release or install the plugin from github

bau720123 commented 8 years ago

thanks @jcesarmobile and @initialxy got it !!!

sencenan commented 8 years ago

@bau720123 is the bug still there?

bau720123 commented 8 years ago

hi @sencenan seem solved thanks