-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incognito for chromium browsers #301
base: master
Are you sure you want to change the base?
Conversation
Added fenix forks support Added chromium support
This PR builds correctly, here is the generated apk.
You must be logged in for the link to work. This is an automatic comment created by a Github Action |
...main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/ClipboardBorrower.java
Fixed
Show fixed
Hide fixed
...main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/ClipboardBorrower.java
Fixed
Show fixed
Hide fixed
...main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/ClipboardBorrower.java
Fixed
Show fixed
Hide fixed
...main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/ClipboardBorrower.java
Fixed
Show fixed
Hide fixed
...main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/ClipboardBorrower.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/modules/companions/Incognito.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/modules/companions/Incognito.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/modules/companions/Incognito.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/UrlHelper.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/UrlHelper.java
Fixed
Show fixed
Hide fixed
Note: I haven't forgot about this. But due to the complexity and their experimental value I'm going to prioritize other tasks over this, sorry. In any case, don't hesitate to keep working on it and ask any question you may need (I need my computer to fully review a pr, but I read all messages from my phone so it is much much faster) |
I'll continue with the bubble then, it should bring support to all android versions. |
This PR builds correctly, here is the generated apk.
You must be logged in for the link to work. This is an automatic comment created by a Github Action |
...n/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/ManualBubble.java
Fixed
Show fixed
Hide fixed
...n/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/ManualBubble.java
Fixed
Show fixed
Hide fixed
...n/java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/ManualBubble.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/utilities/wrappers/Bubble.java
Fixed
Show fixed
Hide fixed
app/src/main/java/com/trianguloy/urlchecker/utilities/wrappers/Bubble.java
Fixed
Show fixed
Hide fixed
...java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/SemiautoBubble.java
Fixed
Show fixed
Hide fixed
...java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/SemiautoBubble.java
Fixed
Show fixed
Hide fixed
...java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/SemiautoBubble.java
Fixed
Show fixed
Hide fixed
...java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/SemiautoBubble.java
Fixed
Show fixed
Hide fixed
...java/com/trianguloy/urlchecker/modules/companions/openUrlHelpers/helpers/SemiautoBubble.java
Fixed
Show fixed
Hide fixed
Finally, I added support for borrowing a clipboard using a bubble. I started working on this like a month ago and it took 2 weeks, since then I couldn't find the time to clean the code. I think that should be it for some time. There is still work to do but, if anyone wants to test this they should be able to, they need to first give permission manually to the app so it can draw over other apps, or it will crash. Currently there is no way to change the helper used, this one creates a bubble that when tapped will restore the contents of the clipboard, it will also do the same after 10 seconds of being created. So, things that still need tweaking:
Now, the "janky" parts. Because we are trying to use the clipboard when we shouldn't, I had to make some weird workarounds. If we are not focused we create a Bubble so we get focus, and before it shows we do what we need with the clipboard and we proceed to kill the bubble, that means that we need to wait for the UI thread to start creating the Bubble to complete background operations on the clipboard. We also can't reuse the bubble that is visible because of its flags, I spent a lot of time trying to figure it out, but I think is not possible without ruining the user experience, if we have focus on the bubble, we can't use the keyboard on other apps. I also don't know if using a notification will help avoid using a fake bubble, but it is very unlikely. I changed the logic to check if the clipboard has changed, in debug it doesn't check the label, in release it is just Things that still need to be done:
I think that's all. |
So, this should be almost everything done. The only thing that I haven't added is keeping the coordinates of the bubble, which last time I tried I couldn't do properly (also tried to keep in mind foldables). Added a button in the open module config to change the settings, and also, there is an explanation, however... is a huge wall of text, don't really know if it can be summarized as the feature is really complex, and I feel a lot of that information can be relevant to the end user. Because of that complexity I think an option (worst case scenario) could be to just hide this feature, I still use the prototype frequently, and while I can't say I find it convenient is not as inconvenient as this hacky code could make it seem, and someone could put this feature to use. Also there is now a "None" helper, when selected if the user tries to open the URL in chrome in incognito it will work just like it currently does, it opens it without incognito. Let me know what you think when you can (don't worry, there is no hurry). |
While I was at it I also made a working version that uses the accessibility service, so it is fully automatic, in the emulator it was really sloppy, but on my phone it was great. |
All the work here is incredible, and being able to make it work was no easy task I'm sure. I've think about it, and how to include it in the app without permission issues or other things that play store may not like. And I had an idea that, now that the feature is complete, I think makes even more sense. Tell me your opinion. The idea is: create a separate app. This app would have a main screen, that will explain the purpose and the usage (that wall of text you mention for example) and maybe a button to try and configure. Then it would have a transparent single activity that will perform the "open in a private session in chrome" feature from the provided link. From the user perspective they could either "send" the link to the activity (and it will be opened) or click and choose (if they don't have a default browser). Similar to other apps that also allows you to "open a link" differently. The separate app would also allow it to have as many permissions as needed, or to create different versions depending on the store. Plus maybe adding support for other browsers! But the main benefit is that, by being separate, you could even use it with other "url managers", or even none (with the share option). Sorry if this seems more like a "I don't want this on the app" response. It's not. It's just that this functionality is way more complex than a simple "button", and I'm afraid that adding it to the app itself will make it very difficult to maintain. Plus I genuinely think that people will benefit from this feature independently. If you like the idea, I can help you setup an independent app with the code. And feel free to reuse any util/class from URLCheck of course (like the readme says: as long as you mention me somewhere it's enough :) Plus I can also try to publish it on my Play Store account if you don't plan to create one yourself (although in this case I recommend to start with FDroid first). Let me know what you think. If you like the idea of a separate app or not. In either case I'll support you 👍 |
I understand, to be honest I was feeling the same while coding this, I could only think about how all this originates from a single boolean, which is there on purpose for some reason, and how it made these unnecesary permissions necessary, and while I tried my best to make good code, the "nature of fighting back" against something not meant to be that way made it impossible to have code as clean as I had hoped. It's a shame, making this a library won't fix the problem either, so I guess the only alternative is making it a separate app, as you propose. This is one of the most requested features, and it is really useful, so I think it should be released, if that means a new app I'm okay with it. Although it will take some time and I don't even know where to start. I would like, if possible, to at least have an experimental apk of this branch, or another one more up to date, on the releases tab of the github. This way if anyone wants to test it, there is the possibility of having early feedback. We can store the branch on the shelf too. |
Ok! No problem. Let's do the following then:
This should allow to keep the original app and additionally build the modified version without issue (and maybe even publish it as apk free on Github if I finally have the time to implement the apk releases...ahem). Anyway, let's start from the beginning: do you want me to do the branches update or you want to try it yourself? |
I'll do the merge myself, I want to add the accessibility service too, and I have some fixes in that branch, then I'll see how to split it properly, I think the incognito class could be a problem as I added a lot of the code there. |
So, I moved everything to a new package, tried to make it like a library, that's why there are some repeated folders. Things that are still outside said package are resources, everything else is nicely packed together.
I understand this is a specific tool, but can't find out how to start on this since the word is so common, my searches yield no result. Could you point me on how to do this? Also I found a bug with the clipboard borrower on my personal phone, but for reasons I will not explain I can't debug it right now, it will have to wait (just writing it somewhere to not forget about it). |
Oh, search for "gradle flavours", and flavourDimension (the code I was using as reference uses "version" as one of those flavours, but maybe any word can be used). It's apparently similar to buildTypes, but has some different considerations. Honestly I don't know much about them, but I know one of those allows to add extra modules...somehow |
Is this still in progress or is it now ready to be reviewed? I also see some conflicts, but I can try to fix them myself if needed. |
It is still WIP, I haven't been at home for a few weeks (in fact I got the mail notification just after coming back), but before that, I tried at least 3 times to move the code to a separate "Android Library" so then it can be easily transfered to the other app. However, I can't make it work, since I have never made an app from scratch there are some things I couldn't figure out (like making the resources of the library work properly, and then actually calling the library from the main app). I was going to give it one last shot before asking for help.
Sure, I'll do it myself while I'm here.
Do not worry about the conflicts, those I will fix myself when everything is ready to be merged. |
So, this time I had more luck and found what I needed, so I did it myself! Anyways, before the module/library thing, there are 2 bugs currently I discovered yesterday, both I cannot debug:
Now, the module, this branch starting 3rd of September, contains alll the small changes made to create the module library. Some commits are worth checking, as I'm not sure I did it right:
|
Mimic build.gradle translations
I am almost finished with this. First, a feature I wanted to add but is missing. For foldables, I was going to store the position of the bubble depending on which screen it is on, but it needs androidx and even then it wasn't complete, to not drag this any longer, I'll investigate this in the future. Then, in local I have already merged with master, but I had one issue that caught my attention, and I need help deciding which is the right way to solve it. So, in this commit (the URL puts you on the exact line, no need to search for it), the intent the app would send doesn't |
I may be wrong (if so just correct me) but from what I could find the component is more specific than a package. You can see the component as a package+activity (sort of). The change was to allow using different activities for the same application (aka package) #196 because otherwise only one was shown. In the commit you mention the exact change was splitted into two files, so it may be a bit hard to follow, but the important distinction is:
|
It doesn't really matter, I just need to know the package and I'll modify everything needed. Because the concept of the library is "give me a package and a mode (incognito) and I'll handle it for you" I think I should use I'm going to add some info to the debug module too. It shouldn't take long but I'm busy until this weedend, hopefully by the end of the next one I have everything done and ready to merge! |
Added info to the debug module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pmd (reported by Codacy) found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
That should be it, no conflicts and finished! There are things that still need to be worked on, but for that I need feedback first, mainly when there are permissions needed but the user has not given those yet and wants to open an url in incognito. Let me know if you need me to make fixes or anything, and don't worry if you take your time, I took mine too, I don't like at all how I dragged this for almost a whole year, my apologies. |
Understood! My turn then. Also, I'm now in the middle of the automation implementation, which reorders slightly the existing incognito code (there will be an automation to enable incognito, but there are no changes related to the functionality itself). If I push that change first (and this pr reports conflicts) I'll fix them myself, don't worry about that (that will also help me understand the changes). There are also two failing github actions, but I want to review them because I'm not sure if it's really an issue with the code or a misconfiguration of the action itself, so for now just ignore that. Again, thank you for your effort! |
# Conflicts: # app/src/main/java/com/trianguloy/urlchecker/modules/companions/Incognito.java # app/src/main/java/com/trianguloy/urlchecker/modules/list/DebugModule.java # app/src/main/res/values-zh-rCN/strings.xml
# Conflicts: # app/src/main/java/com/trianguloy/urlchecker/modules/companions/Incognito.java
#115
This is still a WIP, there are a lot of things to be done yet, but I don't want to keep these and not upload it (again). I think it would be best to check this code first, make the necessary changes and then build on top of it, that's why there are some TODOs in the code. The strings from the OpenModule config have not been updated yet because of this.
Added support for all firefox(fenix) forks.
Added support for chromium forks, it launches the incognito activity and then stores the URL in the clipboard, the user is expected to paste it in the search bar, we then restore the clipboard contents.
No screenshots, nothing in the GUI has changed (yet).
Here is a diagram that kind of explains the code, there are some differences because threading is not linear.
Can't believe GitHub has support for these, I was going to link to the official mermaid web.
The order I would advise checking the files (as is the one in which I made them) is:
Clipboard Borrower is meant to handle the logic of borrowing the clipboard, the user should be able to freely use their clipboard even when we are borrowing it, so we keep track of the last item the clipboard had that we did not put in there. At the very end we restore it. The only situation a user would not have access to their clipboard content is inmediatly after opening an URL in incognito, they would have to wait until we restore the clipboard. This could be solved in the future by using the SemiAuto form UrlHelper, which would restore it after X seconds but if you tap the bubble it would restore it immediately.
Auto Clipboard borrows the clipboard inmediatly and restores it after X seconds, if called again before this, it cancels the thread and starts the timer again.
UrlHelper keeps track of the options available for this "compatibility" we made:
Some things to be considered:
Incognito now has a static section in which scripts can be added to detect apps that can run incognito and modify the intent to do so, I thought this could be extracted into a database file, but I didn't do it because it's probably mesier and, honestly, aside from fenix and chromium, we don't know how other apps work with incognito, it could be more complex.
As a side note, this whole system can help if an application can't open the URLs it is supposed to and has access to a search bar or something similar, which is unlikely, but the option is there.
I think that's all, after you've made all the necessary changes, just ping me and I'll come back to do what's left (bubble and notification), after that I'll push and then I might look at the accesibily service, but I don't promise anything. Take all the time you need.
Also as stated in this comment there is some kind of compatibility with customs tabs, but I have not made any tests with it yet, as I want everything else working correctly first.