[android-developers] Re: Creating a private jar

2009-04-02 Thread Cyril Mottier

Yeah it's kinda boring to use that method :(. I developped my widgets
in order to create them easily in an XML layout. Using the way you
gave me (which, I think, is not that bad when you're just using
images), the user won't be able to create it through an XML layout.
Moreover, my classes use the attrs.xml file to retrieve XML
parameters.

As you said Mark, I'm, like you, also looking for another way around
this!

On Apr 2, 6:02 pm, "Mark Murphy"  wrote:
> > Looking at the Android source code, I noticed that android.jar
> > contains its own ressources so I assume this is possible.
>
> Yeah, but that's special.
>
> There is no way for JARs written to support SDK-level applications to
> embed resources that I have found.
>
> Instead, you need to package your resources separately (e.g., a ZIP file)
> and distribute them for reusers of your JAR to unpack in their APK
> project's res/ tree (or to replace with their own editions of the
> resources, as they see fit). Then, adjust your API to accept resource IDs
> as parameters (like you see for many of the APIs), so your code no longer
> has R.id or R.drawable references itself -- those refererences would be in
> the calling application, who has the resources and the corresponding
> R.java file.
>
> If there's another way around this, I'm certainly interested to hear about
> it...
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Is ProgressBar correctly handling padding-values?

2009-03-05 Thread Cyril Mottier

I prefer you being terse and giving understandable answers than no one
answering me :p. Thanks ;)

On 4 mar, 18:09, Romain Guy  wrote:
> onkeydown: make sure your view is focusable and focused.
>
> Padding: known bug, fixed in cupcake.
>
> Sorry for being terse, sent from my phone :)
>
> On Mar 4, 2009 9:05 AM, "Cyril M"  wrote:
>
> Here is a skeleton of the class I'm currently working on.
> Unfortunatly, i'm stuck on two problems and it's driving me mad !
>
> The first problem is about the onKeyDown(KeyEvent) : I don't
> understand why this method isn't called while I pressed a key on the
> emulator.
> The second problem deals with padding. Indeed, I'm always creating
> widget using fake paddings in order to be sure my widget correctly
> handle those values. Unfortunatly, I tried to extend a ProgressBar and
> I had some problems because my ProgressBar is clipped.
>
> My code is :
>
> package com.niji.android.myhouse;
>
> import android.content.Context;
> import android.graphics.Canvas;
> import android.graphics.Color;
> import android.graphics.Paint;
> import android.graphics.drawable.Drawable;
> import android.util.AttributeSet;
> import android.util.Log;
> import android.view.KeyEvent;
> import android.view.MotionEvent;
> import android.widget.ProgressBar;
>
> public class ProgressWheel extends ProgressBar {
>
>        private static final String TAG_LOG = "ProgressWheel";
>        private static final Paint mPaint = new Paint();
>
>        private float oldX;
>
>        public ProgressWheel(Context context, AttributeSet attrs) {
>                this(context, attrs, 0);
>        }
>
>        public ProgressWheel(Context context, AttributeSet attrs, int
> defStyle) {
>                super(context, attrs, defStyle);
>
>                mPaint.setStrokeWidth(1.0f);
>                mPaint.setColor(Color.MAGENTA);
>                mPaint.setStyle(Paint.Style.STROKE);
>
>                setPadding(5, 15, 40, 10)
>
>        }
>
>       �...@override
>        protected synchronized void onDraw(Canvas canvas) {
>                /*
>                 * I'm not sure the onDraw(Canvas) method from ProgressBar is
> correctly
>                 * implemented. Indeed. With padding values, The progressBar
> may be
> "clipped"
>                 */
>                super.onDraw(canvas);
>                canvas.drawRect(0, 0, getWidth()-1, getHeight()-1, mPaint);
>        }
>
>   �...@override
>    public boolean onKeyDown(int keyCode, KeyEvent event) {
>                /*
>                 * I don't understand why this method is not called
>                 */
>        int progress = getProgress();
>        Log.d(TAG_LOG, "onKeyDown");
>        switch (keyCode) {
>            case KeyEvent.KEYCODE_DPAD_LEFT:
>                Log.d(TAG_LOG, "KEYCODE_DPAD_LEFT");
>                if (progress <= 0) break;
>                setProgress(progress - 1);
>                return true;
>
>            case KeyEvent.KEYCODE_DPAD_RIGHT:
>                Log.d(TAG_LOG, "KEYCODE_DPAD_RIGHT");
>                if (progress >= getMax()) break;
>                setProgress(progress + 1);
>                return true;
>        }
>
>        return super.onKeyDown(keyCode, event);
>    }
>
>       �...@override
>        public boolean onTouchEvent(MotionEvent event) {
>                Log.d(TAG_LOG, "onTouchEvent");
>                int progress = getProgress();
>
>                switch (event.getAction()) {
>                case MotionEvent.ACTION_DOWN:
>                        oldX = event.getX();
>                        break;
>                case MotionEvent.ACTION_MOVE:
>                        if (event.getX() > oldX) {
>                                setProgress(progress + 1);
>                        }
>                        else setProgress(progress - 1);
>                        oldX = event.getX();
>                        break;
>
>                default:
>                        break;
>                }
>
>                return true;
>        }
>
> }
>
> and here is my XML layout :
>
> 
>
>         android:id="@+id/RelativeLayout01"
>        android:layout_width="wrap_content"
>        android:layout_height="wrap_content"
>        xmlns:android="http://schemas.android.com/apk/res/android"; >
>
>                    style="?android:attr/progressBarStyleHorizontal"
>                android:layout_centerInParent="true"
>                android:layout_margin="10px"
>                android:layout_width="fill_parent"
>                android:layout_height="wrap_content"
>                android:progress="35" />
>
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en