suraj0208 / WhatsappExtensions

Xposed module for WhatsApp
Apache License 2.0
100 stars 34 forks source link

[FEATURE REQUEST] Remove camera tab #34

Closed ghost closed 5 years ago

ghost commented 7 years ago

Hi @suraj0208, I appreciate your job a lot, I have small request if is possible. I would like a option to remove the camera tab in the main screen. Regards ;) ftrequest

suraj0208 commented 7 years ago

According to me the camera tab cannot be hidden through xposed there is some method level code involved. The hide tabs feature works by skipping some method calls and changing the return values. This cannot be done for camera tab. If you are interested in more technical explanation comment below I'll explain.

ghost commented 7 years ago

I would appreciate it if you would explain it to me. I'm modify your code to try hide it, but I didn't get good results

suraj0208 commented 7 years ago

There are two methods hooked to hide status tab. 1) The viewpager adapter has a method which return the number of tabs to inflate, In my implementation we want 3 tabs instead of 4 ( we want to hide tab at index 2 and inflate tab 3 at its place ). so we hook the method and return 3 from beforeHook

2) Another method used here basically tells which fragment to inflate so when argument to that method is 2 we want to set it to 3 so that 3rd tab will be rendered. So in before hook param.args[0] is modified.

if we apply the same logic for camera i.e set tabs count to 2 and change arg to 1 when it is originally 0 , whatsapp force closes. That means there is some other code that depends on tab 0. If its a method ( which I couldnt find ) we can skip that method call if it doesnt affect other functionality. If it is some part of the code, I'm afraid we cannot use xposed here.

ghost commented 7 years ago

I think i get it. Is there any way to remove it in "drawable"?

Thank you very much for response

suraj0208 commented 7 years ago

can you specify what to you mean by "drawable". If we somehow get the reference to that camera tab. We can set the visibility to gone but user can still switch to that tab. For that we can hook method which is called when tab is changed ( not sure about name and if it exists ) and set changed tab to current tab in beforeHookedMethod. I gave you a hint. See if it is possible, create pull request. I'll merge.

ghost commented 7 years ago

I understand, I'll try hide it. If I have some news I post here. Thank you, Regards ;)

suraj0208 commented 6 years ago

@nosijf982 any updates on that?

ghost commented 6 years ago

No, I had tried a few months ago but without any result, at this moment i'm busy with classes and I don't have time.Sorry

Good luck ;)

suraj0208 commented 6 years ago

Yeah no problem. Just wanted to know. All the best

Krowne commented 6 years ago

Now that I read this, I will shed some light on the matter (without the results you expect).

The camera tab is not created in the same way as the "Text Only" tabs, it creates an image and text dynamically in another method. The text tabs, create them in a totally different method, which is accessible and you can modify the variables. The method of the camera tab uses local variables, which can not be modified with Xposed, since you can only modify public variables. Therefore, it is impossible to modify or delete this tab with Xposed.

suraj0208 commented 5 years ago

as per the above comment closing this for now.