Nov 22, 2016

Remapping hardware buttons on Android

I own a Nexus 5 (several, actually) for a while now, and every few months the power button starts to fail (due to usage)? Sometimes it gives off a signal by itself, like it's stuck. And the screen starts to flicker.

A video posted by Jean Caffou (@jeancaffou) on

But recently the power button just died. For two days I had to press it really hard for it to make contact, but now, nothing works. I'm not a hardware guy myself, so to replace the button physically I need to visit my geeky electronics hacker friend. And it sucks begging people for help. So to workaround it for as long as possible let's try software solutions.
Apps - they work without root, sure. But all of the ones I tested were kind of buggy. One worked on proximity sensor, the other one tried to remap the volume button. But the problem with all of them was they were sending the WAKE command to turn the screen on. And I sometimes had no way to turn the screen off. Except for, you know, using another app. The WAKE command was causing a weird bug when I was ending a call.
When calling, the system turns the screen off and on based on proximity (if you have your phone on your face), so sometimes the device didn't go to sleep, EVER, but the screen was off. So WAKE command did nothing, because the phone thinks that it's still on. So I was stuck.
To get out of this loop, I powered up the adb and sent the POWER command instead of WAKE.

adb shell input keyevent KEYCODE_POWER

The first time I sent this, nothing happened, but internally, the phone went to sleep. The second time I sent it, the phone powered back on. So now I know the problem. And do I really need an app to remap the power buttons?

Turns out, I don't.

There is a system file (unfortunately you need root to edit it) which defines all of the keyboard layout including hardware buttons. It is located in:

/system/usr/keylayout/

Inside of this folder there are a bunch of .kl files - you need to find the right one and open it up.
There you will find the definitions such as:

key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER

Just change the "VOLUME_" ones to POWER.

Reboot to apply changes.

I'm not sure if I'll be able to power on the device if the battery dies, but it works for locking/unlocking.

Because this file is only read on boot, it might work if the device is plugged in a charger so that it boots and reads the definitions.

Sep 20, 2016

Migrating payment extensions to OpenCart 2.2 and 2.3

This is an incomplete list of changes.

In OpenCart 2.2.x
  • In catalog/model/ there is no function currency->getCode()
    (Fatal error: Call to undefined method Cart\Currency::getCode() in ...on line ...)
    //$currency = $this->currency->getCode(); // OC <= 2.1
    $currency = $this->config->get('config_currency'); // OC 2.2
  • In controllers, the prefix to default templates has been automatically added.
    Remove the "default/template" from load->view()
In OpenCart 2.3.x
Along with the listed changes for OpenCart 2.2.x we have noticed these changes:
  • Directory structure has been changed, from catalog/controller/payment/ to catalog/controller/extension/payment. This affects view files, breadcrumbs in the admin as well as the controller class name, files and URL routes.



Sep 17, 2016

Chrome text, icons and buttons too small

With the recent update (september 2016) Chrome is transitioning to "Material design".

You can disable this option and return the previous text and icon size by typing:

chrome://flags/#top-chrome-md

In the address bar. Change the design type to "Non-material" and relaunch Chrome.

Sep 10, 2016

OpenCart plačilni modul Activa (Nestpay)

Za vse verzije OpenCart smo izdelali plačilni modul Activa.

Activa z dnem 30.9.2016 prehaja iz sistema e24PaymentPipe na nov sistem Nestpay.

Modul je dostopen na direktoriju OpenCart Extensions:

Za nakup modula nas kontaktirajte preko e-mail naslova info@krejzi.si

Activa podpira naslednje plačilne kartice:
MasterCard, Maestro, Visa, Visa Electron

Članice sistema Activa so:
Banka Celje, Banka Koper, BKS Bank, Deželna banka Slovenije, Gorenjska banka, Hranilnica LON, Hranilnica Vipava, Nova KBM, Poštna banka Slovenije, Probanka, Raiffeisen banka in Sberbank. Več informacij:



OpenCart plačilni modul Bankart


Za vse verzije OpenCart smo izdelali plačilni modul Bankart

Modul je dostopen na direktoriju OpenCart Extensions.

Za nakup modula nas kontaktirajte preko e-mail naslova info@krejzi.si

Bankart podpira naslednje plačilne kartice: 
Karanta, MasterCard, Visa, Visa Electron, Maestro

Banke, ki so članice sistema Bankart, so:
Abanka Vipa, Banka Sparkasse, Delavska hranilnica, Factor banka, Hypo Alpe-Adria-Bank, Nova Ljubljanska banka, Nova Kreditna banka Maribor, SKB banka in UniCredit Banka Slovenija.


Sep 9, 2016

OpenCart plačilni modul Moneta


Za vse verzije OpenCart smo izdelali plačilni modul Moneta.

Modul je dostopen na direktoriju OpenCart Extensions:

Za nakup modula nas kontaktirajte preko e-mail naslova info@krejzi.si


Mar 14, 2016

WordPress jQuery UI tabs is not a function

When working with jQuery UI you get an error message:

Uncaught TypeError: jQuery(...).tabs is not a function(…)

This is because WordPress' function
wp_enqueue_script( 'jquery-ui' );
doesn't actually enqueue the tabs widget, only the core of jQuery UI.

So after that you need to add:
wp_enqueue_script( 'jquery-ui-tabs' );

See this link below for more info:

Default Scripts Included and Registered by WordPress
https://developer.wordpress.org/reference/functions/wp_enqueue_script/


Feb 18, 2016

Using Wordpress AJAX on Frontend

wp_ajax_* callback functions will return 0 if they are called on the frontend by anonymous users.

This is because of security reasons, but Wordpress has prefixes for "unsecure" calls: wp_ajax_nopriv_*.

Both of the hooks need to be defined to work with logged in and anonymous users.

In functions.php define:
add_action( 'wp_ajax_call_stuff', 'my_callback' );
add_action( 'wp_ajax_nopriv_call_stuff', 'my_callback' );
function my_callback() {
    print_r($_POST);
    exit;
}

Another thing to add is the ajaxurl variable, which is not included on the frontend by default. You can do this in many ways, but I figured the best thing to do is to use wp_localize_script().
wp_localize_script('my_main_script', 'myPrefix', array( 'ajaxurl' => admin_url( 'admin-ajax.php')));

Then, you can call the AJAX request like this:
jQuery.post(myPrefix.ajaxurl, {
  'action': 'call_stuff',
  'whatever': '1'
 }, 
 function(response){
  alert('The server responded: ' + response);
 }
);