-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Kimentii/development
Добавление ветки с android приложением.
- Loading branch information
Showing
128 changed files
with
3,560 additions
and
1,607 deletions.
There are no files selected for viewing
27 changes: 18 additions & 9 deletions
27
...stApplication/TrackPlatformAPI/.gitignore → code/Java/Mobile/Application2.0/.gitignore
100755 → 100644
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 |
---|---|---|
@@ -1,9 +1,18 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
*.iml | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/captures | ||
.externalNativeBuild | ||
*.log | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
|
2 changes: 1 addition & 1 deletion
2
...plication/TrackPlatformAPI/app/.gitignore → ...Java/Mobile/Application2.0/app/.gitignore
100755 → 100644
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 |
---|---|---|
@@ -1 +1 @@ | ||
/build | ||
/build |
63 changes: 32 additions & 31 deletions
63
...ication/TrackPlatformAPI/app/build.gradle → ...va/Mobile/Application2.0/app/build.gradle
100755 → 100644
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 |
---|---|---|
@@ -1,31 +1,32 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
defaultConfig { | ||
applicationId "com.example.yuras.trackplatformapi" | ||
minSdkVersion 17 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.1.0' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.2' | ||
compile 'com.android.support:design:25.3.1' | ||
testCompile 'junit:junit:4.12' | ||
} | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '25.0.2' | ||
defaultConfig { | ||
applicationId "com.example.kimentii.application20" | ||
minSdkVersion 17 | ||
targetSdkVersion 17 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
productFlavors { | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.3.1' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.2' | ||
testCompile 'junit:junit:4.12' | ||
} |
42 changes: 25 additions & 17 deletions
42
...n/TrackPlatformAPI/app/proguard-rules.pro → ...ile/Application2.0/app/proguard-rules.pro
100755 → 100644
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 |
---|---|---|
@@ -1,17 +1,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Users\yuras\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Android\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
52 changes: 26 additions & 26 deletions
52
...kplatformapi/ExampleInstrumentedTest.java → ...pplication20/ExampleInstrumentedTest.java
100755 → 100644
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
package com.example.yuras.trackplatformapi; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.example.yuras.trackplatformapi", appContext.getPackageName()); | ||
} | ||
} | ||
package com.example.kimentii.application20; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.example.kimentii.application20", appContext.getPackageName()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
code/Java/Mobile/Application2.0/app/src/main/AndroidManifest.xml
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,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.kimentii.application20"> | ||
|
||
<uses-permission android:name="android.permission.BLUETOOTH" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".activities.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".activities.MotionActivity" | ||
android:parentActivityName=".activities.MainActivity"/> | ||
<activity | ||
android:name=".activities.SensorsActivity" | ||
android:parentActivityName=".activities.MainActivity"/> | ||
<activity | ||
android:name=".activities.ServoActivity" | ||
android:parentActivityName=".activities.MainActivity"/> | ||
<activity | ||
android:name=".activities.SettingsActivity" | ||
android:parentActivityName=".activities.MainActivity"> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
164 changes: 164 additions & 0 deletions
164
...tion2.0/app/src/main/java/com/example/kimentii/application20/activities/MainActivity.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,164 @@ | ||
package com.example.kimentii.application20.activities; | ||
|
||
import android.bluetooth.BluetoothAdapter; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.Message; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
import com.example.kimentii.application20.R; | ||
import com.example.kimentii.application20.connectors.BluetoothConnector; | ||
import com.example.kimentii.application20.settings.Settings; | ||
import com.example.kimentii.application20.wrappers.LanguageWrapper; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
public static final String TAG = "TAG"; | ||
private static final int REQUEST_ENABLE_BT = 1; | ||
|
||
private Button motionButton; | ||
private Button servoButton; | ||
private Button sensorsButton; | ||
private Button settingsButton; | ||
private Button exitButton; | ||
private TextView connectionStateTextView; | ||
|
||
private BluetoothConnector bluetoothConnector; | ||
|
||
class Listener implements View.OnClickListener { | ||
Intent intent; | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.motion_button: | ||
intent = MotionActivity.newIntent(getApplicationContext()); | ||
startActivity(intent); | ||
break; | ||
case R.id.servo_button: | ||
intent = ServoActivity.newIntent(getApplicationContext()); | ||
startActivity(intent); | ||
break; | ||
case R.id.sensors_button: | ||
intent = SensorsActivity.newIntent(getApplicationContext()); | ||
startActivity(intent); | ||
break; | ||
case R.id.settings_button: | ||
intent = SettingsActivity.newIntent(getApplicationContext()); | ||
startActivity(intent); | ||
break; | ||
case R.id.exit_button: | ||
try { | ||
if (bluetoothConnector != null) { | ||
bluetoothConnector.disconnect(); | ||
bluetoothConnector.join(); | ||
} | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
finish(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
private void updateConnectionStateView() { | ||
if (bluetoothConnector != null && bluetoothConnector.isConnected()) { | ||
connectionStateTextView.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.CONNECTED)); | ||
} else { | ||
connectionStateTextView.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.NO_CONNECTION)); | ||
} | ||
} | ||
|
||
private void setLocaleLanguage() { | ||
updateConnectionStateView(); | ||
// buttons | ||
motionButton.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.MOTION_BUTTON)); | ||
servoButton.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.SERVO_BUTTON)); | ||
sensorsButton.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.SENSORS_BUTTON)); | ||
settingsButton.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.SETTINGS_BUTTON)); | ||
exitButton.setText(Settings.getInstance().getLanguageWrapper(). | ||
getViewString(LanguageWrapper.EXIT_BUTTON)); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Listener listener = new Listener(); | ||
motionButton = (Button) findViewById(R.id.motion_button); | ||
servoButton = (Button) findViewById(R.id.servo_button); | ||
sensorsButton = (Button) findViewById(R.id.sensors_button); | ||
settingsButton = (Button) findViewById(R.id.settings_button); | ||
exitButton = (Button) findViewById(R.id.exit_button); | ||
connectionStateTextView = (TextView) findViewById(R.id.connection_state_tv_main_activity); | ||
motionButton.setOnClickListener(listener); | ||
servoButton.setOnClickListener(listener); | ||
sensorsButton.setOnClickListener(listener); | ||
settingsButton.setOnClickListener(listener); | ||
exitButton.setOnClickListener(listener); | ||
setLocaleLanguage(); | ||
|
||
|
||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); | ||
if (bluetoothAdapter == null) { | ||
connectionStateTextView.setText(R.string.have_no_bluetooth_module); | ||
Log.d(TAG, "You have no bluetooth."); | ||
} | ||
if (bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { | ||
Handler handler = new Handler() { | ||
@Override | ||
public void handleMessage(Message msg) { | ||
super.handleMessage(msg); | ||
|
||
} | ||
}; | ||
bluetoothConnector = BluetoothConnector.getInstance(); | ||
bluetoothConnector.connect(); | ||
bluetoothConnector.setHandler(handler); | ||
updateConnectionStateView(); | ||
} else { | ||
// Bluetooth выключен. Предложим пользователю включить его. | ||
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); | ||
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
setLocaleLanguage(); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
super.onActivityResult(requestCode, resultCode, data); | ||
if (requestCode == REQUEST_ENABLE_BT && requestCode == RESULT_OK) { | ||
Log.d(TAG, "Bluetooth connected"); | ||
Handler handler = new Handler() { | ||
@Override | ||
public void handleMessage(Message msg) { | ||
super.handleMessage(msg); | ||
|
||
} | ||
}; | ||
bluetoothConnector = BluetoothConnector.getInstance(); | ||
bluetoothConnector.connect(); | ||
bluetoothConnector.setHandler(handler); | ||
updateConnectionStateView(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.