• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[NST/G] Editing framework-res.apk xml files

Search This thread

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
I'd like to make a few small changes in the framework-res.apk. I thought this might be "easy", but so far it's not.

I decompiled the apk file using apktool and located the two files I wanted to alter in res/layout. I made the changes, then saved the two edited files.

Next I opened the original framework-res.apk archive with WinRAR and then dragged the edited xml files into the proper location ("store", not "normal" or "compress") and then closed the archive.

Finally, I used CWM to copy the new framework-res.apk back to the NST and rebooted.

Boot loop.

Is it not possible to deal with slightly edited xml files in this way?
 
Last edited:

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
I'd like to make a few small changes in the framework-res.apk. I thought this might be "easy", but so far it's not.

I decompiled the apk file using apktool and located the two files I wanted to alter in res/layout. I made the changes, then saved the two edited files.

Next I opened the original framework-res.apk archive with WinRAR and then dragged the edited xml files into the proper location ("store", not "normal" or "compress") and then closed the archive.

Finally, I used CWM to copy the new framework-res.apk back to the NST and rebooted.

Boot loop.

It is not possible to deal with slightly edited xml files in this way?
I found a working method: https://forum.xda-developers.com/t/...rk-res-apk-with-apktool.1545361/post-23589640

But...I want to move the quicknav bar to the top of the screen. The changes I made in the xml files do that, but the status bar covers the top part of the quicknav bar. Ideally I'd like the quicknav bar to cover the status bar (maybe not allowed?), or at least position right beneath it.

The relevant xml code which seems to control the screen position of the quicknav bar looks like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quickNavMainView" android:background="@drawable/checker" android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <HorizontalScrollView android:layout_gravity="bottom|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:layout_gravity="bottom|center" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <ImageView android:id="@id/home" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_home_normal" />
            <ImageView android:id="@id/library" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_library_normal" />
            <ImageView android:id="@id/shop" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_shop_normal" />
            <ImageView android:id="@id/search" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_search_normal" />
            <ImageView android:id="@id/settings" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_settings_normal" />
        </LinearLayout>
    </HorizontalScrollView>
</FrameLayout>
I've changed "bottom" in lines 4 and 5 to "top". That gets the job done, but with the problem mentioned: the status bar covers the top portion of the quicknav bar.

Help?
 
Last edited:

Renate

Inactive Recognized Dev / Recognized Contributor
Feb 3, 2012
2,888
1,285
Boston
Nexus 7 (2013)
Moto E5
Changing framework or services or whatever you don't need to go to recovery.
They are just part of Android and have no influence on the Linux.
Code:
# stop
<do stuff>
# start

How about a screen shot?
I don't even think that I've ever even seen the stock QuickNav.

I'm not sure if this frame is the full screen or what.
How about adding android:layout_marginTop="24dp"?
(That dimension was picked out of the air. YMMV)
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
How about a screen shot?
I don't even think that I've ever even seen the stock QuickNav.

I'm not sure if this frame is the full screen or what.
How about adding android:layout_marginTop="24dp"?
(That dimension was picked out of the air. YMMV)
Thanks for the response. I'll try the marginTop idea. I've been looking all over for something like that but just hadn't generated the proper search string I guess.

Getting screenshots was a lot harder than I anticipated. The quicknav bar seems to disable the side hardware buttons when it is displayed but I finally figured out a way to get reasonable shots. You can clearly see the issue with the status bar when the quicknav buttons are moved to the top.
 

Attachments

  • stock_quicknav.jpg
    stock_quicknav.jpg
    124.7 KB · Views: 12
  • moved_quicknav.jpg
    moved_quicknav.jpg
    127.9 KB · Views: 13

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
I'm not sure if this frame is the full screen or what.
How about adding android:layout_marginTop="24dp"?
(That dimension was picked out of the air. YMMV)
You were close (and right, of course)!

The bar becomes a little scrunched for some reason (less white space above and below icons/text) but it just abuts the status bar with android:layout marginTop="18dp". I don't care much about the loss of the white space, so it's on with the rest of my project.

Thanks again for the help.
 

Attachments

  • fixed_quicknav.jpg
    fixed_quicknav.jpg
    128.2 KB · Views: 7

Renate

Inactive Recognized Dev / Recognized Contributor
Feb 3, 2012
2,888
1,285
Boston
Nexus 7 (2013)
Moto E5
Hmm, something's screwy.

Maybe try this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quickNavMainView" android:background="@drawable/checker" android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="18dp">
        <ImageView android:id="@id/home" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_home_normal" />
        <ImageView android:id="@id/library" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_library_normal" />
        <ImageView android:id="@id/shop" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_shop_normal" />
        <ImageView android:id="@id/search" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_search_normal" />
        <ImageView android:id="@id/settings" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_settings_normal" />
    </LinearLayout>
