2017년 6월 2일 금요일

[App Inventor Open Source Development] Re: Disabling the hardware menu button


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 (The new About Screen property in AI2 Version nb122) 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.

--
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:
How to build App Inventor from the MIT sources

--
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" "
--
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" "
see here https://puravidaapps.com/packagename.php


--
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?

-- 
I only want to remove the "invented by MIT" part
see here https://puravidaapps.com/about.php

PS: a better place to ask this question would have been the main forum https://groups.google.com/forum/#!forum/mitappinventortest

--
Thank you Sir. Will do that for next time.

--
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++?

--
Hi there, I really know nothing about AI2U; do they have a forum or something?

--
Can you make a video dude on how to do it exactly it would help us a lot.Thanks!!!!

--

댓글 1개:

  1. Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!..
    SaaS Application Development Company

    답글삭제