yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] Kamy:
To kill contacts app I am using this script and it seems there is a problem with that, as when I click on it, only "1" would be shown on the toast and it doesn't kill the contacts app, any help would be appreciated.

<PreferenceScreen
android:key="script#kill_contacts"
android:summary="Tap to restart Contacts"
android:title="Restart Contacts" />

#!/system/bin/sh
export PATH=/system/bin:$PATH

mount -o rw,remount /system

pkill -TERM -f com.android.contacts
[Android Apps and Games] Wuby986:
It has to be

mount -o remount,rw /system
[Android Apps and Games] Kamy:
Doesn't happen. Still cannot kill the app.

Edit: after implementing the code that Anna mentioned it's working. Thanks [MENTION=5493353]Wuby986[/MENTION]
[Android Apps and Games] Wuby986:
Well nice!!! Actually that was an error that could have fail the exec of the script, but it is not necessary to use pkill, actually pkill is a busybox part and it just need it to be installed
[Android Apps and Games] daxgirl:
You don't need to remount system r for pkill.

The pkill -TERM doesn't work for contacts.

Just use pkill com.android.contacts

You don't need to implement the code for that. Just change your script.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] daxgirl:
Or do you mean you implemented the code I mentioned for special key condition?

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Kamy:
Yes I meant that code though I listened to your advise and didn't use it, only used pkill and it's working. No doubt you guys rock.
[Android Apps and Games] rompnit:
[MENTION=4819130]kmokhtar79[/MENTION].. You can always trigger a 'silent' restart of the apk through HandlePreferenceFragments (I noticed you're restarting contacts).. Doing so makes it function like you have an observer in place. ;)

So for example I have added they keys for digit and background colors to the case "ColorPickerPreference", so as soon as a color is set contacts is restarted and colors applied instantly (at least fast enough that you can close ROM Control and open the dialer w/o any delay)

Here's what I added (In red):

case "ColorPickerPreference":
ColorPickerPreference cpp = (ColorPickerPreference) pf.findPreference(key);
cpp.setColor(sharedPreferences.getInt(key, Color.WHITE));
[COLOR="Red"] if (key.equals("dialer_background_color")) {
Command c = new Command(0, "pkill com.android.contacts");
try {
RootTools.getShell(true).add(c);
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}
} else if (key.equals("main_digit_color")) {
Command c = new Command(0, "pkill com.android.contacts");
try {
RootTools.getShell(true).add(c);
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}
} else if (key.equals("main_letter_color")) {
Command c = new Command(0, "pkill com.android.contacts");
try {
RootTools.getShell(true).add(c);
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}
}[/COLOR]
break;
[Android Apps and Games] daxgirl:
That's really the best way to go about those things!!!

Creating a screen preference to execute scripts is good for complex script. F.e... enable init.d... or manipulate alot of data on partition. .. create nandroid from your custom settings app... and so on...

For killing apps it's better to set silent/dialog special key action like you did.

One more thing. .. who came up with the complexity of pkill -TERM -f package.name??? The command pkill package.name works properly in any Unix shell. ..

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] daxgirl:
[MENTION=1167171]rompnit[/MENTION]... let's make a method for silently killing apps so you don't need to copy the entire try catch for each condition. .. you're a pro enough to do that... ???

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Kamy:
Amazing [emoji120] I am just speechless.
[Android Apps and Games] daxgirl:
Special method for the kick of it

[MENTION=1167171]rompnit[/MENTION] let's try some java fun with you... Just for the kicks of it and because I love you!

Open the HandlePreferenceFragments and at the end of the class before the last closing bracket add this nifry method:

[COLOR="Blue"][B] private void andyKillApp(String pckgName){
Command c = new Command(0, "pkill " + pckgName);
try {
RootTools.getShell(true).add(c);
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}[/B][/COLOR]
}

Now go to where you added all your special keys, delete all and add this instead:

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference p = pf.findPreference(key);
switch (p.getClass().getSimpleName()) {
.
.
.
.
case "ColorPickerPreference":
ColorPickerPreference cpp = (ColorPickerPreference) pf.findPreference(key);
cpp.setColor(sharedPreferences.getInt(key, Color.WHITE));
[COLOR="Blue"][B] String[] keysForContacts = {"dialer_background_color", "main_digit_color", "main_letter_color"};
for (int i=0; i<keysForContacts.length; i++){
if(key.equals(keysForContacts[i])){
andyKillApp("com.android.contacts");
}
}[/B][/COLOR]
break;

Needless to say that any more key you come up with for contacts. you just add to the String[] (which is just a string array).

;)
[Android Apps and Games] Kamy:
one bracket forgotten :laugh:

