Android Workspace Widget

Cochlear Implant Students Dissertation

Research Papers Writing Help

Write My Essay Site

Help With Business Plan

Personal Statement Writing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class WorkspaceAdapter extends ArrayAdapter<applicationinfo> {

   int screenId;
   PackageManager pm;
   private LayoutInflater mInflater;
   private int nCellsPerScreen = 4;

   public WorkspaceAdapter( Context context, int textViewResourceId, List</applicationinfo><applicationinfo> objects ) {
      super( context, textViewResourceId, objects );
      screenId = textViewResourceId;
      pm = context.getPackageManager();
      nCellsPerScreen = context.getResources().getInteger( R.integer.config_portraitCells ) * context.getResources().getInteger( R.integer.config_portraitRows );
      mInflater = (LayoutInflater) context.getSystemService( LAYOUT_INFLATER_SERVICE );
   }

   @Override
   public int getCount() {
      return (int) Math.ceil( (double) super.getCount() / nCellsPerScreen );
   }

   public int getRealCount() {
      return super.getCount();
   }

   @Override
   public View getView( int position, View convertView, ViewGroup parent ) {

      if ( convertView == null ) {
         convertView = mInflater.inflate( screenId, mWorkspace, false );
         ((CellLayout)convertView).setNumCols( nCellsPerScreen );
      }

      CellLayout cell = (CellLayout) convertView;

      int index = position * nCellsPerScreen;
      int realCount = getRealCount();

      for ( int i = 0; i < nCellsPerScreen; i++ ) {
         CellInfo cellInfo = cell.findVacantCell( 1, 1 );
         TextView text;

         if ( cellInfo == null ) {
            text = (TextView) cell.getChildAt( i );
         } else {
            text = (TextView) mInflater.inflate( R.layout.application_boxed, cell, false );
            CellLayout.LayoutParams lp = new CellLayout.LayoutParams( cellInfo.cellX, cellInfo.cellY, cellInfo.spanH,
                  cellInfo.spanV );
            cell.addView( text, i, lp );
         }

         if ( index + i < realCount ) {
            ApplicationInfo appInfo = getItem( index + i );
            CharSequence label = appInfo.loadLabel( pm );
            Drawable bm = appInfo.loadIcon( pm );

            text.setCompoundDrawablesWithIntrinsicBounds( null, bm, null, null ); // new
            text.setText( label );
            text.setClickable( true );
            text.setFocusable( true );
            text.setVisibility( View.VISIBLE );
         } else {
            text.setVisibility( View.INVISIBLE );
         }
      }
      return convertView;
   }
}

Compile skia for android on Mac Lion

Research Paper Essay Well, even if skia is part of the android system and it’s used everywhere by android itself, trying to include skia in my project was quite an hell..
Looking for resources I just found old examples and tips, and every try was just a failure.. but since android uses skia internally to do graphics operations I decided to look into the android project.

Comparing Fractions Homework Help

Build Android: http://source.android.com/source/initializing.html

To get rid of clearsilver errors: http://code.google.com/p/android/issues/detail?id=993#c27

Java 1.5 version complaining: http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard

Well, the first time you’ll try to “ make” everything probably you’ll get this error:

1
./external/elfutils/config-compat-darwin.h:42: error: static declaration of ‘strnlen’ follows non-static declaration

Ap Lit Poetry Essay Help modify ./external/elfutils/config-compat-darwin.h.
replace:

1
2
3
4
5
6
7
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}

with:

1
2
3
4
5
6
7
8
9
#if 0
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}
#endif

Well, at the end of the process I just edited the Android.mk makefile into external/skia adding a new entry for BUILD_STATIC_LIBRARY and the next command was simply:

1
mmm external/skia

which produced the required libskia.a file to be linked in my project.

QuickActionView in Android

