yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] daxgirl:
Let's take a pause and a deep breath...

1. This project provides raw code for you with basic instructions for how to use it. Any troubleshooting is welcome, but I think if you take some time to solve each problem before posting you will manage. As evidently you solved every problem so far on your own!

2. The project is open source, means other people already used it and managed those things, most of them published their source code. Which is a public domain so you can have a look at what they did and take time to study it and learn. That's the purpose of open source.
[Android Apps and Games] Er. Aditya:
The internet meter isnt showing at all not the colors bro...thanks

Yes anna ...am sorry let me try on my own

Thankyou though :)

---------- Post added at 09:33 PM ---------- Previous post was at 09:14 PM ----------

@daxgirl solved it :D

thankyou so much anna , this is awesome :)

now everything works awesome :D
[Android Apps and Games] Er. Aditya:
thankyou guys , more names will be added with time
[Android Apps and Games] micky387:
Hello.

First,as always another amazing thread for noob dev as me .

Thanks to all and @ daxgirl for your work.

I have start my projet and it's good.

i will make and run good script for restart phone with change keymapping (note edge phone)

I will try to add a script to rename PowerOn.ogg .

I try many script but dont work.

Working great in terminal on my phone but dont with app.

I try

#!/system/bin/sh

cd /system/media/audio/ui/
mv PowerOn.ogg PowerOn.ogg.bak

#!/system/bin/sh

mount -o rw,remount /system
cd /system/media/audio/ui/
mv ./PowerOn.ogg ./PowerOn.ogg.bak

echo ""
echo ""
echo "Sound Off"
/system/xbin/busybox mount -o remount,rw /system
/system/xbin/busybox cp /system/media/audio/ui/PowerOn.ogg /system/media/audio/ui/PowerOn.ogg.bak
/system/xbin/busybox mount -o remount,ro /system
echo "Reboot your device"
echo "to apply changes"
/system/xbin/busybox sleep 3
exit

It's not working.

What is wrong ?? Are there another way to rename this file ??

Thanks again

Regards
[Android Apps and Games] Martillero:
It should be something like this:

#!/system/bin/sh

mv /system/media/audio/ui/PowerOn.ogg /system/media/audio/ui/PowerOn.ogg.bak

And for the keylayout i have done the same.

I use this for one:

#!/system/bin/sh

cp -p /system/romcontrol/files/s4/Generic.kl /system/usr/keylayout/Generic.kl

reboot

And this for the other one:

#!/system/bin/sh

cp -p /system/romcontrol/files/s6/Generic.kl /system/usr/keylayout/Generic.kl

reboot

And of course you have to place the files on the specific folder.

I use two different folders in the example but you can put both together with different name and rename it when it changes. You can acomplish this by a lot of ways with the script.

Also you can use a reboot at the end of the script to reboot automatically, but this could be very annoying to some.

Hope it works for you mate.
[Android Apps and Games] Er. Aditya:
if i want to pull a script from a specified from in the rom zip file rather then assets or lets say even from assets > <folder> script then

script#(folder)#blockhost , will this work ?
[Android Apps and Games] micky387:
Thanks mate .I try

#!/system/bin/sh

mv /system/media/audio/ui/PowerOn.ogg /system/media/audio/ui/PowerOn.ogg.bak

but dont work.

I say my name of my script is

soundoff.sh

I have add in xml this

<PreferenceScreen
android:key="script#soundoff"
android:summary="Remove boot sound"
android:title="Boot sound off" />

but dont work.

I dont know why ??

Edit. For info,when i click for execute my script,i have a taost with "1" not "Executed Successfully" as i see in HandlePreferenceFragments.....
[Android Apps and Games] Martillero:
Yeah, then the script has something wrong, maybe some space, i just compiled in android studio, and make the script:

View attachment soundoff.rar

Go to data/data/com.wubydax.romcontrol/files/ and delete the scripts folder.

Put the script downloaded in assets

The preference screen u use is ok

<PreferenceScreen
android:title="Boot sound off"
android:key="script#soundoff"
android:summary="Reboot is required for changes to take effect" />

