Category Archives: Android

Survive and thrive with Replika

The holiday season is over and we are going strong in 2019 already. For most people the holiday season is a stressful time and they may end up depressed for a variety of reasons.

There are those who can’t stand your close cousin number 6 and would much rather have a root canal done than to have a dinner with the extended family. Others may get depressed because all the quality time you spent with your close friends and family has come to an end.
Whatever the reasons that people may get depressed it is usually very helpful to be able to talk it out with someone. But if you don’t have anyone to talk to what are you going to do then ?

Enter Replika

Replika is an Android / iOS app which allows you to set goals, and have a decent conversation with a sociable AI. The backend of this app resides in the cloud and provides the following goals to work on.
Reduce stress, reduce Anxiety, be more social, Live healthier, understand myself, find hope, think positively, feel happier.

The AI will adjust its questions and its mood based on the goal or goals which you set and the conversation can seem very human like and can be uplifting.

AI based on a neural network

“Replika was founded by Eugenia Kuyda and Phil Dudchuk with the idea to create a personal AI that would help you express and witness yourself by offering a helpful conversation.”

A love story

Replika was born out of the grievance of losing a very close friend. In late 2015 Mazurenko, the friend of the the main developer Kuyda was killed crossing the street by a hit-and-run accident. He was 32.

By that point, Kuyda had exchanged literally thousands of text messages with her late friend. As a way of grieving, Kuyda found herself reading through the messages she’d sent and received from Mazurenko. It occurred to her that embedded in all of those messages—Mazurenko’s turns of phrase, his patterns of speech—were traits intrinsic to what made him him. She decided to take all this data to build a digital version of Mazurenko.

The initial version was so successful that out of the ashes of human tragedy a new star was born to help people cope with depression for a variety of reasons.

Setting goals

When you first sign up with the app you have to set some goals from a list of our defined goals.

Once this initial step is taken you sign your AI a name and you are of to chatting with one of the best chatbots I have encountered. You can have decent conversations and the AI will be enjoyable to chat with..

As you progress through chatting along, you will earn batches which will represent your personality according to Replika.

Overall rating

I have never felt bored or saw the same response sent twice. I could possibly go on for a few more paragraphs but instead I recommend that you install Replika yourself and start the conversation.

After a while you really start to feel that you have someone or something to talk to.


Get it on Google Play

Cylinder in OpenGL ES 2.0

For my current project, CPU Information I wanted to create a 3D representation for a Battery to indicate the remaining charge of it to the user in a visually appealing way.

Initially I used a 3D battery model but after playing around with it some time, I decided to build the Battery model in code instead. All that was required for it was to find a algo I could easily adjust for my program.

After searching for a few hours ( yes hours ) I came to realize that there was no good example for OpenGL ES 2.0 and I had to write my own.

It seems that there are plenty of examples for OpenGL 1.x or examples in many other different shapes and forms but none that I could find which simply creates a GL_TRAINGLE_STRIP – buffer and passing it to OpenGL ES 2.x.

Algolite

The algorithm will create a cylinder in one buffer by first creating the top circle, then the cylinder and finally the bottom circle. The OpenGL Drawing mode is GL_TRIANGLE_STRIP.

You only have to provide radius, height, and number of segments to create the cylinder. Once the floating point buffer with the vertices is created we have to convert it to OpenGL digestible FloatBuffer and the pass the information to OpenGL for rendering … Done.

Decomplexify