While I was searching for an custom implementation of the QuickContactBadge for Android, I went into this interesting post ( http://energyexcell.com/?buy-to-let-business-plan-uk Buy To Let Business Plan Uk Lorenz’s Blog ), which had a custom widget called QuickAction.
While it’s a very nice widget, it didn’t fit my needs because I had the necessity of create different action layouts ( horizontal, vertical, grid.. ), so I made a very quick modification to the above code and I ended with this implementation.
Basically I removed from the original Class the ActionItem list and set a Best Website To Buy A Research Paper BaseAdapter as content source. In this way it’s more simple and easy to add more and different views to the widget.
Moreover I added the support for columns ( both fixed and automatic ).
Here you can see a snippet code of the http://ducasco.gr/online-essay-writer/ Online Essay Writer QuickActionView creation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public void onButtonClick( View v ) {
   
   // create the quick action view, passing the view anchor
   QuickActionView qa = QuickActionView.Builder( v );
   
   // set the adapter
   qa.setAdapter( new CustomAdapter( this ) );
     
   // set the number of columns ( setting -1 for auto )
   qa.setNumColumns( (int) (2 + (Math.random() * 10)) );
   qa.setOnClickListener( new DialogInterface.OnClickListener() {

      @Override
      public void onClick( DialogInterface dialog, int which ) {
         dialog.dismiss();
         Toast.makeText( getBaseContext(), "Selected item: " + which, Toast.LENGTH_SHORT ).show();
      }
   } );
     
   // finally show the view
   qa.show();
}

Here some Screenshots:

And here you can find the source code:  Doctor Of Musical Arts Thesis Help source code

ImageView Zoom and Scroll

http://www.jokservice.eu/?i-need-essay-help I Need Essay Help Update: the source code has moved to github, so it’s easier for anyone to fork it!

As long as Android doesn’t have a built-in ImageView widget with zoom and scroll capabilities I tries to create one by myself starting from the google repository.

The result is pretty nice so I’m posting here the source code, if anyone is interested, or simply doesn’t want to waste the time creating a new one.

Here’s a sample code on how to use it in an Activity:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package it.sephiroth.android.demo;

import it.sephiroth.android.library.imagezoom.ImageViewTouch;

import java.io.IOException;

import android.app.Activity;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Images;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

public class ImageZoomActivity extends Activity {
   
   private ImageViewTouch  mImageView;
   
   @Override
   protected void onCreate( Bundle savedInstanceState )
   {
      super.onCreate( savedInstanceState );
     
      requestWindowFeature( Window.FEATURE_NO_TITLE );
      setContentView( R.layout.main );
      getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN );
      selectRandomImage();
   }
   
   @Override
   public void onContentChanged()
   {
      super.onContentChanged();
      mImageView = (ImageViewTouch)findViewById( R.id.imageView1 );
   }
   
   /**
    * pick a random image from your library
    * and display it
    */

   public void selectRandomImage()
   {
      Cursor c = getContentResolver().query( Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null );
      if ( c != null ) {
         int count = c.getCount();
         int position = (int)( Math.random() * count );
         if ( c.moveToPosition( position ) ) {
            long id = c.getLong( c.getColumnIndex( Images.Media._ID ) );
            int orientation = c.getInt( c.getColumnIndex( Images.Media.ORIENTATION ) );
           
            Uri imageUri = Uri.parse( Images.Media.EXTERNAL_CONTENT_URI + "/" + id );
            Bitmap bitmap;
            try {
               bitmap = ImageLoader.loadFromUri( this, imageUri.toString(), 1024, 1024 );
               mImageView.setImageBitmapReset( bitmap, orientation, true );
            }
            catch ( IOException e ) {
               Toast.makeText( this, e.toString(), Toast.LENGTH_LONG ).show();
            }
         }
         c.close();
         c = null;
         return;
      }
   } 
}

 

 

Anyway, if you want to download the source, here is the eclipse source project:
http://blog.sephiroth.it/wp-…/ImageZoom.zip
https://github.com/sephiroth74/ImageViewZoom

Widget: SlidingDrawer top to bottom

My android experiments continue…
In the last project I had to implement a SlidingDrawer which comes from top and left. The problem was that the default widget does not support all the directions, but only bottom to top and right to left.

