Showing posts with label 5. Show all posts
Showing posts with label 5. Show all posts

Thursday, February 12, 2015

Improvements Expected in Google Nexus 6 after Reviewing Nexus 5

Improvements Expected in Google Nexus 6 after Reviewing Nexus 5

Nexus 5 is the flagship phone of Google that was released this October and created a quite a buzz in the tech world with its irresistibly advanced specifications. However, since the inception of civilization the Darwinian philosophy of ‘survival of the fittest’ has ruled the thoughts of the human beings and it continues to do so even today. Human beings always want to improvise and modify everything surrounding them so that they can lead a better life. This basic human drive has also led the tech geeks to consider the improvisation that they expect to see in Nexus 6 within a month of the release of Nexus 5.

Also Read: iPhone 6 (Rumors) Vs Nexus 5
Also Read: 4 Best Tips to Clean Your Touch Screen Device

Advanced processor with greater RAM support, bigger storage capacity, enhanced screen resolution and better camera are some of the standard facets which are improved with the launch of the next generation phones. However, there are also some other very basic aspects on which the developers must pay attention to. Here are some of those basic aspects where we expect improvements when Google Nexus 6 will be released.

Battery
The batteries of smartphones drain out rapidly, especially if the users are avid apps users. So just in case we miss charging our phone for a day, we are going to face the music the next day. This is true for all smartphones, and though some improvements have been made in this genre but we are yet to see a smartphone with 3 – 4 days of battery backup. Therefore, Nexus 6 can give a feat to all other smartphones by developing a battery that suits with the diverse use of the phone.

Water-resistant 
Approximately half or at least one fourth of the smartphone users have lost their beloved phones due to liquid damage. Google Nexus 6 can come up with a technology whereby its next flagship gadget will be 100% resistant to water and thereby providing the potential customers with more than enough reasons to invest on this smartphone. 

Also Read: The Top 10 Best iPhone Apps of 2013
Also Read: How You Can Keep Your Android Phone Safe From Hackers?

Dust- resistant 
Since the smartphones are very fragile, inclusion of technology that resist dust from damaging the smartphone is also a necessity. It will safeguard the phone from climatic damages like moisture and dust.

Solar Charging Unit 
The developers can provide Google Nexus 6 with a battery that can be charged using solar energy along with the mainstream method charging it. This will be a great backup option in case of urgent need.

These are some of the areas where we expect some improvisations when the next flagship phone of Google will be launched in the upcoming year.


About Author:
Abhilash Thakur, A tech buff with a passion for writing. Although loves to write on Nexus 6 and devices run on Android, doesnt miss relevant news on other industry players.

Image Source: http://forum.xda-developers.com/google-nexus-5
Read more »

Sunday, February 1, 2015

Creating EasyKeyboard class Part 5

Today well add the ability to add hold event listeners using key names, and the ability to remove all listeners at once.

Go to EasyKeyboard.as code and add a new function called addEasyHoldListener(), add 2 parameters to it - keyName and handler.

Loop through all keyLabels like we do in addEasyListener() and check if the specified key name matches any of those elements. If so, remember the id of the key name in the array (this will be the key code). If no matches were found, throw an error. Call addHoldListener() with the calculated keyCode and the user-specified handler values.

/**
* Add hold listener for a single key using key string value.
* @paramkeyName String name of the key.
* @paramhandler Function to execute while the key is held every frame.
*/

public function addEasyHoldListener(keyName:String, handler:Function):void {
var code:int = -1;
for (var i:int = 0; i < keyLabels.length; i++) {
if (keyLabels[i] == keyName) {
code = i;
break;
}
}
if (code == -1) {
throw new Error(Incorrect key string value specified - no " + keyName + " key found.);
return;
}
addHoldListener(code, handler);
}

And now its possible to easily add key holding listeners using key names, for example:

keyboard = new EasyKeyboard(stage);
keyboard.addEasyHoldListener("A", function() { trace("A is being held!"); } );

A time might come when the developer would want to remove all the listeners. Lets create a separate function for that, call it kill(). Simply remove the 3 event listeners in it:

/**
* Call this before nullifying the class instance to remove all the listeners.
*/

public function kill():void {
st.removeEventListener(KeyboardEvent.KEY_DOWN, kDown);
st.removeEventListener(KeyboardEvent.KEY_UP, kUp);
st.addEventListener(Event.ENTER_FRAME, frame);
}

Full EasyKeyboard.as code:

