← Back to team overview

ubuntu-phone team mailing list archive

Re: Find out if running on a phone

 

On Mon, Jan 11, 2016 at 9:19 PM, Robert Park <robert.park@xxxxxxxxxxxxx> wrote:
> But dynamically changing between a desktop and a phone doesn't make, eg, the
> accelerometer appear and disappear.
>
> So if you have code that says "if phone: use accelerometer", can you see how
> broken that is? Plugging in a screen and keyboard will effectively disable
> your accelerometer, because your code assumes desktops don't have those.
>
> You should absolutely not be writing code that makes assumptions about what
> features desktops have or what phones have.
>
> You need to detect the feature itself and use it if you have it.
>

+1, if a specific *scenario* (like "TV") results in a feature to be
disabled, the respective middleware has to report this to apps. The
app should not take such decisions on its own.

> On Jan 11, 2016 12:08 PM, "Lorn Potter" <lorn.potter@xxxxxxxxxxxxx> wrote:
>>
>>
>>
>> On 12/01/16 05:35, Robert Park wrote:
>>>
>>> But the point is that you can't have coffee that says "if desktop: x; if
>>> phone: y" because it can change at any time and you can't rely on that.
>>
>>
>> Yes this desktop/phablet mode thing would be dynamic. It can change at any
>> time, which is why it needs to be detected dynamically.
>>
>> When you connect bt keyboard & external display, phone is now in desktop
>> mode. When you flip back your laptop's touchscreen, it's it now phablet
>> mode. It already does the first one except there is no API to let developers
>> know for certain what mode it is in.
>>
>>>
>>> **MUCH** better user experience if you do feature detection, eg "if
>>> push_notifications_available: enable_push_notifications()", this way
>>> they work everywhere they exist, rather than trying to guess whether or
>>> not they exist by making assumptions about what is a "phone" vs what is
>>> a "desktop".
>>>
>>
>> It really depends on what you are doing.
>>
>> We can either provide an API to do so or developers will try and guess
>> these things on their own.
>
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help   : https://help.launchpad.net/ListHelp
>


References