UrlChecker icon indicating copy to clipboard operation
UrlChecker copied to clipboard

Pop-up/Multi Window integration

Open pressRtowin opened this issue 2 years ago • 25 comments
trafficstars

Describe a related problem (optional)

Sometimes you want to open something but not completely leave what you were doing.

Describe your suggested feature

Add support for opening apps in MultiWindow view (even better if configurable to the side of your choice) or as a pop-up window. Perhaps a module could be added which controls whether full screen, MultiWindow, or pop-up view is used?

Describe alternatives you've considered for your suggested feature

No response

Other details

Some other apps have this or similar features built in. Most of the best MultiWindow integrations come from Samsung apps (many allow you to simply drag certain elements to the edge of the screen to open it in MultiWindow), but even Google Messages now opens links automatically in MultiWindow on my Fold 4.

Acknowledgements

  • [X] I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open issue.
  • [X] I have written a short but informative title.
  • [X] I will fill out all of the requested information in this form.

pressRtowin avatar Feb 22 '23 22:02 pressRtowin

even better if configurable to the side of your choice

Not actually sure if that is possible.

pressRtowin avatar Feb 22 '23 22:02 pressRtowin

There's some documentation for this here and here.

pressRtowin avatar Feb 22 '23 22:02 pressRtowin

I found a related bug as well. If another app brings up the "Open with" dialog in MultiWindow like this: Screenshot_20230222_165648_Android System and you select URLCheck from that menu, you end up here: Screenshot_20230222_170117_URLCheck

From there you'd assume that selecting an application to open would open it within that MultiWindow view, but instead, it opens it full screen.

On the other hand, if you're already in MultiWindow view and share/open something within one of the applications already open, and launch URLCheck that way, the MultiWindow layout is preserved. Unfortunately, that results in the application from which you opened the link from always being overwritten by the new application.

pressRtowin avatar Feb 22 '23 23:02 pressRtowin

Hmm, opening a link should preserve the intent flags, so if the app is opened in a half the opened browser should too. Could it be possible to know the original intent flags? In the debug module there should be a launchFlags=0x and a bunch of numbers (you can long tap to copy).

They're these (no private information there): https://developer.android.com/reference/android/content/Intent#flags

TrianguloY avatar Feb 22 '23 23:02 TrianguloY

Hmm, opening a link should preserve the intent flags, so if the app is opened in a half the opened browser should too. Could it be possible to know the original intent flags? In the debug module there should be a launchFlags=0x and a bunch of numbers (you can long tap to copy).

They're these (no private information there): https://developer.android.com/reference/android/content/Intent#flags

Well, like I said, if two apps are already open side by side, opening any link normally will result in the link being opened in whatever side it was opened in, regardless of any flags (with the exception of any that force an app into full screen I'd assume, if that exists) which I believe is standard Android behavior. It's only when something is being opened into MultiWindow, and the "Open with" dialog is the first thing that exists in the MultiWindow view (with no app behind it) that this bug exists. Here are the flags when opening the link in that scenario:

Intent;launchFlags=0x13801000;component=com.trianguloy.urlchecker/.dialogs.MainDialog;end

Also, for clarity, the original feature request was for using URLCheck to open a new MultiWindow or pop-up view, particularly when not already in one.

pressRtowin avatar Feb 23 '23 00:02 pressRtowin

I tested with pop-up view just now, and it appears that if an app wants to open a link in a new pop-up view, that works as intended when selecting URLCheck. It's only new MultiWindows that are affected.

pressRtowin avatar Feb 23 '23 00:02 pressRtowin

It occurred to me that there might be a better way to do this by adding drag & drop functionality directly to the open module, as using the flags alone gives no control over which side apps launch on, if I'm understanding the documentation correctly.

I made a quick workaround in Tasker for the time being which allows me to share any link to my notifications. When the notification pop up appears (or later from the drop down list) I can drag and drop it onto any half of my screen (top/bottom/left/right) as well as to a pop up window, just like most other notifications, and then it lets me pick a browser. If I select URLCheck and select my app of choice from there, it correctly opens in the way that I want it to, but as you can see, it's a bit time consuming (though honestly it's really not that bad and half that delay comes from me not setting URLCheck as my default browser).

When that grid UI happens, it'd be neat to see if there's a way to make the app icons dragable to make this functionality native.

pressRtowin avatar Mar 04 '23 09:03 pressRtowin

Not sure if that drag and drop is available to other apps, seems like a Samsung? feature. I'll check though. I know there is a flag to open in a side-by-side view, but don't think there is an android standard to specify which one 🤔

As for the tasker notification, can't you set it to open in a specific app directly and skipping that choose step?

TrianguloY avatar Mar 04 '23 09:03 TrianguloY

Drag and drop isn't limited to Samsung only. Chrome supports it too, though I can't think of any non-browser apps that support it (and use it for purposes outside of web links) that are not Samsung. It's a bit confusing because the term refers to both using it to split apps to the side or in popups, as well as to the feature for sharing basic data like text and images between currently open apps in multi-window.

