I've developed an xposed module for whatsapp.
http://forum.xda-developers.com/xposed/modules/mod-whatsapp-extensions-add-extra-t3452784
I wanted to add feature to hide our own last seen still see others or report a fake last seen for eg: 1 Jan 1970.
I made following assumptions:
To do that first I hooked date and System.currentTimeInMillis methods to make whatsapp think its 1 Jan 1970. That worked but still last seen was shown perfectly.
Assumption: The last seen time value is directly taken from the server
Then I looked in the source to find where last_seen preference is referenced. Turns out it is only referenced in SettingsPrivacy activity's class.
Assumption: To hide our last seen and still see others we need to change last seen preference to 'visible to all' and turn that back to off once we get the last seen.
but the problem is it uses onPreferenceChangeListener. We cannot hook a method from the interface directly.
I cannot find the subclass which implements onPreferenceChangeListener as the classes shown in code are synthetic.
Please if anyone can help me with this, it will be great. I need to find which is preferencechangelistener for that preference. Rest I will manage.
This is kind of a brute force trick to get the implementation but I guess you can hook the app ClassLoader.loadClass and for each loaded class check if it implements the interface. If so hook its onPreferenceChangeListener.
I found a way to do it and its working.
http://forum.xda-developers.com/xposed/modules/mod-whatsapp-extensions-add-extra-t3452784
The way to do it is by hooking a method which takes a preference as argument. We create a preference ( com.whatsapp.preference.WAprivacy preference to be precise ) and then pass this preference with last seen set to desired value to the method. And we are done.
It is working so far.
Related
I'm repairing my friend's code and got confused.
My friend wants to fetch entered text (in EditText). Seems easy, right? Well, it is but instead of user input, he gets this warning/error:
To be honest I'm not sure how to fix it. He is coding in Kotlin (Android 10).
Activity that contains EditText:
And XML:
This is how it looks when debugging:
The app started working just fine after running "File -> invalidate Cashes/Restart" option, I just don't understand where this warning came from and how to fix it because the error remained unchanged (even though the app works). Do you have an idea how to solve it?
All the best!
fyi lambda expression like setOnClickListener from kotlin is not debuggable, see here.
if you want to debug variables inside setOnClickListener you should use the normal one e.g. setOnClickListener(object: View.OnClickListener {..})
sometimes there will be problem in auto generated binding files, if so it will be solved after invalidate cache and restart ide. sometimes the warning/error show but the project and complied without errors. so no need to worry about that. for next time post the code as code not screen shots.
I understand that the question is regarding evaluating expression, but there is a way you can read variables from your debugger console, even if you're inside an anonymous callback. I found it helpful sometimes. Here are the steps:
First enter debugger mode inside of your anonymous callback,
In your debugger console, look at the right side for "Frames"
Within Frames under , you'll see stack of function execution first top one on the list is the latest:
Click on row(s) below the latest function, until you find an instance of your activity AddInformationActivity. You will see the activity instance on the right side window under Variables. Don't go as far as selecting functions browned out, because those are from internal libraries.
When you see you AddInformationActivity instance, you can expand it and see its variables.
Hope that helps!
It's not a beautiful way, but if you create a method like this:
private fun debug() {
println()
}
and add a breakpoint on the println() it'll capture the activity.
(Don't use TODO as it'll crash the app with a NotImplementedError once called.)
I have this method now in my code all the time to call it whenever I need it.
I know, that question is old, but I just stumbled over it and needed a way.
I am using MVVMCross's wrapper around the Xamarin Android AutoCompleteTextView.
I use the PartialTextChanged changed event to signal that I need to call the ViewModel, from the View, to get some more suggestions.
This works fine up to the point the user selects an item from the list. After that point no changes to the text will cause the PartialTextChanged event to fire. It is as if filtering is turned off once a selection has been made.
There is a SetText method on the AutoCompleteTextView that seems to turn filtering on\off but I am unsure of the best way to use that.
The TextChangedEvent still fires on the control as does AfterTextChanged just not PartialTextChanged and it is that which drives the updates.
I have debugged through the MVVMCross source and cannot see a solution. Any have any ideas?
Where can I browse them mondroid\xamarin android code?
Thanks
After attaching the MVVMCross Source Code and debugging all the events I found that under certain circumstances I was not updating the ItemsSource after the PartialText property was being changed
The FilteringAdapter uses a ManualResetEvent around the change to PartialText and that is only signalled\set by the NotifyDataSetChanged method.
After finding this I also found that #slodge also mentions this in this answer, AutoComplete MVVM and Java Castings without using Java.Lang.Object on ViewModel. A constraint that until now had passed me by.
Note that because of the Android threading model it is essential that
every change in PartialText is met by an eventual signalled change in
ItemsSource - and this should be a single change in object collection
rather than lots of small changes.
Thanks
I want to make a small change to the Android standard TimePicker class. Specifically, I'm trying to change it so it works in 15 minute increments, rather than 1 minute increments.
This post helped me constrain the range of minute values to {0, 15, 30, 45}, as required in my app. But as I pointed out in a follow up comment, the minute spinner still shows previous minute as current value - 1, and the next minute as current value + 1, which creates a sloppy-feeling user interface.
I looked into the relevant Android source code, and it appears that the changes I would need to make are pretty simple. But when I tried copying the source code into my project I got about a zillion errors relating to the package declaration, where to find Widget, how to resolve R.id variables, etc.
So my question is:
What's the best way to make a small change to a given class from Android source code, and incorporate it into your own project?
In my case, I just need to make a few small changes to TimePicker and NumberPicker, but I'm not sure how to properly set this up in my project.
Thanks for any suggestions.
But when I tried copying the source code into my project I got about a zillion errors relating to the package declaration
Your source file's directory needs to match the package name. And since you cannot overwrite android.widget.TimePicker, you will either need to move that class to a new package or give it a new name.
where to find Widget
That implies that you copied TimePicker into one of your packages. That is fine, but then you need to add in the appropriate import statements for classes that TimePicker referred to from its original package. Or, you need to keep your (renamed) TimePicker in android.widget, adding this package to your project. This is rudimentary Java.
how to resolve R.id variables
If TimePicker relies upon resources that are not part of the Android SDK, you will need to copy those resources from the AOSP into your project as well.
What's the best way to make a small change to a given class from Android source code, and incorporate it into your own project?
IMHO, that cannot be answered readily in the abstract. Generally speaking, you do the sorts of things that I listed above.
You are best off subclassing the relevant classes and overriding the methods you would like to change.
In Java, you can do the following in a subclass:
The inherited fields can be used directly, just like any other
fields.
You can declare a field in the subclass with the same name as
the one in the superclass, thus hiding it (not recommended).
You can
declare new fields in the subclass that are not in the superclass.
The inherited methods can be used directly as they are.
You can write a new instance method in the subclass that has the same signature as the one in the superclass, thus overriding it.
You can write a new static method in the subclass that has the same signature as the one in the superclass, thus hiding it.
You can declare new methods in the subclass that are not in the superclass.
You can write a subclass constructor that invokes the constructor of the superclass, either implicitly or by using the keyword super.
More info on subclassing in Java
So, what I'm actually looking for is this solution: Get/pick an image from Android's built-in Gallery app programmatically but working in a preference and not in an activity.
I created a class that I put in my setting and I want to use that class to be able to find the URI of an image selected by the user on its phone. I couldn't use the code in that link because of "startActivityForResult". Which is not available in a preference.
Any idea how to bypass this ?
PROGRESS REPORT:
So, I tried some stuff in the mean time. Instead, in my settings, I added the following:
<Preference
android:key="test"
android:title="open image"
android:persistent="true">
<intent android:action="android.intent.action.GET_CONTENT"
android:value="image/*"/>
</Preference>
First, instead of "GET_CONTENT", it was "PICK", but with it, I can only go with Google Docs and the Sim Card Tool Kit, which is far from the gallery or any thing to browse the file system.
With "GET_CONTENT", it crashes.
I also added the "android.permission.WRITE_EXTERNAL_STORAGE" premission, even if I just want to read. But I didn't found any (let put this as a sub question, if there's a way to just ask to read and not write).
PROGRESS REPORT #2
I replaced android:value by android:mimeType and I goes directly to the gallery. Now, just need to know if I really got the URI and it's solved.
PROGRESS REPORT #3
At this point, here's the real problem. When I go through my SharedPreferences, the value stays empty, even after selecting an images. So, I guess there a little hack to do. So now, that's the question. Based on the example of my preference screen above, how can I retrieve the value of "test", assuming that when the intent is called, it put it somewhere ?
I finally found a solution... it's not as feng shui as I would like, but it works.
I simply code the preference screen by hand and then I was able to access the "startActivityForResult" function.
From this point, it took 3 to 5 minutes to solve it and finalize all the details.
Hope it helps some people.
You have an example there: http://www.anddev.org/code-snippets-for-android-f33/preference-screen-with-custom-views-t8472.html
But the one I used was on google, but I couldn't find the link.
So I have this big stupid problem with the preferences in my live-wallpaper.
First, PreferenceManager.getDefaultSharedPreferences, doesn't work. I'm calling it in my Main class, a subclass of WallpaperService in the function onCreate. For the parameter, I first tried "this" and then this.getBaseContext(), but it doesn't matter. So, when I print the values, nothing shows up!
Second, I saw in another answer here that to put some default values, use something like PreferenceManager.setDefaultValues(this.getBaseContext(), R.xml.setting, true);. So, this, doesn't get my defaultValues at all. They're all zeros and even one values from my setting.xml doesn't show up in the list. I explicitly put a android:defaultValue for each of them.
Note that once I put values for each of them in the preferences, this problem doesn't happen. But still, for someone who installs my app, it needs to work on the first time it's launched.
Preferences are a bear. I always start with a working example, and then modify it to suit my needs; it's impossible to remember the formalisms :-). The "obvious" place to start is the "second" Cube example in the SDK, which uses a preferences activity to choose between cube and dodecahedron shapes. For something more sophisticated, you might wanna look at Moonblink's "Substrate" package, which combines multiple wallpapers, and has complex settings. Project home is here: http://code.google.com/p/moonblink/wiki/Substrate , then click Source at top left, then Browse, Trunk, Substrate, src, etc. GF