|
|
@@ -12,6 +12,8 @@ import android.hardware.SensorManager;
|
|
|
import android.content.Context;
|
|
|
import android.widget.Toast;
|
|
|
import android.content.res.AssetManager;
|
|
|
+import android.view.ScaleGestureDetector;
|
|
|
+
|
|
|
import crown.android.CrownEnum;
|
|
|
|
|
|
/**
|
|
|
@@ -19,6 +21,7 @@ import crown.android.CrownEnum;
|
|
|
*/
|
|
|
public class CrownActivity extends Activity
|
|
|
{
|
|
|
+
|
|
|
// Debug
|
|
|
public static String TAG = "CrownActivity";
|
|
|
|
|
|
@@ -32,9 +35,10 @@ public class CrownActivity extends Activity
|
|
|
private CrownTouch mTouch;
|
|
|
private CrownSensor mSensor;
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+ // Gestures detectors
|
|
|
+ private ScaleGestureDetector mScaleDetector;
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
{
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -48,29 +52,25 @@ public class CrownActivity extends Activity
|
|
|
setContentView(mView);
|
|
|
|
|
|
// Init Input
|
|
|
- mTouch = new CrownTouch();
|
|
|
+ mTouch = new CrownTouch(this);
|
|
|
mSensor = new CrownSensor(this);
|
|
|
+
|
|
|
+ mScaleDetector = new ScaleGestureDetector(this, new ScaleListener());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onStart()
|
|
|
{
|
|
|
super.onStart();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onRestart()
|
|
|
{
|
|
|
super.onRestart();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onResume()
|
|
|
{
|
|
|
super.onResume();
|
|
|
@@ -83,18 +83,14 @@ public class CrownActivity extends Activity
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onPause()
|
|
|
{
|
|
|
super.onPause();
|
|
|
mView.onPause();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onStop()
|
|
|
{
|
|
|
super.onStop();
|
|
|
@@ -103,21 +99,46 @@ public class CrownActivity extends Activity
|
|
|
mSensor.stopListening();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public void onDestroy()
|
|
|
{
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Callback method which takes touch data and
|
|
|
- * sends them to Crown.
|
|
|
- */
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
public boolean onTouchEvent(MotionEvent event)
|
|
|
{
|
|
|
+ mScaleDetector.onTouchEvent(event);
|
|
|
+
|
|
|
mTouch.onTouch(event);
|
|
|
- return true;
|
|
|
+ return super.onTouchEvent(event);
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
+ public boolean hasMultiTouchSupport(Context context)
|
|
|
+ {
|
|
|
+ return context.getPackageManager().hasSystemFeature("android.hardware.touchscreen.multitouch");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+//-----------------------------------------------------------------------------------
|
|
|
+ private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener
|
|
|
+ {
|
|
|
+ public boolean onScale(ScaleGestureDetector detector)
|
|
|
+ {
|
|
|
+ Log.i(TAG, "onScale.");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean onScaleBegin(ScaleGestureDetector detector)
|
|
|
+ {
|
|
|
+ Log.i(TAG, "onScaleBegin.");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void onScaleEnd(ScaleGestureDetector detector)
|
|
|
+ {
|
|
|
+ Log.i(TAG, "onScaleBegin.");
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|