[COLOR="Blue"]private void andyKillApp(String pckgName) {
Command c = new Command(0, "pkill " + pckgName);
try {
RootTools.getShell(true).add(c);
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}
[COLOR="Red"]}[/COLOR]
} [/COLOR]

I am just showing my assignment and far from what you are doing guys, This is what I added for ListPreference according to [MENTION=4714483]daxgirl[/MENTION] and seems working.

case "MyListPreference":
MyListPreference l = (MyListPreference) pf.findPreference(key);
String lValue = sharedPreferences.getString(key, "");
//Any action on the rouge list preference will be performed only if there was no exception
if (!isOutOfBounds) {
CharSequence[] mEntries = l.getEntries();
int mValueIndex = l.findIndexOfValue(lValue);
l.setSummary(mEntries[mValueIndex]);
l.setSummary(mEntries[l.findIndexOfValue(lValue)]);
[COLOR="Red"] String[] keysForContacts = {"dialer_background_style"};
for (int i=0; i<keysForContacts.length; i++){
if(key.equals(keysForContacts[i])){
andyKillApp("com.android.contacts");
}
}[/COLOR]
} else {
l.setSummary("");
}
break;
[Android Apps and Games] daxgirl:
This is VERY nice!!! You can change the method name... you can call it aryaModKillApp or mokhtarKillApp ;) Andy is just an example for special people called Andy to take care of their special keys ;)

Plus, you only have one key... you can just use a condition and call the method for that cobdition. No need to run 'for' loop on one string. For loops are better to handle more than 2 items in array. You just have one ;)

I will explain what that means... I created a string array of strings (keys). Then I called a for loop and said basically : please go over all the keys on the array (from 0 position (int i=0) to the end of array (i <array.lenght), and if key equals a key at given position in an array , call a method to kill an app.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Kamy:
So no matter if it's ColorPickerPreference or MyListPreference or CheckBoxPreference, we add our key in strings (key)?
[Android Apps and Games] daxgirl:
Well you need to be in the right preference case preferably. But you can create more than one string array and more than one loop. It would be easier for me to come up with one common solution for all keys that need certain app reboot if I had more info. In any case, we can work with keys regardless of what type preference they come from. This method is a special method that takes care of any change in the shared preferences file for this fragment.

So when a preference gets changed, it knows the key for it. So we can just make special conditions for all keys regardless of preference.

I am off to sleep now before the night shift but tomorrow when I have time I will make a little example of what I mean. ...
[Android Apps and Games] daxgirl:
You're such a smali coder... just make a long if statement with || separations (meaning "or") for all your keys and then call the method once... not that you're doing it wrong... but mannnnn that's a lot of code... ???
[Android Apps and Games] tdunham:
Honey, I just haven't had the time. :crying:

I already have custom backgrounds for notification panel, Fullscreen InCall and Main Dialer so wasn't in a huge rush to jump in. Its not nearly as elegant as this one but I'll get to it as soon as I can.
[Android Apps and Games] daxgirl:
Np. Let me know if and when you're ready for it.
[Android Apps and Games] tdunham:
Lol, yes that makes more sense doesn't it to use 'or' instead of inefficient 'if/else'.
[Android Apps and Games] Kamy:
Nice. Thank all of you guys.

Edit: Tapatalk doesn't let me hit the thank button. Would catch up clicking again.
[Android Apps and Games] daxgirl:
No worries. Well that [MENTION=1042140]tdunham[/MENTION] for you... the man is the king!!!
[Android Apps and Games] tdunham:
You may already be using this but for reference for the modification you need I have already created guide on how to utilize global Boolean and included is how to create modcfg toggle examples for rom control with default ON or default OFF condition in smali.

It is located in my guide thread under miscellaneous for future reference if ever needed:

[Guide] How to setup a global Boolean toggle that will work anywhere in SystemUI
[Android Apps and Games] Kamy:
Really appreciate. I have been reading it since you shated it and eventually did it for colorizing mod. This is an amazing boolean that makes the mod more joyful after understanding it. [emoji106]
[Android Apps and Games] JonathanRAZ:
Thank you [MENTION=5750672]Er. Aditya[/MENTION] your source helped me with how to use calligraphy and chrisjenx source helped https://github.com/chrisjenx/Calligraphy/blob/master/README.md and [MENTION=4714483]daxgirl[/MENTION] thank you again for the rom control and all greatest devs in here
[Android Apps and Games] daxgirl:
Looks awesome!!!!!! Congrats!!!
[Android Apps and Games] JonathanRAZ:
Thank you thats what happens when we use the search button :) i still have way more edit to do learned some basic stuff but helped me a lot on this journey lmao
[Android Apps and Games] daxgirl:
Nice!!! I like the font. Elegant and simple.
[Android Apps and Games] JonathanRAZ:
Its my favorite font its ComingSoon Font
[Android Apps and Games] Er. Aditya:
That's the way we learn here...congrats and have a great day :)
[Android Apps and Games] tdunham:
So...

