viezel / TiSocial.Framework

iOS6+ Social.Framework. Appcelerator apps are able to share content to Facebook and Twitter.
MIT License
257 stars 102 forks source link

Windows loose "focus" event when activity view is loaded. #86

Open bcpi opened 10 years ago

bcpi commented 10 years ago

This is a sample app that shows how the focus event is lost on all windows within a TabGroup right after an activity view is loaded.

My environment is TiSocial.Framework v1.7.3, Ti SDK 3.2.2GA, iOS Simulator 7.1, iPhone 5s iOS 7.1.

Test: Load the sample app. Click between tab 1 and tab 2 several times to see the label change with the focus event. Then click the "share" button to load the activity view. Click cancel on the activity view, and switch tabs back and forth again. Now the focus event does not fire and the labels don't get updated.

app.js

(function() {

    Ti.UI.setBackgroundColor('#ffffff');

    var tg = Ti.UI.createTabGroup(),

        win1 = Ti.UI.createWindow({
            title: 'Tab 1'
        }),

        win2 = Ti.UI.createWindow({
            title: 'Tab 2'
        }),

        tab1 = Ti.UI.createTab({
            title: 'Tab 1',
            window: win1
        }),

        tab2 = Ti.UI.createTab({
            title: 'Tab 2',
            window: win2
        }),

        btn = Ti.UI.createButton({top: 80, title:'Click to Share'}),

        lbl1 = Ti.UI.createLabel({font: {fontSize:40}}),

        lbl2 = Ti.UI.createLabel({font: {fontSize:40}}),

        social = require('dk.napp.social'),

        idx1 = 0,

        idx2 = 100;

    // events
    btn.addEventListener('click', function() {
        social.activityView({
             text: 'Testing...'
        });
    });

    win1.addEventListener('focus', function(e) {
        idx1++;
        lbl1.text = 'Tab 1: ' + idx1;
        Ti.API.info('Focused tab 1 window.');
    });

    win2.addEventListener('focus', function(e) {
        idx2--;
        lbl2.text = 'Tab 2: ' + idx2;
        Ti.API.info('Focused tab 2 window.');
    });

    // assemble + open
    win1.add(btn);
    win1.add(lbl1);
    win2.add(lbl2);
    tg.addTab(tab1);
    tg.addTab(tab2);
    tg.open();

})();
jdrucey commented 10 years ago

^ I second this! My app relies on the 'focus' event, with out a fix, this bug renders my app unusable =(

Raphzz commented 10 years ago

^ Happens on my app as well...all windows looses focus event

justadaniel commented 10 years ago

Same here

mobilebanzai commented 10 years ago

Same here, Mads are you listening?

kopiro commented 10 years ago

Same here.

bcpi commented 10 years ago

also present in Ti SDK 3.0.0GA

paomosca commented 10 years ago

i confirm in 3.3.0GA and 3.2.3GA, after closing the activity or after sharing, all the app (every window, even not already created) loose focus event, so apparently there is an overlay win on top of the stack that never release correctly

paomosca commented 10 years ago

guys waiting for being fixed as soon as possible try this workaround:

var fakeWin = Ti.UI.createWindow({ backgroundColor: 'transparent', zIndex: 1500, touchEnabled: false, top: 20//fullscreen: true }); fakeWin.open(); fakeWin.close();

on complete, error and cancelled events

bradwhiteVB commented 7 years ago

Hi wondering why there has been no movement on this issue since it is such a deal breaker. I'd like to also add that blur events are also removed.

I tried the fake window technique and it doesn't work for iPhon6 and iphone 7 devices on iOS10. For reference I am coding with Ti SDK 5.5.1GA. I also can't work my app unless I use focus events.

Has someone found another workable solution to this?