Guía de Inicio HDroidGUI

Based in HDROIDGUI SETUP TUTORIAL
http://www.hmgforum.com/viewtopic.php?f=35&t=4229&hilit=hdroidgui

1) Download Java Development Kit (JDK) version 7 for Windows (if you have other version installed, please uninstall first):

http://www.oracle.com/technetwork/es/java/javase/downloads/jdk7-downloads-1880260.html 

2015-03-27_110459

2015-03-27_110601

2) Run it and accept suggested install location (at the date of this post, it is: C:\Program Files\java\jdk1.7.0_75. It will change according version number) .

3) Go to: https://developer.android.com/sdk/index.html (‘SDK Tools Only’ section, near the end of the page) and download Windows version.

2015-03-27_111754

2015-03-27_112228

 

4) Create the folder tree: c:\Android\sdk and install Android SDK there.

2015-03-27_113035 2015-03-27_113115 2015-03-27_113151 2015-03-27_113232

 

5) Run C:\Android\sdk\SDK Manager.exe and follow these directions found in android.com:

2015-03-27_113744

 

As a minimum when setting up the Android SDK, you should download the latest tools and Android platform:

Open the Tools directory and select:
Android SDK Tools
Android SDK Platform-tools
Android SDK Build-tools (highest version)

Open the first Android X.X folder (the latest version) and select:
SDK Platform
A system image for the emulator, such as
ARM EABI v7a System Image

6) Go to https://developer.android.com/tools/sdk/ndk/index.html and download Android NDK for Windows release 10d (at the time of this post) and extract in C:\Android\android-ndk-r10d

2015-03-27_114429
7) Go to https://github.com/alkresin/HDroidGUI and click on ‘Download ZIP’. Unzip on C:\Android\projects\HDroidGUI

2015-03-27_115050

 

8) Edit the file C:\Android\projects\HDroidGUI\setenv.bat and change paths according to the location of the tools you’ve installed. With the versions installed at the time of this post, it should look as this:

@set ANDROID_HOME=c:\Android\sdk
@set BUILD_TOOLS=%ANDROID_HOME%\build-tools\21.1.2
@set NDK_HOME=c:\Android\android-ndk-r10d
@set JAVA_HOME=c:\Program Files (x86)\Java\jdk1.7.0_75

@set ADB=%ANDROID_HOME%\platform-tools\adb.exe
@set ANDROID_JAR=%ANDROID_HOME%/platforms/android-21/android.jar

@set HRB_BIN=c:\hb32\bin
@set HRB_INC=c:\hb32\include

c:\Android\projects\HDroidGUI\comp.bat

@call setenv

call "%JAVA_HOME%/bin/javac" -d libs -cp %ANDROID_JAR% -sourcepath src src/su/harbour/hDroidGUI/*.java
@if errorlevel 1 goto end

@rem jar cvf hdroidgui.jar -C libs .
:end
@pause

Tips:

– Please, be careful: Path names changes with tools versions!
– JAVA_HOME could be different according your Windows version and language. Please, check it.
– I have Harbour installed at c:\hb32. If that is not your path, please change it as needed. If you do not have Harbour installed, please check it.

Download from:
http://sourceforge.net/projects/harbour-project/files/latest/download?source=files
and unzip at c:\hb32

9) Build HDROIDGUI: C:\Android\projects\HDroidGUI\BuildAll.bat

2015-03-27_115910

 

10) Now, we will download a sample project called HDCALCUL. Go to https://github.com/alkresin/hdcalcul and click on ‘Download ZIP’. Unzip on c:\Android\projects\hdcalcul

View c:\Android\projects\hdcalcul\setenv.bat

@set HDROIDGUI=\android\projects\hdroidgui
@call %HDROIDGUI%/setenv

@set APPNAME=hdcalcul
@set PACKAGE=su.harbour.hdcalcul
@set PACKAGE_PATH=su\harbour\hdcalcul
@set MAIN_CLASS=MainActivity
@set DEV_HOME=%CD%

11) build the .apk running: c:\Android\projects\hdcalcul\build.bat. The .apk will be generated at c:\Android\projects\hdcalcul\bin.

@call setenv
@call clear

@%HRB_BIN%\harbour src\main.prg /q /i%HDROIDGUI%\src\include /i%HRB_INC% /ojni\

@if errorlevel 1 goto end

@set NDK_LIBS_OUT=lib

@set SRC_FILES=main.c
%NDK_HOME%\prebuilt\windows\bin\make.exe -f %NDK_HOME%/build/core/build-local.mk %* >a1.out 2>a2.out

@if exist lib\armeabi\libh4droid.so goto comp
@echo Errors while compiling C sources
@goto end

:comp
call %BUILD_TOOLS%/aapt.exe package -f -m -S res -J src -M AndroidManifest.xml -I %ANDROID_JAR%

@if errorlevel 1 goto end

@rem compile, convert class dex

@rem call %JAVA_HOME%/bin/javac -d obj -cp %ANDROID_JAR%;%HDROIDGUI%\hdroidgui.jar -sourcepath src src/%PACKAGE_PATH%/*.java
call "%JAVA_HOME%/bin/javac" -d obj -cp %ANDROID_JAR%;%HDROIDGUI%\libs -sourcepath src src/%PACKAGE_PATH%/*.java

@if errorlevel 1 goto end

call %BUILD_TOOLS%/dx.bat --dex --output=bin/classes.dex obj %HDROIDGUI%\libs

@if errorlevel 1 goto end

@rem create APK
call %BUILD_TOOLS%/aapt.exe package -f -M AndroidManifest.xml -S res -I %ANDROID_JAR% -F bin/%APPNAME%.unsigned.apk bin

call %BUILD_TOOLS%/aapt.exe add %DEV_HOME%/bin/%APPNAME%.unsigned.apk lib/armeabi/libharbour.so

@if errorlevel 1 goto end

call %BUILD_TOOLS%/aapt.exe add %DEV_HOME%/bin/%APPNAME%.unsigned.apk lib/armeabi/libh4droid.so

@rem sign APK
call "%JAVA_HOME%/bin/keytool" -genkey -v -keystore myrelease.keystore -alias key2 -keyalg RSA -keysize 2048 -validity 10000 -storepass calcpass -keypass calcpass -dname "CN=Alex K, O=Harbour, C=RU"

call "%JAVA_HOME%/bin/jarsigner" -sigalg SHA1withRSA -digestalg SHA1 -keystore myrelease.keystore -storepass calcpass -keypass calcpass -signedjar bin/%APPNAME%.signed.apk bin/%APPNAME%.unsigned.apk key2
%BUILD_TOOLS%/zipalign -v 4 bin/%APPNAME%.signed.apk bin/%APPNAME%.apk

:end
@pause

12) To test it, you only must to copy the .apk generated file to an Android device
and run it.

13) In my case I have synchronized the smarphone and notebook with the cloud, so I copy the .apk file from the notebook folder and automatically updated on the smartphone, same with screenshots of the smartphone are immediately in the notebook 🙂

Screenshot_2015-03-25-pag1

Harbour y OCX

/*
    Demo uso de OCX SkinCrafter
    NOTA: Boton derecho en ejecutable, compatibilidad, 
    ejecutar el programa como administrador.
*/

#include "oohg.ch"

FUNCTION Main()

  Local aSkins := Directory( ".\Skins\*.Skf" )
  Local aItems := {}
  Local nCont

  Public oSkin

    If Empty( aSkins )
        Aadd( aItems, {""} )
    EndIf

    For nCont := 1 To Len( aSkins )
        Aadd( aItems, { aSkins[nCont][1] } )
    Next

    InitOcx()
    CreateObjSkin()

    aLic := { "SKINCRAFTER", ;
              "SKINCRAFTER.COM", ;
              "[email protected]", ;
              "DEMOSKINCRAFTERLICENCE" }

    oSkin:InitLicenKeys(aLic[1],aLic[2],aLic[3],aLic[4])
    oSkin:DefineLanguage(0)
    oSkin:InitDecoration(1)

    InitSkin( aItems[1][1] )

    Define Window Win_0 At 0, 0 ;
           Width 640 Height 480 ;
           Title 'ooHG with SkinCrafter by MigSoft' ;
           Icon "Skin" Main Nomaximize ;
           On Release ExitOcx()

        @ 160,   4 Frame frame_1 Caption '' ;
                   Width 330 Height 280

        @ 180,  13 Grid grid_1 Width 310 ;
                   Height 250 Headers {'Skin'} ;
                   Widths {285} Items aItems Value 1 ;
                   On DblClick Aplica()

        @ 20,  360 Label lbl_1 Value 'Etiqueta' AutoSize

        @ 15,  417 TextBox cTexto  Value "TextBox"   ;
                   Width 200 Height 022
        @ 60,  360 CheckBox lCheck Caption 'Checkbox';
                   Width 100 Height 20
        @ 60,  530 DatePicker date_1                 ;
                   Width 90  Height 20
        @ 100, 360 ProgressBar progress_1 Value 33   ;
                   Width 260 Height 20
        @ 150, 380 MonthCalendar month_1

        @ 400, 360 Button btn_2 Caption '&Aplicar' ;
                   Action Aplica() ;
                   Width 70 Height 20
        @ 400, 450 Button btn_1 Caption '&Salir'   ;
                   Action Win_0.Release() ;
                   Width 70 Height 20
        @ 400, 540 Button btn_3 Caption '&Mensaje' ;
                   Action MsgInfo( "Saludos cordiales" ) ;
                   Width 70 Height 20

        @ 7,9 FRAME frame_2 CAPTION "" ;
              WIDTH 190 HEIGHT 95 ;

        Win_0.frame_1.fontcolor := {0,0,0}
        Win_0.frame_1.fontname  := 'MS Sans Serif'
        Win_0.frame_1.fontsize  := 10

        @ 15,  208 LISTBOX list_1 WIDTH  98 HEIGHT 110 ;
                   FONT 'MS Sans Serif' ;
                   ITEMS { 'Harbour','xHarbour' } SIZE 10 ;

        Win_0.list_1.fontcolor  := {0,0,0}
        Win_0.list_1.backcolor  := {255,255,255}

        @ 135,  16 BUTTON button_1 CAPTION 'Normal' ;
                   ACTION msginfo('Button pressed') ;
                   WIDTH 70 HEIGHT 20 ;
                   FONT 'MS Sans Serif' SIZE 10 ;

        Win_0.button_1.fontcolor:={0,0,0}

        @ 135, 126 BUTTON button_2 ;
            CAPTION 'Focused' ;
            ACTION msginfo('Button pressed') ;
            WIDTH 70 ;
            HEIGHT 20 ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.button_2.fontcolor:={0,0,0}

        @ 135, 236 BUTTON button_3 ;
            CAPTION 'HightLight' ;
            ACTION msginfo('Button pressed') ;
            WIDTH 70 ;
            HEIGHT 20 ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.button_3.fontcolor:={0,0,0}

        @ 25,  15 TEXTBOX text_1 ;
            HEIGHT 24 ;
            WIDTH 90 ;
            Font 'MS Sans Serif' ;
            size 10 ;
            VALUE "TextBox";
            MAXLENGTH 20 ;

        Win_0.text_1.fontcolor:={0,0,0}
        Win_0.text_1.backcolor:={255,255,255}

        @ 60,  15 COMBOBOX combo_1 ;
            WIDTH  90 ;
            FONT 'MS Sans Serif' ;
            ITEMS {"GUI 1","GUI 2","GUI 3"} ;
            VALUE 2 ;
            SIZE 10 ;

        Win_0.combo_1.fontcolor:={0,0,0}
        Win_0.combo_1.backcolor:={255,255,255}

        @ 18, 110 CHECKBOX checkbox_1 ;
            CAPTION 'Check' ;
            WIDTH 80 ;
            HEIGHT 28;
            VALUE .F. ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.checkbox_1.fontcolor:={0,0,0}

        @ 46, 110 RADIOGROUP radiogroup_1 ;
            OPTIONS  {'option 1','option 2'}  ;
            VALUE 1 ;
            WIDTH  80 ;
            SPACING  25 ;
            FONT 'MS Sans Serif' ;
            SIZE 10 ;

        Win_0.radiogroup_1.fontcolor:={0,0,0}

        @ 110, 13 PROGRESSBAR progressbar_1 ;
            RANGE 1,100 ;
            VALUE 35;
            WIDTH 186 ;
            HEIGHT 18 ;

        Win_0.progressbar_1.fontcolor:={0,0,0}
        Win_0.progressbar_1.backcolor:={255,255,255}

    End Window

    Center   Window Win_0
    Activate Window Win_0

RETURN .T.


Static Function Aplica()

Local aRenglon:=Win_0.grid_1.Item( Win_0.grid_1.Value )

    InitSkin( aRenglon[1] )

Return .T.

Function InitSkin( cSkin )

    oSkin:LoadSkinFromFile( ".\Skins\" + cSkin )
    oSkin:ApplySkin()

Return .T.

Function InitOcx()

    Execute File ;
    "regsvr32 /s .\SkinCrafter3_vs2012.Dll" ;
    Wait Minimize

Return .T.

Function ExitOcx()

    Execute File ;
    "regsvr32 /s /u .\SkinCrafter3_vs2012.Dll" ;
    Wait Minimize

Return .T.

Function CreateObjSkin()

    Local cOcxFileName := "SkinCrafter.SCSkin3"

    OCX_bSaveHandler := errorblock( { |x| break(x) } )
    BEGIN SEQUENCE
          oSkin := GetActiveObject( cOcxFileName )
    RECOVER USING oError
          OCX_Error = oError:genCode
    END
    errorblock( OCX_bSaveHandler )

    if OCX_Error != 0
       OCX_bSaveHandler := errorblock( { |x| break(x) } )
       BEGIN SEQUENCE
             oSkin := CreateObject( cOcxFileName )
       RECOVER USING oError
             MsgStop( 'SkinCrafter DLL not available or '+ ;
             'insufficient permissions !!!', 'Warning...' )
             ExitOcx()
             RETURN .F.
       END
       errorblock( OCX_bSaveHandler )
     endif

Return .T.