Then, run the app, and try to launch the script again.
[Android Apps and Games] micky387:
Thanks man,working.

Strange,your sript it's same as me,Files match ok with notepad++...

:confused:

EDIT.

I use the same script with soundon.sh

I rename ogg.bak-->ogg but same problem. Dont work I have "1" in toast,not "Executed Successfully" same as sound off .... :confused:
[Android Apps and Games] Martillero:
Glad to help mate...

Probably a blank space somewhere or something like that ?
[Android Apps and Games] micky387:
Thanks.

I expect this problem and i found why some script doesnt work...

By default,when you creat Bash Script in android studio,it not in good format.

With Notepad++,open you script and go to Edit-->EOL convertion and make sure it's in (or convert) UNIX format.

Go to encoding and be sure it's "Encode in UTF-8 without BOM"

Save your script and enjoy ;)
[Android Apps and Games] Wuby986:
scripts are copied from asset folder inside the app to app's file folder in /data/data and chmodded on onCreate.

why you need to put them in different folders?
[Android Apps and Games] est_yasser:
Here's the source code of my app

The only thing new to the app structure is that I've added RTL support.

One question: Am I allowed to change the package name and folders inside it ?
[Android Apps and Games] Wuby986:
sure!!! this is YOUR app!! remeber.. you did it [emoji2][emoji2]

as for source code, you should post it in the tread of your rom, so users can see it, they are the ones supposed to be intrested in, it's not for us [emoji4]

edit which folders? there are not so many that you could change the name.. actually only one (prefs) but i personally don't see the point in that

because if you are talking about the /java/com/wubydax it will get changed as soon as you refractor the package name
[Android Apps and Games] est_yasser:
I posted there already, thank you.

and also posted here in case if someone else interested :D
[Android Apps and Games] tdunham:
Ok here I finally am. :victory:

I've added FilePreference for UI restart to HandlePreferenceFragments and it does work but I just thought I'd ask if it looks ok so I get it 'proper' the first time. ;)

case "FilePreference":
FilePreference f = (FilePreference) pf.findPreference(key);
f.setChecked(sharedPreferences.getBoolean(key, true));
if (key.equals("modcfg_toggle_color_enable")) {
appRebootRequired("com.android.systemui");
}
break;
[Android Apps and Games] daxgirl:
You rock! Gread job! But we should make sure this specific type of preference doesn't write to database.
[Android Apps and Games] tdunham:
Oops. ;)

Well, this is why I asked.

So... since I'm riding in way late to this party, which part of the java tells it to write the key?

Edit: I would think since its a filepreference, it should've skipped the sql entry somewhere but I just thought of a purpose for that too so no need to remove it entirely.
[Android Apps and Games] tdunham:
My guess:

f.setChecked(sharedPreferences.getBoolean(key, true));
[Android Apps and Games] tdunham:
I have a small request.

The app does take about 15 seconds to setup on first launch.

Would it be possible to add a 'Please wait... configuring settings' on first run or something similar?

It seems to be most logical rather than staring at a blank screen while it does it's thing; a little less confusing for the average user too. :)
[Android Apps and Games] daxgirl:
Hmmmmmm. .. I don't have a blank screen. Not for 15 seconds not for even 3 seconds. The first launch has a super Su request which has a progress bar showing and saying "Acquiring root rights... please wait." Right after that the app loads immediately. No delay not even a second.

This app in in essence no different from what you had before. Absolutely no reason for it to show a blank screen.
[Android Apps and Games] tdunham:
Well that's not good. I was assuming it was normal.

