diff --git a/YetAnotherDrawableDemo/AndroidManifest.xml b/YetAnotherDrawableDemo/AndroidManifest.xml
index 1a3b909..639a58a 100644
--- a/YetAnotherDrawableDemo/AndroidManifest.xml
+++ b/YetAnotherDrawableDemo/AndroidManifest.xml
@@ -13,6 +13,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/default.properties b/YetAnotherDrawableDemo/default.properties
index 66db0d1..db9665c 100644
--- a/YetAnotherDrawableDemo/default.properties
+++ b/YetAnotherDrawableDemo/default.properties
@@ -9,3 +9,5 @@
# Project target.
target=android-10
+android.library.reference.1=..\\YetAnotherDrawableDemoLib
+android.library.reference.2=../YetAnotherDrawableDemoApp
diff --git a/YetAnotherDrawableDemo/res/drawable/line_drawable.xml b/YetAnotherDrawableDemo/res/drawable/line_drawable.xml
new file mode 100644
index 0000000..6ec2358
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/drawable/line_drawable.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/drawable/oval_drawable.xml b/YetAnotherDrawableDemo/res/drawable/oval_drawable.xml
index cf9574c..df66b23 100644
--- a/YetAnotherDrawableDemo/res/drawable/oval_drawable.xml
+++ b/YetAnotherDrawableDemo/res/drawable/oval_drawable.xml
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/YetAnotherDrawableDemo/res/drawable/rectangle_drawable.xml b/YetAnotherDrawableDemo/res/drawable/rectangle_drawable.xml
new file mode 100644
index 0000000..6ffdde1
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/drawable/rectangle_drawable.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/drawable/ring_drawable.xml b/YetAnotherDrawableDemo/res/drawable/ring_drawable.xml
new file mode 100644
index 0000000..7da06cb
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/drawable/ring_drawable.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/cameratransform_drawable_config.xml b/YetAnotherDrawableDemo/res/layout/cameratransform_drawable_config.xml
new file mode 100644
index 0000000..6f52856
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/cameratransform_drawable_config.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/cameratransform_rotatex_config.xml b/YetAnotherDrawableDemo/res/layout/cameratransform_rotatex_config.xml
new file mode 100644
index 0000000..0628da0
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/cameratransform_rotatex_config.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/cameratransform_rotatey_config.xml b/YetAnotherDrawableDemo/res/layout/cameratransform_rotatey_config.xml
new file mode 100644
index 0000000..c272ba4
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/cameratransform_rotatey_config.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/res/layout/cameratransform_rotatez_config.xml b/YetAnotherDrawableDemo/res/layout/cameratransform_rotatez_config.xml
new file mode 100644
index 0000000..5548fac
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/cameratransform_rotatez_config.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/res/layout/cameratransform_translate_config.xml b/YetAnotherDrawableDemo/res/layout/cameratransform_translate_config.xml
new file mode 100644
index 0000000..907a8b5
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/cameratransform_translate_config.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/code_drawable_config.xml b/YetAnotherDrawableDemo/res/layout/code_drawable_config.xml
new file mode 100644
index 0000000..28ed981
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/code_drawable_config.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/drawablerect_as_background.xml b/YetAnotherDrawableDemo/res/layout/drawablerect_as_background.xml
new file mode 100644
index 0000000..00e2993
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/drawablerect_as_background.xml
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/matrixtransform_drawable_config.xml b/YetAnotherDrawableDemo/res/layout/matrixtransform_drawable_config.xml
new file mode 100644
index 0000000..557d2bb
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/matrixtransform_drawable_config.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/matrixtransform_rotate_config.xml b/YetAnotherDrawableDemo/res/layout/matrixtransform_rotate_config.xml
new file mode 100644
index 0000000..d88dca8
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/matrixtransform_rotate_config.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/matrixtransform_scale_config.xml b/YetAnotherDrawableDemo/res/layout/matrixtransform_scale_config.xml
new file mode 100644
index 0000000..2afa375
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/matrixtransform_scale_config.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/matrixtransform_skew_config.xml b/YetAnotherDrawableDemo/res/layout/matrixtransform_skew_config.xml
new file mode 100644
index 0000000..af74762
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/matrixtransform_skew_config.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/matrixtransform_translate_config.xml b/YetAnotherDrawableDemo/res/layout/matrixtransform_translate_config.xml
new file mode 100644
index 0000000..f40d036
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/matrixtransform_translate_config.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/layout/xml_drawable_config.xml b/YetAnotherDrawableDemo/res/layout/xml_drawable_config.xml
new file mode 100644
index 0000000..4feaa15
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/layout/xml_drawable_config.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YetAnotherDrawableDemo/res/menu/view_config.xml b/YetAnotherDrawableDemo/res/menu/view_config.xml
new file mode 100644
index 0000000..ddde038
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/menu/view_config.xml
@@ -0,0 +1,6 @@
+
+
diff --git a/YetAnotherDrawableDemo/res/values/arrays.xml b/YetAnotherDrawableDemo/res/values/arrays.xml
new file mode 100644
index 0000000..63adf4e
--- /dev/null
+++ b/YetAnotherDrawableDemo/res/values/arrays.xml
@@ -0,0 +1,21 @@
+
+
+
+ - Drawable in code
+ - Drawable in XML
+ - Matrix Transformations
+ - Camera Transformations
+
+
+ - Rotate
+ - Scale
+ - Skew
+ - Translate
+
+
+ - Translate
+ - Rotate X
+ - Rotate Y
+ - Rotate Z
+
+
diff --git a/YetAnotherDrawableDemo/res/values/strings.xml b/YetAnotherDrawableDemo/res/values/strings.xml
index a5f2448..6171602 100644
--- a/YetAnotherDrawableDemo/res/values/strings.xml
+++ b/YetAnotherDrawableDemo/res/values/strings.xml
@@ -2,4 +2,5 @@
Hello World, YetAnotherDrawableDemoActivity!
YetAnotherDrawableDemo
+ Configure
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateXConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateXConfigActivity.java
new file mode 100644
index 0000000..8e5dde4
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateXConfigActivity.java
@@ -0,0 +1,49 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class CameraTransformationRotateXConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_ROTATEX = "ROTATEX";
+ public static final String ROTATEX_ANGLE = "ROTATEX_ANGLE";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.cameratransform_rotatex_config);
+
+ mTextAngle = (EditText)findViewById(R.id.editAngleX);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(ROTATEX_ANGLE)) {
+ mTextAngle.setText(Float.toString(data.getFloat(ROTATEX_ANGLE)));
+ }
+
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableCameraTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_ROTATEX);
+ b.putFloat(ROTATEX_ANGLE, Float.parseFloat(mTextAngle.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextAngle;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateYConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateYConfigActivity.java
new file mode 100644
index 0000000..92d1ee6
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateYConfigActivity.java
@@ -0,0 +1,49 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class CameraTransformationRotateYConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_ROTATEY = "ROTATEY";
+ public static final String ROTATEY_ANGLE = "ROTATEY_ANGLE";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.cameratransform_rotatey_config);
+
+ mTextAngle = (EditText)findViewById(R.id.editAngleY);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(ROTATEY_ANGLE)) {
+ mTextAngle.setText(Float.toString(data.getFloat(ROTATEY_ANGLE)));
+ }
+
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableCameraTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_ROTATEY);
+ b.putFloat(ROTATEY_ANGLE, Float.parseFloat(mTextAngle.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextAngle;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateZConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateZConfigActivity.java
new file mode 100644
index 0000000..150ef2c
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationRotateZConfigActivity.java
@@ -0,0 +1,49 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class CameraTransformationRotateZConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_ROTATEZ = "ROTATEZ";
+ public static final String ROTATEZ_ANGLE = "ROTATEZ_ANGLE";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.cameratransform_rotatez_config);
+
+ mTextAngle = (EditText)findViewById(R.id.editAngleZ);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(ROTATEZ_ANGLE)) {
+ mTextAngle.setText(Float.toString(data.getFloat(ROTATEZ_ANGLE)));
+ }
+
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableCameraTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_ROTATEZ);
+ b.putFloat(ROTATEZ_ANGLE, Float.parseFloat(mTextAngle.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextAngle;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationTranslateConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationTranslateConfigActivity.java
new file mode 100644
index 0000000..34aa439
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationTranslateConfigActivity.java
@@ -0,0 +1,64 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class CameraTransformationTranslateConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_TRANSLATE = "TRANSLATE";
+ public static final String TRANSLATE_DX = "TRANSLATE_DX";
+ public static final String TRANSLATE_DY = "TRANSLATE_DY";
+ public static final String TRANSLATE_DZ = "TRANSLATE_DZ";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.cameratransform_translate_config);
+
+ mTextDX = (EditText)findViewById(R.id.editCamDX);
+ mTextDY = (EditText)findViewById(R.id.editCamDY);
+ mTextDZ = (EditText)findViewById(R.id.editCamDZ);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(TRANSLATE_DX)) {
+ mTextDX.setText(Float.toString(data.getFloat(TRANSLATE_DX)));
+ }
+
+ if(data.containsKey(TRANSLATE_DY)) {
+ mTextDY.setText(Float.toString(data.getFloat(TRANSLATE_DY)));
+ }
+
+ if(data.containsKey(TRANSLATE_DZ)) {
+ mTextDZ.setText(Float.toString(data.getFloat(TRANSLATE_DZ)));
+ }
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableCameraTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_TRANSLATE);
+ b.putFloat(TRANSLATE_DX, Float.parseFloat(mTextDX.getText().toString()));
+ b.putFloat(TRANSLATE_DY, Float.parseFloat(mTextDY.getText().toString()));
+ b.putFloat(TRANSLATE_DZ, Float.parseFloat(mTextDZ.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextDX;
+ private EditText mTextDY;
+ private EditText mTextDZ;
+
+}
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationTypeSelectorActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationTypeSelectorActivity.java
new file mode 100644
index 0000000..b2d40a4
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CameraTransformationTypeSelectorActivity.java
@@ -0,0 +1,89 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.app.ListActivity;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+public class CameraTransformationTypeSelectorActivity extends ListActivity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Resources res = getResources();
+ String[] names = res.getStringArray(R.array.camera_transformations_available);
+ this.setListAdapter(new ArrayAdapter(this,
+ android.R.layout.simple_list_item_1, names));
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ super.onListItemClick(l, v, position, id);
+
+ Intent myIntent = null;
+ if(position == 0)
+ {
+ myIntent = new Intent(CameraTransformationTypeSelectorActivity.this, CameraTransformationTranslateConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putFloat(CameraTransformationTranslateConfigActivity.TRANSLATE_DX, defaultDX);
+ bundle.putFloat(CameraTransformationTranslateConfigActivity.TRANSLATE_DY, defaultDY);
+ bundle.putFloat(CameraTransformationTranslateConfigActivity.TRANSLATE_DZ, defaultDZ);
+ myIntent.putExtras(bundle);
+ }
+ if(position == 1)
+ {
+ myIntent = new Intent(CameraTransformationTypeSelectorActivity.this, CameraTransformationRotateXConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putFloat(CameraTransformationRotateXConfigActivity.ROTATEX_ANGLE, defaultRotationXAngle);
+ myIntent.putExtras(bundle);
+ }
+ if(position == 2)
+ {
+ myIntent = new Intent(CameraTransformationTypeSelectorActivity.this, CameraTransformationRotateYConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putFloat(CameraTransformationRotateYConfigActivity.ROTATEY_ANGLE, defaultRotationYAngle);
+ myIntent.putExtras(bundle);
+ }
+ if(position == 3)
+ {
+ myIntent = new Intent(CameraTransformationTypeSelectorActivity.this, CameraTransformationRotateZConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putFloat(CameraTransformationRotateZConfigActivity.ROTATEZ_ANGLE, defaultRotationZAngle);
+ myIntent.putExtras(bundle);
+ }
+
+ config = null;
+ startActivityForResult(myIntent, 0);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ config = intent.getExtras();
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ result.putExtras(config);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ Bundle config;
+
+
+ float defaultRotationXAngle = 0;
+ float defaultRotationYAngle = 0;
+ float defaultRotationZAngle = 0;
+
+ float defaultDX = 0;
+ float defaultDY = 0;
+ float defaultDZ = 0;
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableActivity.java
index 7c0d788..636ec13 100644
--- a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableActivity.java
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableActivity.java
@@ -1,5 +1,63 @@
package com.hfk.yadd;
-public class CustomDrawableActivity {
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+public class CustomDrawableActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ vw = new CustomDrawableView(this);
+
+ setContentView(vw);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.view_config, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int menuItem = item.getItemId();
+ switch (menuItem) {
+ case R.id.mnu_genericconfig:
+ Intent myIntent = new Intent(CustomDrawableActivity.this, CustomDrawableConfigActivity.class);
+
+ Bundle b = new Bundle();
+ b.putBoolean(CustomDrawableConfigActivity.DRAW_RECTANGLE, vw.getDrawRectangle());
+ b.putBoolean(CustomDrawableConfigActivity.DRAW_OVAL, vw.getDrawOval());
+ b.putBoolean(CustomDrawableConfigActivity.DRAW_ARC, vw.getDrawArc());
+ b.putBoolean(CustomDrawableConfigActivity.SET_BOUNDS, vw.getSetBounds());
+
+ myIntent.putExtras(b);
+
+ startActivityForResult(myIntent, 0);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ Bundle config = intent.getExtras();
+
+ vw.setDrawRectangle(config.getBoolean(CustomDrawableConfigActivity.DRAW_RECTANGLE));
+ vw.setDrawOval(config.getBoolean(CustomDrawableConfigActivity.DRAW_OVAL));
+ vw.setDrawArc(config.getBoolean(CustomDrawableConfigActivity.DRAW_ARC));
+ vw.setSetBounds(config.getBoolean(CustomDrawableConfigActivity.SET_BOUNDS));
+
+ }
+
+ private CustomDrawableView vw;
}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationActivity.java
new file mode 100644
index 0000000..7bcce71
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationActivity.java
@@ -0,0 +1,53 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+public class CustomDrawableCameraTransformationActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ vw = new CustomDrawableCameraTransformationView(this);
+
+ setContentView(vw);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.view_config, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int menuItem = item.getItemId();
+ switch (menuItem) {
+ case R.id.mnu_genericconfig:
+ Intent myIntent = new Intent(CustomDrawableCameraTransformationActivity.this, CustomDrawableCameraTransformationConfigActivity.class);
+
+ startActivityForResult(myIntent, 0);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ Bundle config = intent.getExtras();
+
+ vw.setTransformationPipeline(config);
+
+
+ }
+
+ private CustomDrawableCameraTransformationView vw;
+}
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationConfigActivity.java
new file mode 100644
index 0000000..78dd48d
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationConfigActivity.java
@@ -0,0 +1,82 @@
+package com.hfk.yadd;
+
+import java.util.ArrayList;
+
+import android.app.Activity;
+import android.app.ListActivity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+
+public class CustomDrawableCameraTransformationConfigActivity extends ListActivity {
+
+ public static final String TRANSFORMATIONORDER_TYPE = "TRANSFORMATIONORDER_TYPE";
+ public static final String TRANSFORMATION_TYPE = "TRANSFORMATION_TYPE";
+
+ public static final String TRANSLATETOCENTER = "TRANSLATETOCENTER";
+ public static final String OVALOUTTRANSFORM = "OVAKOUTTRANSFORM";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.cameratransform_drawable_config);
+
+ adapter=new ArrayAdapter(this,
+ android.R.layout.simple_list_item_1,
+ listItems);
+ setListAdapter(adapter);
+
+ checkBoxTranslateToCenter = (CheckBox)findViewById(R.id.checkBoxCamTranslateToCenter);
+ checkBoxOvalOutTransform = (CheckBox)findViewById(R.id.checkBoxCamOvalOutTransform);
+
+ b = new Bundle();
+
+ }
+
+ public void addItems(View v) {
+
+ Intent myIntent = new Intent(CustomDrawableCameraTransformationConfigActivity.this, CameraTransformationTypeSelectorActivity.class);
+
+ startActivityForResult(myIntent, 0);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ Bundle config = intent.getExtras();
+
+ listItems.add(Integer.toString(sequence) + " " + config.getString(TRANSFORMATION_TYPE));
+ adapter.notifyDataSetChanged();
+
+ b.putParcelable("MTX_" + Integer.toString(sequence), config);
+ b.putBoolean(TRANSLATETOCENTER, checkBoxTranslateToCenter.isChecked());
+ b.putBoolean(OVALOUTTRANSFORM, checkBoxOvalOutTransform.isChecked());
+
+ sequence++;
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+
+ Bundle b = null;
+ ArrayList listItems=new ArrayList();
+ ArrayAdapter adapter;
+
+ CheckBox checkBoxTranslateToCenter;
+ CheckBox checkBoxOvalOutTransform;
+
+ int sequence = 0;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationView.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationView.java
new file mode 100644
index 0000000..8311f00
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableCameraTransformationView.java
@@ -0,0 +1,122 @@
+package com.hfk.yadd;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Camera;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.shapes.OvalShape;
+import android.graphics.drawable.shapes.RectShape;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+public class CustomDrawableCameraTransformationView extends View {
+
+ public CustomDrawableCameraTransformationView(Context context) {
+ super(context);
+
+ rectangleDrawable = new ShapeDrawable(new RectShape());
+ ovalDrawable = new ShapeDrawable(new OvalShape());
+
+ rectangleDrawable.getPaint().setColor(0xff74AC23);
+ ovalDrawable.getPaint().setColor(0xff74AC23);
+
+ pipeline = new Bundle();
+ }
+
+ protected void onDraw(Canvas canvas) {
+ //final Matrix currentMatrix = canvas.getMatrix();
+
+ int rectX = this.getWidth()/2 - (width/2);
+ int rectY = this.getHeight()/2 - (height/2);
+ rectangleDrawable.setBounds(rectX, rectY, rectX + width, rectY + height);
+
+ int ovalX = rectX - width;
+ int ovalY = rectY - height;
+ ovalDrawable.setBounds(ovalX, ovalY, ovalX + width, ovalY + height);
+
+ Matrix matrix;
+ matrix = new Matrix();
+
+ Camera camera;
+ camera = new Camera();
+
+ if(pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER) && pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER))
+ //camera.translate(-1 * this.getWidth() / 2, -1 * this.getHeight() / 2, 0);
+ matrix.postTranslate(-1 * this.getWidth() / 2, -1 * this.getHeight() / 2);
+
+ int sequence = 0;
+ while(pipeline.containsKey("MTX_" + Integer.toString(sequence)))
+ {
+ Bundle currTransform = (Bundle)pipeline.getParcelable("MTX_" + Integer.toString(sequence));
+ String transformationType = currTransform.getString(CustomDrawableCameraTransformationConfigActivity.TRANSFORMATION_TYPE);
+ if(transformationType.equals(CameraTransformationRotateXConfigActivity.TRANSFORMATION_ROTATEX))
+ {
+ float rotationX = currTransform.getFloat(CameraTransformationRotateXConfigActivity.ROTATEX_ANGLE);
+ camera.rotateX(rotationX);
+ }
+
+ if(transformationType.equals(CameraTransformationRotateYConfigActivity.TRANSFORMATION_ROTATEY))
+ {
+ float rotationY = currTransform.getFloat(CameraTransformationRotateYConfigActivity.ROTATEY_ANGLE);
+ camera.rotateY(rotationY);
+ }
+
+ if(transformationType.equals(CameraTransformationRotateZConfigActivity.TRANSFORMATION_ROTATEZ))
+ {
+ float rotationZ = currTransform.getFloat(CameraTransformationRotateZConfigActivity.ROTATEZ_ANGLE);
+ camera.rotateZ(rotationZ);
+ }
+
+ if(transformationType.equals(MatrixTransformationTranslateConfigActivity.TRANSFORMATION_TRANSLATE))
+ {
+ float dx = currTransform.getFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DX);
+ float dy = currTransform.getFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DY);
+ float dz = currTransform.getFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DY);
+ camera.translate(dx, dy, dz);
+ }
+
+ sequence++;
+ }
+
+ Matrix cameraMatrix = new Matrix();
+ camera.getMatrix(cameraMatrix);
+ matrix.postConcat(cameraMatrix);
+
+ if(pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER) && pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER))
+ //camera.translate(this.getWidth() / 2, this.getHeight() / 2, 0);
+ matrix.postTranslate(this.getWidth() / 2, this.getHeight() / 2);
+
+ final Matrix currentMatrix = canvas.getMatrix();
+
+ //camera.applyToCanvas(canvas);
+ canvas.concat(matrix);
+ if(pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM) && !pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM))
+ ovalDrawable.draw(canvas);
+ rectangleDrawable.draw(canvas);
+
+ canvas.setMatrix(currentMatrix);
+ if(!pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM) || pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM))
+ ovalDrawable.draw(canvas);
+
+ }
+
+ public void setTransformationPipeline(Bundle pipeline)
+ {
+ this.pipeline = pipeline;
+ }
+
+ private ShapeDrawable rectangleDrawable = null;
+ private ShapeDrawable ovalDrawable = null;
+
+ //int x = 100;
+ //int y = 100;
+ int width = 50;
+ int height = 50;
+
+ Bundle pipeline;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableConfigActivity.java
new file mode 100644
index 0000000..aa42dac
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableConfigActivity.java
@@ -0,0 +1,68 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.CheckBox;
+
+public class CustomDrawableConfigActivity extends Activity {
+
+ public static final String DRAW_RECTANGLE = "DRAW_RECTANGLE";
+ public static final String DRAW_OVAL = "DRAW_OVAL";
+ public static final String DRAW_ARC = "DRAW_RING";
+ public static final String SET_BOUNDS = "SET_BOUNDS";
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.code_drawable_config);
+
+ m_chkDrawRectangle = (CheckBox)findViewById(R.id.checkBoxInCodeDrawRectangle);
+ m_chkDrawArc = (CheckBox)findViewById(R.id.checkBoxInCodeDrawArc);
+ m_chkDrawOval = (CheckBox)findViewById(R.id.checkBoxInCodeDrawOval);
+ m_chkSetBounds = (CheckBox)findViewById(R.id.checkBoxInCodeSetBounds);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(CustomDrawableConfigActivity.DRAW_RECTANGLE)) {
+ m_chkDrawRectangle.setChecked(data.getBoolean(CustomDrawableConfigActivity.DRAW_RECTANGLE));
+ }
+ if(data.containsKey(CustomDrawableConfigActivity.DRAW_OVAL)) {
+ m_chkDrawOval.setChecked(data.getBoolean(CustomDrawableConfigActivity.DRAW_OVAL));
+ }
+ if(data.containsKey(CustomDrawableConfigActivity.DRAW_ARC)) {
+ m_chkDrawArc.setChecked(data.getBoolean(CustomDrawableConfigActivity.DRAW_ARC));
+ }
+ if(data.containsKey(CustomDrawableConfigActivity.SET_BOUNDS)) {
+ m_chkSetBounds.setChecked(data.getBoolean(CustomDrawableConfigActivity.SET_BOUNDS));
+ }
+ }
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putBoolean(CustomDrawableConfigActivity.DRAW_RECTANGLE, m_chkDrawRectangle.isChecked());
+ b.putBoolean(CustomDrawableConfigActivity.DRAW_OVAL, m_chkDrawOval.isChecked());
+ b.putBoolean(CustomDrawableConfigActivity.DRAW_ARC, m_chkDrawArc.isChecked());
+ b.putBoolean(CustomDrawableConfigActivity.SET_BOUNDS, m_chkSetBounds.isChecked());
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private CheckBox m_chkDrawRectangle;
+ private CheckBox m_chkDrawOval;
+ private CheckBox m_chkDrawArc;
+ private CheckBox m_chkSetBounds;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLActivity.java
new file mode 100644
index 0000000..a1266d7
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLActivity.java
@@ -0,0 +1,69 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+public class CustomDrawableFromXMLActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ vw = new CustomDrawableFromXMLView(this);
+
+ setContentView(vw);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.view_config, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int menuItem = item.getItemId();
+ switch (menuItem) {
+ case R.id.mnu_genericconfig:
+ Intent myIntent = new Intent(CustomDrawableFromXMLActivity.this, CustomDrawableFromXMLConfigActivity.class);
+
+ Bundle b = new Bundle();
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_LINE, vw.getDrawLine());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_OVAL, vw.getDrawOval());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RECTANGLE, vw.getDrawRectangle());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RING, vw.getDrawRing());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.SET_BOUNDS, vw.getSetBounds());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.AS_SHAPEDRAWABLE, vw.getAsShapeDrawable());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.AS_GRADIENTDRAWABLE, vw.getAsGradientDrawable());
+
+ myIntent.putExtras(b);
+
+ startActivityForResult(myIntent, 0);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ Bundle config = intent.getExtras();
+
+ vw.setDrawLine(config.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_LINE));
+ vw.setDrawOval(config.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_OVAL));
+ vw.setDrawRectangle(config.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RECTANGLE));
+ vw.setDrawRing(config.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RING));
+ vw.setSetBounds(config.getBoolean(CustomDrawableFromXMLConfigActivity.SET_BOUNDS));
+ vw.setAsShapeDrawable(config.getBoolean(CustomDrawableFromXMLConfigActivity.AS_SHAPEDRAWABLE));
+ vw.setAsGradientDrawable(config.getBoolean(CustomDrawableFromXMLConfigActivity.AS_GRADIENTDRAWABLE));
+
+ }
+
+ private CustomDrawableFromXMLView vw;
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLConfigActivity.java
new file mode 100644
index 0000000..f1b7e5f
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLConfigActivity.java
@@ -0,0 +1,88 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.CheckBox;
+
+public class CustomDrawableFromXMLConfigActivity extends Activity {
+
+ public static final String DRAW_RECTANGLE = "DRAW_RECTANGLE";
+ public static final String DRAW_LINE = "DRAW_LINE";
+ public static final String DRAW_OVAL = "DRAW_OVAL";
+ public static final String DRAW_RING = "DRAW_RING";
+ public static final String SET_BOUNDS = "SET_BOUNDS";
+ public static final String AS_SHAPEDRAWABLE = "AS_SHAPEDRAWABLE";
+ public static final String AS_GRADIENTDRAWABLE = "AS_GRADIENTDRAWABLE";
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.xml_drawable_config);
+
+ m_chkDrawRectangle = (CheckBox)findViewById(R.id.checkBoxInXMLDrawRectangle);
+ m_chkDrawLine = (CheckBox)findViewById(R.id.checkBoxInXMLDrawLine);
+ m_chkDrawOval = (CheckBox)findViewById(R.id.checkBoxInXMLDrawOval);
+ m_chkDrawRing = (CheckBox)findViewById(R.id.checkBoxInXMLDrawRing);
+ m_chkSetBounds = (CheckBox)findViewById(R.id.checkBoxInXMLSetBounds);
+ m_chkAsShapeDrawable = (CheckBox)findViewById(R.id.checkBoxInXMLAsShapeDrawable);
+ m_chkAsGradientDrawable = (CheckBox)findViewById(R.id.checkBoxInXMLAsGradientDrawable);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.DRAW_RECTANGLE)) {
+ m_chkDrawRectangle.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RECTANGLE));
+ }
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.DRAW_LINE)) {
+ m_chkDrawLine.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_LINE));
+ }
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.DRAW_OVAL)) {
+ m_chkDrawOval.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_OVAL));
+ }
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.DRAW_RING)) {
+ m_chkDrawRing.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RING));
+ }
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.SET_BOUNDS)) {
+ m_chkSetBounds.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.SET_BOUNDS));
+ }
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.AS_SHAPEDRAWABLE)) {
+ m_chkAsShapeDrawable.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.AS_SHAPEDRAWABLE));
+ }
+ if(data.containsKey(CustomDrawableFromXMLConfigActivity.AS_GRADIENTDRAWABLE)) {
+ m_chkAsGradientDrawable.setChecked(data.getBoolean(CustomDrawableFromXMLConfigActivity.AS_GRADIENTDRAWABLE));
+ }
+ }
+
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RECTANGLE, m_chkDrawRectangle.isChecked());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_LINE, m_chkDrawLine.isChecked());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_OVAL, m_chkDrawOval.isChecked());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.DRAW_RING, m_chkDrawRing.isChecked());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.SET_BOUNDS, m_chkSetBounds.isChecked());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.AS_SHAPEDRAWABLE, m_chkAsShapeDrawable.isChecked());
+ b.putBoolean(CustomDrawableFromXMLConfigActivity.AS_GRADIENTDRAWABLE, m_chkAsGradientDrawable.isChecked());
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private CheckBox m_chkDrawRectangle;
+ private CheckBox m_chkDrawLine;
+ private CheckBox m_chkDrawOval;
+ private CheckBox m_chkDrawRing;
+ private CheckBox m_chkSetBounds;
+ private CheckBox m_chkAsShapeDrawable;
+ private CheckBox m_chkAsGradientDrawable;
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLView.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLView.java
index 0142ca1..f50d91f 100644
--- a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLView.java
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableFromXMLView.java
@@ -1,97 +1,145 @@
package com.hfk.yadd;
import android.content.Context;
+import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.util.Log;
import android.view.View;
public class CustomDrawableFromXMLView extends View {
- private Drawable mDrawable1;
- private Drawable mDrawable2;
-
+
public CustomDrawableFromXMLView(Context context) {
super(context);
Resources res = context.getResources();
try {
- mDrawable1 = (Drawable) res.getDrawable(R.drawable.oval_drawable);
- mDrawable2 = (Drawable) res.getDrawable(R.drawable.oval_drawable);
+ rectangleDrawable = (Drawable) res.getDrawable(R.drawable.rectangle_drawable);
+ ovalDrawable = (Drawable) res.getDrawable(R.drawable.oval_drawable);
+ lineDrawable = (Drawable) res.getDrawable(R.drawable.line_drawable);
+ ringDrawable = (Drawable) res.getDrawable(R.drawable.ring_drawable);
} catch (Exception ex) {
Log.e("Error", "Exception loading drawable: " + ex.getMessage());
}
-
-// try {
-// mDrawable = (ShapeDrawable) Drawable.createFromXml(res, res.getXml(R.drawable.oval_drawable));
-// } catch (Exception ex) {
-// Log.e("Error", "Exception loading drawable: " + ex.getMessage());
-// }
-
-
-
- //mDrawable = new ShapeDrawable(new OvalShape());
- //mDrawable.getPaint().setColor(0xff74AC23);
- mDrawable1.setBounds(x, y, x + width, y + height);
- mDrawable2.setBounds(x, y, x + width, y + height);
+
}
protected void onDraw(Canvas canvas) {
- Camera camera = new Camera();
-// camera.setLocation (10, 10, 0);
-
-// camera.translate(10, 10, -200);
- //camera.rotateX(60);
- //camera.rotateY(60);
- //camera.rotateZ(60);
-
- //camera.applyToCanvas(canvas);
-
- Matrix matrix;
- matrix = new Matrix();
-
- // (ref1)
- //matrix.postTranslate(-1 * (x+width/2), -1 * (y+height/2));
-
- //camera.getMatrix(matrix);
-
- // set overrides previous calls to other set methods
- // thus, following three lines do not combine the transformations
- //matrix.setScale(3.0f, 3.0f);
- // skew waarde is tangens(hoek), dus 1 is skew van 45 graden en waarden groter dan 1 hebben eigenlijk geen zin
- //matrix.setSkew(0.8f, 0.0f);
- //matrix.setScale(3.0f, 3.0f);
-
- // apply a transformation after all other transformations
- matrix.postScale(3.0f, 3.0f);
- matrix.postSkew(0.8f, 0.0f);
-
- //canvas.setMatrix(matrix);
-
- // apply a transformation before all other transformations
- // this equals starting with a posttranslate with teh same parameters (ref1)
- matrix.preTranslate(-1 * (x+width/2), -1 * (y+height/2));
-
-
- matrix.postTranslate(x+width/2, y+height/2);
-
- final Matrix currentMatrix = canvas.getMatrix();
-
- // set the canvas to the new transformation matrix and draw your stuff
- canvas.concat(matrix);
- mDrawable1.draw(canvas);
-
- // restore what was the original matrix without any tranformation and draw your stuff
- canvas.setMatrix(currentMatrix);
- mDrawable2.draw(canvas);
+ if(fSetBounds)
+ {
+ rectangleDrawable.setBounds(x, y, x + width, y + height);
+ ovalDrawable.setBounds(x, y, x + width, y + height);
+ lineDrawable.setBounds(x, y, x + width, y + height);
+ ringDrawable.setBounds(x, y, x + width, y + height);
+ }
+ if(fDrawRectangle)
+ if(fCastToShapeDrawable)
+ ((ShapeDrawable)rectangleDrawable).draw(canvas);
+ else if(fCastToGradientDrawable)
+ ((GradientDrawable)rectangleDrawable).draw(canvas);
+ else
+ rectangleDrawable.draw(canvas);
+ if(fDrawOval)
+ ovalDrawable.draw(canvas);
+ if(fDrawLine)
+ lineDrawable.draw(canvas);
+ if(fDrawRing)
+ ringDrawable.draw(canvas);
+ }
+
+ public boolean getAsShapeDrawable()
+ {
+ return fCastToShapeDrawable;
+ }
+
+ public void setAsShapeDrawable(boolean castToShapeDrawable)
+ {
+ fCastToShapeDrawable = castToShapeDrawable;
+ }
+
+ public boolean getAsGradientDrawable()
+ {
+ return fCastToGradientDrawable;
+ }
+
+ public void setAsGradientDrawable(boolean castToGradientDrawable)
+ {
+ fCastToGradientDrawable = castToGradientDrawable;
+ }
+
+ public boolean getSetBounds()
+ {
+ return fSetBounds;
+ }
+
+ public void setSetBounds(boolean setBounds)
+ {
+ fSetBounds = setBounds;
}
+
+ public boolean getDrawRectangle()
+ {
+ return fDrawRectangle;
+ }
+
+ public void setDrawRectangle(boolean drawRectangle)
+ {
+ fDrawRectangle = drawRectangle;
+ }
+
+ public boolean getDrawOval()
+ {
+ return fDrawOval;
+ }
+
+ public void setDrawOval(boolean drawOval)
+ {
+ fDrawOval = drawOval;
+ }
+
+ public boolean getDrawLine()
+ {
+ return fDrawLine;
+ }
+
+ public void setDrawLine(boolean drawLine)
+ {
+ fDrawLine = drawLine;
+ }
+
+ public boolean getDrawRing()
+ {
+ return fDrawRing;
+ }
+
+ public void setDrawRing(boolean drawRing)
+ {
+ fDrawRing = drawRing;
+ }
+
+ private Drawable rectangleDrawable = null;
+ private Drawable ovalDrawable = null;
+ private Drawable lineDrawable = null;
+ private Drawable ringDrawable = null;
+
+ boolean fCastToShapeDrawable = false;
+ boolean fCastToGradientDrawable = true;
+
+ boolean fSetBounds = true;
+
+ boolean fDrawRectangle = true;
+ boolean fDrawOval = false;
+ boolean fDrawLine = false;
+ boolean fDrawRing = false;
- int x = 200;
- int y = 200;
+ int x = 100;
+ int y = 100;
int width = 50;
int height = 50;
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationActivity.java
new file mode 100644
index 0000000..f2809e3
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationActivity.java
@@ -0,0 +1,52 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+public class CustomDrawableMatrixTransformationActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ vw = new CustomDrawableMatrixTransformationView(this);
+
+ setContentView(vw);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.view_config, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ int menuItem = item.getItemId();
+ switch (menuItem) {
+ case R.id.mnu_genericconfig:
+ Intent myIntent = new Intent(CustomDrawableMatrixTransformationActivity.this, CustomDrawableMatrixTransformationConfigActivity.class);
+
+ startActivityForResult(myIntent, 0);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ Bundle config = intent.getExtras();
+
+ vw.setTransformationPipeline(config);
+
+ }
+
+ private CustomDrawableMatrixTransformationView vw;
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationConfigActivity.java
new file mode 100644
index 0000000..48b9c2b
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationConfigActivity.java
@@ -0,0 +1,86 @@
+package com.hfk.yadd;
+
+import java.util.ArrayList;
+
+import android.app.Activity;
+import android.app.ListActivity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+
+public class CustomDrawableMatrixTransformationConfigActivity extends ListActivity {
+
+ public static final String TRANSFORMATIONORDER_TYPE = "TRANSFORMATIONORDER_TYPE";
+ public static final String TRANSFORMATION_TYPE = "TRANSFORMATION_TYPE";
+
+ public static final String TRANSFORMATIONORDER_SET = "TRANSFORMATIONORDER_SET";
+ public static final String TRANSFORMATIONORDER_PRE = "TRANSFORMATIONORDER_PRE";
+ public static final String TRANSFORMATIONORDER_POST = "TRANSFORMATIONORDER_POST";
+
+ public static final String TRANSLATETOCENTER = "TRANSLATETOCENTER";
+ public static final String OVALOUTTRANSFORM = "OVAKOUTTRANSFORM";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.matrixtransform_drawable_config);
+
+ adapter=new ArrayAdapter(this,
+ android.R.layout.simple_list_item_1,
+ listItems);
+ setListAdapter(adapter);
+
+ checkBoxTranslateToCenter = (CheckBox)findViewById(R.id.checkBoxTranslateToCenter);
+ checkBoxOvalOutTransform = (CheckBox)findViewById(R.id.checkBoxOvalOutTransform);
+
+ b = new Bundle();
+
+ }
+
+ public void addItems(View v) {
+
+ Intent myIntent = new Intent(CustomDrawableMatrixTransformationConfigActivity.this, MatrixTransformationTypeSelectorActivity.class);
+
+ startActivityForResult(myIntent, 0);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ Bundle config = intent.getExtras();
+
+ listItems.add(Integer.toString(sequence) + " " + config.getString(TRANSFORMATION_TYPE));
+ adapter.notifyDataSetChanged();
+
+ b.putParcelable("MTX_" + Integer.toString(sequence), config);
+ b.putBoolean(TRANSLATETOCENTER, checkBoxTranslateToCenter.isChecked());
+ b.putBoolean(OVALOUTTRANSFORM, checkBoxOvalOutTransform.isChecked());
+
+ sequence++;
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+
+ Bundle b = null;
+ ArrayList listItems=new ArrayList();
+ ArrayAdapter adapter;
+
+ CheckBox checkBoxTranslateToCenter;
+ CheckBox checkBoxOvalOutTransform;
+
+ int sequence = 0;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationView.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationView.java
new file mode 100644
index 0000000..36e10b9
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableMatrixTransformationView.java
@@ -0,0 +1,158 @@
+package com.hfk.yadd;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Camera;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.shapes.OvalShape;
+import android.graphics.drawable.shapes.RectShape;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+public class CustomDrawableMatrixTransformationView extends View {
+
+ public CustomDrawableMatrixTransformationView(Context context) {
+ super(context);
+
+ rectangleDrawable = new ShapeDrawable(new RectShape());
+ ovalDrawable = new ShapeDrawable(new OvalShape());
+
+ rectangleDrawable.getPaint().setColor(0xff74AC23);
+ ovalDrawable.getPaint().setColor(0xff74AC23);
+
+ pipeline = new Bundle();
+ }
+
+ protected void onDraw(Canvas canvas) {
+ int rectX = this.getWidth()/2 - (width/2);
+ int rectY = this.getHeight()/2 - (height/2);
+ rectangleDrawable.setBounds(rectX, rectY, rectX + width, rectY + height);
+
+ int ovalX = rectX - width;
+ int ovalY = rectY - height;
+ ovalDrawable.setBounds(ovalX, ovalY, ovalX + width, ovalY + height);
+
+ Matrix matrix;
+ matrix = new Matrix();
+
+ if(pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER) && pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER))
+ matrix.postTranslate(-1 * this.getWidth() / 2, -1 * this.getHeight() / 2);
+
+ int sequence = 0;
+ while(pipeline.containsKey("MTX_" + Integer.toString(sequence)))
+ {
+ Bundle currTransform = (Bundle)pipeline.getParcelable("MTX_" + Integer.toString(sequence));
+ String transformationType = currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATION_TYPE);
+ if(transformationType.equals(MatrixTransformationRotateConfigActivity.TRANSFORMATION_ROTATE))
+ {
+ float rotation = currTransform.getFloat(MatrixTransformationRotateConfigActivity.ROTATE_ANGLE);
+ String transformationOrderType = currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE);
+ if(transformationOrderType.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ matrix.setRotate(rotation);
+ }
+ if(transformationOrderType.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ matrix.preRotate(rotation);
+ }
+ if(transformationOrderType.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ matrix.postRotate(rotation);
+ }
+ }
+
+ if(transformationType.equals(MatrixTransformationTranslateConfigActivity.TRANSFORMATION_TRANSLATE))
+ {
+ float dx = currTransform.getFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DX);
+ float dy = currTransform.getFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DY);
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ matrix.setTranslate(dx, dy);
+ }
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ matrix.preTranslate(dx, dy);
+ }
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ matrix.postTranslate(dx, dy);
+ }
+ }
+
+ if(transformationType.equals(MatrixTransformationScaleConfigActivity.TRANSFORMATION_SCALE))
+ {
+ float sx = currTransform.getFloat(MatrixTransformationScaleConfigActivity.SCALE_SX);
+ float sy = currTransform.getFloat(MatrixTransformationScaleConfigActivity.SCALE_SY);
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ matrix.setScale(sx, sy);
+ }
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ matrix.preScale(sx, sy);
+ }
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ matrix.postScale(sx, sy);
+ }
+ }
+
+ if(transformationType.equals(MatrixTransformationSkewConfigActivity.TRANSFORMATION_SKEW))
+ {
+ float kx = currTransform.getFloat(MatrixTransformationSkewConfigActivity.SKEW_KX);
+ float ky = currTransform.getFloat(MatrixTransformationSkewConfigActivity.SKEW_KY);
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ matrix.setSkew(kx, ky);
+ }
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ matrix.preSkew(kx, ky);
+ }
+ if(currTransform.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE).equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ matrix.postSkew(kx, ky);
+ }
+ }
+
+ sequence++;
+ }
+
+ if(pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER) && pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.TRANSLATETOCENTER))
+ matrix.postTranslate(this.getWidth() / 2, this.getHeight() / 2);
+
+ final Matrix currentMatrix = canvas.getMatrix();
+
+ canvas.concat(matrix);
+ if(pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM) && !pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM))
+ ovalDrawable.draw(canvas);
+ rectangleDrawable.draw(canvas);
+
+ canvas.setMatrix(currentMatrix);
+ if(!pipeline.containsKey(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM) || pipeline.getBoolean(CustomDrawableMatrixTransformationConfigActivity.OVALOUTTRANSFORM))
+ ovalDrawable.draw(canvas);
+
+ }
+
+ public void setTransformationPipeline(Bundle pipeline)
+ {
+ this.pipeline = pipeline;
+ }
+
+ private ShapeDrawable rectangleDrawable = null;
+ private ShapeDrawable ovalDrawable = null;
+
+// int xRect = 50;
+// int yRect = 50;
+// int xOval = 100;
+// int yOval = 100;
+ int width = 50;
+ int height = 50;
+
+ Bundle pipeline;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableView.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableView.java
index 9bc018c..79cfdfb 100644
--- a/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableView.java
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/CustomDrawableView.java
@@ -2,27 +2,125 @@
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.shapes.ArcShape;
import android.graphics.drawable.shapes.OvalShape;
+import android.graphics.drawable.shapes.RectShape;
import android.view.View;
public class CustomDrawableView extends View {
- private ShapeDrawable mDrawable;
public CustomDrawableView(Context context) {
super(context);
- int x = 10;
- int y = 10;
- int width = 50;
- int height = 50;
-
- mDrawable = new ShapeDrawable(new OvalShape());
- mDrawable.getPaint().setColor(0xff74AC23);
- mDrawable.setBounds(x, y, x + width, y + height);
+ rectangleDrawable = new ShapeDrawable(new RectShape());
+ ovalDrawable = new ShapeDrawable(new OvalShape());
+ arcDrawable = new ShapeDrawable(new ArcShape(45, 300));
+// Line and Ring are not available, because in XML, these come from the GradientDrawable class
+// lineDrawable = new ShapeDrawable(new OvalShape());
+// ringDrawable = new ShapeDrawable(new OvalShape());
}
protected void onDraw(Canvas canvas) {
- mDrawable.draw(canvas);
+ arcDrawable.getPaint().setColor(0xff74AC23);
+
+ if(fSetBounds)
+ {
+ rectangleDrawable.setBounds(x, y, x + width, y + height);
+ ovalDrawable.setBounds(x, y, x + width, y + height);
+ arcDrawable.setBounds(x, y, x + width, y + height);
+// lineDrawable.setBounds(x, y, x + width, y + height);
+// ringDrawable.setBounds(x, y, x + width, y + height);
+ }
+ if(fDrawRectangle)
+ rectangleDrawable.draw(canvas);
+ if(fDrawOval)
+ ovalDrawable.draw(canvas);
+ if(fDrawArc)
+ arcDrawable.draw(canvas);
+// if(fDrawLine)
+// lineDrawable.draw(canvas);
+// if(fDrawRing)
+// ringDrawable.draw(canvas);
+ }
+
+ public boolean getSetBounds()
+ {
+ return fSetBounds;
+ }
+
+ public void setSetBounds(boolean setBounds)
+ {
+ fSetBounds = setBounds;
+ }
+
+ public boolean getDrawRectangle()
+ {
+ return fDrawRectangle;
+ }
+
+ public void setDrawRectangle(boolean drawRectangle)
+ {
+ fDrawRectangle = drawRectangle;
}
+
+ public boolean getDrawOval()
+ {
+ return fDrawOval;
+ }
+
+ public void setDrawOval(boolean drawOval)
+ {
+ fDrawOval = drawOval;
+ }
+
+ public boolean getDrawArc()
+ {
+ return fDrawArc;
+ }
+
+ public void setDrawArc(boolean drawArc)
+ {
+ fDrawArc = drawArc;
+ }
+
+// public boolean getDrawLine()
+// {
+// return fDrawLine;
+// }
+//
+// public void setDrawLine(boolean drawLine)
+// {
+// fDrawLine = drawLine;
+// }
+//
+// public boolean getDrawRing()
+// {
+// return fDrawRing;
+// }
+//
+// public void setDrawRing(boolean drawRing)
+// {
+// fDrawRing = drawRing;
+// }
+
+ private ShapeDrawable rectangleDrawable = null;
+ private ShapeDrawable ovalDrawable = null;
+ private ShapeDrawable arcDrawable = null;
+// private Drawable lineDrawable = null;
+// private Drawable ringDrawable = null;
+
+ boolean fSetBounds = true;
+
+ boolean fDrawRectangle = false;
+ boolean fDrawOval = false;
+ boolean fDrawArc = true;
+// boolean fDrawLine = false;
+// boolean fDrawRing = false;
+
+ int x = 100;
+ int y = 100;
+ int width = 50;
+ int height = 50;
}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationRotateConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationRotateConfigActivity.java
new file mode 100644
index 0000000..2208378
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationRotateConfigActivity.java
@@ -0,0 +1,88 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class MatrixTransformationRotateConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_ROTATE = "ROTATE";
+ public static final String ROTATE_ANGLE = "ROTATE_ANGLE";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.matrixtransform_rotate_config);
+
+ radioOrderGroup = (RadioGroup)findViewById(R.id.radioRotationOrder);
+ mTextAngle = (EditText)findViewById(R.id.editAngle);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(ROTATE_ANGLE)) {
+ mTextAngle.setText(Float.toString(data.getFloat(ROTATE_ANGLE)));
+ }
+
+ if(data.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE)) {
+ String order = data.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE);
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbRotateTypeSet);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbRotateTypePre);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbRotateTypePost);
+ radioOrderButton.setChecked(true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_ROTATE);
+
+ int selectedOrderControlId = radioOrderGroup.getCheckedRadioButtonId();
+ RadioButton radioOrderButton = (RadioButton) findViewById(selectedOrderControlId);
+ if(radioOrderButton.getText().equals("Set"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET);
+ }
+ if(radioOrderButton.getText().equals("Pre"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE);
+ }
+ if(radioOrderButton.getText().equals("Post"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ }
+
+ b.putFloat(ROTATE_ANGLE, Float.parseFloat(mTextAngle.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextAngle;
+ private RadioGroup radioOrderGroup;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationScaleConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationScaleConfigActivity.java
new file mode 100644
index 0000000..948922f
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationScaleConfigActivity.java
@@ -0,0 +1,96 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class MatrixTransformationScaleConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_SCALE = "SCALE";
+ public static final String SCALE_SX = "SCALE_SX";
+ public static final String SCALE_SY = "SCALE_SY";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.matrixtransform_scale_config);
+
+ radioOrderGroup = (RadioGroup)findViewById(R.id.radioScaleOrder);
+ mTextSX = (EditText)findViewById(R.id.editSX);
+ mTextSY = (EditText)findViewById(R.id.editSY);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(SCALE_SX)) {
+ mTextSX.setText(Float.toString(data.getFloat(SCALE_SX)));
+ }
+
+ if(data.containsKey(SCALE_SY)) {
+ mTextSY.setText(Float.toString(data.getFloat(SCALE_SY)));
+ }
+
+ if(data.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE)) {
+ String order = data.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE);
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbScaleTypeSet);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbScaleTypePre);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbScaleTypePost);
+ radioOrderButton.setChecked(true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_SCALE);
+
+ int selectedOrderControlId = radioOrderGroup.getCheckedRadioButtonId();
+ RadioButton radioOrderButton = (RadioButton) findViewById(selectedOrderControlId);
+ if(radioOrderButton.getText().equals("Set"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET);
+ }
+ if(radioOrderButton.getText().equals("Pre"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE);
+ }
+ if(radioOrderButton.getText().equals("Post"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ }
+
+ b.putFloat(SCALE_SX, Float.parseFloat(mTextSX.getText().toString()));
+ b.putFloat(SCALE_SY, Float.parseFloat(mTextSY.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextSX;
+ private EditText mTextSY;
+ private RadioGroup radioOrderGroup;
+
+}
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationSkewConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationSkewConfigActivity.java
new file mode 100644
index 0000000..1b2d746
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationSkewConfigActivity.java
@@ -0,0 +1,97 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+
+public class MatrixTransformationSkewConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_SKEW = "SKEW";
+ public static final String SKEW_KX = "SKEW_KX";
+ public static final String SKEW_KY = "SKEW_KY";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.matrixtransform_skew_config);
+
+ radioOrderGroup = (RadioGroup)findViewById(R.id.radioSkewOrder);
+ mTextKX = (EditText)findViewById(R.id.editKX);
+ mTextKY = (EditText)findViewById(R.id.editKY);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(SKEW_KX)) {
+ mTextKX.setText(Float.toString(data.getFloat(SKEW_KX)));
+ }
+
+ if(data.containsKey(SKEW_KY)) {
+ mTextKY.setText(Float.toString(data.getFloat(SKEW_KY)));
+ }
+
+ if(data.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE)) {
+ String order = data.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE);
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbSkewTypeSet);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbSkewTypePre);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbSkewTypePost);
+ radioOrderButton.setChecked(true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_SKEW);
+
+ int selectedOrderControlId = radioOrderGroup.getCheckedRadioButtonId();
+ RadioButton radioOrderButton = (RadioButton) findViewById(selectedOrderControlId);
+ if(radioOrderButton.getText().equals("Set"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET);
+ }
+ if(radioOrderButton.getText().equals("Pre"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE);
+ }
+ if(radioOrderButton.getText().equals("Post"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ }
+
+ b.putFloat(SKEW_KX, Float.parseFloat(mTextKX.getText().toString()));
+ b.putFloat(SKEW_KY, Float.parseFloat(mTextKY.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextKX;
+ private EditText mTextKY;
+ private RadioGroup radioOrderGroup;
+
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationTranslateConfigActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationTranslateConfigActivity.java
new file mode 100644
index 0000000..b5234d6
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationTranslateConfigActivity.java
@@ -0,0 +1,96 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+public class MatrixTransformationTranslateConfigActivity extends Activity {
+
+ public static final String TRANSFORMATION_TRANSLATE = "TRANSLATE";
+ public static final String TRANSLATE_DX = "TRANSLATE_DX";
+ public static final String TRANSLATE_DY = "TRANSLATE_DY";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.matrixtransform_translate_config);
+
+ radioOrderGroup = (RadioGroup)findViewById(R.id.radioTranslateOrder);
+ mTextDX = (EditText)findViewById(R.id.editDX);
+ mTextDY = (EditText)findViewById(R.id.editDY);
+
+ Bundle data = getIntent().getExtras();
+ if(data != null){
+ if(data.containsKey(TRANSLATE_DX)) {
+ mTextDX.setText(Float.toString(data.getFloat(TRANSLATE_DX)));
+ }
+
+ if(data.containsKey(TRANSLATE_DY)) {
+ mTextDY.setText(Float.toString(data.getFloat(TRANSLATE_DY)));
+ }
+
+ if(data.containsKey(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE)) {
+ String order = data.getString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE);
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbTranslateTypeSet);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbTranslateTypePre);
+ radioOrderButton.setChecked(true);
+ }
+ if(order.equals(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST))
+ {
+ RadioButton radioOrderButton = (RadioButton) findViewById(R.id.rbTranslateTypePost);
+ radioOrderButton.setChecked(true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ Bundle b = new Bundle();
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATION_TYPE, TRANSFORMATION_TRANSLATE);
+
+ int selectedOrderControlId = radioOrderGroup.getCheckedRadioButtonId();
+ RadioButton radioOrderButton = (RadioButton) findViewById(selectedOrderControlId);
+ if(radioOrderButton.getText().equals("Set"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_SET);
+ }
+ if(radioOrderButton.getText().equals("Pre"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_PRE);
+ }
+ if(radioOrderButton.getText().equals("Post"))
+ {
+ b.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE,
+ CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ }
+
+ b.putFloat(TRANSLATE_DX, Float.parseFloat(mTextDX.getText().toString()));
+ b.putFloat(TRANSLATE_DY, Float.parseFloat(mTextDY.getText().toString()));
+
+ result.putExtras(b);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ private EditText mTextDX;
+ private EditText mTextDY;
+ private RadioGroup radioOrderGroup;
+
+}
\ No newline at end of file
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationTypeSelectorActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationTypeSelectorActivity.java
new file mode 100644
index 0000000..a58a4fc
--- /dev/null
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/MatrixTransformationTypeSelectorActivity.java
@@ -0,0 +1,96 @@
+package com.hfk.yadd;
+
+import android.app.Activity;
+import android.app.ListActivity;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+public class MatrixTransformationTypeSelectorActivity extends ListActivity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Resources res = getResources();
+ String[] names = res.getStringArray(R.array.matrix_transformations_available);
+ this.setListAdapter(new ArrayAdapter(this,
+ android.R.layout.simple_list_item_1, names));
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ super.onListItemClick(l, v, position, id);
+
+ Intent myIntent = null;
+ if(position == 0)
+ {
+ myIntent = new Intent(MatrixTransformationTypeSelectorActivity.this, MatrixTransformationRotateConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE, CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ bundle.putFloat(MatrixTransformationRotateConfigActivity.ROTATE_ANGLE, defaultRotationAngle);
+ myIntent.putExtras(bundle);
+ }
+ if(position == 1)
+ {
+ myIntent = new Intent(MatrixTransformationTypeSelectorActivity.this, MatrixTransformationScaleConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE, CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ bundle.putFloat(MatrixTransformationScaleConfigActivity.SCALE_SX, defaultSX);
+ bundle.putFloat(MatrixTransformationScaleConfigActivity.SCALE_SY, defaultSY);
+ myIntent.putExtras(bundle);
+ }
+ if(position == 2)
+ {
+ myIntent = new Intent(MatrixTransformationTypeSelectorActivity.this, MatrixTransformationSkewConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE, CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ bundle.putFloat(MatrixTransformationSkewConfigActivity.SKEW_KX, defaultKX);
+ bundle.putFloat(MatrixTransformationSkewConfigActivity.SKEW_KY, defaultKY);
+ myIntent.putExtras(bundle);
+ }
+ if(position == 3)
+ {
+ myIntent = new Intent(MatrixTransformationTypeSelectorActivity.this, MatrixTransformationTranslateConfigActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putString(CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_TYPE, CustomDrawableMatrixTransformationConfigActivity.TRANSFORMATIONORDER_POST);
+ bundle.putFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DX, defaultSX);
+ bundle.putFloat(MatrixTransformationTranslateConfigActivity.TRANSLATE_DY, defaultSY);
+ myIntent.putExtras(bundle);
+ }
+
+ config = null;
+ startActivityForResult(myIntent, 0);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent intent){
+ config = intent.getExtras();
+ }
+
+ @Override
+ public void onBackPressed() {
+ Intent result = new Intent();
+
+ result.putExtras(config);
+
+ setResult(Activity.RESULT_OK, result);
+
+ super.onBackPressed();
+ }
+
+ Bundle config;
+
+ float defaultRotationAngle = 0;
+
+ float defaultKX = 0;
+ float defaultKY = 0;
+
+ float defaultSX = 1;
+ float defaultSY = 1;
+
+ float defaultDX = 0;
+ float defaultDY = 0;
+}
diff --git a/YetAnotherDrawableDemo/src/com/hfk/yadd/YetAnotherDrawableDemoActivity.java b/YetAnotherDrawableDemo/src/com/hfk/yadd/YetAnotherDrawableDemoActivity.java
index 57907a0..2758410 100644
--- a/YetAnotherDrawableDemo/src/com/hfk/yadd/YetAnotherDrawableDemoActivity.java
+++ b/YetAnotherDrawableDemo/src/com/hfk/yadd/YetAnotherDrawableDemoActivity.java
@@ -1,14 +1,40 @@
package com.hfk.yadd;
import android.app.Activity;
+import android.app.ListActivity;
+import android.content.Intent;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+public class YetAnotherDrawableDemoActivity extends ListActivity {
-public class YetAnotherDrawableDemoActivity extends Activity {
- /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- //setContentView(R.layout.main);
- setContentView(new CustomDrawableFromXMLView(this));
+ Resources res = getResources();
+ String[] names = res.getStringArray(R.array.views_available);
+ this.setListAdapter(new ArrayAdapter(this,
+ android.R.layout.simple_list_item_1, names));
}
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ super.onListItemClick(l, v, position, id);
+
+ Intent myIntent = null;
+ if(position == 0)
+ myIntent = new Intent(YetAnotherDrawableDemoActivity.this, CustomDrawableActivity.class);
+ if(position == 1)
+ myIntent = new Intent(YetAnotherDrawableDemoActivity.this, CustomDrawableFromXMLActivity.class);
+ if(position == 2)
+ myIntent = new Intent(YetAnotherDrawableDemoActivity.this, CustomDrawableMatrixTransformationActivity.class);
+ if(position == 3)
+ myIntent = new Intent(YetAnotherDrawableDemoActivity.this, CustomDrawableCameraTransformationActivity.class);
+
+ startActivity(myIntent);
+ }
}
\ No newline at end of file