Showing posts with label ICS. Show all posts
Showing posts with label ICS. Show all posts

Monday, March 19, 2012

How to add Virtual Softkeys / Navigation bar to Gingerbread.


Virtual buttons allows for the buttons (Home, Back, etc) to be incorporated in the bottom of the screen.



The Input system in Android provides special features for implementing virtual soft keys.

There are three cases:

1. If the virtual soft keys are displayed graphically on the screen, as on the Galaxy Nexus, then they are implemented by the Navigation Bar component in the System UI package.

2. If the virtual soft keys are implemented as an extended touchable region that is part of the main touch screen, as on the Nexus One, then the input system uses a virtual key map file to translate X / Y touch coordinates into Linux key codes, then uses the key layout file to translate Linux key codes into Android key codes.

3. If the virtual soft keys are implemented as capacitive buttons that are separate from the main touch screen, as on the Nexus S, then the kernel device driver or firmware is responsible for translating touches into Linux key codes which the input system then translates into Android key codes using the key layout file.

From ICS onwards, Android supports the (1) case along with (2) and (3) case. The introduction of virtual buttons does not necessarily spell the end to hardware buttons, as such devices with buttons will simply not display the digital buttons.

This article targets for the devices which are running on Gingerbread (2.3.6) without the hardware buttons. 

I Back-ported the "Virtual Soft keys / Navigation Bar from ICS (4.0.3) to Gingerbread (2.3.6) .

The animation changes of ICS have been discarded in Gingerbread and the Functionality of 'Recent Applications list ' of ICS hasn't been taken into GB.

Follow these steps to get the Virtual soft keys on Gingerbread (2.3.6).

Prerequisites : 
           a) AOSP Gingerbread code (2.3.6) -- Get it from here
           b) AOSP ICS source code    (4.0.3)    -- Get it from here 

Source File Changes:
 
All the source file changes are in '/frameworks/base' module.

Addition of source files : New source files have been added from ICS to GB.

     a) NavigationBarView.java: Copy this file from ICS to GB.  
         ICS Location : /frameworks/base/packages/systemui/src/com/android
                                 /systemui/statusbar/phone/
         GB Location :  /frameworks/base/packages/systemui/src/com/android
                                /systemui/statusbar/
         Note :  Ignore out all the animator related stuffs in this source file.
                     Change the package name also.

    b) KeyButtonView.java: Copy this file from ICS to GB.  
         ICS Location : /frameworks/base/packages/systemui/src/com/android
                                 /systemui/statusbar/policy/
         GB Location :  /frameworks/base/packages/systemui/src/com/android
                                /systemui/statusbar/
         Note :  Ignore out all the animator related stuffs in this source file.
                     Change the package name also.

Modification to source files

 a) core/java/android/view/KeyCharacterMap.java :
 b) core/java/android/view/View.java
 c) core/java/android/view/ViewGroup.java
 d) core/java/android/view/WindowManager.java
 e) include/ui/InputDispatcher.h
 f) packages/SystemUI/src/com/android/systemui/statusbar/StatusBarService.java
g) policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Resource File Changes :

Addition of Resource Files : New Resource files have been added from ICS to GB
a) Copy these files from /frameworks/base/packages/SystemUI
      /res/drawable-hdpi  to
      /frameworks/base/packages/SystemUI/res/drawable

  • packages/SystemUI/res/drawable/ic_sysbar_back.png
  • packages/SystemUI/res/drawable/ic_sysbar_back_land.png
  • packages/SystemUI/res/drawable/ic_sysbar_highlight.png
  • packages/SystemUI/res/drawable/ic_sysbar_highlight_land.png
  • packages/SystemUI/res/drawable/ic_sysbar_home.png
  • packages/SystemUI/res/drawable/ic_sysbar_home_land.png
  • packages/SystemUI/res/drawable/ic_sysbar_lights_out_dot_large.png
  • Packages/SystemUI/res/drawable/ic_sysbar_lights_out_dot_small.png
  • packages/SystemUI/res/drawable/ic_sysbar_menu.png
  • packages/SystemUI/res/drawable/ic_sysbar_menu_land.png
  • packages/SystemUI/res/drawable/ic_sysbar_recent.png
  • packages/SystemUI/res/drawable/ic_sysbar_recent_land.png
b) navigation_bar.xml: Copy this file from /frameworks/base/packages/SystemUI
    /res/layout/  to
    /frameworks/base/packages/SystemUI/res/layout/

 c) attrs.xml         : Copy this file from /frameworks/base/packages/SystemUI/res/values/ to /frameworks/base/packages/SystemUI/res/values/


 Modifications to Resource Files :

a) core/res/res/values/dimens.xml
b) packages/SystemUI/res/layout/status_bar.xml
c) packages/SystemUI/res/values/dimens.xml
d) packages/SystemUI/res/values/strings.xml

Will be updating the complete patches list of the modifications soon !!!

Happy Navigating !!

Thursday, December 22, 2011

How to add Indian Languages to Android ICS (4.0.3)

Google is officially supporting the Indian languages rendering from 4.0.3 onwards.
The AOSP code supports rendering of three Indian languages in Web-kit. (Devanagari, Tamil, and Bengali).
I just added support for the other Indian languages as well. Tested it on my Nexus-S device

Prerequisites :

Follow these instructions:

1) Download the "Binary" file of the Indian language from this link.
         Ex: lohit-kananda-ttf-2.5.0.tar.gz

2) Untar the downloaded file and Copy the extracted folder into  
    external/lohit-fonts directory
        Ex: lohit-kannada-ttf-2.5.0

3) Rename the folder name to lohit-kannada-ttf

4) Modify the Android.mk file which is present in external\lohit-fonts directory

       ifneq ($(SMALLER_FONT_FOOTPRINT),true)
            extra_lohit_fonts := Lohit-Bengali.ttf Lohit-Tamil.ttf Lohit-Kannada.ttf
        endif 


       include $(CLEAR_VARS)
        LOCAL_MODULE := Lohit-Kannada.ttf
        LOCAL_SRC_FILES := lohit-kannada-ttf/$(LOCAL_MODULE)
        LOCAL_MODULE_CLASS := ETC
        LOCAL_MODULE_TAGS := optional
        LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
        include $(BUILD_PREBUILT)

5) Modify the FontAndroid.cpp file (external/webkit/source/webcore/platform/graphics/android)

    a) Add an language entry to CustomScript enum
             enum CustomScript {
               Bengali,
               Devanagari,

               Kannada,
               .......
              };

    b) Add the ttf file path to the TextRunWalker Paths

           const char* TextRunWalker::paths[] = {
              "/system/fonts/Lohit-Bengali.ttf",
             "/system/fonts/Lohit-Devanagari.ttf",

             "/system/fonts/Lohit-Kannada.ttf",
             ........
          };

    c) Now setup the Font for Script Run
         TextRunWalker::setupFontForScriptRun()
          {
            case HB_Script_Kannada:
              complexPlatformData = setupComplexFont(Kannada, platformData);
            break;

          }
 
6) Add the *.ttf file in Fallback_fonts.xml (frameworks\base\data\fonts)

Note : Assamese language is not enabled as Harfbuzz is not supporting this language.