Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
2439905184 committed Jun 28, 2020
0 parents commit 4ffa173
Show file tree
Hide file tree
Showing 63 changed files with 3,363 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.application'

android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 27

defaultConfig {
applicationId "com.my.newproject"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:support-v4:27.0.2
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
}
apply plugin: 'com.google.gms.google-services'
57 changes: 57 additions & 0 deletions app/build/bin/injected/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.newproject">

<uses-sdk
android:minSdkVersion="1"
android:targetSdkVersion="1"/>

<application
android:allowBackup="true"
android:label="积木编程"
android:icon="@drawable/app_icon"
android:largeHeap="true"
android:theme="@style/AppTheme">

<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait">

<intent-filter>

<action
android:name="android.intent.action.MAIN"/>

<category
android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

<activity
android:name=".EditorActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>

<activity
android:name=".SourceCodeActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>

<activity
android:name=".GgameActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>

<activity
android:name=".FunctionListActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>

</application>

</manifest>

6 changes: 6 additions & 0 deletions app/build/bin/injected/gen/com/my/newproject/BuildConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package com.my.newproject;

public final class BuildConfig {
public final static boolean DEBUG = true;
}
Binary file added app/build/bin/res/drawable-xhdpi/app_icon.png
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.
Binary file added app/build/bin/res/drawable-xhdpi/default_image.png
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.
Binary file added app/build/bin/res/drawable-xhdpi/ji1.png
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.
Binary file added app/build/bin/res/drawable-xhdpi/xoc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/build/gen/com/my/newproject/BuildConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** Automatically generated file. DO NOT MODIFY */
package com.my.newproject;

public final class BuildConfig {
public final static boolean DEBUG = true;
}
36 changes: 36 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.newproject">
<application
android:allowBackup="true"
android:label="积木编程"
android:icon="@drawable/app_icon"
android:largeHeap="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".EditorActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>
<activity
android:name=".SourceCodeActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>
<activity
android:name=".GgameActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>
<activity
android:name=".FunctionListActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"/>
</application>
</manifest>
111 changes: 111 additions & 0 deletions app/src/main/java/com/my/newproject/BluetoothConnect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.my.newproject;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.UUID;

public class BluetoothConnect {
private static final String DEFAULT_UUID = "00001101-0000-1000-8000-00805F9B34FB";

private Activity activity;

private BluetoothAdapter bluetoothAdapter;

public BluetoothConnect(Activity activity) {
this.activity = activity;
this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}

public boolean isBluetoothEnabled() {
if(bluetoothAdapter != null) return true;

return false;
}

public boolean isBluetoothActivated() {
if(bluetoothAdapter == null) return false;

return bluetoothAdapter.isEnabled();
}

public void activateBluetooth() {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
activity.startActivity(intent);
}

public String getRandomUUID() {
return String.valueOf(UUID.randomUUID());
}

public void getPairedDevices(ArrayList<HashMap<String, Object>> results) {
Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();

if(pairedDevices.size() > 0) {
for(BluetoothDevice device : pairedDevices) {
HashMap<String, Object> result = new HashMap<>();
result.put("name", device.getName());
result.put("address", device.getAddress());

results.add(result);
}
}
}

public void readyConnection(BluetoothConnectionListener listener, String tag) {
if(BluetoothController.getInstance().getState().equals(BluetoothController.STATE_NONE)) {
BluetoothController.getInstance().start(this, listener, tag, UUID.fromString(DEFAULT_UUID), bluetoothAdapter);
}
}

public void readyConnection(BluetoothConnectionListener listener, String uuid, String tag) {
if(BluetoothController.getInstance().getState().equals(BluetoothController.STATE_NONE)) {
BluetoothController.getInstance().start(this, listener, tag, UUID.fromString(uuid), bluetoothAdapter);
}
}


public void startConnection(BluetoothConnectionListener listener, String address, String tag) {
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address);

BluetoothController.getInstance().connect(device, this, listener, tag, UUID.fromString(DEFAULT_UUID), bluetoothAdapter);
}

public void startConnection(BluetoothConnectionListener listener, String uuid, String address, String tag) {
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(address);

BluetoothController.getInstance().connect(device, this, listener, tag, UUID.fromString(uuid), bluetoothAdapter);
}

public void stopConnection(BluetoothConnectionListener listener, String tag) {
BluetoothController.getInstance().stop(this, listener, tag);
}

public void sendData(BluetoothConnectionListener listener, String data, String tag) {
String state = BluetoothController.getInstance().getState();

if(!state.equals(BluetoothController.STATE_CONNECTED)) {
listener.onConnectionError(tag, state, "Bluetooth is not connected yet");
return;
}

BluetoothController.getInstance().write(data.getBytes());
}

public Activity getActivity() {
return activity;
}

public interface BluetoothConnectionListener {
void onConnected(String tag, HashMap<String, Object> deviceData);
void onDataReceived(String tag, byte[] data, int bytes);
void onDataSent(String tag, byte[] data);
void onConnectionError(String tag, String connectionState, String message);
void onConnectionStopped(String tag);
}
}
Loading

0 comments on commit 4ffa173

Please sign in to comment.