• Android

    ListView on ScrollView

    Buat custom ListView tanpa fitur scroll.

    package al.akh.example.testing.view;
    import android.content.Context;
    import android.util.AttributeSet;
    import android.view.ViewGroup;
    import android.widget.ListView;
    
    public class ListViewNonScroll extends ListView {
    
        public ListViewNonScroll(Context context) {
            super(context);
        }
        public ListViewNonScroll(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        public ListViewNonScroll(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
        @Override
        public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
                    Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
            ViewGroup.LayoutParams params = getLayoutParams();
            params.height = getMeasuredHeight();
        }
    }

     

    Pada layout resource file, gunakan custom ListView yang telah dibuat di atas.

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fadingEdgeLength="0dp"
        android:fillViewport="true"
        android:overScrollMode="never"
        android:scrollbars="none" >
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <al.akh.example.testing.view.ListViewNonScroll
                android:id="@+id/list_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/ >
    
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/list_view" >
                ...
            </RelativeLayout>
        </RelativeLayout>
    
    </ScrollView>
  • Linux

    Mount raw file

    Katakanlah kita mempunyai raw file hasil dari dd command.

    dd if=/dev/sda of=/mnt/data/backup/akhalos.img

    Langkah pertama adalah membuat folder untuk mount file image.

    sudo mkdir /mnt/akhalos

    Langkah selanjutnya adalah mencari nilai offset sector yang ada pada file image yang nantinya akan digunakan sebagai parameter offset pada perintah mount.

    fdisk -l /mnt/data/backup/akhalos.img
    Device       Boot Start      End  Sectors Size Id Type
    akhalos.img1 *     2048 16777182 16775135   8G 83 Linux
    

    Dari data diatas, didaptkan offset sebesar 2048. Karena nilai setiap sector adalah 512 bytes, maka nilai offset yang didapatkan untuk parameter mount adalah 2048*512 = 1048576. Sehingga, perintah mountnya menjadi:

    sudo mount -o loop,offset=1048576 /mnt/data/backup/akhalos.img /mnt/akhalos
  • RaspberryPi

    3.5inch RPi Display

    Features

    • 320×480 resolution
    • Resistive touch control
    • Supports any revision of Raspberry Pi (directly-pluggable)
    • Compatible with Raspberry Pi A, B, A+, B+, 2B, 3B, 3B+versions
    • Drivers provided (works with your own Raspbian/Ubuntu directly)
    • Size perfectly fits the Pi
    • High quality immersion gold surface plating
    • Supports Raspbian system, ubuntu system ,kali Linux system

    Key Parameters

    SKU MPI3501
    LCD Type TFT
    LCD Interface SPI
    Touch Screen Type Resistive
    Touch Screen Controller XPT2046
    Colors 65536
    Backlight LED
    Resolution 320*240 (Pixel)
    Aspect Ratio 8:5
    Backlight Current TBD
    Operating Temp. (℃) TBD

    Interface

    PIN NO. SYMBOL DESCRIPTION
    1, 17 3.3V Power positive (3.3V power input)
    2, 4 5V Power positive (5V power input)
    3, 5, 7, 8, 10, 22 NC NC
    6, 9, 14, 20, 25 GND Ground
    11 TP_IRQ Touch Panel interrupt, low level while the Touch Panel detects touching
    12 KEY1 Key
    13 RST Reset
    15 LCD_RS LCD instruction control, Instruction/Data Register selection
    16 KEY2 KEY
    18 KEY3 KEY
    19 LCD_SI / TP_SI SPI data input of LCD/Touch Panel
    21 TP_SO SPI data output of Touch Panel
    23 LCD_SCK / TP_SCK SPI clock of LCD/Touch Panel
    24 LCD_CS LCD chip selection, low active
    26 TP_CS Touch Panel chip selection, low active

    Driver Installation

    • Download raspbian image.
      https://www.raspberrypi.org/downloads/raspbian/
    • Tulis raspberry image ke sdcard.
    • Buka terminal, install driver lcd pada Raspberry Pi.
      git clone https://github.com/goodtft/LCD-show.git
      chmod -R 755 LCD-show
      cd LCD-show/
      sudo ./LCD35-show
    • Tunggu beberapa saat, Raspberry Pi akan reboot dengan sendirinya.

    Touch screen calibration

    Touchscreen dapat dikalibrasi dengan menggunakan program xinput_calibrator.

    cd LCD-show/
    sudo dpkg -i -B xinput-calibrator_0.7.5-1_armhf.deb

    Setelah instalasi selesai, buka Preference->Calibrate Touchscreen. Ikuti perintah yang muncul pada layar. Jika kalibrasi selesai, copy parameter yang dihasilkan pada file 99-calibration.conf, kemudian simpan di folder /ect/X11/xorg.conf.d/.

    /ect/X11/xorg.conf.d/99-calibration.conf

    Problem Solving

    • Jika touchsreen antara x dan y tertukar, dapat diatasi dengan solusi berikut ini:
      sudo nano /boot/config.txt
      dtoverlay=piscreen,speed=16000000,rotate=90
      reboot
    • Jika x axis posisinya dalam keaadan mirror, dapat diatasi dengan solusi memasang evdev.
      apt-get install xserver-xorg-input-evdev

      Ganti urutan file pada folder /usr/share/X11/xorg.conf.d. Hal ini dilakukan agar konfigurasi evdev tidak tertimpa (overide) dengan konfigurasi libinput. Ganti angka evdev.conf lebih tinggi dari pada libinput.conf.

      cd /usr/share/X11/xorg.conf.d
      sudo mv 10-evdev.conf 45-evdev.conf
      reboot

    Download

    Jika kesulitan untuk memasang drivernya, dapat langsung mengunduh image yang sudah disediakan.

     

     

    Image Name Version Support Password Download
    Raspbian 2018-06-29 PI3B+/A/A+/
    B/B+/PI2/PI3/
    ZERO/ZERO W
    user:pi
    password:raspberry
    MPI3501-Raspbian-20180629.7z
    Ubuntu Mate:16.04 PI3,PI2 user:pi
    password:raspberry
    3.5inch-RPI3-RPI2-ubuntu-mate-16.04-beta2.7z
    Kali-linux 2018.2(nexmon) PI3B+,PI3,PI2 user:root
    password:toor
    3.5SPI-kali-linux-2018.2-rpi3B+-nexmon.7z
  • RaspberryPi

    Cross-compilation Qt 5.9.6 for RaspberryPi

    Persiapan Raspberry Pi

    Update package

    Edit sources list /etc/apt/sources.list, kemudian uncomment baris deb-src:

    sudo nano /etc/apt/sources.list
    sudo apt-get update
    sudo apt-get dist-upgrade
    sudo reboot

    Update Raspberry Pi firmware

    sudo rpi-update
    sudo reboot

    Install dependencies

    sudo apt-get build-dep qt4-x11
    sudo apt-get build-dep libqt5gui5
    sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0

    Persiapan Linux Host

    Pada tutorial ini digunakan Ubuntu 16.04 x64.

    Update package

    sudo apt-get update
    sudo apt-get -y upgrade

    Install dependencies

    sudo apt-get install git bison python gperf

    Buat folder kerja

    sudo mkdir /opt/qt5pi
    sudo chown akhal:akhal /opt/qt5pi
    cd /opt/qt5pi

    Clone toolchain

    git clone https://github.com/raspberrypi/tools

    Tambahkan toolchain binary di variabel PATH

    nano ~/.bashrc

    Tambahkan baris berikut:

    export PATH=$PATH:/opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin

    Download QT Source

    https://download.qt.io/official_releases/qt/5.9/5.9.6/single/qt-everywhere-opensource-src-5.9.6.tar.xz

    Untar QT source

    tar -xvf t-everywhere-opensource-src-5.9.6.tar.xz

    Buat hf configuration

    cp -R qt-everywhere-opensource-src-5.9.6/qtbase/mkspecs/linux-arm-gnueabi-g++ qt-everywhere-opensource-src-5.9.6/qtbase/mkspecs/linux-arm-gnueabihf-g++
    sed -i -e 's/arm-linux-gnueabi-/arm-linux-gnueabihf-/g' qt-everywhere-opensource-src-5.9.6/qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf

    Copy raspberry pi sysroot

    mkdir sysroot sysroot/usr sysroot/opt
    rsync -avz akhal@192.168.1.100:/lib sysroot
    rsync -avz akhal@192.168.1.100:/usr/include sysroot/usr
    rsync -avz akhal@192.168.1.100:/usr/lib sysroot/usr
    rsync -avz akhal@192.168.1.100:/opt/vc sysroot/opt

    Buat symlinks to “missing” libraries

    mv sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0_backup
    ln -s sysroot/opt/vc/lib/libEGL.so sysroot/usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
    mv sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0 sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0_backup
    ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
    ln -s sysroot/opt/vc/lib/libEGL.so sysroot/opt/vc/lib/libEGL.so.1
    ln -s sysroot/opt/vc/lib/libGLESv2.so sysroot/opt/vc/lib/libGLESv2.so.2

    Ganti absolute symlinks dalam bentuk relative symlinks

    wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
    chmod +x sysroot-relativelinks.py
    ./sysroot-relativelinks.py sysroot

    Buat folder untuk build

    mkdir qt5build
    cd qt5build

    Konfigurasi QT Source

    ../qt-everywhere-opensource-src-5.9.6/configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake examples -make libs -v

    Jika muncul error unknown CPU architecture ketika konfigurasi, tambahkan baris -no-use-gold-linker sehingga menjadi:

    ../qt-everywhere-opensource-src-5.9.6/configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake examples -make libs -v -no-use-gold-linker

    Make

    Jika konfigurasi sudah selesai, jalankan perintah make.

    make
    make install

    Upload hasil compile ke Raspberry Pi

    cd /opt/qt5pi
    rsync -avz sysroot/usr/local/qt5pi akhal@192.168.1.100:/usr/local

    Konfigurasi Pada QT Creator

    Install QT

    Konfigurasi toolkit

    Buka QT Creator, kemudian pilih option dan tambahkan parameter-parameter berikut:

    • Tools->Options…->Devices->Add
      Generic Linux Device
      Edit host, username, dan password.
    • Tools->Build&Run->Debuggers->Add
      Edit name dan path ( /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb )
    • Tools->Compilers->Add->GCC->C
      Edit name dan path ( /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc )
    • Tools->Compilers->Add->GCC->C++
      Edit name dan path ( /opt/qt5pi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ )
    • Tools->Qt Versions->Add
      Pilih /opt/qt5pi/sysroot/usr/local/qt5pi/bin/qmake
    • Tools->Kits->Add
      Edit name
      Device type: Generic Linux Device
      Device: raspberry pi device
      Sysroot: Choose /opt/qt5pi/sysroot
      C and C++: Choose prior created raspberry pi compilers
      Debugger: Choose prior created raspberry pi debugger
      Qt version: Choose prior created raspberry pi qt version

    Selesai

  • RaspberryPi

    SSH login as root

    Jika ingin login menggunakan ssh sebagai root pada raspberry pi, perlu mengganti file config untuk sshd.

    • login, kemudian edit file config untuk sshd.
      sudo nano /etc/ssh/sshd_config
    • Cari baris PermitRootLogin prohibit-password, kemudian ganti menjadi PermitRootLogin yes
    • Tutup file & simpan.
    • Reboot
  • Linux

    Configure Static IP Addresses on Ubuntu 18.04 LTS Server

    Untuk mengganti ip pada Ubuntu server 18.04, dapat menggunakan NetPlan. Pertama-tama, lihat network device dengan menggunakan perintah ip addr. Misal yang akan diganti adalah eth0.
    Langkah selanjutnya buat file 01-netcfg.yaml di folder /etc/netplan.

    sudo nano /etc/netplan/01-netcfg.yaml

    Untuk mengganti ip address, tuliskan baris berikut:

    # This file describes the network interfaces available on your system
    # For more information, see netplan(5).
    network:
     version: 2
     renderer: networkd
     ethernets:
       eth0:
         dhcp4: no
         dhcp6: no
         addresses: [192.168.1.2/24]
         gateway4: 192.168.1.1
         nameservers:
           addresses: [8.8.8.8,8.8.4.4]

    Keluar dari editor, kemudian jalankan command berikut ini:

    sudo netplan apply
  • Linux

    Locale Issue on Ubuntu

    Error message:

    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
            LANGUAGE = (unset),
            LC_ALL = (unset),
            LC_TIME = "id_ID.UTF-8",
            LC_MONETARY = "id_ID.UTF-8",
            LC_ADDRESS = "id_ID.UTF-8",
            LC_TELEPHONE = "id_ID.UTF-8",
            LC_NAME = "id_ID.UTF-8",
            LC_MEASUREMENT = "id_ID.UTF-8",
            LC_IDENTIFICATION = "id_ID.UTF-8",
            LC_NUMERIC = "id_ID.UTF-8",
            LC_PAPER = "id_ID.UTF-8",
            LANG = "en_US.UTF-8"
        are supported and installed on your system.
    perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
    locale: Cannot set LC_ALL to default locale: No such file or directory

    Edit bashrc:

    nano ~/.bashrc

    Tambahkan code berikut:

    export LC_ALL="en_US.UTF-8"
  • Linux

    Fujitsu Touchpad Not Working In Ubuntu 18.04

    Untuk mengatasi masalah touchpad yang tidak berfungsi, dapat dilakukan dengan menambahkan i8042.notimeout i8042.nomux pada grub.
    Edit parameter grub.

    sudo gedit /etc/default/grub

    Edit baris berikut GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" sehingga menjadi:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.notimeout i8042.nomux"

    Update grub:

    sudo update-grub

    Langkah terakhir, reboot system.

  • Android

    Custom ActionBar on Android

    Buat activity untuk ActionBar. Misal saya beri nama custom_actionbar_center.xml.

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:background="@android:color/transparent">
    
        <TextView
            android:id="@+id/title_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:textSize="25sp"
            android:textColor="#fff"
            android:gravity="center"
            android:text="title"
            />
    
        <ImageButton
            android:id="@+id/ibtn_bluetooth"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginRight="15dp"
            android:layout_alignParentRight="true"
            android:foregroundGravity="center"
            android:background="@null"
            android:src="@drawable/ic_settings_white_32dp" />
    
    </RelativeLayout>

    Tambahkan code berikut pada activity

    ActionBar mActionBar = getSupportActionBar();
    assert mActionBar != null;
    mActionBar.setDisplayShowHomeEnabled(false);
    mActionBar.setDisplayShowTitleEnabled(false);
    LayoutInflater mInflater = LayoutInflater.from(this);
    View actionBar = mInflater.inflate(R.layout.custom_actionbar_center, null);
    TextView mTitleTextView = actionBar.findViewById(R.id.title_text);
    mTitleTextView.setText(R.string.app_name);
    mActionBar.setCustomView(actionBar);
    mActionBar.setDisplayShowCustomEnabled(true);
    ((Toolbar) actionBar.getParent()).setContentInsetsAbsolute(0,0);
    

    Jika ingin menghilangkan shadow di bawah ActionBar, tambahkan code berikut pada activity:

    getSupportActionBar().setElevation(0);
  • Linux

    How to Fix Time Differences in Ubuntu 16.04 and Windows 10 Dual Boot

    Untuk mengatasi masalah perbedaan waktu ketika dual boot antara ubuntu dan windows, dapat dilakukan dengan cara menonaktifkan UTC dan menggunakan local time. Berikut adalah langkah-langkahnya:

    • Buka terminal, kemudian jalankan command berikut:
      timedatectl set-local-rtc 1 --adjust-system-clock
    • Cek apakah sudah berubah menjadi local time, dengan menggunakan command berikut:
      timedatectl
    • reboot