</FrameLayout>
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
Hmm, something's screwy.

Maybe try this:
Code:
<?xml version="1.0" encoding="utf-8"?>
...etc.
It seems to make no discernible difference. I notice that the line:

Code:
<HorizontalScrollView android:layout_gravity="bottom|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">

is missing from your version. That, too, seems to make no difference.

There is another xml file which seems to have something to do with the "appicons" (which are just png images stored in the apk, text included):

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/appIcon" android:layout_width="wrap_content" android:layout_height="wrap_content"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView android:layout_gravity="top|left|center" android:id="@id/badgeImage" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</FrameLayout>

Not seeing anything there that jumps out at me. If the android:layout_marginTop="18dp" is changed to something like "100dp" the bar more or less collapses into a fat line, as well as moving further down the display window, so there is some interaction between the "simple" shifting of the vertical display of the bar and the vertical size of the bar itself.

Like I say, it's not a big deal for me. As long as content is not cut off, a slight flattening of quicknav bar is fine.
 

Renate

Inactive Recognized Dev / Recognized Contributor
Feb 3, 2012
2,888
1,285
Boston
Nexus 7 (2013)
Moto E5
All the tiles are 120 x 112 so that the horizontal scroll is overblown. (5 x 120 = 600).
I was trying to get rid of that.
Use my only Linear Layout and change layout_height="112dp"
For testing purposes you can also add android:background="#cccccc".
That way if the LL expands but the buttons don't you can see the shading.
 
Last edited:

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
All the tiles are 120 x 112 so that the horizontal scroll is overblown. (5 x 120 = 600).
I was trying to get rid of that.
Use my only Linear Layout and change layout_height="112dp"
For testing purposes you can also add android:background="#cccccc".
That way if the LL expands but the buttons don't you can see the shading.
Does the android:background="#cccccc" go in the LinearLayout section or in the overall FrameLayout? Right now it's kinda moot because I can't seem to produce an apk file that does not cause a bootloop. I have a previous trial version with android:layout_ marginTop="20dp" which does NOT produce a bootloop. The file size is about 2874 Kb. Every new version I try to build with Apktool today is coming out around 3366 Kb and they all cause a bootloop. I have no idea what is going on with Apktool, but I'll keep plugging away, with breaks for mental health!
 

Renate

Inactive Recognized Dev / Recognized Contributor
Feb 3, 2012
2,888
1,285
Boston
Nexus 7 (2013)
Moto E5
Does the android:background="#cccccc" go in the LinearLayout section...
In the LL.

When you're floundering in layouts, it's helpful to set some color background for each containing element.
Obviously, on a B&W device you'll not see that, but a screen grab will show it.
(You can just stick to background colors that are differentiable in B&W,)

The FrameLayout is the whole screen which dims the normal screen.
The LinearLayout should be 600 x 120 automatically.
You can even do a reality check by saying (in LL) android:layout_height="500dp".
 

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
When you're floundering in layout...
I think "floundering" is the operative word here!

Try as I might, I have been unable to produce a framework-res.apk that did not cause a boot loop IF I left out the
Code:
<HorizontalScrollView android:layout_gravity="bottom|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">

This is what I have right now:

Code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@id/quickNavMainView" android:background="@drawable/checker" android:layout_width="fill_parent" android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <HorizontalScrollView android:layout_gravity="top|center" android:id="@id/quickNavHSView" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:layout_gravity="top|center" android:layout_width="wrap_content" android:layout_height="112dp" android:layout_marginTop="18dp" android:background="#cccccc">
            <ImageView android:id="@id/home" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_home_normal" />
            <ImageView android:id="@id/library" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_library_normal" />
            <ImageView android:id="@id/shop" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_shop_normal" />
            <ImageView android:id="@id/search" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_search_normal" />
            <ImageView android:id="@id/settings" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/c_quicknav_settings_normal" />
        </LinearLayout>
    </HorizontalScrollView>
</FrameLayout>

I was surprised to find that changing android:layout_gravity="top|center" in the LinearLayout section did NOT move the bar to the top. It was only when I made the change in the HorizontalScrollView that the bar went to the top of the screen (or almost).

I don't see any shading and perhaps the boxes are now even a bit smaller than before (see screenshot below). Again, I could live with this so it's not a deal-breaker for my intended project. It is interesting (and maybe just a little hair-raising) how these things interact in ways that I would not expect.
 

Attachments

  • quicknav.jpg
    quicknav.jpg
    129.1 KB · Views: 4

Renate

Inactive Recognized Dev / Recognized Contributor
Feb 3, 2012
2,888
1,285
Boston
Nexus 7 (2013)
Moto E5
When you have a "boot loop" (which is just really Android flailing while the Linux is fine) you should check the logcat, it will tell you where the problem is.

