forked from bitcraze/crazyflie-android-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit, only joysticks and icon
- Loading branch information
Arnaud Taffanel
committed
Nov 4, 2012
0 parents
commit 648f0fc
Showing
23 changed files
with
828 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="se.bitcraze.crazyfliecontrol" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="13" | ||
android:targetSdkVersion="15" /> | ||
|
||
<application | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/title_activity_main" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** Automatically generated file. DO NOT MODIFY */ | ||
package se.bitcraze.crazyfliecontrol; | ||
|
||
public final class BuildConfig { | ||
public final static boolean DEBUG = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
* | ||
* This class was automatically generated by the | ||
* aapt tool from the resource data it found. It | ||
* should not be modified by hand. | ||
*/ | ||
|
||
package se.bitcraze.crazyfliecontrol; | ||
|
||
public final class R { | ||
public static final class attr { | ||
} | ||
public static final class drawable { | ||
public static final int ic_action_search=0x7f020000; | ||
public static final int ic_launcher=0x7f020001; | ||
} | ||
public static final class id { | ||
public static final int joysticks=0x7f070000; | ||
public static final int menu_connect=0x7f070001; | ||
public static final int menu_disconnect=0x7f070002; | ||
} | ||
public static final class layout { | ||
public static final int activity_main=0x7f030000; | ||
} | ||
public static final class menu { | ||
public static final int activity_main=0x7f060000; | ||
} | ||
public static final class string { | ||
public static final int app_name=0x7f040000; | ||
public static final int connect=0x7f040004; | ||
public static final int copter_channel=0x7f040005; | ||
public static final int hello_world=0x7f040001; | ||
public static final int menu_connect=0x7f040006; | ||
public static final int menu_disconnect=0x7f040002; | ||
public static final int title_activity_main=0x7f040003; | ||
} | ||
public static final class style { | ||
public static final int AppTheme=0x7f050000; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" > | ||
|
||
<com.MobileAnarchy.Android.Widgets.Joystick.DualJoystickView | ||
android:id="@+id/joysticks" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentLeft="true" | ||
android:layout_alignParentRight="true" | ||
android:layout_alignParentTop="true" > | ||
|
||
</com.MobileAnarchy.Android.Widgets.Joystick.DualJoystickView> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:id="@+id/menu_connect" android:title="@string/menu_connect" android:showAsAction="never"></item><item android:id="@+id/menu_disconnect" | ||
android:title="@string/menu_disconnect" | ||
android:orderInCategory="100" | ||
android:showAsAction="never" /> | ||
|
||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="android:Theme.Holo.Light" /> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" /> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<string name="app_name">CrazyflieControl</string> | ||
<string name="hello_world">Hello world!</string> | ||
<string name="menu_disconnect">Disconnect</string> | ||
<string name="title_activity_main">Crazyflie Control</string> | ||
<string name="connect">Connect</string> | ||
<string name="copter_channel">Copter channel:</string> | ||
<string name="menu_connect">Connect</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="android:Theme.Light" /> | ||
|
||
</resources> |
147 changes: 147 additions & 0 deletions
147
src/com/MobileAnarchy/Android/Widgets/Joystick/DualJoystickView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
package com.MobileAnarchy.Android.Widgets.Joystick; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.Paint; | ||
import android.util.AttributeSet; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.LinearLayout; | ||
|
||
public class DualJoystickView extends LinearLayout { | ||
@SuppressWarnings("unused") | ||
private static final String TAG = DualJoystickView.class.getSimpleName(); | ||
|
||
private final boolean D = false; | ||
private Paint dbgPaint1; | ||
|
||
private JoystickView stickL; | ||
private JoystickView stickR; | ||
|
||
private View pad; | ||
|
||
public DualJoystickView(Context context) { | ||
super(context); | ||
stickL = new JoystickView(context); | ||
stickR = new JoystickView(context); | ||
initDualJoystickView(); | ||
} | ||
|
||
public DualJoystickView(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
stickL = new JoystickView(context, attrs); | ||
stickR = new JoystickView(context, attrs); | ||
initDualJoystickView(); | ||
} | ||
|
||
private void initDualJoystickView() { | ||
setOrientation(LinearLayout.HORIZONTAL); | ||
|
||
if ( D ) { | ||
dbgPaint1 = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
dbgPaint1.setColor(Color.CYAN); | ||
dbgPaint1.setStrokeWidth(1); | ||
dbgPaint1.setStyle(Paint.Style.STROKE); | ||
} | ||
|
||
pad = new View(getContext()); | ||
} | ||
|
||
@Override | ||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
super.onMeasure(widthMeasureSpec, heightMeasureSpec); | ||
removeView(stickL); | ||
removeView(stickR); | ||
|
||
float padW = getMeasuredWidth()-(getMeasuredHeight()*2); | ||
int joyWidth = (int) ((getMeasuredWidth()-padW)/2); | ||
LayoutParams joyLParams = new LayoutParams(joyWidth,getMeasuredHeight()); | ||
|
||
stickL.setLayoutParams(joyLParams); | ||
stickR.setLayoutParams(joyLParams); | ||
|
||
stickL.TAG = "L"; | ||
stickR.TAG = "R"; | ||
stickL.setPointerId(JoystickView.INVALID_POINTER_ID); | ||
stickR.setPointerId(JoystickView.INVALID_POINTER_ID); | ||
|
||
addView(stickL); | ||
|
||
ViewGroup.LayoutParams padLParams = new ViewGroup.LayoutParams((int) padW,getMeasuredHeight()); | ||
removeView(pad); | ||
pad.setLayoutParams(padLParams); | ||
addView(pad); | ||
|
||
addView(stickR); | ||
} | ||
|
||
@Override | ||
protected void onLayout(boolean changed, int l, int t, int r, int b) { | ||
super.onLayout(changed, l, t, r, b); | ||
stickR.setTouchOffset(stickR.getLeft(), stickR.getTop()); | ||
} | ||
|
||
public void setAutoReturnToCenter(boolean left, boolean right) { | ||
stickL.setAutoReturnToCenter(left); | ||
stickR.setAutoReturnToCenter(right); | ||
} | ||
|
||
public void setOnJostickMovedListener(JoystickMovedListener left, JoystickMovedListener right) { | ||
stickL.setOnJostickMovedListener(left); | ||
stickR.setOnJostickMovedListener(right); | ||
} | ||
|
||
public void setOnJostickClickedListener(JoystickClickedListener left, JoystickClickedListener right) { | ||
stickL.setOnJostickClickedListener(left); | ||
stickR.setOnJostickClickedListener(right); | ||
} | ||
|
||
public void setYAxisInverted(boolean leftYAxisInverted, boolean rightYAxisInverted) { | ||
stickL.setYAxisInverted(leftYAxisInverted); | ||
stickL.setYAxisInverted(rightYAxisInverted); | ||
} | ||
|
||
public void setMovementConstraint(int movementConstraint) { | ||
stickL.setMovementConstraint(movementConstraint); | ||
stickR.setMovementConstraint(movementConstraint); | ||
} | ||
|
||
public void setMovementRange(float movementRangeLeft, float movementRangeRight) { | ||
stickL.setMovementRange(movementRangeLeft); | ||
stickR.setMovementRange(movementRangeRight); | ||
} | ||
|
||
public void setMoveResolution(float leftMoveResolution, float rightMoveResolution) { | ||
stickL.setMoveResolution(leftMoveResolution); | ||
stickR.setMoveResolution(rightMoveResolution); | ||
} | ||
|
||
public void setUserCoordinateSystem(int leftCoordinateSystem, int rightCoordinateSystem) { | ||
stickL.setUserCoordinateSystem(leftCoordinateSystem); | ||
stickR.setUserCoordinateSystem(rightCoordinateSystem); | ||
} | ||
|
||
@Override | ||
protected void dispatchDraw(Canvas canvas) { | ||
super.dispatchDraw(canvas); | ||
if (D) { | ||
canvas.drawRect(1, 1, getMeasuredWidth()-1, getMeasuredHeight()-1, dbgPaint1); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean dispatchTouchEvent(MotionEvent ev) { | ||
boolean l = stickL.dispatchTouchEvent(ev); | ||
boolean r = stickR.dispatchTouchEvent(ev); | ||
return l || r; | ||
} | ||
|
||
@Override | ||
public boolean onTouchEvent(MotionEvent ev) { | ||
boolean l = stickL.onTouchEvent(ev); | ||
boolean r = stickR.onTouchEvent(ev); | ||
return l || r; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/com/MobileAnarchy/Android/Widgets/Joystick/JoystickClickedListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.MobileAnarchy.Android.Widgets.Joystick; | ||
|
||
public interface JoystickClickedListener { | ||
public void OnClicked(); | ||
public void OnReleased(); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/com/MobileAnarchy/Android/Widgets/Joystick/JoystickMovedListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.MobileAnarchy.Android.Widgets.Joystick; | ||
|
||
public interface JoystickMovedListener { | ||
public void OnMoved(int pan, int tilt); | ||
public void OnReleased(); | ||
public void OnReturnedToCenter(); | ||
} |
Oops, something went wrong.