May
07
2012
0

Latest CyanogenMod 9 Nightlies Now Include Theme Engine Support – AOKP Gets In On The Action As Well

This image has no alt text

  

If you’re currently running a rooted device that happens to be blessed with CyanogenMod 9 support, you’ll be glad to know that the world famous custom ROM now includes theme engine support in their latest “nightlies.”

Just like we saw back in CM7 (their previous Gingerbread custom ROM), users can once again take their customizing to new heights with the option to change everything from the color and icons of their favorite ROM. Very unlike CM7 however, is the Theme Chooser app has been kicked to the curb in favor of the new “Themes” option, accessed straight from within the settings app.

Also added in the latest CM9 nightlies are custom lockscreen shortcuts (picture above) that can be tweaked to launch your favorite and most used apps. Oh — and if you’re an AOKP fan, one of the devs from that project let everyone know via his Twitter today that this new themeing engine will also be making its way into their ROMs as well.

I always felt ICS could use a little more pink in it. Definitely excited to give this a go. Here’s a quick video showing off this fresh new feature in action.

[CM9 Nightlies | Google+ | Via Droid-Life]


Written by admin in: android, android news |
May
03
2012
0

Three UK starting Galaxy S3 presales tomorrow

Three UK is already set to offer presales for the Samsung Galaxy S3 soon. They’ve announced that presale opportunities will begin tomorrow. The tariff for this one is £34 per month and that will get you the phone and all the data you want.

As an added bonus, anyone who preorders the device between now and May 30th, the device’s launch date, will be entered for a chance to win 1 of 26 Samsung Smart TVs. The exact models and size are not known. Either way, it’s not a bad incentive to claim the phone ahead of time. Read on for full details.

Samsung Galaxy SIII - available to pre-order on Three from 4th May.

Samsung’s much anticipated smartphone, the Samsung Galaxy SIII, will be available to pre-order on Three from 4th May.

The Galaxy SIII will be available on The One Plan with all-you-can-eat data at £34 per month and with no upfront cost.

In addition, everyone that pre-orders the Samsung Galaxy SIII with Three before the 30th May will be automatically entered into a daily draw to win one of 26 brand new Samsung Smart TVs.

Nigel Field, director of devices at Three, said, “We can’t wait to bring Samsung’s amazing Galaxy SIII to Three, and we’re very proud to be one of their UK launch partners. With our high speed, award-winning network and market-leading all-you-can-eat data, we believe we can deliver the ultimate mobile internet experience to our customers with this phone.

“The Galaxy SII was one of the smartphones of 2011, and we’re expecting its successor, the Samsung Galaxy SIII, to be amongst 2012’s biggest mobile success stories.”

Customers can pre-order a Samsung Galaxy SIII by calling 0800 358 1799 from 9am tomorrow, or by visiting their local 3Store. They can register for updates and information about the Samsung Galaxy SIII at http://three.co.uk/SamsungGalaxy.

Pricing:
Samsung Galaxy SIII on The One Plan
£34 per month
No upfront cost

All-you-can-eat data
2000 any network minutes
5000 Three-to-Three minutes
5000 texts
Tethering included


Written by admin in: android, android news |
May
02
2012
0

Map the touch position with a mask

In previous exercise, I show how to:
- Detect touched position on a ImageView
- Get color on a specified location from ImageView’s background bitmap
- Display text on a specified location in a custom View

In this step, I want to convert the touch position to a meaningful description, such as Head, Body, Heart, Hand and Foot. As show in the video here.

I make(copy) the Android Bitmap as the image source of the custom ImageView, TouchView. And re-paint the image with specified color for various part. Both images have the same size, and same pattern. Copy them in /res/drawable/ folder.

When I get the touch position from onTouchEvent() method in TouchView, I get the pixel color from the mask image, instead of get from the original image. So I can detect the touched part by comparing the mask pixel color with various specified color.

In order to compare the Android image and the mask image, I have to make both in same proportion. So I re-assign main.xml to use Anadroid:src instead of android:background. And I use fixed layout size for the FrameLayout.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
 <FrameLayout
        android:layout_width="384px"
        android:layout_height="384px"
     >

     <com.exercise.AndroidDetechTouch.TouchView
         android:id="@+id/myandroid"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:src="@drawable/android"
         />
     <com.exercise.AndroidDetechTouch.InfoView
         android:id="@+id/infoview"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         />

 </FrameLayout>
</LinearLayout>

The custom ImageView, TouchView.java