I don't know how I missed where that HorizontalScroll was being used.
Yeah, I do. I was accidentally looking for quickNavHsView and not quickNavHSView.
In services.jar, com/android/server/status/StatusBarService uses that.
It must be a HorizontalScroll. You need that.

The quick nav itself is com/android/server/status/BNGossamerQuickNavbar

The default for layouts is top anyway.

Make the LinearLayout big, android:layout_height="300dp".
You won't see any background of the LL until it's bigger than its contents.
 
  • Like
Reactions: nmyshkin

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
Make the LinearLayout big, android:layout_height="300dp".
You won't see any background of the LL until it's bigger than its contents.
OK. I did that but I'm not sure exactly what it tells me except that the size of the layout is greater than the size of the actual navbar images? I see this sort of thing when I am designing a scene in Tasker and the background field is larger than the image itself. There I would know what to do. Here....

Also, how does this relate to the squished (cut off?) images in the navbar?

Edit: I take some of this back now that I have looked more closely at the screenshot. The navbar is not so squished, although still not full size. This would suggest that if I make android:layout_height even larger the navbar will return to normal size. And maybe it does not matter since the background is transparent if I don't specify a color?
 

Attachments

  • quicknav_300dp.jpg
    quicknav_300dp.jpg
    105.8 KB · Views: 4
Last edited:

Renate

Inactive Recognized Dev / Recognized Contributor
Feb 3, 2012
2,888
1,285
Boston
Nexus 7 (2013)
Moto E5
So, Bob's your uncle.
For the LinearLayout
android:layout_height="152dp" android:layout_marginTop="40dp"
You don't need to add a background.

How are you getting those screenshots and why are they JPEGs?
You can use
Code:
# screenshot /sdcard/snap.png
I forget if AdbGrab works for that.
There is that whole screenshot/screencap/framebuffer thing.
(Also format 1 & formt 2)
 
  • Like
Reactions: nmyshkin

nmyshkin

Recognized Contributor
Nov 21, 2013
1,418
422
So, Bob's your uncle.
For the LinearLayout
android:layout_height="152dp" android:layout_marginTop="40dp"
You don't need to add a background.

How are you getting those screenshots and why are they JPEGs?
You can use
Code:
# screenshot /sdcard/snap.png
I forget if AdbGrab works for that.
There is that whole screenshot/screencap/framebuffer thing.
(Also format 1 & formt 2)
Well, that's just nifty! Thanks for looking at this and helping out.

I'm getting the screenshots using my swiss army knife app QuickTiles which includes a screenshot option. This uses the Screenshot Easy app as a plugin. I selected jpeg as the format, could have been png. You may recall that the native screenshot capabilities of the NST leave something to be desired. Screenshots come out with a green cast (or is is blue?) because of some weird color coding which I can't remember now.

Anyway, I normally have Quick Tiles assigned to the "clock" region of the status bar, but I want the quicknav bar there, so I temporarily assigned Quick Tiles to the "n" button. As much as I love Quick Tiles and spent a lot of time figuring it all out, I will be the first to admit that it is sometimes maddeningly slow to open. Other times it is nearly immediate, just like any other app on the NST. The quicknav bar (which I don't use at all), opens instantaneously. Over time and use I've worked my tile selection down to 5 (6 for my NSTG), so I've been thinking about trying to adapt the quicknav bar to replace Quick Tiles. It doesn't have the gee-whiz stuff like the battery percentage, date, and so on, but the response time is what I'm after at this point in my life.
 

Attachments

  • fixed_quicknav.jpg
    fixed_quicknav.jpg
    123.1 KB · Views: 7
  • QTiles.jpg
    QTiles.jpg
    40.2 KB · Views: 7

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    When you have a "boot loop" (which is just really Android flailing while the Linux is fine) you should check the logcat, it will tell you where the problem is.

    I don't know how I missed where that HorizontalScroll was being used.
    Yeah, I do. I was accidentally looking for quickNavHsView and not quickNavHSView.
    In services.jar, com/android/server/status/StatusBarService uses that.
    It must be a HorizontalScroll. You need that.

    The quick nav itself is com/android/server/status/BNGossamerQuickNavbar

    The default for layouts is top anyway.

    Make the LinearLayout big, android:layout_height="300dp".
    You won't see any background of the LL until it's bigger than its contents.
    1
    So, Bob's your uncle.
    For the LinearLayout
    android:layout_height="152dp" android:layout_marginTop="40dp"
    You don't need to add a background.

    How are you getting those screenshots and why are they JPEGs?
    You can use
    Code:
    # screenshot /sdcard/snap.png
    I forget if AdbGrab works for that.
    There is that whole screenshot/screencap/framebuffer thing.
    (Also format 1 & formt 2)