package com.kircode.EasyKeyboard 
{
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;

/**
* Utility for easy keyboard listener management.
* @author Kirill Poletaev
*/
public class EasyKeyboard
{
public var listeners:Array = [];
private var keyLabels:Array = ["0","1","2","3","4","5","6","7","Backspace","Tab","10","11","Center","Enter","14","15","Shift","Control","Alt","Pause","Caps Lock","21","22","23","24","25","26","27","28","29","30","31","Space","Page Up","Page Down","End","Home","Left","Up","Right","Down","41","42","43","44","Insert","Delete","47","0","1","2","3","4","5","6","7","8","9","58","59","60","61","62","63","64","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","Windows","Windows","Menu","94","95","Num 0","Num 1","Num 2","Num 3","Num 4","Num 5","Num 6","Num 7","Num 8","Num 9","Num *","Num +","108","Num -","Num .","Num /","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","124","125","126","127","128","129","130","131","132","133","134","135","136","137","138","139","140","141","142","143","Num Lock","Scroll Lock","146","147","148","149","150","151","152","153","154","155","156","157","158","159","160","161","162","163","164","165","166","167","168","169","170","171","172","173","174","175","176","177","178","179","180","181","182","183","184","185",";","+",",","-",".","/","~","193","194","195","196","197","198","199","200","201","202","203","204","205","206","207","208","209","210","211","212","213","214","215","216","217","218","[","\","]","","223","224","225","226","227","228","229","230","231","232","233","234","235","236","237","238","239","240","241","242","243","244","245","246","247","248","249","250","251","252","253","254","255"];
private var st:Stage;

public function EasyKeyboard(stage:Stage)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, kDown);
stage.addEventListener(KeyboardEvent.KEY_UP, kUp);
stage.addEventListener(Event.ENTER_FRAME, frame);
st = stage;
}

private function frame(evt:Event):void {
for (var i:int = 0; i < listeners.length; i++) {
if (listeners[i] is HoldListener && listeners[i].flag) {
listeners[i].handler.call();
}
}
}

/**
* Call this before nullifying the class instance to remove all the listeners.
*/

public function kill():void {
st.removeEventListener(KeyboardEvent.KEY_DOWN, kDown);
st.removeEventListener(KeyboardEvent.KEY_UP, kUp);
st.addEventListener(Event.ENTER_FRAME, frame);
}

/**
* Add event listener for a single key using a keycode.
* @paramkeyCode Key code of the key.
* @paramhandlerDown Function to be called when the key is pressed down.
* @paramhandlerUp Function to be called when the key is released.
* @paramalt Used in combination with the alt key.
* @paramctrl Used in combination with the ctrl key.
* @paramshift Used in combination with the shift key.
*/

public function addListener(keyCode:int, handlerDown:Function = null, handlerUp:Function = null, alt:Boolean = false, ctrl:Boolean = false, shift:Boolean = false):void {
listeners.push(new KeyListener(keyCode, handlerDown, handlerUp, alt, ctrl, shift));
}

/**
* Add event listener for a single key using a keycode.
* @paramkeyCode Key code of the key.
* @paramhandler Function to execute while the key is held every frame.
*/

public function addHoldListener(keyCode:int, handler:Function):void {
listeners.push(new HoldListener(keyCode, handler, false));
}

/**
* Add event listener for a single key using key string value.
* @paramkeyName String name of the key.
* @paramhandlerDown Function to be called when the key is pressed down.
* @paramhandlerUp Function to be called when the key is released.
* @paramalt Used in combination with the alt key.
* @paramctrl Used in combination with the ctrl key.
* @paramshift Used in combination with the shift key.
*/

public function addEasyListener(keyName:String, handlerDown:Function = null, handlerUp:Function = null, alt:Boolean = false, ctrl:Boolean = false, shift:Boolean = false):void {
var code:int = -1;
for (var i:int = 0; i < keyLabels.length; i++) {
if (keyLabels[i] == keyName) {
code = i;
break;
}
}
if (code == -1) {
throw new Error(Incorrect key string value specified - no " + keyName + " key found.);
return;
}
addListener(code, handlerDown, handlerUp, alt, ctrl, shift);
}

/**
* Add hold listener for a single key using key string value.
* @paramkeyName String name of the key.
* @paramhandler Function to execute while the key is held every frame.
*/

public function addEasyHoldListener(keyName:String, handler:Function):void {
var code:int = -1;
for (var i:int = 0; i < keyLabels.length; i++) {
if (keyLabels[i] == keyName) {
code = i;
break;
}
}
if (code == -1) {
throw new Error(Incorrect key string value specified - no " + keyName + " key found.);
return;
}
addHoldListener(code, handler);
}

private function kDown(evt:KeyboardEvent):void {
for (var i:int = 0; i < listeners.length; i++) {
if (evt.keyCode == listeners[i].keyCode && listeners[i] is KeyListener && evt.altKey == listeners[i].alt && evt.ctrlKey == listeners[i].ctrl && evt.shiftKey == listeners[i].shift) {
if (listeners[i].handlerD) listeners[i].handlerD.call();
}
if (evt.keyCode == listeners[i].keyCode && listeners[i] is HoldListener) {
listeners[i].flag = true;
}
}
}

private function kUp(evt:KeyboardEvent):void {
for (var i:int = 0; i < listeners.length; i++) {
if (evt.keyCode == listeners[i].keyCode && listeners[i] is KeyListener && evt.altKey == listeners[i].alt && evt.ctrlKey == listeners[i].ctrl && evt.shiftKey == listeners[i].shift) {
if (listeners[i].handlerU) listeners[i].handlerU.call();
}
if (evt.keyCode == listeners[i].keyCode && listeners[i] is HoldListener) {
listeners[i].flag = false;
}
}
}

}

}

Thanks for reading!
Read more »