I'll capture the logs and see if I can find anything from there.
[Android Apps and Games] daxgirl:
Well observer the way I understand it needs to get triggered and then do something. So it can start a method f.e.... but been you say general, do you mean for all the apps? How is it going to do it? I mean run a certain method in systemui f.e.? Could it be I misunderstand you?

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Wuby986:
Not sure i understand correctly, but as soon as you make a change to a preference it is written to db, it depends on system modded app to react to the change, accordingly if has the observer or not
[Android Apps and Games] peppe130:
[MENTION=4714483]daxgirl[/MENTION] & [MENTION=5493353]Wuby986[/MENTION] Dears, I'm speechless!!!!!!!!!!!
[Android Apps and Games] remuntada78:
i mean for all the key stored in system database , for those that are already there, and for those that we will add, so a general observer that read database and key state and it update the keys in real time after that we make a choice f.e hide/show or change some color ect.
[Android Apps and Games] daxgirl:
Sweetie, nice to see you!!! How's the vacation??? Missing you!!!

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] daxgirl:
That would be nice if you could trigger methods inside a different app... but how can you?

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] remuntada78:
[emoji1] [emoji1] i don't know, it was just an idea

Inviato dal mio SM-G900F utilizzando Tapatalk
[Android Apps and Games] daxgirl:
Post #2. Added further instructions. Mainly basic structure and how to add new navigation drawer section item.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] daxgirl:
There we go!!!

The thread is now open. The instructions are complete. They have tons of typos I guess but I just can't go over them right now. It will have to do for now.
​

We are here to answer any question or address any iossue you might have with the project! Have fun!!!​
[Android Apps and Games] Kamy:
Now it's like a handbook. I hope I can be clever enough to build something that at least can run and see it on my phone screen. Loool. Thanks for your time you are amazing.
[Android Apps and Games] Er. Aditya:
you have to be the most smartest ma'am in israel

respect anna , i am no where compared to everyone here but you give hopes to starters that yes they can do :)
[Android Apps and Games] daxgirl:
I have opened studio for the first time less than a year ago. And I mean for the first te ever to write my own code. Before than I was playing around with apktool and alittle eclipse but never anything of own. I don't jave much time to study, and I have a full time job. I had absplutely no background in programming in any language before then. anything I can do, you can do too.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Er. Aditya:
yes mentor , il try my best

thankyou once again anna and [MENTION=1042140]tdunham[/MENTION] [MENTION=5292754]remuntada78[/MENTION] [MENTION=5493353]Wuby986[/MENTION] [MENTION=3065070]Goldie[/MENTION] [MENTION=2438295]claude96[/MENTION]
[Android Apps and Games] daxgirl:
Once you pull it from git it's already operational and can compile and run. Ask [MENTION=1167171]rompnit[/MENTION]. He did it. He now plays every day with studio and asks very nice questions.

It's an oportunity to put your hands on something original and start tasting your own coding. We believe it will be just the step you need to become your own original developer. There is nothing that feels better than your own app compiling and running on your device.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] daxgirl:
Just to clarify one more time: we do not need credits. Neither do we want them. Our code is credited by us.

From now on its not OUR app, it's YOUR app. The code belongs to everyone. The app belongs to anyone. Whatever you do - it is now YOU development.

From the moment you first compile and run - pat yourself on a shoulder for us. You did it! YOU DID IT! You now actually OWN part of your rom. It is now original development you're doing.

Change name, change colors, change images, change sizes... play around. .. it is now your own code.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Kamy:
Me motivated. For sure I would do make it no matter how long it takes.

So lucky we have you on xda, these much of precious time you spent sharing with us and you ask for nothing. I guess that would be one of the best gift, I mean it, I received this year.
[Android Apps and Games] daxgirl:
My personal best hope for this thread is, that as much as we grow up together on [MENTION=1042140]tdunham[/MENTION] thread in smali modding, we grow here together in java prigramming and original development.

We debug, we add, we make more beautiful. .. we all learn and teach each other. I am no expert in java. I am merely a student (self taught ). We can take this thread to great places in joint growth and study of the beauty of actual android development.

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] Wuby986:
I couldn't say it better!!!!!!!!!!
[Android Apps and Games] daxgirl:
I am proud to have you as my friend and partner! Really really proud! Can never thank you enough for just being you!!!