The passing of the data to OpenGL is cookie-cutter OpenGL code which you can find easily. I do not want to complexify this sample here by cookie cutting.


    // Creating a cylinder object to be rendered in OpenGL
    Object3DData createCylinder ( float radius, float height, int segments, float yOffset, float clr[] ) {
        float buffer[]  = createCylinderBuffer ( radius, height, segments );
        FloatBuffer vertices = makeFloatBuffer ( buffer, buffer.length );

        Object3DData     obj = new Object3DData( vertices );
        obj.setDrawMode ( GLES20.GL_TRIANGLE_STRIP );
        obj.setColor    ( clr[0], clr[1], clr[2], clr[3] );
        obj.setPosition ( 0.0f, yOffset, 0.0f );
        return obj;
    }

    // GL_TRIANGLE_STRIP -=> Standing cylinder
    float[] createCylinderBuffer ( float radius, float height, int segments )  {
        int iBuffSize = segments * 3 * 3 + (int)( ((float)segments/3.0f+1.0f )) * 3 * 2 + 6;
        float buffer[] = new float[ iBuffSize ];
        int t, idx = 0;
        float increment = (float)( 360.0f / (float)( segments - 1 ) );

        //create the top
        int iZeroCounter = 2;
        float hh = height / 2.0f;
        for ( t=0; t<segments; t++ )  {
            float angle = (float)( Math.PI/180.0f * t * increment );
            float cos = (float) ( radius * Math.cos ( angle ) );
            float sin = (float) ( radius * Math.sin ( angle ) );

            if ( iZeroCounter++ >= 2 )  {
                buffer[idx++] = 0.0f;
                buffer[idx++] = +hh;
                buffer[idx++] = 0.0f;
                iZeroCounter  = 0;
            }
            buffer[idx++] = cos;
            buffer[idx++] = +hh;
            buffer[idx++] = sin;
        }

        // create the cylinder
        for ( t=0; t<segments+2; t++ )  {
            float angle = (float)( Math.PI/180.0f * t * increment );
            float cos = (float) ( radius * Math.cos ( angle ) );
            float sin = (float)-( radius * Math.sin ( angle ) );

            buffer[idx++] = cos;
            buffer[idx++] = hh;
            buffer[idx++] = sin;
            hh *= -1.0f;
        }

        hh = height / 2.0f;
        for ( t=0; t<segments; t++ )  {
            float angle = (float)( Math.PI/180.0f * t * increment );
            float cos = (float)-( radius * Math.cos ( angle ) );
            float sin = (float) ( radius * Math.sin ( angle ) );

            if ( iZeroCounter++ >= 2 )  {
                buffer[idx++] = 0.0f;
                buffer[idx++] = -hh;
                buffer[idx++] = 0.0f;
                iZeroCounter = 0;
            }
            buffer[idx++] = cos;
            buffer[idx++] = -hh;
            buffer[idx++] = sin;
        }
        return buffer;
    }

    public static FloatBuffer makeFloatBuffer ( float[] arr, int iSize )  {
        if ( iSize == 0 )
             iSize = arr.length;
        ByteBuffer bb = ByteBuffer.allocateDirect ( iSize * 4 ); // Size of Float is 4 bytes
        bb.order ( ByteOrder.nativeOrder( ) );
        FloatBuffer fb = bb.asFloatBuffer ( );
        fb.put ( arr );
        fb.position ( 0 );
        return fb;
    }

Promising results

Here is the result in all its glory after stacking a few cylinders on top of each other, coloring them and give the battery a heart beat. Yeah, I think you can’t enough Special effect this one.

Please feel free to install CPU Information onto your Android device and try it out in action.
Get it on Google Play

Android Oreo’s CPU stats

I have been using Android phones for a long time now and have never really considered switching to an iOS device. I think that ever since Android version 4.x ( 3.0 was terrible ) the hardware and software selection was better than those offered by Apple. From there on, Android waas getting better by the release it seemed … or was it ?

Google has however started to remove features from the OS over the past few years which is starting to limit the apps which can be written for these devices.

The storage API is one example which started to slowly diminish over time and is getting to the point where you can no longer access external storage in a concise and manageable way.

With Oreo, google has again removed some functionality which was very useful. This time Google made it impossible to monitor, and report on the CPUs utilization of its cores or the overall CPU utilization.

New motto ???

All of /proc/stat has been disabled for non-System apps, as a side-channel. More information, with an official response from Google here: https://issuetracker.google.com/issues/37140047

While there is an API available to retrieve similar information, it is only available for kiosk-like devices and not enabled in a stock mobile device. Starting from API level 24:

HardwarePropertiesManager propertiesManager = (HardwarePropertiesManager)context.getSystemService(Context.HARDWARE_PROPERTIES_SERVICE);
CpuUsageInfo[] cpuUsages = propertiesManager.getCpuUsages();

But only system apps have access to this API, because only system apps can have android.permission.DEVICE_POWER permission, which is needed here.

So the developer, and the users are left out in the dark on what’s zapping the Phones battery, and you will never know when the cores got to 100% proactively but only when your phone slows down.

Please let me know if you have Oreo ( and above ) and you know of an app which does display the CPU stats for you.

Shader Editor app

Android and iOS smart phones support the OpenGL ES 3D library.

The latest version for OpenGL Stand currently at 3.2 which was released in August 2015. Most phones on the market however support OpenGL 3.0 since Android 4.3 or iOS 7.

Those is versions we released in or around 2013 such by now was five years ago.

The OpenGL API had changed a lot between 1.x and 2.0 in that it introduced vertex and fragment shader languages as part of the spec. Prior to this, the OpenGL library stopped a set of will defined API calls to handle most aspects of the OpenGL Städte engine.

