From dfef5495fda3bb98c85096d0ae3c46e279bdc979 Mon Sep 17 00:00:00 2001 From: vng Date: Sat, 18 Jun 2011 00:38:23 +0300 Subject: [PATCH] Fix formatting (2 spaces for tab and replace tabs with spaces). --- android/jni/main_native.cpp | 135 ++++++++-------- .../mapswithme/maps/GesturesProcessor.java | 153 +++++++++--------- .../src/com/mapswithme/maps/MWMActivity.java | 59 ++++--- .../src/com/mapswithme/maps/MainGLView.java | 101 ++++++------ 4 files changed, 224 insertions(+), 224 deletions(-) diff --git a/android/jni/main_native.cpp b/android/jni/main_native.cpp index 900e5b0fae..50e6a4d98a 100644 --- a/android/jni/main_native.cpp +++ b/android/jni/main_native.cpp @@ -3,88 +3,89 @@ #include #include - #define LOG(...) __android_log_print(ANDROID_LOG_INFO, "mapswithme", __VA_ARGS__) namespace jni_help { - // Some examples of sig: - // "()V" - void function returning void; - // "(Ljava/lang/String;)V" - String function returning void; - jmethodID GetJavaMethodID(JNIEnv * env, jobject obj, - char const * fn, char const * sig) - { - jclass cls = env->GetObjectClass(obj); - jmethodID mid = env->GetMethodID(cls, fn, sig); - assert(mid != 0); - return mid; - } + // Some examples of sig: + // "()V" - void function returning void; + // "(Ljava/lang/String;)V" - String function returning void; + jmethodID GetJavaMethodID(JNIEnv * env, jobject obj, char const * fn, + char const * sig) + { + jclass cls = env->GetObjectClass(obj); + jmethodID mid = env->GetMethodID(cls, fn, sig); + assert(mid != 0); + return mid; + } - class String - { - JNIEnv * m_env; - jstring m_s; - jchar const * m_ret; - public: - String(JNIEnv * env, jstring s) : m_env(env), m_s(s) - { - LOG("String constructor"); - m_ret = m_env->GetStringChars(m_s, NULL); - } - ~String() - { - LOG("String destructor"); - m_env->ReleaseStringChars(m_s, m_ret); - } - }; + class String + { + JNIEnv * m_env; + jstring m_s; + jchar const * m_ret; + public: + String(JNIEnv * env, jstring s) : + m_env(env), m_s(s) + { + LOG("String constructor"); + m_ret = m_env->GetStringChars(m_s, NULL); + } + ~String() + { + LOG("String destructor"); + m_env->ReleaseStringChars(m_s, m_ret); + } + }; } - extern "C" { - /* Some dummy functions. - JNIEXPORT jstring JNICALL - Java_com_mapswithme_maps_MWMActivity_stringsJNI(JNIEnv * env, jobject thiz, jstring s) - { - LOG("Enter stringsJNI"); + /* Interop example functions. + JNIEXPORT jstring JNICALL + Java_com_mapswithme_maps_MWMActivity_stringsJNI(JNIEnv * env, jobject thiz, + jstring s) + { + LOG("Enter stringsJNI"); - { - jni_help::String str(env, s); - } + { + jni_help::String str(env, s); + } - LOG("Leave stringsJNI"); - return env->NewStringUTF("Return string from JNI."); - } + LOG("Leave stringsJNI"); + return env->NewStringUTF("Return string from JNI."); + } - JNIEXPORT void JNICALL - Java_com_mapswithme_maps_MWMActivity_callbackFromJNI(JNIEnv * env, jobject thiz) - { - LOG("Enter callbackFromJNI"); + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_MWMActivity_callbackFromJNI(JNIEnv * env, jobject thiz) + { + LOG("Enter callbackFromJNI"); - env->CallVoidMethod(thiz, jni_help::GetJavaMethodID(env, thiz, - "callbackVoid", "()V")); - env->CallVoidMethod(thiz, jni_help::GetJavaMethodID(env, thiz, - "callbackString", "(Ljava/lang/String;)V"), - env->NewStringUTF("Pass string from JNI.")); + env->CallVoidMethod(thiz, + jni_help::GetJavaMethodID(env, thiz, "callbackVoid", "()V")); + env->CallVoidMethod( + thiz, + jni_help::GetJavaMethodID(env, thiz, "callbackString", + "(Ljava/lang/String;)V"), env->NewStringUTF("Pass string from JNI.")); - LOG("Leave callbackFromJNI"); - } - */ + LOG("Leave callbackFromJNI"); + } + */ - JNIEXPORT void JNICALL - Java_com_mapswithme_maps_MainGLView_nativeInit(JNIEnv * env, jobject thiz) - { - } + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_MainGLView_nativeInit(JNIEnv * env, jobject thiz) + { + } - JNIEXPORT void JNICALL - Java_com_mapswithme_maps_GesturesProcessor_nativeMove(JNIEnv * env, jobject thiz, - jint mode, jdouble x, jdouble y) - { - } + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_GesturesProcessor_nativeMove(JNIEnv * env, + jobject thiz, jint mode, jdouble x, jdouble y) + { + } - JNIEXPORT void JNICALL - Java_com_mapswithme_maps_GesturesProcessor_nativeZoom(JNIEnv * env, jobject thiz, - jint mode, jdouble x1, jdouble y1, jdouble x2, jdouble y2) - { - } + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_GesturesProcessor_nativeZoom(JNIEnv * env, + jobject thiz, jint mode, jdouble x1, jdouble y1, jdouble x2, jdouble y2) + { + } } diff --git a/android/src/com/mapswithme/maps/GesturesProcessor.java b/android/src/com/mapswithme/maps/GesturesProcessor.java index 08c4786891..bcdfd614ce 100644 --- a/android/src/com/mapswithme/maps/GesturesProcessor.java +++ b/android/src/com/mapswithme/maps/GesturesProcessor.java @@ -3,82 +3,83 @@ package com.mapswithme.maps; import android.graphics.PointF; import android.view.MotionEvent; - public class GesturesProcessor { - private final int NONE = 0; - private final int MOVE = 1; - private final int ZOOM = 2; - - // Do not modify this constant values (or take into account native code, please). - private final int START = 0; - private final int PROCESS = 1; - private final int END = 2; - - private PointF m_pt1; - private PointF m_pt2; - private int m_mode; - - private void getPointsMove(MotionEvent e) - { - m_pt1.set(e.getX(), e.getY()); - } - - private void getPointsZoom(MotionEvent e) - { - m_pt1.set(e.getX(0), e.getY(0)); - m_pt2.set(e.getX(1), e.getY(1)); - } - - public GesturesProcessor() - { - m_pt1 = new PointF(); - m_pt2 = new PointF(); - m_mode = NONE; - } - - public void onTouchEvent(MotionEvent e) - { - switch (e.getAction() & MotionEvent.ACTION_MASK) - { - case MotionEvent.ACTION_DOWN: - getPointsMove(e); - m_mode = MOVE; - nativeMove(START, m_pt1.x, m_pt1.y); - break; - - case MotionEvent.ACTION_POINTER_DOWN: - getPointsZoom(e); - nativeZoom(START, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y); - break; - - case MotionEvent.ACTION_UP: - getPointsMove(e); - nativeMove(END, m_pt1.x, m_pt1.y); - m_mode = NONE; - break; - - case MotionEvent.ACTION_POINTER_UP: - getPointsZoom(e); - nativeZoom(END, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y); - m_mode = NONE; - break; - - case MotionEvent.ACTION_MOVE: - if (m_mode == MOVE) - { - getPointsMove(e); - nativeMove(PROCESS, m_pt1.x, m_pt1.y); - } - else if (m_mode == ZOOM) - { - getPointsZoom(e); - nativeZoom(PROCESS, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y); - } - break; - } - } - - private native void nativeMove(int mode, double x, double y); - private native void nativeZoom(int mode, double x1, double y1, double x2, double y2); + private final int NONE = 0; + private final int MOVE = 1; + private final int ZOOM = 2; + + // Do not modify this constant values (or take into account native code, + // please). + private final int START = 0; + private final int PROCESS = 1; + private final int END = 2; + + private PointF m_pt1; + private PointF m_pt2; + private int m_mode; + + private void getPointsMove(MotionEvent e) + { + m_pt1.set(e.getX(), e.getY()); + } + + private void getPointsZoom(MotionEvent e) + { + m_pt1.set(e.getX(0), e.getY(0)); + m_pt2.set(e.getX(1), e.getY(1)); + } + + public GesturesProcessor() + { + m_pt1 = new PointF(); + m_pt2 = new PointF(); + m_mode = NONE; + } + + public void onTouchEvent(MotionEvent e) + { + switch (e.getAction() & MotionEvent.ACTION_MASK) + { + case MotionEvent.ACTION_DOWN: + getPointsMove(e); + m_mode = MOVE; + nativeMove(START, m_pt1.x, m_pt1.y); + break; + + case MotionEvent.ACTION_POINTER_DOWN: + getPointsZoom(e); + nativeZoom(START, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y); + break; + + case MotionEvent.ACTION_UP: + getPointsMove(e); + nativeMove(END, m_pt1.x, m_pt1.y); + m_mode = NONE; + break; + + case MotionEvent.ACTION_POINTER_UP: + getPointsZoom(e); + nativeZoom(END, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y); + m_mode = NONE; + break; + + case MotionEvent.ACTION_MOVE: + if (m_mode == MOVE) + { + getPointsMove(e); + nativeMove(PROCESS, m_pt1.x, m_pt1.y); + } else if (m_mode == ZOOM) + { + getPointsZoom(e); + nativeZoom(PROCESS, m_pt1.x, m_pt1.y, m_pt2.x, m_pt2.y); + } + break; + } + } + + private native void nativeMove(int mode, double x, double y); + + private native void nativeZoom(int mode, double x1, double y1, double x2, + double y2); } diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java index eeed043fc5..38086c8d89 100644 --- a/android/src/com/mapswithme/maps/MWMActivity.java +++ b/android/src/com/mapswithme/maps/MWMActivity.java @@ -5,37 +5,36 @@ import com.mapswithme.maps.MainGLView; import android.app.Activity; import android.os.Bundle; - public class MWMActivity extends Activity { - private MainGLView m_view; - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - m_view = new MainGLView(getApplication()); - - setContentView(m_view); - } - - @Override - protected void onPause() - { - super.onPause(); - m_view.onPause(); - } + private MainGLView m_view; - @Override - protected void onResume() - { - super.onResume(); - m_view.onResume(); - } - - static - { - System.loadLibrary("mapswithme"); - } + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + m_view = new MainGLView(getApplication()); + + setContentView(m_view); + } + + @Override + protected void onPause() + { + super.onPause(); + m_view.onPause(); + } + + @Override + protected void onResume() + { + super.onResume(); + m_view.onResume(); + } + + static + { + System.loadLibrary("mapswithme"); + } } diff --git a/android/src/com/mapswithme/maps/MainGLView.java b/android/src/com/mapswithme/maps/MainGLView.java index 4bd5dda0ca..35ba396ed6 100644 --- a/android/src/com/mapswithme/maps/MainGLView.java +++ b/android/src/com/mapswithme/maps/MainGLView.java @@ -10,60 +10,59 @@ import android.opengl.GLSurfaceView; import android.util.Log; import android.view.MotionEvent; - public class MainGLView extends GLSurfaceView { - private static String TAG = "MainGLView"; - - GesturesProcessor m_gestures; - - public MainGLView(Context context) - { - super(context); - init(); - } - - private void init() - { - m_gestures = new GesturesProcessor(); - - // Do native initialization with OpenGL. - nativeInit(); - - setRenderer(new Renderer()); - - // When renderMode is RENDERMODE_WHEN_DIRTY, the renderer only rendered - // when the surface is created, or when requestRender() is called. - setRenderMode(RENDERMODE_WHEN_DIRTY); - } - - private static class Renderer implements GLSurfaceView.Renderer - { - @Override - public void onDrawFrame(GL10 gl) - { - Log.i(TAG, "Renderer::onDrawFrame"); - } + private static String TAG = "MainGLView"; - @Override - public void onSurfaceChanged(GL10 gl, int width, int height) - { - Log.i(TAG, "Renderer::onSurfaceChanged"); - } + GesturesProcessor m_gestures; - @Override - public void onSurfaceCreated(GL10 gl, EGLConfig config) - { - Log.i(TAG, "Renderer::onSurfaceCreated"); - } - } - - @Override - public boolean onTouchEvent(MotionEvent e) - { - m_gestures.onTouchEvent(e); - return true; // if handled + public MainGLView(Context context) + { + super(context); + init(); + } + + private void init() + { + m_gestures = new GesturesProcessor(); + + // Do native initialization with OpenGL. + nativeInit(); + + setRenderer(new Renderer()); + + // When renderMode is RENDERMODE_WHEN_DIRTY, the renderer only rendered + // when the surface is created, or when requestRender() is called. + setRenderMode(RENDERMODE_WHEN_DIRTY); + } + + private static class Renderer implements GLSurfaceView.Renderer + { + @Override + public void onDrawFrame(GL10 gl) + { + Log.i(TAG, "Renderer::onDrawFrame"); } - - private native void nativeInit(); + + @Override + public void onSurfaceChanged(GL10 gl, int width, int height) + { + Log.i(TAG, "Renderer::onSurfaceChanged"); + } + + @Override + public void onSurfaceCreated(GL10 gl, EGLConfig config) + { + Log.i(TAG, "Renderer::onSurfaceCreated"); + } + } + + @Override + public boolean onTouchEvent(MotionEvent e) + { + m_gestures.onTouchEvent(e); + return true; // if handled + } + + private native void nativeInit(); }