I spent a good deal of yesterday dealing with reinstalling android studio and sdk, took me several tries and then there's always the blessing of figuring out all the initial errors to get it going. Of course, it didn't help that I had two SDK's installed to begin with. LOL

Anyway, I decided to download the current git and merge my changes and just noticed that thumbnailpreferences isn't included. Just wondering, its a great feature. I think I was the one to ask for it way back when. :D

Edit: Just found the additional rom control thumbnailpreference files and attached it.

Not sure if its all there but it must be what I got from here originally to add to mine.
[Android Apps and Games] asc1977:
I searched about this for m todo list. I am right that that is the way to show preview of icons we can choose that we can use for exampöe for toggle round background image?

In which post you find that so i can read there a little before starting to implement.

Thx
[Android Apps and Games] daxgirl:
Hey Troy (oh the almighty and never sleeping one)!

Yeah, we still haven't merged the thumbnail preference... HUGE ROFL! I mean I remember that we added it as beta feature.. and now a year later with every dev using it, it's still not up on git...

That's my bad actually. I keep thinking... OK. In v2. So guess what I am thinking now... so ok... in v2.. ??????

Di you need help re-implementing it? You're so brave to reinstall studio. If my studio needs reinstalling, I have a suicide note ready... ???????
[Android Apps and Games] daxgirl:
Here you go

http://xdaforums.com/showthread.php?p=63548185
[Android Apps and Games] asc1977:
Thx anna, i read later there and try to add to romcontrol. I like if i see what i choose before choose
[Android Apps and Games] daxgirl:
Dear friends,

Signing Rom Control

It's note worthy that any app, especially built with app compat, will run faster and smoother in release build than in debug build. We have never emphasized this before, but our friend [MENTION=5750672]Er. Aditya[/MENTION] has brought to our attention that opening app is abit laggy sometimes.

1. It's all is being reworked. The code for now is overall old and needs to be optimized ALOT.

2. Running debug build is always slower.

Here is Google's guide to create signing configs and build a release version.

We HIGHLY recommend you do that.

Please note! before updating sources on git REMOVE any signature information from your sources.​
[Android Apps and Games] Er. Aditya:
thankyou ma'am just signed my first :D
[Android Apps and Games] asc1977:
Get it. Thx anna
[Android Apps and Games] Gayos24:
20:42:49 Gradle sync started

20:42:58 Gradle sync failed: Gradle version 2.2 is required. Current version is 2.10. If using the gradle wrapper, try editing the distributionUrl in C:\Users\remyz\Desktop\rom control\CustomSettingsForDevs-master\gradle\wrapper\gradle-wrapper.properties to gradle-2.2-all.zip.

Please fix the project's Gradle settings.

Consult IDE log for more details (Help | Show Log)

how to fix this ?
[Android Apps and Games] daxgirl:
As it says.. you need to fix the version of gradle wrapper. You can find more help with this by researching online. Compilation errors which are IDE related is not what we can help you with. But a lot of info on those errors online.
[Android Apps and Games] daxgirl:
Sooooooo we have some exciting project going on...

Highlights:

1. No more million fragments. One fragment manages different preferences.

2. Updated navigation drawer.. adding items is a piece of cake...

3. Some new exciting preference classes, f.e. script preference and intent preference are independent subclasses of preference class which manage their own work. No more conditions for them in the main fragment...

4. Built in about activity...

5. Built in select image functionality...