That’s why I grabbed the SlidingDrawer source code and modified it in order to allow any direction ( defined as styleable in attrs.xml ). The only problem using custom styleable xml is that if you want to use this widget as library you need to include in the main project also the attrs.xml file as well.. a bit frustrating.

Anyway this is just the sample xml how to include the widget:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
   <view class="it.sephiroth.demo.slider.widget.MultiDirectionSlidingDrawer"
     xmlns:my="http://schemas.android.com/apk/res/it.sephiroth.demo.slider"
     android:id="@+id/drawer"
     my:direction="topToBottom"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     my:handle="@+id/handle"
     my:content="@+id/content">
      <include android:id="@id/content"
        layout="@layout/pen_content" />
      <imageview android:id="@id/handle"
        android:layout_width="wrap_content"
        android:layout_height="40px"
        android:src="@drawable/sliding_drawer_handle_bottom" />
   </view>
</relativelayout>

Btw If you’re interest, here you can find the full source code of the widget including a running application:

SlidingDrawer Demo 

* Updated the code thanks to Maciej Ciemięga.

Android experiments

As you probably understood during last days I’m completely absorbed in Android development.
While experimenting new things ( it remembers to me the first days with Flash 🙂 ) I did a couple of applications and I’ve published them to the market ( it takes less than one hour to be published on the market, just some weeks less than on the app store ).

First one is a simple note application, very similar to the iPhone note app. This one was for testing the ContentProvider and the built-in android search feature.
Second one is for view, search, plan routes for the Milan subway. This is a mix of features: google maps api, layar intergration, gps locations..

How-to debug native code with Android

This is a step by step guide for executing and debugging native code on Android with Eclipse.

1. Prerequisites

The SDK version used for this guide is Froyo with the NDK r4b ( crystax release ).
Also Eclipse CDT plugin it’s very useful for our purposes, so install it.
Last plugin to install it’s the Sequoyah plugin for Eclipse.

2. Project setup

At this point let’s create a new Android project, name it “Example” and use the “com.darkwavegames.com” package name, add also an Activity name of your choice.
Select Android 2.2 as base SDK version and complete the project wizard.

Now you need to add the native support for the newly created project. Just right click on the project root element in the package explorer and select “add native support”.

In the next dialog write the path of your NDK folder and give also name for your library.
After this operation a new folder “jni” will be created with a .cpp file, header filer and an Android makefile, Android.mk, which can be edited to modify all the includes, linker and compiler options. In the Android.mk file you also need to specify all the source file you want to use within the LOCAL_SRC_FILE directive.

3. Debug

In order to enable debug of native code in Android you have to face different problems, based also on the device and the firmware version, and if the native code is multi thread or single thread.
First of all you need to mofify the AndroidManifest.xml file adding the attribute “debuggable” to true ( remember also to enable the “Debug USB” option under the Application device menu ).
At this point you can debug all the java code within your eclipse debugger, for for the native C debug you need more steps.

Continue reading

Playing with a LocalActivityManager bug

If you already used the ActivityGroup class you probably used also the LocalActivityManager instance to manage your group’s activities. I was creating my activity which should also manages its internal history ( using a ViewFlipper for animating the activity views ).
The problem came out once I tried to destroy an activity from the history using the LocalActivityManager destroy method. After an activity was removed from both my internal history and from the local activity manager I was unable to create a new instance of the same activity.

After googling for my problem I found that it was because a bug in the LocalActivityManager class: http://code.google.com/p/android/issues/detail?id=12359
This is exactly my problem! In fact, debugging the android code ( see this post for debugging android code ) at that point it was clear that the record it’s not removed from the internal http://asbsteel.com/?medical-personal-statement-editing-services Medical Personal Statement Editing Services mActivities map.

Fortunately there are Reflections which can help me! I added this piece of code after the call to the destroy method:

1
2
3
Field mActivitiesField = getLocalActivityManager().getClass().getDeclaredField( "mActivities" );
mActivitiesField.setAccessible( true );
((Map) mActivitiesField.get( getLocalActivityManager() )).remove( id );

and that trick does the job