And yes, selecting URLCheck as my default browser would skip that step, and I'm sure there's a way to open another app directly with Tasker too. I just like keeping my choices open. I haven't dug into tasker (and its plugins) enough yet to know how to configure a notification to open its link directly in an app without interfering with drag and drop yet, and unfortunately, setting URLCheck as my default browser—while eliminating the need to choose again after I drop the notification—would also eliminate my ability to choose when initially opening the link (if not done with a share action instead. So then I'd have to open the link, which would go to URLCheck by default, then use URLCheck to open the link with Tasker, then drag and drop the notification where I want it, then have URLCheck come up by default again, and FINALLY choose the final app to open in multi-window. 😂

pressRtowin avatar Mar 04 '23 09:03 pressRtowin

https://developer.samsung.com/codelab/galaxy-z/multi-window-drag-drop.html#Objective That seems to cover enabling text drag and drop, and I'm not sure how closely that's related to the full drag and drop support that chrome and some other Samsung apps seem to have.

pressRtowin avatar Mar 04 '23 09:03 pressRtowin

Not sure if that drag and drop is available to other apps, seems like a Samsung? feature.

Hi, apparently Android implements this out of the box, see: https://developer.android.com/develop/ui/views/receive-rich-content

Ilithy avatar Mar 04 '23 09:03 Ilithy

Not sure if that drag and drop is available to other apps, seems like a Samsung? feature.

Hi, apparently Android implements this out of the box, see: https://developer.android.com/develop/ui/views/receive-rich-content

Oh! That link is for receiving content, but it was a valuable source to find the "send" counterpart, which I think is this: https://developer.android.com/develop/ui/views/touch-and-input/drag-drop Interesting...

TrianguloY avatar Mar 04 '23 09:03 TrianguloY

Just so we're all on the same page (those links reference many similar and related things, but I'm not seeing the exact functionality I'm referring to, but it could all be one thing in the back end for all I know), I put together a short example (featuring chrome, Samsung internet, play store, and a quick peek at my tasker script too):

https://linksharing.samsungcloud.com/zBQitxm1ErWk

pressRtowin avatar Mar 04 '23 10:03 pressRtowin