We will need to open a new thread. Because we can not merge old op with new one. It's going to be... well, NEW. [MENTION=2739548]tamirda[/MENTION], prepare to SUFFER... ???
[Android Apps and Games] tamirda:
oh well. i I have too :silly::silly::silly:
[Android Apps and Games] Kamy:
[emoji7]
[Android Apps and Games] JonathanRAZ:
Thank you wow this update nice great job
[Android Apps and Games] nguyentankiet:
Your work is great, when release new source, anna?
[Android Apps and Games] tdunham:
I have an unusual problem. I just reinstalled android studio recently and I noticed that a bunch of menu items are completely gone from this section where I call a few shell scripts. All of the scripts do exist.

Screenshots attached.

Last screenshot is what is supposed to be displayed.
[Android Apps and Games] Kamy:
I had it too. But if I remember well it was fixed after cleaning project in android studio (toolbar>build>clean project)
[Android Apps and Games] daxgirl:
Troy, replace dots in your scripts names with underscores. Or dashes... anything but dots...

It removes them because it thinks those are app activities that don't exists...

???

And of course, as Kamy said, cleaning build is always a good idea.
[Android Apps and Games] tdunham:
Good stuff, everything is working again as it should. I'm not sure why I did the names that way because I normally use the underscores but I must have had an off day because I did that with the entire group.

Well at least those were the only ones, I have a ton of shell scrips for various tasks and these were the only oops. :)
[Android Apps and Games] daxgirl:
I am sure you never have off days.. you just get very distracted on a certain hangouts group... it's our fault ?
[Android Apps and Games] micky387:
[MENTION=4714483]daxgirl[/MENTION]

thanks for all your work and [MENTION=5493353]Wuby986[/MENTION] too .

I've added ThumbnailListPreference stuff. Working great :good:

I have just one issue. If i add "android:dependency=" in .xml with this pref ,i have a FC

Is it possible to edit ThumbnailListPreference.java for this ??

Thanks a lot anna :cool:
[Android Apps and Games] daxgirl:
Mmmmmmmmmmmmmm interesting. We will have a look at what the **** it wants... thanks!!!
[Android Apps and Games] micky387:
Logcat in android studio give me

I dont know if it will help you ;)
[Android Apps and Games] daxgirl:
Actually, it does. Will add condition for that to test if the view is enabled. Thanks.
[Android Apps and Games] ROBERT CM:
Thanks [MENTION=4714483]daxgirl[/MENTION] and [MENTION=5493353]Wuby986[/MENTION] for this amazing update and for continue give support to this great proyect..

Waiting release this new source.. [emoji2]
[Android Apps and Games] amtra:
[MENTION=4714483]daxgirl[/MENTION]

i tried to add this code in rom control ui_prefs.xml to make it bit more Detailed view

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Status Bar Mods">
<PreferenceCategory android:title="Notification Panel Background">
<PreferenceScreen android:title="Select Image" android:key="notification_panel_bg" android:dependency="enable_custom_bg" />
<com.wubydax.romcontrol.prefs.SeekBarPreference android:max="255" android:title="Image opacity" android:key="notification_panel_alpha" android:dependency="enable_custom_bg" android:defaultValue="255" min="0" />
<SwitchPreference android:title="Custom Background" android:key="enable_custom_bg" android:defaultValue="true" android:summaryOn="Custom bg enabled" android:summaryOff="Custom bg disabled" />
</PreferenceCategory>
</PreferenceCategory>
<PreferenceCategory android:title="Touchwiz Mods">
<PreferenceCategory android:title="Gesture anywhere on Home screen" />
<com.wubydax.romcontrol.prefs.MyListPreference android:entries="@array/launcher_gesture_entries" android:title="Double tap" android:key="doubletap" android:summary="%s" android:entryValues="@array/launcher_gesture_values" />
<com.wubydax.romcontrol.prefs.MyListPreference android:entries="@array/launcher_gesture_entries" android:title="Swipe Up" android:key="swipe_up" android:summary="%s" android:entryValues="@array/launcher_gesture_values" />
<com.wubydax.romcontrol.prefs.MyListPreference android:entries="@array/launcher_gesture_entries" android:title="Swipe Down" android:key="swipe_down" android:summary="%s" android:entryValues="@array/launcher_gesture_values" />
</PreferenceCategory>
</PreferenceCategory>
</PreferenceScreen>