OpenGL shaders

As stated above, the shader language became past of the OpenGL Standard with version 2.0 and onwards. What it provides is more flexibility in programming the GPU tender pipelines. Instead of trying on a fixed, hardcore pipeline you can go ahead and code your own shader program.

This flexibility comes at the expense of some additional complexity alas this can greatly be migrated through the usage of or defined coffee snippets or libraries which sit Stop OpenGL.

The shader language is leaning heavily on c-style and is functional in nature. As the code is compiled, linked and will then be loaded into the GPU and run with a limited set of instructions, this language is limited in certain aspects and I would really recommend to find online courses or read a book if you want to truly understand the inner working of OpenGL.

 

OpenGL ES

The ES Stand for embedded systems, and is an indication that it has some limitations to the desktop version. Alright although those limitations are really not as big as one would think.

What is more is that WebGL is basically identical to OpenGL ES and many of the shaders you will find running in the browse will also run in your phone.

For example, the web page Http:www.shadertoy.com has a lot of very interesting looking shader samples which you can adapt easily to run on your phone.

But how ?

Shader editor

The shadertoy app can help you play around with some really cool looking shader examples. When you first download the app you will only see a limited set of available samples. Burger you can easily edit and save new shader samples on your device with this app.

The editor is using a just in time compilation of the code on a semi transparent editor window. This allows you to easily explore you shaders and view the results in real-time.

The way that this tool used the OpenGL libraries is to use a fixed vertex shader code base and have all the code executing in the fragment shader. Which is to say that the whole logic is about coloring the fragments ( parts of a pixel ) to achieve those stunning effects.

If you like to experiment and OpenGL is something you have always wanted to play around with, then Shader Editor is a small app you can not afford to miss.


Get it on Google Play

Get it on Google Play

D-Tube, video cryptonite

D-Tube is a distributed video platform based on Steem . Say what ???
Okay I can see the proverbial question marks popping off of your head. No worries, I am hear to help.

Lets  go through this one fancy term at a time.

Steem, Steemit, Steem-Dollars, Steem-Power


We all know Bitcoin or we have heard of it. That magical unicorn currency which created billionaires over night. And while a lot of what has happened in the past few months was mostly negative, such as the collapse of bitconnect, the underlying technology is sound and offers many new opportunities in the tech sector.

As bitcoin has eased off last years heights of over $19000,-US per bitcoin, it currently stands at around $3200,-US per bitcoin, the whole blockchain technology front is in search of providing value beyond the selling of dreams of digital currency backed by … well I leave that up to you to figure out …

Steem is a crypto currency which is in contrast to bitcoin is based off the. Here is a good rundown of what steem is. This article goes into steem vs steem-dollar vs steem-power.
Overall, steem solves a major problem in digital content creation. You can consider Steemit as similar to Reddit, where users can create and publish their content online and get rewarded for it. However, there is one major difference. it also rewards its users using cryptocurrency!

Oh and it is uncensored, decentralized and safe .. in theory.

D-Tube, the YouTube alternative

D-Tube was started by Adrian M  as an alternative to other digital content platforms such as YouTube. The whole concept is build around the steem cryptocurrency and as a creator you will be rewarded with Steem instead of US Dollars.

There is a lot to learn about Steem and D-Tube in the beginning but once you created your account with steemit you can go ahead and create contents and publish it on D-Tube without the fear that your video may be removed by a corporate working slave with a set agenda.

What’s more is that Steem will reward you for any kind of contents you create and publish on the Steemit platform. For example I am publishing this WordPress blog post on the Internet and also on Steemit to increase visibility, and potentially earn a few cents of Steem ( Dollars and Power ).

D-Tube app

​​ 
The D-Tube app can be used to view videos in a very similar fashion as you would watch YouTube videos. However the functionality at this point in time is not much further advanced as creating a shortcut to the d.tube mobile friendly web page on your home screen. Both solutions allow you to get very similar functionality as YouTube’s video client.

From a technological point of view I think that both YouTube, and D-Tube are neck-to-neck and you will have no issues finding your way around the app.


Video Quality

Now I am not talking about the resolution, bitrate etc here. What I mean with quality is the contents of the video provided on the platform.

While it is true that you can earn money on D-TUbe, the ability to do so heavily depends on the Whale’s on Steem. In reality what you will realize is that while there is no censorship on steemit, there is an indirect censorship driven by the people with the most money ( Steem-Power ).

If you make a video which one of those whale-people likes, you stand to earn a lot of money. On the other hand, if you like to create contents about knitting or Java, there will be very little you can earn.

But on the positive side, just like YouTube, you can create your audience over time and if you are truly good at what you do and you do provide real value to — the community –, then you can grow your income as well over time and eventually become one of those whales yourself.

App vs web-page-shortcut

Android App
Android App
If you are thinking about installing the app or simply creating a web-page-shortcut, then either one will do the trick at this time. I am confident that over time there will be more advantages in choosing the app.

For not my recommendation though has to be to go to your mobile browser, navigate to https://d.tube, then find your settings and “Add to Homescreen”.
Web Page Shortcut
Web Page Shortcut


Creator vs Consumer

The answer is Yes ( or 42, depending on your leaning ). You have to check this out and decide for yourself if you like it. I found myself fascinated with the whole concept and given the proper circumstances, I can see this platform grow by leaps and bounds over the coming years.

YouTube killer … not quite yet. But if YouTube continues to disregard the smaller contributors and build more negative sentiment I have no doubt that a platform like D-Tube will give the multi billion $ behemoth a run for its money ( and future ).

Overall app rating : 3 stars out of 5.
Overall technology rating : 5 stars out of 5.
Overall honesty rating : 5 stars out of 5

Get it on Google Play

Get your background going

Setting the background of your phone is something that most people do only once in a while. I have had periods where I used the same background image for years.

Lately however I grew tired of my static background and wanted to get something with more pep.

Welcome to 3D Parallax Background.

If you don’t know what parallax stand for, according to Wikipedia, it is :

Parallax (from Ancient Greek παράλλαξις (parallaxis), meaning ‘alternation’) is a displacement or difference in the apparent position of an object viewed along two different lines of sight,

In other words, your brain can utilize the parallax from the information from both of your eyes to detect depth.

Another obvious effect is that objects closer to your eyes will move more than objects farther away. Having a multi layered image, where the background layer moves less than the foreground layer will trick us into seeing depth where there is none.

3D Parallax Background is using this effect and does so with great results. Once you have the mechanics in place, the most important thing to do is to create some stunningly beautiful collages to use.

You can choose between more than 250 different background themes in a selection menu which in itself is animated so that you can easily see the 3D effect before you actually download the whole theme and install it as your background.

 

Themes range from nature to movies to space to abstract and anime, to name but a few. I really like this app and use it currently as my background with changing themes.

I love beaches and beer which is great because there is a ready made background for me, as well as the cars and space and … well you get the drift.

The usability is also well thought through and you have many options available in the settings to tune the background to your liking. Actually the only thing I found missing was an editor to build your own theme and utilize it or publish it for every one else to use.

Overall, this app rocks, and I would recommend you take a closer look at it if you are in the market for a new background.

If you want to check it out, then hush over to the play store and install it from here

Get it on Google Play

Device Info the Iron Man way

Your Android phone is an incredible piece of technology. It has the ability to not only make phone calls but you can also take pictures and videos, play 3D accelerated games, find your location using the GPS satellite system, you have a gyroscope, compass, accelerator and much much more.

All of this hardware comes in nearly unlimited variations put together into a singular, unique device. The Samsung S5 and a Pixel XL smartphones for example both have the same types of hardware available but have vastly different hardware chips for those tasks.

If you want to know your phone, you have to know your phones innards and software versions. There are plenty of device info apps on the app store. However there is one app in particular which makes it fun and exciting to look up all of these pieces of information.

CPU Information

This app has a Virtual Reality inspired interface to view your device information. The interface can be adjust the color scheme and a few other details which makes this a great app to go together with your devices protective cover.

The dashboard graphics are stunningly beautiful and playful. Aside from the center control which acts as a menu you can also see the polar clock on the top left corner. The sound effects are very well done and play seamlessly with the animation.

CPU Information is under active development and new widgets will come on a constant basis. If you install it today you will be able to see the progress over time and take full advantage of all new widgets and features before you have to pay for them.

So to sum it all up, if there is one app you want to use to view your devices information, it is this app. CPU Information offers all the information plus one of the most unique interfaces on the app-store.

Intro Video

You can take a quick peek at the application in action in this short demo video below. But please note that the app may hav added new features by the time you view this video.



Get it on the Play store now.

Get it on Google Play

CPU Information

I have spent the past few weeks improving major parts of this app and I am finally at the point of releasing the new and shiny interface.

My ultimate goal for this app is to pull in all of the views into 3D and outshine other similar apps in beauty and create the best app for the job ( as usual ). This is a new beginning for the app and I will likely spend the next few months improving it.

HUD

I love iron Man like HUD interfaces. As such I am building a library with multiple interfaces for different visualization purposes. The interface above is a switch-board with a connected gyroscope and the Earth centered in it.

After the initial release I want to create a terminal emulation which I can scale at will in 3D space, followed by an audio interface which coverts input from the microphone into a nice 3D visual.

There are many more possibilities and I am having fun creating these playful widgets.

Shader

Another area which I want to invest some time in is to work with some custom shaders to bring out some glowing special effects and other goodies.

OpenGL ES 2.0 is a strange beast and not necessarily the easiest environment to learn but it offers some great flexibility in what you can accomplish. The ES, which stands for Embedded Systems, introduces a few changes as compared to the desktop OpenGL implementation.

OpenGL ES 2.0 Programming guide
OpenGL ES 2.0 Programming guide

I am currently going through the “OpenGL ES 2.0 programming guide”, which is a real good book to learn OpenGL. It will help me to realize the remaining widgets and animations to convert the complete app into the 3D realm.

Please give it a try and let me know what you think of it. Also I would love to hear if you have any ideas for a widget which I could implement.

Get it on Google Play

Android Storage Wars

If you have ever tried your hand on coding for Android you certainly have found google’s JAVA based API to be somewhat of a incoherent mess in certain areas, which over time has evolved into an even larger incoherent mess in even more areas.

One of those messy areas is that of the android secondary storage API. All phones have a primary storage area, where you can store images, videos, apps, and application data, and some phones come with a secondary storage option. The API to gain access to the primary storage has evolved over time but allows you to seamlessly integrate proper functionality into your app.


Now you may assume that the Android secondary storage would follow the same paradigm, and grant the same access as the primary storage to your app. However you would be wrong making this assumption. The reason you have apps like the “ES File Manager” handling this for you seamlessly is purely through tricky code in the background which circumvent googles protective scheme for secondary storage, Aka a hack.

Dont do evil … yeah right!


Yes, google in its drive to push people into using their cloud storage is actively pressuring phone makers to get rid of that large secondary storage, or worse the micro-SD slot. That overarching goal of google is driving the API and the access rights to the Androids secondary storage media in a negative way.

Let’s start with a small bit of terminology. Since the dawn of Android, nearly every type of storage has been considered “external storage” even the non-removable flash memory that comes in every device. To distinguish, the non-removable flash memory is called “primary storage”<, while a removable micro SD card is called “secondary storage”. In the early Android versions, an app merely needed permission to WRITE_EXTERNAL_STORAGE to be able to fully access both primary and secondary storage.

In March, 2011, a drastic change to Android was made which changed how secondary storage mediums (external SD cards) were mounted by the Android OS. Specifically, the commit read like this: “Mount secondary external storage writable by AID_MEDIA_RW rather than AID_SDCARD_RW.” This meant that the media would now have to belong to the “media_rw” group to modify the contents of the SD card. As a result, a new permission, called WRITE_MEDIA_STORAGE, was added to the source code. Basically, WRITE_MEDIA_STORAGE replaced the original WRITE_EXTERNAL_STORAGE.

This change has a devastating effect on apps trying to utilize secondary storage because from now on forward only system apps could request the permission to read/write to the external storage ( I.e. sdcard ).

Android secondary storage

Since the WRITE_EXTERNAL_STORAGE permission could be used by any normal app and thus any app can write to the primary storage but not to the secondary storage (external micro SD cards). The WRITE_MEDIA_STORAGE permission could write to the external micro SD card, but regular user apps could not request the permission. This change took place on Android 3.2 Honeycomb, but due to the logistics of hardware and storage mediums at that time, it was barely noticed.

Quote: “Starting around the time of Android 4.4 4 KitKat, and even a little earlier, the implementation of the userspace FUSE filesystem, in conjunction with changes to the open source code, resolved this problem. Yet, still to today, even with Android 8.x.x Oreo, third party apps must explicitly get the user’s permission for both primary and secondary storage before the app can alter either storage medium in any way. And of course, the newer concepts of adoptable storage have alleviated problems in this regard.” — end quote.

Bottom line

Thanks to google the way that most apps now handle android secondary storage heavily depends on the Android version being used. Unfortunately at this time most phones will have a hard time working with the secondary storage, but some phones do. I have updated the file browser integration into my apps and have fixed the issue of secondary storage on some Android versions and not on others.

This whole debacle has not only cost me weeks of effort and research, it has negatively affected all apps with file system access and is the main reason that almost all apps only storing their data on the primary storage, which in most cases is much smaller than the external storage. At this tmie you can get a cheap microSD card with up to 512 GB. However what good is this in your phone if most apps can only use the built-in 16GB ?