package com.exercise.AndroidDetechTouch;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;

public class TouchView extends ImageView {

 Bitmap bitmap, mask;
 double bmWidth, bmHeight; 

 String touchInfo;
 float touchX, touchY;

 String part;

 public TouchView(Context context) {
  super(context);
  // TODO Auto-generated constructor stub
  init();
 }

 public TouchView(Context context, AttributeSet attrs) {
  super(context, attrs);
  // TODO Auto-generated constructor stub
  init();
 }

 public TouchView(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  // TODO Auto-generated constructor stub
  init();
 }

 private void init(){

  bitmap = ((BitmapDrawable)getDrawable()).getBitmap();
  mask = BitmapFactory.decodeResource(getResources(), R.drawable.android_mask);
  bmWidth = (double)bitmap.getWidth();
  bmHeight = (double)bitmap.getHeight();
 }

 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  // TODO Auto-generated method stub
  setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),
       MeasureSpec.getSize(heightMeasureSpec));
 }

 @Override
 public boolean onTouchEvent(MotionEvent event) {
  // TODO Auto-generated method stub

  switch(event.getAction()){
  case MotionEvent.ACTION_DOWN:
  case MotionEvent.ACTION_MOVE:
   touchX = event.getX();
   touchY = event.getY();

   long maskColor = getColor(touchX, touchY);

   //Match the color in Mask bitmap
   if(maskColor == Color.RED){
    touchInfo = "Heart";
   }else if(maskColor == Color.GREEN){
    touchInfo = "Head";
   }else if(maskColor == Color.BLUE){
    touchInfo = "Body";
   }else if(maskColor == -256){
    touchInfo = "Hand";
   }else if(maskColor == -16711681){
    touchInfo = "Foot";
   }else{
    touchInfo = "";
   }

   ((AndroidDetechTouchActivity)getContext()).updateMsg(touchInfo, touchX, touchY, (int)maskColor);
   return true;

  default:
   return false;
  }

 }

 private long getColor(float x, float y){

  if ( x < 0 || y < 0 || x > (float)getWidth() || y > (float)getHeight()){
   return 0; //Invalid, return 0
  }else{
   //Convert touched x, y on View to on Bitmap
   int xBm = (int)(x * (bmWidth / (double)getWidth()));
      int yBm = (int)(y * (bmHeight / (double)getHeight()));

   return mask.getPixel(xBm, yBm);
  }
 }

}

InfoView.java, the wording will be display here.

package com.exercise.AndroidDetechTouch;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class InfoView extends View {

 String info = "";
 float x = 0; //init value
 float y = 0; //init value
 int color = Color.BLACK;

 public InfoView(Context context) {
  super(context);
  // TODO Auto-generated constructor stub
 }

 public InfoView(Context context, AttributeSet attrs) {
  super(context, attrs);
  // TODO Auto-generated constructor stub
 }

 public InfoView(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  // TODO Auto-generated constructor stub
 }

 @Override
 protected void onDraw(Canvas canvas) {
  // TODO Auto-generated method stub
  super.onDraw(canvas);

  Paint paint = new Paint();
  paint.setStyle(Paint.Style.FILL_AND_STROKE);
  paint.setColor(color);
  paint.setStrokeWidth(2);
  paint.setTextSize(30);

  canvas.drawLine(x-10, y, x+10, y, paint);
  canvas.drawLine(x, y-10, x, y+10, paint);
  canvas.drawText(info, x, y, paint);

 }

 public void updateInfo(String t_info, float t_x, float t_y, int t_c){
  info = t_info;
  x = t_x;
  y = t_y;
  color = t_c;
  invalidate();
 }

 public void clearInfo(){
  info = "";
  x = 0;
  y = 0;
  invalidate();
 }

}

main activity, AndroidDetechTouchActivity.java

package com.exercise.AndroidDetechTouch;

import android.app.Activity;
import android.os.Bundle;

public class AndroidDetechTouchActivity extends Activity {

 TouchView myAndroid;
 InfoView infoView;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        myAndroid = (TouchView)findViewById(R.id.myandroid);
        infoView = (InfoView)findViewById(R.id.infoview);

    }

    public void updateMsg(String t_info, float t_x, float t_y, int t_c){

     infoView.updateInfo(t_info, t_x, t_y, t_c);

    }

    public void clearMsg(){

     infoView.clearInfo();

    }

}

Download the files.


Written by admin in: android, sample code |

AndGPS | Connect Android Phone To GPS Solutions