I got compilation errors, should i need to add PreferenceCategory or PreferenceScreen?
[Android Apps and Games] Wuby986:
and the error is shown in log?
[Android Apps and Games] amtra:
W: D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\res\xml\ui_prefs.xml:17: error: Error parsing XML: mismatched tag
W:
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\SENTHI~1\AppData\Local\Temp\brut_util_Jar_2815275134963419158.tmp, p, --forced-package-id, 127, --min-sdk-version, 21, --target-sdk-version, 21, --version-code, 1, --version-name, 1.0, -F, C:\Users\SENTHI~1\AppData\Local\Temp\APKTOOL6966568622958854891.tmp, -0, arsc, -0, arsc, -I, D:\Sundar\Ramesh\AdvancedApkTool\1-BDFreak\Frameworks\1.apk, -S, D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\res, -M, D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:437)
at brut.androlib.Androlib.buildResources(Androlib.java:371)
at brut.androlib.Androlib.build(Androlib.java:281)
at brut.androlib.Androlib.build(Androlib.java:254)
at brut.apktool.Main.cmdBuild(Main.java:224)
at brut.apktool.Main.main(Main.java:84)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\SENTHI~1\AppData\Local\Temp\brut_util_Jar_2815275134963419158.tmp, p, --forced-package-id, 127, --min-sdk-version, 21, --target-sdk-version, 21, --version-code, 1, --version-name, 1.0, -F, C:\Users\SENTHI~1\AppData\Local\Temp\APKTOOL6966568622958854891.tmp, -0, arsc, -0, arsc, -I, D:\Sundar\Ramesh\AdvancedApkTool\1-BDFreak\Frameworks\1.apk, -S, D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\res, -M, D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:436)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:423)
... 5 more
Caused by: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\SENTHI~1\AppData\Local\Temp\brut_util_Jar_2815275134963419158.tmp, p, --forced-package-id, 127, --min-sdk-version, 21, --target-sdk-version, 21, --version-code, 1, --version-name, 1.0, -F, C:\Users\SENTHI~1\AppData\Local\Temp\APKTOOL6966568622958854891.tmp, -0, arsc, -0, arsc, -I, D:\Sundar\Ramesh\AdvancedApkTool\1-BDFreak\Frameworks\1.apk, -S, D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\res, -M, D:\Sundar\Ramesh\AdvancedApkTool\3-Out\RomControl.apk\AndroidManifest.xml]
at brut.util.OS.exec(OS.java:95)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:430)
... 6 more
[Android Apps and Games] Wuby986:
are you decompiling it!?!?!?

what's wrong!?!?

you have SOURCES and you are supposed to USE that in android studio. we don't help on decompile our own OPENSOURCE app......... got what i mean?
[Android Apps and Games] amtra:
Yes for sure... but i dont have my own pc so i will trying out these mods on my office PC. Dont have system Admin Rights to Install Android studio, if i do illegally i will be fired out.. This is wat the situation around here for months.. BTW thanks for ur Answers..:good:
[Android Apps and Games] Wuby986:
Then you shouldn't be using the app if you cant.

you are lucky you can use all the tools you need for modding without admin rights.

Inviato dal mio SM-G935F utilizzando Tapatalk
[Android Apps and Games] amtra:
The only tools i am using is apktool for compile/decompile and Notepad++ as both can run without admin rights
[Android Apps and Games] daxgirl:
Let's us put it for you this way. You are not allowed to use apktool on our app. You're not allowed to use it on ANY app since it's a hacking tool.

We all use apktool, but we don't come to samsung to ask why their app is not possible to compile with apktool. So same is here. If you use it - use it, we can't stop you. If you come to us and tell us that you use apktool on our app, you are risking being sued. So far so good?
[Android Apps and Games] amtra:
I understood mam.. Will try to learn how to overcome this error. BTW thanks for u both.. :good::good:

---------- Post added at 05:30 PM ---------- Previous post was at 05:07 PM ----------

One more question.. Can i add Preference Fragment inside another Preference Fragment?
[Android Apps and Games] daxgirl:
Theoretically speaking yes. There is nested fragment support in android. But not a preference fragment inside another preference fragment. In order to nest a fragment you need a layout container. Preference fragments do not have layouts per say.
[Android Apps and Games] amtra:
Thanks for ur help...:good: