yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] daxgirl:
The way you explained it you wanted the dependencies to be the same boolean as the master switch. If you want it the opposite, inside setDependencies method add exclamation point where you say setChecked. F.e. setChecked (!isMasterChecked)...

Full method:

private void setDependencies(boolean isMasterChecked){
String[] keysArray = {"one_key", "two_key", "three_key"}; //You can set as many keys as you want to be dependent as long as they are all switch preferences. You can play around with that
for(int i=0; i<keysArray.length; i++){
SwitchPreference dependantSwitch = (SwitchPreference) pf.findPreference(keysArray[i]);
dependantSwitch.setChecked([COLOR="Blue"][B]![/B][/COLOR]isMasterChecked);
}
}
[Android Apps and Games] tdunham:
The exclamation point causes a StackOverflowError with Rom Control. I haven't seen that one before and its doesn't even give me a toast, just pauses and closes the app silently.
[Android Apps and Games] daxgirl:
It most definitely shouldn't do that. I will give it a go when I get to pc later on and update you. Or just expand a condition. As in if (isMasterChecked){

.....setChecked (false)...

}else {

.....setChecked (true)...

}

Just an idea. Since I am without pc I cannot type whole code.

But there is no reason for your error. All the exclamation point did was use the boolean in reverse. It's a legitimate java statement.
[Android Apps and Games] Martillero:
It's working for me, i have two text views on same space so i use a switcher to choose between them.

I did this:

case "SwitchPreference":
SwitchPreference s = (SwitchPreference) pf.findPreference(key);
s.setChecked(sharedPreferences.getBoolean(key, true));
if(s.getKey().equals("MyCustomText_toggle")){
setDependencies(s.isChecked());
}
if(s.getKey().equals("Cpu_text_togle")){
setDependencies2(s.isChecked());
}
break;

Downthere i ve set 2 new methods:

private void setDependencies(boolean isMasterChecked){
String[] keysArray = {"Cpu_text_togle"};
for(int i=0; i<keysArray.length; i++){
SwitchPreference dependantSwitch = (SwitchPreference) pf.findPreference(keysArray[i]);
dependantSwitch.setChecked(!isMasterChecked);
}
}

private void setDependencies2(boolean isMasterChecked){
String[] keysArray = {"MyCustomText_toggle"};
for(int i=0; i<keysArray.length; i++){
SwitchPreference dependantSwitch = (SwitchPreference) pf.findPreference(keysArray[i]);
dependantSwitch.setChecked(!isMasterChecked);
}
}

So, when one switcher in on the other disable it automatically along with all its normal dependencies. I had some fc only when i put a non existing key (two_key", "three_key").
[Android Apps and Games] daxgirl:
Yeah, no reason for !boolean not to work. Unless it's a java version problem.
[Android Apps and Games] tdunham:
I think this was a mistake on my part. I put the keys in place of master_switch instead of leaving it alone .

Is this value correct, leave it as master_switch?

if(s.getKey().equals("[COLOR="Blue"]master_switch[/COLOR]")){

Here is where I added it for switchpreference, I just wanted to make sure was ok there:

case "SwitchPreference":
SwitchPreference s = (SwitchPreference) pf.findPreference(key);
s.setChecked(sharedPreferences.getBoolean(key, true));
if (key.equals("quick_connect_toggle")) {
appRebootRequired("com.android.systemui");
} else {
}
if (key.equals("toggle_background_enable")) {
appRebootRequired("com.android.systemui");
} else {
}
if (key.equals("custom_carrier")) {
appRebootRequired("com.android.systemui");
}
[COLOR="blue"]if(s.getKey().equals("master_switch")){
setDependencies(s.isChecked());
[/COLOR] }
break;

Edit:

Oops, just noticed I left out the ELSE.

Be right back...
[Android Apps and Games] Wuby986:
master_switch is supposed to be the name of the switch the other dependency will depend on.. so it has to be the name of the key as you put it in the xml
[Android Apps and Games] daxgirl:
Actually "master_switch" is supposed to be the key for your preference which others are dependant on.
[Android Apps and Games] daxgirl:
Jinx ???
[Android Apps and Games] tdunham:
I found a typo you both are too quick I edited the post ;), forgot the else statement but it didn't seem to matter.

The reason I asked about the master_switch is because I see this reference to isMasterChecked. Anyway, I have more info... without the exclamation point, the dependency statement seems to work as it always has (no difference in the way it works), with the exclamation point, stackoverflow error.

master key on, so are the dependencies

master key off, so are the dependencies

What I am trying:

master key off, dependencies are on

master key on, dependencies are off

---------- Post added at 11:54 AM ---------- Previous post was at 11:51 AM ----------

And I know you asked, the two dependencies I am trying to toggle state are not switchpreferences, they are MyListPreference & IntentDialogPreference.

Maybe this is the difference.

---------- Post added at 12:07 PM ---------- Previous post was at 11:54 AM ----------

I removed the dependencie statements from both MyListPreference & IntentDialogPreference just to test. It force closes rom control when the exclamation point is added if I select the switchpreference toggle so it doesn't appear to work as intended. I will let you review your changes when you have the extra time. :D
[Android Apps and Games] Wuby986:
nor the else nor the kind of preference makes difference in this case.

i don't see the " ! " in your code.. where you put it?
[Android Apps and Games] tdunham:
I amended my post above if you didn't see it:

I removed the dependencie statements from both MyListPreference & IntentDialogPreference just to test. It force closes rom control when the exclamation point is added if I select the switchpreference toggle so it doesn't appear to work as intended. I will let you review your changes when you have the extra time.

Here is my updated code:

case "SwitchPreference":
SwitchPreference s = (SwitchPreference) pf.findPreference(key);
s.setChecked(sharedPreferences.getBoolean(key, true));
if (key.equals("quick_connect_toggle")) {
appRebootRequired("com.android.systemui");
} else {
}
if (key.equals("toggle_background_enable")) {
appRebootRequired("com.android.systemui");
} else {
}
if (key.equals("custom_carrier")) {
appRebootRequired("com.android.systemui");
} else {
}
[COLOR="Blue"]if(s.getKey().equals("multi_window_enabled")) {
setDependencies(s.isChecked());
[/COLOR] }
break;

Further on down:

private void setDependencies(boolean isMasterChecked) {
String[] keysArray = {"multi_window_enabled"}; //You can set as many keys as you want to be dependent as long as they are all switch preferences. You can play around with that
for(int i=0; i<keysArray.length; i++) {
SwitchPreference dependantSwitch = (SwitchPreference) pf.findPreference(keysArray[i]);
dependantSwitch.setChecked[COLOR="blue"](!isMasterChecked);[/COLOR]
}
}
[Android Apps and Games] Martillero:
Im from phone now, so i cant look it clearly right now, but i think you put the masterkey (multi_window_enabled) inside the method too, you need to put there the key (or keys) that should turn it on/off depending on multi_window_enabled value.
[Android Apps and Games] tdunham:
Here is where the dependies go in my buttons_and_display_prefs.xml:

<SwitchPreference
android:title="Multiwindow"
android:key="multi_window_enabled"
android:defaultValue="false"
android:summaryOn="ON - Custom Longpress disabled"
android:summaryOff="OFF - Custom Longpress enabled" />
<com.wubydax.romcontrol.prefs.MyListPreference
android:entries="@array/left_longpress"
android:title="LongPress Assignment"
android:key="left_longpress_button"
[COLOR="Blue"]android:dependency="multi_window_enabled"
[/COLOR] android:summary="%s"
android:defaultValue="0"
android:entryValues="@array/left_longpress_values" />
<com.wubydax.romcontrol.prefs.IntentDialogPreference
android:title="LongPress Application"
includeSearch="true"
setSeparatorString="\##"
android:key="left_custom_app"
[COLOR="blue"]android:dependency="multi_window_enabled"
[/COLOR] android:summary="None" />

For multi window toggled to off, I need state of left_longpress_button & left_custom_app turned on. Attached is screenshot of how it is currently working and you can see when multi window is off, both dependencies are also off. I need dependencies on, when master is off.
[Android Apps and Games] daxgirl:
Hey, I am back.

See the problem? You told us that the dependant preferences are SwitchPreference. In fact, they are list preference and intent preference. So the method would never work. Because we are making it work on switch preferences. Which would be a problem since it's an instance of a different class.

What you need is reversed dependency in Enabled state. Which is a completely different thing. I know wuby is helping you in private, but since you brought it for discussion here I am saying. What you need is a different kinda method.
[Android Apps and Games] tdunham:
Alright new challenge... :rolleyes:

Right now I have a ListPreference that uses an array but I would like to use the values of the array individually because, for my purposes, I am using drawables as thumbnails to select custom backgrounds.

Rather than having a separate list of the thumbnails, it would be more efficient to select the thumbnail and have it select that item in the array.

So here is the array, nothing special there:

<com.wubydax.romcontrol.prefs.MyListPreference
android:entries="@array/pulldown_bg_entries"
android:title="Select Your Backgrounds Here!!!"
android:key="pulldown_background"
android:summary="%s"
android:defaultValue="0"
android:entryValues="@array/pulldown_bg_values" />

And here is where I have a list of the images for preview...

<PreferenceScreen
android:icon="@drawable/pulldown1"
android:title="Pulldown 1" />
<PreferenceScreen
android:icon="@drawable/pulldown2"
android:title="Pulldown 2" />
<PreferenceScreen
android:icon="@drawable/pulldown3"
android:title="Pulldown 3" />
<PreferenceScreen
android:icon="@drawable/pulldown4"
android:title="Pulldown 4" />
<PreferenceScreen
android:icon="@drawable/pulldown5"
android:title="Pulldown 5" />
<PreferenceScreen
android:icon="@drawable/pulldown6"
android:title="Pulldown 6" />
<PreferenceScreen
android:icon="@drawable/pulldown7"
android:title="Pulldown 7" />
<PreferenceScreen
android:icon="@drawable/pulldown8"
android:title="Pulldown 8" />
<PreferenceScreen
android:icon="@drawable/pulldown9"
android:title="Pulldown 9" />
<PreferenceScreen
android:icon="@drawable/pulldown10"
android:title="Pulldown 10" />
[Android Apps and Games] daxgirl:
If I understand correctly you want a dialog popup with list of items with thumbnales next to each instead of the list preference?
[Android Apps and Games] tdunham:
Correct. A list with thumbnails. It would be a pretty cool addition too I think.
[Android Apps and Games] daxgirl:
Can be done no problem. Send your thumbnails in a zip and we will find an elegant solution for that. I am now studying Content Providers and UriMatchers and believe me as much as I would prefer doing what you ask (which is MUCH easier) I need to study (crying!!!). But later on we will have some fun ;)
[Android Apps and Games] tdunham:
No worries. Just trying to make things more efficient. :)
[Android Apps and Games] tdunham:
As I think more, maybe still a list preference but with support for [MENTION=3944923]drawab[/MENTION]le as part of the string would be a way to go? So string would get read with

[MENTION=3944923]drawab[/MENTION]le; string
[Android Apps and Games] daxgirl:
Gotcha
[Android Apps and Games] tdunham:
Now navigate to method called updateDatabase(...) and add the following statement (in bold blue):

Umm did you forget something in this area? ;) :rolleyes:
[Android Apps and Games] daxgirl:
Nope. Scroll to the right... ?
[Android Apps and Games] Martillero:
OMG, this is so nice and awesome! :highfive:

Thanks a lot Anna! and tdunham too for the idea :good:

Will test a little bit more, but for now working fantastic ;)
[Android Apps and Games] daxgirl:
Yeah, Troy is a troublemaker with style ??? he has the craziest best ideas!!!
[Android Apps and Games] daxgirl:
Just wanted to say that sitting here and watching your images and seeing what beauties you guys manage to make with the skeleton code is just amazing. I save the images you upload. It's so amazing watching developers creating in source code with little or no background. For us it's pure pleasure to see it happening. Thank you guys! [MENTION=4830018]Martillero[/MENTION] your preference looks so amazing! And the theme is VERY cool!!! Well done!!! You guys should give yourselves a huge pat on a shoulder!!! You ROCK!!!
[Android Apps and Games] Martillero:
Well... none of those mods could be done without wubby and you, and all the people that spends hours and hours of time looking for new mods.

You guys not only give us source and tools, also a lot of explanations, and baby step guides to guys with no background at all like me, to learn, and not only follow.

There's no better feeling than understand what you are doing, of course following guides is important, but the way you give us those guides and tips, make us think and learn.

For me that's the point in modding, think, learn and understand to keep going forward.

So thanks a lot guys!
[Android Apps and Games] tdunham:
Ok, I'm stuck. ;)

I am getting 2 similar errors on recompile (both handlepreference):

Error:(256, 33) error: cannot find symbol class ThumbnailListPreference

Error:(373, 142) error: cannot find symbol class ThumbnailListPreference

ThumbnailListPreference.java is definitely there.
[Android Apps and Games] daxgirl:
Did you put it inside the prefs package?
[Android Apps and Games] tdunham:
It is in with the rest of the prefs and I can see it. I just copied it in there. I've never added one before that's ok isn't it?
[Android Apps and Games] daxgirl:
Yeah you just basically paste it in android studio and it does the refactoring if needed.

No errors (red underlines) in android studio?
[Android Apps and Games] daxgirl:
Look into the class you added and make sure you have the package name on top. .. first line in java file
[Android Apps and Games] tdunham:
Yes, only HandlePreferenceFragments and the two references within there that refer to the thumbnail that were just added.
[Android Apps and Games] daxgirl:
Delete the class you added. Extract it again from the zip I added. Right click on it and select copy. Then right click in android studio on prefs package and choose paste. Rebuild. Let me know.
[Android Apps and Games] tdunham:
Oh nevermind. It was prompting for Alt-Enter to resolve the reference that I didn't see. Once that was done the errors went away. :D
[Android Apps and Games] daxgirl:
Oh it needed the import...
[Android Apps and Games] daxgirl:
Sooooooo do we have a winner?
[Android Apps and Games] tdunham:
Yessssss! Had to add back in what I removed. I guess I was getting used to android studio doing the work for me I missed that it needed to import the code.

I am always happy to be a welcome distraction.
[Android Apps and Games] daxgirl:
Nah its my pleasure. I am awake anyway ?

Preference works fine? You know... being the ordering party you need to be satisfied with the product ???
[Android Apps and Games] tdunham:
I have a little housecleaning to do in the xml now to remove the obsolete code now that I don't need it but the new way is so much nicer.

Thanks, you're the best!:highfive::highfive:
[Android Apps and Games] Martillero:
Hi guys!

Hi had a strange issue on the thumbnail list preference, when i click on the text of the preference or the thumbnail itself the preference change and no issue, but when i press on the radiobutton, radiobutton keeps pressed and selected and nothing happens:

I have added:

android:clickable="false"

in the layout and seems to be working well now, but i though it will be better to ask if this is ok.

[MENTION=1042140]tdunham[/MENTION] this is happening to you?
[Android Apps and Games] daxgirl:
What you added is good. I have canceled focusability of the radio. It's working well here. But if you have issues, disabling clicking ability is ok. If it works for you - cudos!
[Android Apps and Games] Martillero:
Yep, working great, thanks again :good:

Messing around i found out that the popup reboot could be used with scripts too adding the getKey().contains and name of script we want, very cool to those scripts that needs a reboot to update.
[Android Apps and Games] tdunham:
Nice find, I didn't even notice it until you pointed it out. :good:

Added the fix to the thumbnail_item_view.xml layout and it's working fine here as well.
[Android Apps and Games] Petreion:
:)Fantastic guide ,thanks for your time to make it,the best app for custom rom i will try it in my rom thanks:)
[Android Apps and Games] malbert16442:
finally got app 100% understanding

just two questions:

If I wanted to put a gif as a banner how would I do that.

Also: Any way to make side panel smaller.
[Android Apps and Games] daxgirl:
I have to check about gif. Probably need to build animated drawable. As for side panel you can play around with nav drawer width in the layout file.
[Android Apps and Games] civato:
I had the same problem

I had the same problem with the latest git source of the app. I even tried every tip that was posted here but still clicking on the app wouldn't open it.

So I started to compare latest source with the initial source code.

The solution to this problem simple, it doesn''t look anymore for "intent" (getIntent) it only looks for the key (getKey).

So restoring the initial code section of this in HandlePreferenceFragements.java resulted in able to open the app when the Key was not good and you needed to use the "intent" like this for example with the app "AdAway", the key doesn't work here as it targetclass got the .ui. inbetween. So I used the "intent" method. and it didn't work with the latest github source code.

<PreferenceScreen
android:title="AdAway"
android:summary="Block Advertising">
<intent
android:targetClass="org.adaway.ui.BaseActivity"
android:targetPackage="org.adaway" />
</PreferenceScreen>

Here is the code I restored and now it works again with the "intent" method to call a app.

In HandlePreferenceFragements.java. at line 422 you replace this :

} else if (preference.getKey() == null) {
// setToolbarForNested(preference);
}

With this to fix it:

} else if (preference.getKey() == null && preference.getIntent()!=null) {
Intent intentFromPreference = preference.getIntent();
c.startActivity(intentFromPreference);
}

I hope this will clear the problem of the app calling.

Now I got a problem of my own and cannot figure it out.

It is script related.

This script works:

#!/bin/sh

mount -o rw,remount /system

cp -p /system/etc/phronesis/silent.ogg /system/media/audio/ui/PowerOn.ogg
cp -p /system/etc/phronesis/silent.ogg /system/media/audio/ui/PowerOff.ogg

But this doesn't and I just don't know why.

#!/bin/sh

mount -o rw,remount /system/vendor/lib

cp -p /system/etc/phronesis/liboemcrypto.so /system/vendor/lib/liboemcrypto.so.bak

As this one, doesn't work.

#!/bin/sh

mount -o rw,remount /system

rm -rf /system/priv-app/GmsCore/
rm -rf /system/priv-app/GoogleBackupTransport/
rm -rf /system/priv-app/GoogleFeedback/
rm -rf /system/priv-app/GoogleLoginService/
rm -rf /system/priv-app/GoogleOneTimeInitializer/
rm -rf /system/priv-app/GooglePartnerSetup/
rm -rf /system/priv-app/GoogleServicesFramework/
rm -rf /system/priv-app/Phonesky/
rm -rf /system/framework/com.google.android.maps.jar
rm -rf /system/framework/com.google.android.media.effects.jar
rm -rf /system/app/Gmail2/
rm -rf /system/app/GoogleCalendarSyncAdapter/
rm -rf /system/app/GoogleContactsSyncAdapter/
rm -rf /system/app/GoogleTTS/

cp -p -a -R /system/etc/phronesis/Google/* /system

sleep 3

reboot

All tips are welcome.
[Android Apps and Games] daxgirl:
Hey Civato!

I will update the code with the fix for the intent. I keep forgetting to do that. Thank you for your help!

As for your scripts, they all seem ok. I would suggest to try and run them on the emulator or better yet run them as .sh files directly from the system folder or data folder of the app. Or from scripter... The exit code might give you an idea as to what is wrong. Sometimes there is a space that appears at the end of a line that will crash it. In any case both scripts look ok. So it's most probably just some linux-being-spoiled-and-picky thing.

Our team's expert on bash scripts is [MENTION=5493353]Wuby986[/MENTION] so he will probably be able to tell you more about the scripts. I literally suck at them ;)
[Android Apps and Games] civato:
Script runner executes them just fine with no error. it seems there is no permission for the romcontrol app to write to system when running the script.
[Android Apps and Games] daxgirl:
There is no such a thing as no permissions writing to system. The scripts are executed under sudo.it has nothing to do with app I am afraid. Only with shell.
[Android Apps and Games] civato:
When I run the script from the romcontrol app it shows "1" and not "executed successfully".

I'm running the app on android 5.1.1 and I build the app for api22 as target.

Will try some more stuff. As under android 5.0.2 it works just fine.
[Android Apps and Games] daxgirl:
Mmmmmm interesting the build target shouldn't affect it, as she'll scripts runs at kernel level and not android. The app build is only affecting android libraries which have nothing to do with Linux. It's even more weird that it works on 5.0.2 and doesn't work on 5.1.1. Should not make a difference. I have asked wuby to have a look. We will see what he says..
[Android Apps and Games] Er. Aditya:
that usually happens when there's error in script not the rom control
[Android Apps and Games] civato:
Got the sound scripts working , now the netflix fix script. Will let you know.
[Android Apps and Games] ravian29:
i am also trying to run a script to delete hosts file, its simple script but i am also getting 1 as an error. When i try to run script on phone with script runner applications, it works but when in rom control it gives me error. i am on note 5 n9208 5.1.1, Here is script

#!/bin/sh

cd /system/etc/

rm hosts

Second bug i am facing is, when i go into inside preferencescreen statusbar does not show and remain white, please see screenshot
[Android Apps and Games] daxgirl:
In your script you didn't make the system writable. You need to remount it r/w to be able to delete files. Even with su. Add the line to remount as r/w and you should be good to go.

As for the white screen, it's a problem with app compat and action bars in preferences. That's how it treats imbeded preference screens. I will have another go at it as soon as I finish my latest study project.
[Android Apps and Games] ravian29:
thanks for your quick reply, now i tried this but still no luck

#!/bin/sh

mount -o rw,remount /system

cd /system/etc/

rm hosts
[Android Apps and Games] daxgirl:
Try

rm -rf hosts in the last line

Make sure your script had no spaces at the end.

Make sure the file you are trying to delete exists.

Try executing script from terminal and see the exit code.
[Android Apps and Games] ravian29:
no still no luck but i have changed logic to make it work, now instead of deleting i am renaming it.

i am not sure why this is happening in rom control in terminal it is working fine
[Android Apps and Games] daxgirl:
I have no answer to that. You have to understand the app has no control over executing the script. Absolutely none. It just opens the way to the shell. Make sure the hosts file has not been deleted already. Make sure the script is being copied to the data/data folder of our app.

We don't execute the scripts. The kernel does. So once it's there and executable and has no errors, it should work. [MENTION=1042140]tdunham[/MENTION] has tens of scripts in rom control app and they all execute fine. So, given the facts, it's most definitely something that got overlooked along the way.

Again, we get lots of questions here about scripts. Whereas this is one thing that has absolutely nothing to do with the app. The app has no control over running scripts. We just give you the place to put them and su to run them. If they don't run, there is a problem in the implementation.