Sent from my awesome g920f powered by 6thGear
[Android Apps and Games] DaOldMan:
Great effort Dax&Wuby! Didn't read the whole op yet :) but will soon. What a gem for developers, and finally not in smali. I am sure we will see this app staring in many new roms very soon. This app will open a whole new world to many....
[Android Apps and Games] daxgirl:
Do you have the progress dialog waiting for Su? I mean the one saying Acquiring root rights?
[Android Apps and Games] micky387:
Me too,Rom Control open instantly
[Android Apps and Games] tdunham:
Ok, I'm not positive but it looks to me like it is trying to check every shell script we have included and there are about 30 of them and it seems to be stopping and checking every one. It takes up a good section of the log.

Here is an example and this section repeats for every shell script contained in app/assets/scripts:

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

java.io.IOException: Error running exec(). Command: [chmod, 755, /data/data/com.wubydax.romcontrol/files/scripts/enable_mod_nfc.sh] Working Directory: null Environment: null

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.ProcessManager.exec(ProcessManager.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.Runtime.exec(Runtime.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.Runtime.exec(Runtime.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.Runtime.exec(Runtime.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at com.wubydax.romcontrol.HandleScripts.copyAsset(HandleScripts.java:102)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at com.wubydax.romcontrol.HandleScripts.copyAssetFolder(HandleScripts.java:55)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at com.wubydax.romcontrol.MainViewActivity$CheckSu.onPostExecute(MainViewActivity.java:382)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at com.wubydax.romcontrol.MainViewActivity$CheckSu.onPostExecute(MainViewActivity.java:323)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at android.os.AsyncTask.finish(AsyncTask.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at android.os.AsyncTask.access$500(AsyncTask.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at android.os.Handler.dispatchMessage(Handler.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at android.os.Looper.loop(Looper.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at android.app.ActivityThread.main(ActivityThread.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.reflect.Method.invoke(Native Method)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.reflect.Method.invoke(Method.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

Caused by: java.io.IOException: Too many open files

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

at java.lang.ProcessManager.exec(Native Method)

[ 10-10 07:27:27.259 11847:11847 W/System.err ]

... 18 more

---------- Post added at 11:44 AM ---------- Previous post was at 11:40 AM ----------

But the more I look at it, it seems this might just be the chmod (set permissions) part of the app and if the file doesn't exist yet is why I see the null errors.
[Android Apps and Games] daxgirl:
It has a condition to not chmod if the file isn't there. Shouldn't be doing anything but just copy your scripts. Which is instantaneous.
[Android Apps and Games] tdunham:
Ok, this definitely is my problem area.

As a test, I removed all the scripts from the assets folder and removed rom control data/data folder so it would do a refresh and it comes up instantly as it should. In the Handlescripts, I see this but no if/else for file I/O check. Maybe it is accomplished differently than I am thinking. ;)

File parent = new File(scriptFilesDirPath);
scriptsInFiles = parent.list();
//If the file was just copied, we make it executable
if(isCopied){
for(int file=0; file<scriptsInFiles.length; file++){
try {
Runtime.getRuntime().exec("chmod 755 " + scriptFilesDirPath + File.separator + scriptsInFiles[file]);
} catch (IOException e) {
e.printStackTrace();
}
}
}
return isCopied;

---------- Post added at 11:58 AM ---------- Previous post was at 11:55 AM ----------

Nevermind, this is the if/else condition. I see it now.

---------- Post added at 12:06 PM ---------- Previous post was at 11:58 AM ----------

I think the best way to go about this since we have so many scripts in ours, is for someone else to add them to theirs, wipe data on rom control and see if they get the big lag also. This would indicate that some modification might need to be made to the source to accommodate the null object issue I am experiencing. The problem may not be as apparent for others if there are only several scripts to check for.
[Android Apps and Games] daxgirl:
You can upload your zipped scripts and we will test later on today.
[Android Apps and Games] tdunham:
Attached, thank you.
[Android Apps and Games] Wuby986:
sooooo here we are...

you found a nice one!! :D

it wasn't as easy to found the problem as i would expect.. it was all due to the large amount of files to be done all together , so we fist moved the copy and chmod in the doInBackground method of async task for CheckSU hoping that was only becasue not handled in BG.. but no.. then we went for chmod recursively the folder "script" that contains all the script, so it will read as a single operation and not multiple to be done at same time..

anna pushed the commit to git.. let us know ( we tried and seems fine now ;) )
[Android Apps and Games] tdunham:
Well that is awesome sir.

I am glad to find a resolution for this.
[Android Apps and Games] daxgirl:
Would you like us to post a full solution here?
[Android Apps and Games] Wuby986:
oh yeah well edits are cut the copy part from MainViewActivity method onPostExecute

//Accessing the ability of the device to get root and the ability of app to achieve su privileges.
am = getAssets();
//Calling the helper class HandleScripts to copy scripts to the files folder and chmod 755.
//Scripts can be then accessed and executed using script#scriptname key for PreferenceScreen in PreferenceFragments
hs = new HandleScripts(MainViewActivity.this);
hs.copyAssetFolder();

and move it in the doInBackground method

if (RootTools.isAccessGiven()) {
//Accessing the ability of the device to get root and the ability of app to achieve su privileges.
am = getAssets();
//Calling the helper class HandleScripts to copy scripts to the files folder and chmod 755.
//Scripts can be then accessed and executed using script#scriptname key for PreferenceScreen in PreferenceFragments
hs = new HandleScripts(MainViewActivity.this);
hs.copyAssetFolder();
return null
}

then go to HandleScripts method and search for the line

Runtime.getRuntime().exec("chmod 755 " + scriptFilesDirPath + File.separator + scriptsInFiles[file]);

edit it to

Runtime.getRuntime().exec("chmod -R 755 " + scriptFilesDirPath);

and coment out lines:

scriptsInFiles = parent.list();
for(int file=0; file<scriptsInFiles.length; file++){
and a last "}" just before return state

i hope is understandable :)
[Android Apps and Games] Martillero:
Thanks a lot guys for the fix, it was happening to me too, and now its all fixed :good:

You are awesome :victory:
[Android Apps and Games] Wuby986:
i just noticed, because anna told me :D , that she did other edits, you can find those in commits.. like making doInBackground return void and so on..
[Android Apps and Games] Martillero:
Yep, I copy the changes from the commits on github [emoji106]
[Android Apps and Games] tdunham:
Scripts writes & chmods are working great for me here too.

Tnx Roberto & Anna!!! :good::good:
[Android Apps and Games] tdunham:
Alright, I have another unusual request...

Is there a way to set a Reverse dependency?

Right now the dependency is set for when the flag is 1, I have an instance where I would like to also have a new dependency when the flag is 0 (off).

Cheers - TD

Edit:

Or at least point me to where the dependency is defined and maybe I can figure out the java changes from there. ;)
[Android Apps and Games] daxgirl:
So, after you explained to us what you mean in pm, we understand that you need a value of some two state preferences to be dependent on a value of one certain two state preference.

So just an idea for you:

Inside onSharedPreferencesChanged:

case "SwitchPreference":
SwitchPreference s = (SwitchPreference) pf.findPreference(key);
s.setChecked(sharedPreferences.getBoolean(key, true));
[COLOR="Blue"][B] if(s.getKey().equals("master_switch")){
setDependencies(s.isChecked());
}[/B][/COLOR]
break;

and later on in a code (in any place you like in between other methods), add a method like this:

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(isMasterChecked);
}
}

We cool?
[Android Apps and Games] tdunham:
I cant seem to find onSharedPreferencesChanged.
[Android Apps and Games] asc1977:
Short question and sorry if its written somewhere:

Can i use this on S6edge with 5.1.1 custom rom. I want to add this to my rom

Gesendet von meinem SM-G925F mit Tapatalk
[Android Apps and Games] thereassaad:
& short answer yes u can ..
[Android Apps and Games] Wuby986:
you can find it in the HandlePreferenceFragment class
[Android Apps and Games] tdunham:
Ok found it! It does work but maybe the boolean is backwards. When the master key is off, so are the dependencies (master key off, dependencies should be on). I'll experiment with that later, i am working right now. I'll report back later.