mirror of
https://github.com/etlegacy/JoyStick.git
synced 2025-04-20 00:10:47 +00:00
Compare commits
No commits in common. "master" and "v1.1.0" have entirely different histories.
25 changed files with 160 additions and 634 deletions
38
.github/workflows/build.yaml
vendored
38
.github/workflows/build.yaml
vendored
|
@ -1,38 +0,0 @@
|
|||
name: Publish package to GitHub Packages
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
name: Checkout sources
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
name: Setup Java 17
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
|
||||
- name: Build and publish
|
||||
run: ./gradlew publish --no-daemon --info
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -32,5 +32,9 @@ proguard-project.txt
|
|||
local.properties
|
||||
|
||||
#gradle
|
||||
build
|
||||
.gradle
|
||||
signing.properties
|
||||
gradle
|
||||
gradlew
|
||||
gradlew.bat
|
||||
signing.properties
|
57
README.md
57
README.md
|
@ -1,38 +1,48 @@
|
|||
# JoyStick
|
||||
Android Library for JoyStick View.
|
||||
|
||||
Android Library for JoyStick View.<br>
|
||||
Customizable, small and lightweight.
|
||||
|
||||
## Sample App
|
||||

|
||||
[](https://bintray.com/erz05/maven/JoyStick/_latestVersion) [](http://android-arsenal.com/details/1/2712)
|
||||
|
||||

|
||||
<H2>Sample App</H2>
|
||||
<img height="70px" src="https://github.com/erz05/JoyStick/blob/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" />
|
||||
<a href="https://play.google.com/store/apps/details?id=com.erz.joystick&utm_source=global_co&utm_medium=prtnr&utm_content=Mar2515&utm_campaign=PartBadge&pcampaignid=MKT-AC-global-none-all-co-pr-py-PartBadges-Oct1515-1"><img height="70px" alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/apps/en-play-badge.png" /></a>
|
||||
|
||||

|
||||
<img width="300px" src="https://github.com/erz05/JoyStick/blob/master/images/Screenshot_2015-10-30-21-38-13.png" />
|
||||
<br><br>
|
||||
<img width="300px" src="https://github.com/erz05/JoyStick/blob/master/images/Screenshot_2015-10-30-21-43-47.png" />
|
||||
<br><br>
|
||||
JoyStick with Image for button<br>
|
||||
<img width="300px" src="https://github.com/erz05/JoyStick/blob/master/images/Screenshot_2015-11-02-18-05-49.png" />
|
||||
<br>
|
||||
|
||||
## Usage
|
||||
Gradle Import: This github repository
|
||||
<H2>Usage</H2>
|
||||
Gradle Import: jcenter <br>
|
||||
|
||||
```groovy
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url uri("https://maven.pkg.github.com/etlegacy/JoyStick")
|
||||
url "http://dl.bintray.com/erz05/maven"
|
||||
}
|
||||
|
||||
//Or
|
||||
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.etlegacy.android:JoyStick:1.2.0'
|
||||
compile 'com.github.erz05:JoyStick:1.1.0'
|
||||
}
|
||||
```
|
||||
|
||||
## v1.1.0 BREAKING CHANGE!
|
||||
<H2>v1.1.0 BREAKING CHANGE!</H2>
|
||||
|
||||
* Made changes to JoyStickListener
|
||||
* Added Direction to onMove
|
||||
* Added Event calls for onTap and onDoubleTap
|
||||
1. Made changes to JoyStickListener<br>
|
||||
a. Added Direction to onMove<br>
|
||||
b. Added Event calls for onTap and onDoubleTap<br>
|
||||
|
||||
## Defaults:
|
||||
<H2>Defaults:</H2>
|
||||
|
||||
1. Background = White
|
||||
2. Button = Red
|
||||
|
@ -40,7 +50,7 @@ dependencies {
|
|||
4. StayPut = false
|
||||
5. Directional-Axis = 8
|
||||
|
||||
## Setup:
|
||||
<H2>Setup:</H2>
|
||||
|
||||
```xml
|
||||
<com.erz.joysticklibrary.JoyStick
|
||||
|
@ -49,7 +59,6 @@ dependencies {
|
|||
android:layout_height="200dp"
|
||||
android:layout_gravity="bottom"/>
|
||||
|
||||
<!-- default 25: radius percentage of full size of the view between 25% and 50% -->
|
||||
<com.erz.joysticklibrary.JoyStick
|
||||
android:id="@+id/joy2"
|
||||
android:layout_width="200dp"
|
||||
|
@ -58,20 +67,20 @@ dependencies {
|
|||
app:padColor="#55ffffff"
|
||||
app:buttonColor="#55ff0000"
|
||||
app:stayPut="true"
|
||||
app:percentage="25"
|
||||
app:percentage="25" //default 25: radius percentage of full size of the view between 25% and 50%
|
||||
app:backgroundDrawable="R.drawable.background"
|
||||
app:buttonDrawable="R.drawable.button"/>
|
||||
```
|
||||
|
||||
```java
|
||||
JoyStick joyStick = findViewById(R.id.joyStick);
|
||||
JoyStick joyStick = (JoyStick) findViewById(R.id.joyStick);
|
||||
|
||||
//or
|
||||
|
||||
JoyStick joyStick = new JoyStick(context);
|
||||
```
|
||||
|
||||
## JoyStickListener:
|
||||
<H2>JoyStickListener:</H2>
|
||||
|
||||
```java
|
||||
//JoyStickListener Interface
|
||||
|
@ -88,7 +97,7 @@ joyStick.setListener(this);
|
|||
2. onTap: gets called onSingleTapConfirmed
|
||||
3. onDoubleTap: gets called onDoubleTap
|
||||
|
||||
## Directions:
|
||||
<H2>Directions:</H2>
|
||||
1. DIRECTION_CENTER = -1
|
||||
2. DIRECTION_LEFT = 0
|
||||
3. DIRECTION_LEFT_UP = 1
|
||||
|
@ -106,7 +115,7 @@ joyStick.getDirection();
|
|||
```
|
||||
or get it from the JoyStickListener
|
||||
|
||||
## Axis Types:
|
||||
<H2>Axis Types:</H2>
|
||||
1. TYPE_8_AXIS
|
||||
2. TYPE_4_AXIS
|
||||
3. TYPE_2_AXIS_LEFT_RIGHT
|
||||
|
@ -118,7 +127,7 @@ To set Axis Type:
|
|||
joyStick.setType(JoyStick.TYPE_4_AXIS);
|
||||
```
|
||||
|
||||
## Getters/Setters
|
||||
<H2>Getters/Setters</H2>
|
||||
|
||||
```java
|
||||
//Set GamePad Color
|
||||
|
@ -149,7 +158,7 @@ joyStick.getAngle();
|
|||
joyStick.getAngleDegrees();
|
||||
```
|
||||
|
||||
## License
|
||||
<H2>License</H2>
|
||||
Copyright 2015 erz05
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
namespace "com.erz.joystick"
|
||||
compileSdk 33
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "26.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.erz.joystick"
|
||||
minSdkVersion 31
|
||||
targetSdk 33
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
@ -19,13 +17,13 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(path: ':joysticklibrary')
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||
compile 'com.android.support:design:26.1.0'
|
||||
// compile 'com.github.erz05:JoyStick:1.1.0'
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.erz.joystick;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
|
@ -3,18 +3,19 @@
|
|||
package="com.erz.joystick">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:exported="true"
|
||||
android:label="@string/title_activity_fullscreen"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:configChanges="orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
|
|
@ -9,8 +9,10 @@ import android.view.SurfaceView;
|
|||
public class GameLoop extends Thread {
|
||||
private static final long FPS = 24;
|
||||
private static final long ticksPS = 1000 / FPS;
|
||||
private final SurfaceView view;
|
||||
private SurfaceView view;
|
||||
private boolean running = false;
|
||||
private long startTime;
|
||||
private long sleepTime;
|
||||
private Canvas canvas;
|
||||
|
||||
public GameLoop(SurfaceView view) {
|
||||
|
@ -24,7 +26,7 @@ public class GameLoop extends Thread {
|
|||
@Override
|
||||
public void run() {
|
||||
while (running) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
startTime = System.currentTimeMillis();
|
||||
try {
|
||||
canvas = view.getHolder().lockCanvas();
|
||||
synchronized (view.getHolder()) {
|
||||
|
@ -35,14 +37,12 @@ public class GameLoop extends Thread {
|
|||
view.getHolder().unlockCanvasAndPost(canvas);
|
||||
}
|
||||
}
|
||||
long sleepTime = ticksPS - (System.currentTimeMillis() - startTime);
|
||||
if (sleepTime <= 0) {
|
||||
sleepTime = 20;
|
||||
}
|
||||
|
||||
sleepTime = ticksPS - (System.currentTimeMillis() - startTime);
|
||||
try {
|
||||
//noinspection BusyWait
|
||||
sleep(sleepTime);
|
||||
if (sleepTime > 0)
|
||||
sleep(sleepTime);
|
||||
else
|
||||
sleep(10);
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Vector;
|
|||
public class GameView extends SurfaceView implements SurfaceHolder.Callback {
|
||||
|
||||
private int i;
|
||||
private final int size = 20;
|
||||
private int size = 20;
|
||||
private int minSpeed;
|
||||
private int maxSpeed;
|
||||
private int minRadius;
|
||||
|
@ -33,12 +33,12 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
private double angle;
|
||||
private double power;
|
||||
private double angle2;
|
||||
private final Bitmap droid;
|
||||
private Bitmap droid;
|
||||
private GameLoop gameLoop;
|
||||
private final Paint paint;
|
||||
private final Vector<Star> stars = new Vector<>();
|
||||
private Paint paint;
|
||||
private Vector<Star> stars = new Vector<>();
|
||||
private RectF rectF = new RectF();
|
||||
private final Random random = new Random();
|
||||
private Random random = new Random();
|
||||
|
||||
public GameView(Context context) {
|
||||
this(context, null);
|
||||
|
@ -57,7 +57,6 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
if (canvas == null) return;
|
||||
canvas.drawColor(Color.BLACK);
|
||||
|
||||
|
@ -95,8 +94,8 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
this.height = height;
|
||||
float min = Math.min(width, height);
|
||||
|
||||
float centerX = (float) width / 2;
|
||||
float centerY = (float) height / 2;
|
||||
float centerX = width / 2;
|
||||
float centerY = height / 2;
|
||||
posX = centerX;
|
||||
posY = centerY;
|
||||
radius = min / 12;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.erz.joystick;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.erz.joysticklibrary.JoyStick;
|
||||
|
||||
public class MainActivity extends Activity implements JoyStick.JoyStickListener {
|
||||
public class MainActivity extends AppCompatActivity implements JoyStick.JoyStickListener {
|
||||
|
||||
private GameView gameView;
|
||||
|
||||
|
@ -15,13 +14,13 @@ public class MainActivity extends Activity implements JoyStick.JoyStickListener
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
gameView = findViewById(R.id.game);
|
||||
JoyStick joy1 = findViewById(R.id.joy1);
|
||||
gameView = (GameView) findViewById(R.id.game);
|
||||
JoyStick joy1 = (JoyStick) findViewById(R.id.joy1);
|
||||
joy1.setListener(this);
|
||||
joy1.setPadColor(Color.parseColor("#55ffffff"));
|
||||
joy1.setButtonColor(Color.parseColor("#55ff0000"));
|
||||
|
||||
JoyStick joy2 = findViewById(R.id.joy2);
|
||||
JoyStick joy2 = (JoyStick) findViewById(R.id.joy2);
|
||||
joy2.setListener(this);
|
||||
joy2.enableStayPut(true);
|
||||
joy2.setPadBackground(R.drawable.pad);
|
||||
|
@ -30,14 +29,13 @@ public class MainActivity extends Activity implements JoyStick.JoyStickListener
|
|||
|
||||
@Override
|
||||
public void onMove(JoyStick joyStick, double angle, double power, int direction) {
|
||||
int id = joyStick.getId();
|
||||
|
||||
if (id == R.id.joy1) {
|
||||
gameView.move(angle, power);
|
||||
} else if(id == R.id.joy2) {
|
||||
gameView.rotate(angle);
|
||||
} else {
|
||||
Log.w("onMove", "Wrong id detected on the move");
|
||||
switch (joyStick.getId()) {
|
||||
case R.id.joy1:
|
||||
gameView.move(angle, power);
|
||||
break;
|
||||
case R.id.joy2:
|
||||
gameView.rotate(angle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/fullscreenBackgroundColor"
|
||||
android:theme="@style/ThemeOverlay.Etlegacyjoystick.FullscreenContainer"
|
||||
tools:context=".MainActivity">
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.erz.joystick.GameView
|
||||
android:id="@+id/game"
|
||||
|
@ -23,6 +19,6 @@
|
|||
android:id="@+id/joy2"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_gravity="bottom|end"/>
|
||||
android:layout_gravity="bottom|right"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,7 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<style name="ThemeOverlay.Etlegacyjoystick.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_900</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A400</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -1,6 +0,0 @@
|
|||
<resources>
|
||||
<declare-styleable name="FullscreenAttrs">
|
||||
<attr name="fullscreenBackgroundColor" format="color" />
|
||||
<attr name="fullscreenTextColor" format="color" />
|
||||
</declare-styleable>
|
||||
</resources>
|
|
@ -3,9 +3,4 @@
|
|||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="light_blue_600">#FF039BE5</color>
|
||||
<color name="light_blue_900">#FF01579B</color>
|
||||
<color name="light_blue_A200">#FF40C4FF</color>
|
||||
<color name="light_blue_A400">#FF00B0FF</color>
|
||||
<color name="black_overlay">#66000000</color>
|
||||
</resources>
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">JoyStick</string>
|
||||
<string name="title_activity_fullscreen">FullscreenActivity</string>
|
||||
<string name="dummy_button">Dummy Button</string>
|
||||
<string name="dummy_content">DUMMY\nCONTENT</string>
|
||||
</resources>
|
|
@ -21,13 +21,4 @@
|
|||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
<style name="Widget.AppTheme.ActionBar.Fullscreen" parent="Widget.AppCompat.ActionBar">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.AppTheme.ButtonBar.Fullscreen" parent="">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
<item name="android:buttonBarStyle">?android:attr/buttonBarStyle</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<style name="AppTheme.Fullscreen" parent="AppTheme">
|
||||
<item name="android:actionBarStyle">@style/Widget.AppTheme.ActionBar.Fullscreen</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowBackground">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.Etlegacyjoystick.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A200</item>
|
||||
</style>
|
||||
</resources>
|
15
app/src/test/java/com/erz/joystick/ExampleUnitTest.java
Normal file
15
app/src/test/java/com/erz/joystick/ExampleUnitTest.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package com.erz.joystick;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view.
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
49
build.gradle
49
build.gradle
|
@ -3,58 +3,23 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
def parseGitVersion() {
|
||||
def major = 1
|
||||
def minor = 2
|
||||
def patch = 0
|
||||
def postfix = '-UNKNOWN'
|
||||
def hash = ''
|
||||
def output = 'git describe --long --tags --dirty --always'.execute().text.trim()
|
||||
project.logger.info("Ran git describe with the output: {}", output)
|
||||
(output =~ /^v(\d+)\.(\d+)\.(\d+)-(\d+)-(\w+)/).each { match, majorVal, minorVal, patchVal, commitVal, hashVal ->
|
||||
if (output.toLowerCase().endsWith('-dirty')) {
|
||||
patchVal = (patchVal as int + 1) as String
|
||||
postfix = '-DIRTY'
|
||||
} else if(commitVal as int > 0) {
|
||||
patchVal = (patchVal as int + 1) as String
|
||||
postfix = '-SNAPSHOT'
|
||||
} else {
|
||||
postfix = ''
|
||||
}
|
||||
|
||||
major = majorVal as int
|
||||
minor = minorVal as int
|
||||
patch = patchVal as int
|
||||
hash = hashVal
|
||||
}
|
||||
def outputHash = [version: "${major}.${minor}.${patch}${postfix}", hash: hash]
|
||||
project.logger.info("Parsed version: {}", outputHash.version)
|
||||
return outputHash
|
||||
}
|
||||
|
||||
def versionInfo = parseGitVersion()
|
||||
|
||||
version = versionInfo.version
|
||||
def root = project
|
||||
|
||||
subprojects { Project ch ->
|
||||
ch.version = root.version
|
||||
ch.repositories {
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('clean', Delete) {
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +0,0 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
244
gradlew
vendored
244
gradlew
vendored
|
@ -1,244 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
92
gradlew.bat
vendored
92
gradlew.bat
vendored
|
@ -1,92 +0,0 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -1,15 +1,13 @@
|
|||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'maven-publish'
|
||||
}
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.novoda.bintray-release'
|
||||
|
||||
android {
|
||||
namespace "com.erz.joysticklibrary"
|
||||
compileSdk 33
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion "27.0.3"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 26
|
||||
targetSdk 33
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
versionCode 2
|
||||
versionName "1.1"
|
||||
}
|
||||
|
@ -19,67 +17,23 @@ android {
|
|||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
publishing {
|
||||
singleVariant("release") {
|
||||
withSourcesJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = 'com.etlegacy.android'
|
||||
artifactId = 'joystick'
|
||||
version = project.version
|
||||
|
||||
pom {
|
||||
name = 'Android JoyStick library'
|
||||
description = 'Android Library for JoyStick View'
|
||||
url = 'https://github.com/etlegacy/JoyStick'
|
||||
/*
|
||||
developers {
|
||||
developer {
|
||||
id = 'johnd'
|
||||
name = 'John Doe'
|
||||
email = 'john.doe@etlegacy.com'
|
||||
}
|
||||
}
|
||||
*/
|
||||
scm {
|
||||
connection = 'scm:git:git@github.com:etlegacy/JoyStick.git'
|
||||
url = 'https://github.com/etlegacy/JoyStick.git'
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
from components.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
if (System.getenv("GITHUB_ACTOR") != null) {
|
||||
maven {
|
||||
name = "GitHubPackages"
|
||||
url = "https://maven.pkg.github.com/etlegacy/JoyStick"
|
||||
credentials {
|
||||
username = System.getenv("GITHUB_ACTOR")
|
||||
password = System.getenv("GITHUB_TOKEN")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
maven {
|
||||
def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
|
||||
def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
|
||||
url = (project.version as String).endsWith("-SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
|
||||
}
|
||||
}
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.novoda:bintray-release:0.7.0'
|
||||
}
|
||||
}
|
||||
|
||||
assemble {
|
||||
doFirst {
|
||||
println("Assembling version: ${project.version}")
|
||||
}
|
||||
}
|
||||
publish {
|
||||
userOrg = 'erz05'
|
||||
groupId = 'com.github.erz05'
|
||||
artifactId = 'JoyStick'
|
||||
version = '1.1.0'
|
||||
description = 'Android Library for JoyStick View'
|
||||
website = 'https://github.com/erz05/JoyStick'
|
||||
}
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.erz.joysticklibrary;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -33,7 +32,6 @@ import android.view.View;
|
|||
/**
|
||||
* Created by edgarramirez on 10/30/15.
|
||||
* JoyStick view with lots of customizable options
|
||||
* @noinspection unused
|
||||
*/
|
||||
public class JoyStick extends View implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
|
||||
|
||||
|
@ -53,9 +51,9 @@ public class JoyStick extends View implements GestureDetector.OnGestureListener,
|
|||
public static final int TYPE_2_AXIS_UP_DOWN = 44;
|
||||
|
||||
private JoyStickListener listener;
|
||||
private final Paint paint;
|
||||
private final RectF temp;
|
||||
private final GestureDetector gestureDetector;
|
||||
private Paint paint;
|
||||
private RectF temp;
|
||||
private GestureDetector gestureDetector;
|
||||
private int direction = DIRECTION_CENTER;
|
||||
private int type = TYPE_8_AXIS;
|
||||
private float centerX;
|
||||
|
@ -113,28 +111,29 @@ public class JoyStick extends View implements GestureDetector.OnGestureListener,
|
|||
padColor = Color.WHITE;
|
||||
buttonColor = Color.RED;
|
||||
|
||||
if (attrs == null) {
|
||||
return;
|
||||
}
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.JoyStick);
|
||||
if (typedArray != null) {
|
||||
padColor = typedArray.getColor(R.styleable.JoyStick_padColor, Color.WHITE);
|
||||
buttonColor = typedArray.getColor(R.styleable.JoyStick_buttonColor, Color.RED);
|
||||
stayPut = typedArray.getBoolean(R.styleable.JoyStick_stayPut, false);
|
||||
percentage = typedArray.getInt(R.styleable.JoyStick_percentage, 25);
|
||||
if (percentage > 50) percentage = 50;
|
||||
if (percentage < 25) percentage = 25;
|
||||
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.JoyStick);
|
||||
padColor = typedArray.getColor(R.styleable.JoyStick_padColor, Color.WHITE);
|
||||
buttonColor = typedArray.getColor(R.styleable.JoyStick_buttonColor, Color.RED);
|
||||
stayPut = typedArray.getBoolean(R.styleable.JoyStick_stayPut, false);
|
||||
percentage = typedArray.getInt(R.styleable.JoyStick_percentage, 25);
|
||||
if (percentage > 50) percentage = 50;
|
||||
if (percentage < 25) percentage = 25;
|
||||
int padResId = typedArray.getResourceId(R.styleable.JoyStick_backgroundDrawable, -1);
|
||||
int buttonResId = typedArray.getResourceId(R.styleable.JoyStick_buttonDrawable, -1);
|
||||
|
||||
int padResId = typedArray.getResourceId(R.styleable.JoyStick_backgroundDrawable, -1);
|
||||
int buttonResId = typedArray.getResourceId(R.styleable.JoyStick_buttonDrawable, -1);
|
||||
if (padResId > 0) {
|
||||
padBGBitmap = BitmapFactory.decodeResource(getResources(), padResId);
|
||||
}
|
||||
if (buttonResId > 0) {
|
||||
buttonBitmap = BitmapFactory.decodeResource(getResources(), buttonResId);
|
||||
}
|
||||
|
||||
if (padResId > 0) {
|
||||
padBGBitmap = BitmapFactory.decodeResource(getResources(), padResId);
|
||||
typedArray.recycle();
|
||||
}
|
||||
}
|
||||
if (buttonResId > 0) {
|
||||
buttonBitmap = BitmapFactory.decodeResource(getResources(), buttonResId);
|
||||
}
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,7 +169,6 @@ public class JoyStick extends View implements GestureDetector.OnGestureListener,
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
gestureDetector.onTouchEvent(event);
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
rootProject.name = 'JoyStick'
|
||||
include ':app', ':joysticklibrary'
|
||||
|
|
Loading…
Reference in a new issue