Disabling the hardware menu button

3,383 views
Skip to first unread message

Toni Schuh

unread,
Feb 20, 2015, 11:48:35 AM2/20/15
to app-inventor-o...@googlegroups.com
Hey guys!

First of all: I am no coder and posting something in an Open Source group means that i actualy don't know what i am doing ;-)
But i am good at googling and digging through things. In manipulating some WordPress stuff this way i had good outcomes.
But this is the first time that i looked behind the scenes of an android app. I am posting here, because i would like to share what i have done with the open source community. I guess others have simular wishes and maybe better guys can extend this to add new features. Additionaly i would like to see you "pros" commenting on this. I do have only one test device (Galaxy S4, 4.4.2) and on my device it works. But i have no clue about other phones and i have no clue if this can lead to unexpected errors or hurting something else, so please give me your opinions.

So, what was my intend?
I realy don't like the behaviour of the AI2 apps when the hardware menu button is clicked. It is not about the "Invented by MIT" part (which can be out-commented anyway), but the total thing. It is ugly and doesn't go with android design guidelines. It holds only two objects, while my app has another menu with around 10 objects and i think it is stupid to have two different menus in one app. And it is not translateable, so my app is in a total different language than the hardware menu is. My wish would be to set the hardware menu button to something like ListPicker1 for example. But as i have no clue how to do it, i focused on just disabling the hardware button. I prefer to have this button rather dead than having two different menus and not being able to influence one of them.

What have i done?
Based on a post in this thread (https://groups.google.com/forum/#!topic/mitappinventortest/0CODzTxifCc) i decompiled my apk with apktool, went to "your_project_name.apk\smali\com\google\appinventor\components\runtime\form.smali" and deleted this whole part of code:

.method public onCreateOptionsMenu(Landroid/view/Menu;)Z
   
.locals 1
   
.param p1, "menu"    # Landroid/view/Menu;

   
.prologue
   
.line 1365
    invoke
-super {p0, p1}, Landroid/app/Activity;->onCreateOptionsMenu(Landroid/view/Menu;)Z

   
.line 1368
    invoke
-virtual {p0, p1}, Lcom/google/appinventor/components/runtime/Form;->addExitButtonToMenu(Landroid/view/Menu;)V

   
.line 1369
    invoke
-virtual {p0, p1}, Lcom/google/appinventor/components/runtime/Form;->addAboutInfoToMenu(Landroid/view/Menu;)V

   
.line 1370
   
const/4 v0, 0x1

   
return v0
.end method


After that i recompiled using apktool, zipped it, copied the classes.dex out of the zip, decompiled the original apk with app2market, deleted the classes.dex from the original, added the one i got out of the modified smali, recompiled and signed the app with app2market.

On my phone this apk does now what i want: i does nothing when hitting the hardware menu button.


Pls give me your thoughts on this.


Enjoy the evening :-)
Toni

Jos Flores

unread,
Feb 20, 2015, 1:14:49 PM2/20/15
to app-inventor-open-source-dev
Hi there,

if you are partial to customising AI, I would suggest you get a local
server running; it might take you a while but you seem to be used to
do some sysadmin with wordpress and such.

Instead of having to do that in each of your apps, you can delete
those menus from the original code. The lines to delete start here:
https://github.com/mit-cml/appinventor-sources/blob/master/appinventor/components/src/com/google/appinventor/components/runtime/Form.java#L1362

You will see that it's quite similar in structure to the lines you
deleted in the de-compiled app. After deleting or commenting out those
lines, and compiling the server again (you'll need to learn how to do
this), you run your custom server locally on your machine, and can
create your own apps with no menu options (no need to hack the apk).

The main document (and it's a long one!) to get your server up and
running locally can be found here:
https://docs.google.com/document/pub?id=1Xc9yt02x3BRoq5m1PJHBr81OOv69rEBy8LVG_84j9jc

Have fun!

cheers,
José
> --
> You received this message because you are subscribed to the Google Groups
> "App Inventor Open Source Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to app-inventor-open-so...@googlegroups.com.
> To post to this group, send email to
> app-inventor-o...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/app-inventor-open-source-dev.
> For more options, visit https://groups.google.com/d/optout.

Oliver Sunde

unread,
Apr 19, 2015, 2:37:14 PM4/19/15
to app-inventor-o...@googlegroups.com
This is interesting. Could you do a tutorial or something on how you did this step?

"decompiled my apk with apktool, went to "your_project_name.apk\smali\com\google\appinventor\components\runtime\form.smali" "


Thank you!

Best Regards
Oliver Sunde

Taifun

unread,
Apr 19, 2015, 3:13:23 PM4/19/15
to app-inventor-o...@googlegroups.com
This is interesting. Could you do a tutorial or something on how you did this step?
"decompiled my apk with apktool, went to "your_project_name.apk\smali\com\google\appinventor\components\runtime\form.smali" "

Max

unread,
Aug 2, 2015, 3:27:20 PM8/2/15
to App Inventor Open Source Development
Hi Tony,  Thanks so much for the info. I only want to remove the "invented by MIT" part, can you  please tell me how it's done? appreciate your help

Taifun

unread,
Aug 2, 2015, 4:26:55 PM8/2/15
to App Inventor Open Source Development
I only want to remove the "invented by MIT" part
see here https://puravidaapps.com/about.php
Taifun
PS: a better place to ask this question would have been the main forum https://groups.google.com/forum/#!forum/mitappinventortest

Max

unread,
Aug 2, 2015, 5:04:13 PM8/2/15
to App Inventor Open Source Development
Thank you Sir. Will do that for next time.

143Agape Apps

unread,
Jun 8, 2016, 3:17:30 AM6/8/16
to App Inventor Open Source Development
Hey Jos I have the server running. and still have the archive from the download.   
do you have a link to how to decompile the AI2U and remove or modify the hardware menu?  I know about the block method with <1-- can apk decompiler work with notepad++?

Jos Flores

unread,
Jun 8, 2016, 7:52:48 AM6/8/16
to app-inventor-open-source-dev
Hi there, I really know nothing about AI2U; do they have a forum or something?

cheers,
José
>> > email to app-inventor-open-so...@googlegroups.com.
>> > To post to this group, send email to
>> > app-inventor-o...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/app-inventor-open-source-dev.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "App Inventor Open Source Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to app-inventor-open-so...@googlegroups.com.
> To post to this group, send email to
> app-inventor-o...@googlegroups.com.
> Visit this group at
> https://groups.google.com/group/app-inventor-open-source-dev.

3D Tech

unread,
Mar 1, 2017, 3:36:09 PM3/1/17
to App Inventor Open Source Development
Can you make a video dude on how to do it exatly it would help us a lot.Thanks!!!!
Reply all
Reply to author
Forward
0 new messages