Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 295BA9E7B for ; Thu, 19 Apr 2012 19:33:22 +0000 (UTC) Received: (qmail 73868 invoked by uid 500); 19 Apr 2012 19:33:22 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 73824 invoked by uid 500); 19 Apr 2012 19:33:21 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 73816 invoked by uid 99); 19 Apr 2012 19:33:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Apr 2012 19:33:21 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bowserj@gmail.com designates 209.85.212.171 as permitted sender) Received: from [209.85.212.171] (HELO mail-wi0-f171.google.com) (209.85.212.171) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Apr 2012 19:33:16 +0000 Received: by wibhj13 with SMTP id hj13so1575001wib.0 for ; Thu, 19 Apr 2012 12:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=/UL6CSVx3LffAeNyi8QBHXQO1gUVN8VzP5uCWRLEJ4s=; b=EjdHVE5EeRxpWc5te9MiXrBbqoUEXd5rppMFAKrnAeC6Zfyew+X7ZrkhXz8OFL0JoL u8zRZwreyb0mZkg3M13g2QPr5Ibjsd46z/CGWCCb/0EbYpRPMi+qloVWEQjhQwhQDij+ T3Jfheb/tecne+E4FzVpD6SC3Fd+vXp4ARB6JcFcNizbYasy8HwQULQcDQryPQ02ZOB5 7pwSeIoVRfhE3NCDVO3Ju9Mtp4aShbj1BEJOpUGAES7zSgSbSOFqnKWxWlt+Tl2aTVys 2DkSsFQ0ZD8ULvStMBuTSpu6CTwcpfvv8sCs0xhPsvrrtP7uET8oDyCAYazVS7RCECQE Ra2g== MIME-Version: 1.0 Received: by 10.180.94.161 with SMTP id dd1mr8160767wib.16.1334863975429; Thu, 19 Apr 2012 12:32:55 -0700 (PDT) Received: by 10.223.103.7 with HTTP; Thu, 19 Apr 2012 12:32:55 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 Apr 2012 12:32:55 -0700 Message-ID: Subject: Re: [Android] Back Key events and Reality From: Joe Bowser To: callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=f46d04462e9e14365204be0d3d0f X-Virus-Checked: Checked by ClamAV on apache.org --f46d04462e9e14365204be0d3d0f Content-Type: text/plain; charset=ISO-8859-1 OK, here's what happened. When I currently work on Cordova, I run the project as an activity, and not as a jar. This is done for convenience because I've had jars lose sync with the code that I'm debugging in Eclipse in the past. However, what this means is that I don't have a working back button. Activity has a default behaviour for the back button. This default behaviour is defined by onBackPressed and onKeyDown when you extend an activity, which is of course that the application would exit. Therefore, one would assume that since any class that uses the jar extends DroidGap and that since DroidGap is extending Activity that the class would extend Activity by virtue of it being a DroidGap class. In reality this is wrong, and somehow through some voodoo the onKeyUp event work even though it shouldn't because the App should have ran the Activity's onKeyDown and onBackPressed. In short, I have to use the bin/create scripts because Java inheritance doesn't seem to work the way I thought it should. Joe On Thu, Apr 19, 2012 at 12:22 PM, Simon MacDonald wrote: > That's ominous. > > Simon Mac Donald > http://hi.im/simonmacdonald > > > On Thu, Apr 19, 2012 at 3:20 PM, Joe Bowser wrote: > > > OK, let's revert the changes. It looks like I'm going to have to change > > how I work on this project. > > > > On Thu, Apr 19, 2012 at 12:15 PM, Filip Maj wrote: > > > > > Actually the latest master breaks back button on my galaxy nexus too. > > > > > > I'll run through the tests and help out with this. > > > > > > On 4/19/12 12:07 PM, "Joe Bowser" wrote: > > > > > > >There's a problem with the log statement that you provided, namely the > > > >fact > > > >that this.backHistory() actually goes back in the history before it > > > >returns > > > >true or false. This was causing the app to constantly exit when we > were > > > >running mobile-spec, which was similar to the original bug. I > removed > > it > > > >because I wanted the log statements to just log, and here's what I got > > > >from > > > >the Motorola Device: > > > > > > > >04-20 02:56:14.187 19771 19771 D BackPressed: in onBackPressed > > > >04-20 02:56:14.187 19771 19771 D BackPressed: bound = false > > > >04-20 02:56:14.187 19771 19771 D BackPressed: exiting > > > >04-20 02:56:14.234 1032 1032 D ActivitityRenderTarget: onResume > > > >04-20 02:56:14.257 19771 19771 D BackButton: I got an up from > > KEYCODE_BACK > > > >04-20 02:56:14.265 19771 19771 D BackButton: I'm doing nothing > > > >04-20 02:56:14.265 19771 19771 D BackPressed: returning false > > > > > > > >So, here we're exiting the app on the keyDown, and the keyUp is also > > > >happening which is exactly what I would expect since you have to do a > > > >onKeyDown before an onKeyUp. Here's the same thing on the Samsung > > Galaxy > > > >S2: > > > > > > > >D/BackPressed(17630): in onBackPressed > > > >D/BackPressed(17630): bound = false > > > >D/BackPressed(17630): exiting > > > >I/InputDispatcher( 2704): Delivering key to current input target: > > action: > > > >1, channel '409de9f8 org.apache.cordova/org.apache.cordova.StandAlone > > > >(server)' > > > > > > > >...A bunch of crap about widgets not being drawn right on the home > > screen > > > >which is resuming... > > > > > > > >D/BackButton(17630): I got an up from KEYCODE_BACK > > > >D/BackButton(17630): I'm doing nothing > > > >D/BackPressed(17630): returning false > > > > > > > >I should remove the crap Samsung puts on their default build, but this > > > >does > > > >illustrate my point more clearly. Once we remove the extra > backHistory > > > >call, things seem to work properly on this end and the app does exit. > > It > > > >seems incredibly strange that the Note would fail. > > > > > > > >On Thu, Apr 19, 2012 at 11:48 AM, Simon MacDonald > > > > > > >> wrote: > > > > > > > >> Oh, and here is the dirt simple .html I was using. I was checking a > > > >> possible camera bug and found I couldn't exit the app. > > > >> > > > >> http://dl.dropbox.com/u/887989/camera.html > > > >> > > > >> Simon Mac Donald > > > >> http://hi.im/simonmacdonald > > > >> > > > >> > > > >> On Thu, Apr 19, 2012 at 2:44 PM, Simon MacDonald > > > >> wrote: > > > >> > > > >> > You can get my version of DroidGap with the extra logs from: > > > >> > > > > >> > http://dl.dropbox.com/u/887989/DroidGap.java > > > >> > > > > >> > Did you clone the 1.6.1 tag or the bleeding edge? > > > >> > > > > >> > Simon Mac Donald > > > >> > http://hi.im/simonmacdonald > > > >> > > > > >> > > > > >> > On Thu, Apr 19, 2012 at 2:38 PM, Joe Bowser > > > wrote: > > > >> > > > > >> >> I cloned a fresh repo, and what's in DroidGap.java works on this > > end, > > > >> and > > > >> >> matches what I have in my working tree. We don't have your > > attached > > > >> >> DroidGap.java, can you send it again? > > > >> >> > > > >> >> On Thu, Apr 19, 2012 at 11:28 AM, Simon MacDonald < > > > >> >> simon.macdonald@gmail.com > > > >> >> > wrote: > > > >> >> > > > >> >> > When I pull the latest from incubator-cordova-android and build > > it > > > >> into > > > >> >> my > > > >> >> > app the back key does not work. I've verified this on my > samsung > > > >>note > > > >> >> and > > > >> >> > on the emulator. > > > >> >> > > > > >> >> > Please take a look at the attached DroidGap.java file which > I've > > > >> added a > > > >> >> > few logs. When I click on the back button on the note or on the > > > >> >> emulator I > > > >> >> > see these logs: > > > >> >> > > > > >> >> > 04-19 14:16:49.373: D/BackButton(390): I got an up from > > > >>KEYCODE_BACK > > > >> >> > 04-19 14:16:49.373: D/BackButton(390): I'm doing nothing > > > >> >> > 04-19 14:16:49.373: D/BackPressed(390): returning false > > > >> >> > > > > >> >> > I'm not seeing the onBackPressed method being called at all. > Can > > > >> Joe/Fil > > > >> >> > try my DroidGap.java to see if they get a different set of > logs? > > > >> >> > > > > >> >> > Note that the .html I'm loading has one and only one file and > > does > > > >>not > > > >> >> > call 'document.addEventListener("backbutton", onBackKey, > true)". > > > >>It is > > > >> >> just > > > >> >> > a plain vanilla .html file. > > > >> >> > > > > >> >> > Simon Mac Donald > > > >> >> > http://hi.im/simonmacdonald > > > >> >> > > > > >> >> > > > > >> >> > On Thu, Apr 19, 2012 at 2:17 PM, Filip Maj > > wrote: > > > >> >> > > > > >> >> >> We definitely cannot revert that commit Joe put in. Back > button > > > >> didn't > > > >> >> >> work at all (just exited) before that commit. > > > >> >> >> > > > >> >> >> Sucks that the note is broken but it works as expected on > other > > > >> devices > > > >> >> >> (as Joe points out). > > > >> >> >> > > > >> >> >> Simon can you try to debug the issue on the Note and see how > the > > > >> >> execution > > > >> >> >> flow differs from the other Android devices? > > > >> >> >> > > > >> >> >> On 4/19/12 10:58 AM, "Joe Bowser" wrote: > > > >> >> >> > > > >> >> >> >OK, I just went through Mobile Spec's manual tests on the > > > >>following > > > >> >> >> >devices: > > > >> >> >> > > > > >> >> >> >Galaxy Nexus > > > >> >> >> >Nexus S > > > >> >> >> >Motorola RAZR > > > >> >> >> >Samsung Galaxy S2 > > > >> >> >> >LG Optimus One > > > >> >> >> > > > > >> >> >> >Currently, if you don't override the back button, the > > backPressed > > > >> >> event > > > >> >> >> >fires on the keyDown. If we override the event, the > backbutton > > > >> >> doesn't > > > >> >> >> >work on the keydown, but the event fires on the keyup > instead. > > > >> This I > > > >> >> >> >think is the proper behaviour since we're intercepting the > back > > > >> button > > > >> >> >> and > > > >> >> >> >making it the users' responsibility to handle this event. > > > >> >> >> > > > > >> >> >> >The old method had the default behaviour for the back button > > > >>(where > > > >> it > > > >> >> >> >quits on keydown) occur, as well as the keyUp behaviour > happen. > > > >>Of > > > >> >> >> >course, > > > >> >> >> >since the app is exited and is in the background whatever > > happens > > > >> with > > > >> >> >> the > > > >> >> >> >back button at that point is moot. The fact is that I expect > > the > > > >> back > > > >> >> >> >button to work when I press it, and I don't consciously think > > > >>about > > > >> >> key > > > >> >> >> up > > > >> >> >> >or key down when I do so. I also think that Google put it on > > > >> keydown > > > >> >> for > > > >> >> >> >a > > > >> >> >> >reason, especially since it's not really a key anymore. > > > >> >> >> > > > > >> >> >> >On Thu, Apr 19, 2012 at 10:48 AM, Joe Bowser < > > bowserj@gmail.com> > > > >> >> wrote: > > > >> >> >> > > > > >> >> >> >> You're saying that the behaviour is different on the Note? > > I'll > > > >> run > > > >> >> >> >> through our device bank here, but the fact is that the Back > > > >>Button > > > >> >> >> would > > > >> >> >> >> ALWAYS exit, not progress through the history but just > > > >>straight up > > > >> >> exit > > > >> >> >> >> regardless of where in the app you were. What I added was > > > >> >> backPressed > > > >> >> >> >> which would only exit if you were at the top of the > history. > > > >> Also, > > > >> >> >> >> backPressed should be supported for Android versions higher > > > >>than > > > >> >> >> Android > > > >> >> >> >> 2.0, and since we're only supporting 2.1+, we should have > > been > > > >> fine. > > > >> >> >> >> > > > >> >> >> >> I'll investigate this, but honestly if it's not consistent > > > >>across > > > >> >> >> >>devices, > > > >> >> >> >> what do we do then? > > > >> >> >> >> > > > >> >> >> >> On Thu, Apr 19, 2012 at 10:26 AM, Simon MacDonald < > > > >> >> >> >> simon.macdonald@gmail.com> wrote: > > > >> >> >> >> > > > >> >> >> >>> The reason we switched to keyUp is so you could slide your > > > >>finger > > > >> >> off > > > >> >> >> >>>the > > > >> >> >> >>> up button in case you changed your mind about clicking on > > the > > > >> back > > > >> >> >> >>>button. > > > >> >> >> >>> > > > >> >> >> >>> I noticed that you checked in: > > > >> >> >> >>> > > > >> >> >> >>> > > > >> >> >> >>> > > > >> >> >> >>> > > > >> >> >> > > > >> >> > > > >> > > https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git > > > >> ; > > > >> >> >> >>>a=commit;h=180696baec28d6e6b67e8bb23a5302f21bce6b79 > > > >> >> >> >>> > > > >> >> >> >>> On my Samsung Galaxy Note running Android 2.3.6 the back > > > >>button > > > >> >> does > > > >> >> >> >>>not > > > >> >> >> >>> work. That is when I do not regisiter for a "backbutton" > > > >>listener > > > >> >> and > > > >> >> >> I > > > >> >> >> >>> expect that when I click the back key that my app would > > exit. > > > >> With > > > >> >> our > > > >> >> >> >>>fix > > > >> >> >> >>> the back button doesn't exit the app. I have to click the > > home > > > >> >> button > > > >> >> >> >>>to > > > >> >> >> >>> exit. > > > >> >> >> >>> > > > >> >> >> >>> Reverting your change returns the back button behaviour to > > > >> normal. > > > >> >> So > > > >> >> >> >>> something is still janky. I haven't been able to test it > on > > my > > > >> >> phone > > > >> >> >> >>>as I > > > >> >> >> >>> can't convince it to be recognized on my laptop. > > > >> >> >> >>> > > > >> >> >> >>> Simon Mac Donald > > > >> >> >> >>> http://hi.im/simonmacdonald > > > >> >> >> >>> > > > >> >> >> >>> > > > >> >> >> >>> On Tue, Apr 17, 2012 at 8:46 PM, Joe Bowser > > > >> > > > >> >> >> wrote: > > > >> >> >> >>> > > > >> >> >> >>> > Hey > > > >> >> >> >>> > > > > >> >> >> >>> > Remember this issue: > > > >> >> >> >>> > https://issues.apache.org/jira/browse/CB-367 > > > >> >> >> >>> > > > > >> >> >> >>> > I'm surprised that I'm catching it now, but the Back > > Button > > > >>is > > > >> >> >> really > > > >> >> >> >>> janky > > > >> >> >> >>> > on my Nexus S running 2.3.6, and I'm working on a fix > now. > > > >> What > > > >> >> was > > > >> >> >> >>>the > > > >> >> >> >>> > reasoning behind the Back Button being on the keyUp > > instead > > > >>of > > > >> >> the > > > >> >> >> >>> keyDown? > > > >> >> >> >>> > I don't remember. > > > >> >> >> >>> > > > > >> >> >> >>> > Joe > > > >> >> >> >>> > > > > >> >> >> >>> > > > >> >> >> >> > > > >> >> >> >> > > > >> >> >> > > > >> >> >> > > > >> >> > > > > >> >> > > > >> > > > > >> > > > > >> > > > > > > > > > --f46d04462e9e14365204be0d3d0f--