Author Topic: [HOWTO] Integrating/Adding applications to the settings menu.  (Read 21197 times)

0 Members and 1 Guest are viewing this topic.

  • Thank You
  • -Given: 0
  • -Receive: 3
  • AmazingLarry

    Posts: 70
    User Rating: +16/-0
    Offline
    • Rom Developer
    • *
    • Full Member
    In this tutorial we will cover how to add an item in the settings menu for integration when cooking your own rom, or for personal use. Using windows XP, but should apply to any windows version, Linux users: you most likely are smart enough to use this guide with whatever flavor of linux you're using, so i wont cover linux specific guidelines.

    The original reason i began doing this was because i hate clutter in my app drawer, and i like accessing settings for things from the.... you guessed it: Settings menu.

    For this tutorial we will use the Spare Parts app, but this applies to almost all applications that you would desire adding.

    Materials:
    PSPad or Notepad++ (i'll use PSPad in this tutorial, it's just my preference)
    APKMultiTool
    SpareParts APK
    Settings APK from the rom you wish to modify
    archive manager (winzip or winrar, i use winrar)
    a general understanding of using APKMultiTool or APKManager is a great start, i'll try to make this guide friendly to those who arent familiar.

    01) Install APKMultiTool
    02) Place both APK files in APKMultiTool's place-apk-here-for-modding folder

    03) Start APKMultiTool by double clicking script.bat in the main APKMultiTool folder
    04) Select the settings app by typing 25 then enter, then the number next to the settings app then enter

    05) Decompile both APKS by selecting option number 9 after selecting the APK from the menu from before


    06) Get Back to the APKMultiTool main folder, then enter projects folder, then Settings.apk folder
    07) Navigate to res/xml from this folder and open the settings.xml file with pspad (right click and select PSPad or open from pspad directly) to add a new action and icon

    08) We'll add it right after the display settings entry, find it and copy the entire selection, then after IconPreferenceScreen> hit enter to make a new line.

    09) Paste the entire action, this is what we will edit, you can type it all out word for word, but this is easier, and there is less room for a mistake
    10) after pasting, we'll change the values for the new settings action, string name (title), and drawable name (icon) see below pictures
    11) change all the references from display to sp or spareparts, or anything you want to call it, just make sure it's consistent as in the next steps we will use the titles and strings you created. the @drawable will be the name of the icon you create, the @string will be the title used to display the menu item. you will need to change the target package to spare part's internal app name (this can be found in the SpareParts project folder inside AndroidManifest.xml)

    and the target class (the action within the target package to open or perform). to obtain the target class, the easiest way i've found is installing the app you want to add and using adw and finding a blank area on your homescreen(s), long press, then select custom shortcut>pick your activity>activities>browse down until you find the SpareParts app, and expand with the arrow on the left SpareParts only has one action, but other apps will have several. the first on the list is usually it's opening class it's in the ( )'s in this example it's .SpareParts. the target class is the internal app name.class so here we will add com.android.spare_parts.SpareParts



    12) save the file and close
    13) navigate back to the res folder and enter the values folder

    14) open strings.xml
    15) navigate to the bottom of the strings xml and copy the final string and as before at the end press enter and paste to modify a new string. the first part is the string name that you made above, the second is the actually title that will appear in the settings menu (Spare Parts in ths example)

    16) save the file and close
    17) create a graphic icon (32 pixels by 32 pixels or 32x32) for the selection from the settings menu, we will call it ic_settings_sp.png
    18) place this icon in the res/drawable-mdpi folder
    19) open the public.xml in the res/values folder where you found the strings.xml file
    20) this takes a little work and a little understanding of how hex numbers work. hex numbers go from 0 to 9 then a-f, this gives sixteen values, so hex numbers conform to this order - 0123456789abcdef the reason this is important is that you need to find the last hex number in the drawable range. the public.xml file is usually not in order so it takes some work and some time to find the number you need to assign a new "id" to the icon, and string we are adding. if you are using a fresh Settings.apk basically you'll take the highest number you've found and add 1 to it using the above hex order until you find a number that doesnt exist. in this example the we find it here:

    so copy that line, create a new line under it and add the name of the icon you created and add 1 to the number at the end
    21) repeat the above process to add the string we created earlier in the strings section of public.xml
    22) save the file and close
    24) you are now ready to compile the APK, in the APKMultiTool screen select teh settings.apk using option 25 again and then use option 11 to compile the APK
    25) if you get errors, run the log, at the end of the log it will usually list the problem you encountered if you did. if it mentions something being out of range you need to chek to make sure your numbers are correct, if it mentions missing resources you havent properly added the strings or icons
    26) if all goes well you will be asked if this is a system apk, either option is fine, the second option is if you want to keep old files to avoid errors. answering no is the easiest way. just answering no to both works fine
    27) you should now have a newly compiled APK, in the place-apk-here-for-modding folder with the prefix "unsigned"
    28) open both the Settings.apk and unsignedSettings.apk file with winrar or winzip
    29) transfer find the icon in the unsignedSettings.apk /res/drawable-mdpi folder and transfer it accordingly to the Settings.apk /res/drawable folder, do the same with the /res/xml/settings.xml and the /resources.arsc file.
    30) your new settings apk is now ready to be pushed to /system/app on your device.
    31) Optional - if not already installed, place SpareParts.apk into the /system/app folder to make it a system app
    32) Optional - if you want to remove SpareParts from the app drawer you'll need to decompile the spare parts apk using the steps above and edit one line from the AndroidManifest.xml file, just delete the entire launcher line it looks like this:

    33) Optional - Recompile the SpareParts.xml file and sign it if you wish (SpareParts can be signed, DO NOT perform this step on the Settings.apk file, it will not work due to mismatched signatures in the uid)

    That should be it.

    Questions? ask here
     
    • Stock
    • Huawei H881C
    • Stock
    • n/a
    -=If ya can't do right, you can always do what's left.=-

    Re: [HOWTO] Integrating/Adding applications to the settings menu.

    « Reply #1 on: April 17, 2012, 08:07:35 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • jcole20

    Posts: 545
    User Rating: +120/-0
    Offline
    • Co-Admin
    • *
    • Hero Member
    • Personal Text
      I LOVE TO ARGUE
    Awesome, awesome, awesome... give a little more instructions on pulling intents. Specifically because of the big diff in notification toggles intent and spareparts but this guide is awesome. Thank you! Brilliant!

    Sent from my LGL55C using Tapatalk
    • Custom
    • HTC One M8
    • TWRP
    • Rooted-Rom
    Innovation comes from being as stubborn as possible...





    Re: [HOWTO] Integrating/Adding applications to the settings menu.

    « Reply #2 on: April 20, 2012, 10:58:18 AM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Rookie407

    Posts: 602
    User Rating: +208/-1
    Offline
    • Rom Developer
    • *
    • Postaholic
    • Personal Text
      "Your Mom Likes It..." =)
    Simply amazing! easy to follow step by step instructions. GREAT for any rom dev!
    • Custom
    • Samsung Galaxy S2 SGH-S959g
    • Clock Work Mod
    • Rooted-Rom
    "mi familia es mi vida, vivir de acuerdo con ellos, vivir para ellos, morir por ellos!"





    Re: [HOWTO] Integrating/Adding applications to the settings menu.

    « Reply #3 on: May 22, 2012, 08:19:36 PM »
  • Thank You
  • -Given: 0
  • -Receive: 1
  • element180

    Posts: 292
    User Rating: +17/-0
    Offline
    • *
    • Hero Member
      • Android Area51
    I was just about to ask how to do this but I thought twice and actually searched and found this, heh

    Sent from my AreaROM 2.3 Precedent using Xparent ICS Blue Tapatalk 2
    • GenoCide_187
    • Precedent
    • Clock Work Mod
    • AreaRom v3.2

    If it ain't broke, fix it til it is

    Re: [HOWTO] Integrating/Adding applications to the settings menu.

    « Reply #4 on: May 30, 2012, 12:28:42 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • jcole20

    Posts: 545
    User Rating: +120/-0
    Offline
    • Co-Admin
    • *
    • Hero Member
    • Personal Text
      I LOVE TO ARGUE
    You are not allowed to view links. Register or Login
    I was just about to ask how to do this but I thought twice and actually searched and found this, heh

    Sent from my AreaROM 2.3 Precedent using Xparent ICS Blue Tapatalk 2

    A little fyi: This isn't the easiest thing to do and takes some trial and error... Do not attempt this if you're not comfortable with the programs listed (or if you don't have a viable backup). You must know how to Sign programs correctly, how-to read and edit .xml's and how to use the programs we use to do this stuff. Please, only attempt if you know what you're doing.
    • Custom
    • HTC One M8
    • TWRP
    • Rooted-Rom
    Innovation comes from being as stubborn as possible...





     

    Related Topics

      Subject / Started by Replies Last post
    1 Replies
    1656 Views
    Last post October 26, 2016, 10:12:18 AM
    by Mycofanatic
    10 Replies
    25295 Views
    Last post September 28, 2014, 02:52:06 PM
    by AmazingLarry
    1 Replies
    1783 Views
    Last post July 15, 2013, 05:09:57 PM
    by clark71822
    3 Replies
    2901 Views
    Last post August 23, 2013, 10:41:17 AM
    by treyonator56
    12 Replies
    5484 Views
    Last post February 28, 2014, 07:55:01 PM
    by SLeePYG72786
    14 Replies
    4297 Views
    Last post November 13, 2014, 07:13:33 PM
    by RiCK_Galaxy_Proclaim