Oh and I forgot to show this, but as you can see here, URLCheck works fine as an intermediary when using both the native feature and my Tasker workaround and correctly opens the content in the expected multi-window view (these two are under github's size limit):

https://user-images.githubusercontent.com/25999169/222894270-4da79424-2f62-48f0-8539-19ef845480aa.mp4

https://user-images.githubusercontent.com/25999169/222894383-1a91ea95-ac5c-4fe3-9500-673bc9606374.mp4

pressRtowin avatar Mar 04 '23 10:03 pressRtowin

Yes, I think that's what I'm referring to also. You want the ability to "drag" the open button (or another alternative) so that you can drop it directly on a side/popup view to open it, without any other "choose app" menu.

That's the drag&drop feature from the second link, although that's for text and images mainly and not sure if it can be configured to open an app directly. Edit: apparently it is! You can configure an intent to drag, which I guess it's what could allow you to open the app in another view.

Come to think of it, can't you open urlcheck, select the link from the text module, and drag&drop it? You will still need to choose an app to open, but maybe it's faster than the tasker workaround?

TrianguloY avatar Mar 04 '23 10:03 TrianguloY

That's the drag&drop feature from the second link, although that's for text and images mainly and not sure if it can be configured to open an app directly.

Yeah that's what I mean. I'm not sure if that's the same thing with different parameters or another feature altogether.

Come to think of it, can't you open urlcheck, select the link from the text module, and drag&drop it? You will still need to choose an app to open, but maybe it's faster than the tasker workaround?

Let me show you what that looks like, assuming I still want to use URLCheck in the end to control which app opens the link:

https://user-images.githubusercontent.com/25999169/222894715-f550bc0d-b3fb-4565-a94c-e9b38bcb6b24.mp4

😂

pressRtowin avatar Mar 04 '23 10:03 pressRtowin

Edit: apparently it is! You can configure an intent to drag, which I guess it's what could allow you to open the app in another view.

Oooh there's hope then 😮

pressRtowin avatar Mar 04 '23 10:03 pressRtowin

Oh and, I don't know if you noticed, but in that last video, the second Open menu did not have URLCheck, and I had to go through Better Open With to select URLCheck the second time. That's similar to the issue I was noting before. Just random places where URLCheck decides to call in sick. 😅

I hardly use most other opening/sharing apps anymore, and when I do, it's because of situations like that where URLCheck is available though them but not normally for some reason.

Also, once I do get it open, it looks funny because the old one is still open under the new one (though that's expected since I did no action that would close the first).

pressRtowin avatar Mar 04 '23 10:03 pressRtowin

Oh and, I don't know if you noticed, but in that last video, the second Open menu did not have URLCheck, and I had to go through Better Open With to select URLCheck the second time. That's similar to the issue I was noting before. Just random places where URLCheck decides to call in sick. 😅

That may be because I missed an intent filter. In those cases try to open the interceptor and paste the intent content. That may help discovering the missing configuration.

TrianguloY avatar Mar 04 '23 10:03 TrianguloY

Also, once I do get it open, it looks funny because the old one is still open under the new one (though that's expected since I did no action that would close the first).

It might be nice to add a setting to auto close URLCheck if you drag text from the input module? It would work as a nice alternative for the Apply function we discussed in https://github.com/TrianguloY/UrlChecker/issues/191. You could edit the link as needed and then drag it into a different app, if you already had two open for instance—a bit more elegant than copy/paste.

I.e. close it right after this:

https://user-images.githubusercontent.com/25999169/222895962-cd89e995-1f2a-41ac-95f7-099c1fa5114d.mp4

pressRtowin avatar Mar 04 '23 10:03 pressRtowin

That may be because I missed an intent filter. In those cases try to open the interceptor and paste the intent content. That may help discovering the missing configuration.

Here's the intent for that one specifically. I'll try to keep an eye out for any others I notice and send them your way.

intent://play.google.com/store/apps/details?id=com.trianguloy.urlchecker&hl=en&gl=US&referrer=utm_source%3Dgoogle%26utm_medium%3Dorganic%26utm_term%3Durlcheck&pcampaignid=APPU_1_SR0DZMvHCsamptQPwvW68Ak#Intent;scheme=https;category=android.intent.category.BROWSABLE;launchFlags=0x3400000;end

pressRtowin avatar Mar 04 '23 11:03 pressRtowin

I found a related bug as well.

Going back to this, I did some more research and found some interesting things.

Links opened directly into split screen by Google Messages have these launch flags in App Manager:

launchFlags=0x13001000

Opening sending the link to App Manager but through my Tasker workaround (which also means URLCheck correctly opens it in split screen) gives the following flags instead:

launchFlags=0x13040001

However, as I mentioned before, when opening the link from Messages directly to URLCheck, URLCheck reports the flags as:

launchFlags=0x13801000

Similarly, if I use the Tasker workaround and go to URLCheck instead, I get the following flags:

launchFlags=0x13840001

Both can't be right so something is getting changed somewhere?

pressRtowin avatar Mar 05 '23 20:03 pressRtowin

0x13001000 ->

  • FLAG_ACTIVITY_FORWARD_RESULT
  • FLAG_ACTIVITY_LAUNCH_ADJACENT
  • FLAG_ACTIVITY_NEW_TASK
  • FLAG_ACTIVITY_PREVIOUS_IS_TOP

0x13040001 ->

  • FLAG_ACTIVITY_FORWARD_RESULT
  • FLAG_ACTIVITY_NEW_TASK
  • FLAG_ACTIVITY_NO_USER_ACTION
  • FLAG_ACTIVITY_PREVIOUS_IS_TOP

0x13801000 ->

  • FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
  • FLAG_ACTIVITY_FORWARD_RESULT
  • FLAG_ACTIVITY_LAUNCH_ADJACENT
  • FLAG_ACTIVITY_NEW_TASK
  • FLAG_ACTIVITY_PREVIOUS_IS_TOP

0x13840001 ->

  • FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
  • FLAG_ACTIVITY_FORWARD_RESULT
  • FLAG_ACTIVITY_NEW_TASK
  • FLAG_ACTIVITY_NO_USER_ACTION
  • FLAG_ACTIVITY_PREVIOUS_IS_TOP

(except for that ending '1', which doesn't correspond to any known flag, or I can't find it).

It seems the important flag are FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, which makes the activity don't appear on the recents screen (and that I'll try to add an option to disable, it's a pain) and FLAG_ACTIVITY_LAUNCH_ADJACENT which is what apparently makes the new app appear in a different view.

Btw: I tried to search for a 'intent flag decoder' and couldn't find one. Maybe there is one hidden somewhere, but I just made one myself (very basic and visually horrible, but good enough I guess: https://trianguloy.github.io/githubPages/intentflags/intentflags.html)

TrianguloY avatar Mar 06 '23 23:03 TrianguloY

Interesting that FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS is being added only when opening in URLCheck when according to App Manager, it's not there.

Also odd that it's the ones with FLAG_ACTIVITY_LAUNCH_ADJACENT that fail to open in split screen. The documentation also states the flag does nothing unless FLAG_ACTIVITY_NEW_TASK is also set, but in this case, they are always set together.

Found this in the documentation as well: Screenshot_20230306_172628_Samsung Internet

pressRtowin avatar Mar 06 '23 23:03 pressRtowin

Interesting that FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS is being added only when opening in URLCheck when according to App Manager, it's not there.

Android can add or modify the flags itself, so the apps ca may receive different ones. And now that you mention it, the app IS configured to be excluded from recents (to avoid going back to it by pressing back) so...I think that's the main issue. Maybe the forward flag is the correct alternative here, I need to investigate.

Found this in the documentation as well: Screenshot_20230306_172628_Samsung Internet

There are I think 4 different flags with the "1" value, but none of them seems to be for the activity intents. Android uses flags on a lot of places (they are the best way to specify several booleans) and they are simply powers of 2, so it's expected to clash as long as they are for different things.

TrianguloY avatar Mar 06 '23 23:03 TrianguloY