이수민

최종보고서 수정

Showing 86 changed files with 2694 additions and 2694 deletions
No preview for this file type
*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
*.iml
.gradle
/local.properties
/.idea/caches/build_file_checksums.ser
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
......
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
\ No newline at end of file
......
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.suemin.smartwindow"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.suemin.smartwindow"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
......
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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
......
package com.example.suemin.smartwindow;
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.*;
/**
* Instrumented 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() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.suemin.smartwindow", appContext.getPackageName());
}
}
package com.example.suemin.smartwindow;
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.*;
/**
* Instrumented 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() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.suemin.smartwindow", appContext.getPackageName());
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.suemin.smartwindow">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<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="com.example.suemin.smartwindow.view.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.example.suemin.smartwindow.view.bluetooth.BluetoothLeService"/>
</application>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.suemin.smartwindow">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<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="com.example.suemin.smartwindow.view.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.example.suemin.smartwindow.view.bluetooth.BluetoothLeService"/>
</application>
</manifest>
\ No newline at end of file
......
# Created by .ignore support plugin (hsz.mobi)
### Android template
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# Created by .ignore support plugin (hsz.mobi)
### Android template
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
......
package com.example.suemin.smartwindow.view;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;
import android.support.v7.widget.Toolbar;
import com.example.suemin.smartwindow.R;
import com.example.suemin.smartwindow.view.bluetooth.Bluetooth;
import com.example.suemin.smartwindow.view.environment.Env;
import com.example.suemin.smartwindow.view.home.Home;
public class MainActivity extends AppCompatActivity {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction;
Toolbar tb;
public static final String NOTIFICATION_CHANNEL_ID = "10001";
private int count = 0;
public static NotificationManager notificationManager;
public static NotificationCompat.Builder builder;
private static Uri sounduri;
Home homeFragment = new Home();
Env envFragment = new Env();
Bluetooth bluetoothFragment = new Bluetooth();
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
fragmentTransaction = fragmentManager.beginTransaction();
switch (item.getItemId()) {
case R.id.navigation_home:
replaceFragment(homeFragment);
return true;
case R.id.navigation_env:
replaceFragment(envFragment);
return true;
case R.id.navigation_bt:
replaceFragment(bluetoothFragment);
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tb = (Toolbar) findViewById(R.id.tb);
setSupportActionBar(tb);
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frameLayout, homeFragment).commitAllowingStateLoss();
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.icon_i2))
.setContentTitle("침입자 알림")
.setContentText("침입자가 감지되었습니다")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);
sounduri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.noti_sound);
}
public void replaceFragment(Fragment fragment) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frameLayout, fragment).commit();
}
public static void NotificationSomethings() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setSmallIcon(R.drawable.icon);
CharSequence channelName = "channelname";
String description = "description";
int importance = NotificationManager.IMPORTANCE_HIGH;
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
.build();
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName , importance);
channel.setDescription(description);
channel.enableLights(true);
channel.setLightColor(Color.RED);
channel.setSound(sounduri, audioAttributes);
channel.enableVibration(true);
channel.setVibrationPattern(new long[] {100,200,300,200});
assert notificationManager != null;
notificationManager.createNotificationChannel(channel);
}else builder.setSmallIcon(R.mipmap.ic_launcher);
assert notificationManager != null;
notificationManager.notify(1234, builder.build());
}
}
package com.example.suemin.smartwindow.view;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;
import android.support.v7.widget.Toolbar;
import com.example.suemin.smartwindow.R;
import com.example.suemin.smartwindow.view.bluetooth.Bluetooth;
import com.example.suemin.smartwindow.view.environment.Env;
import com.example.suemin.smartwindow.view.home.Home;
public class MainActivity extends AppCompatActivity {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction;
Toolbar tb;
public static final String NOTIFICATION_CHANNEL_ID = "10001";
private int count = 0;
public static NotificationManager notificationManager;
public static NotificationCompat.Builder builder;
private static Uri sounduri;
Home homeFragment = new Home();
Env envFragment = new Env();
Bluetooth bluetoothFragment = new Bluetooth();
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
fragmentTransaction = fragmentManager.beginTransaction();
switch (item.getItemId()) {
case R.id.navigation_home:
replaceFragment(homeFragment);
return true;
case R.id.navigation_env:
replaceFragment(envFragment);
return true;
case R.id.navigation_bt:
replaceFragment(bluetoothFragment);
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tb = (Toolbar) findViewById(R.id.tb);
setSupportActionBar(tb);
fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frameLayout, homeFragment).commitAllowingStateLoss();
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.icon_i2))
.setContentTitle("침입자 알림")
.setContentText("침입자가 감지되었습니다")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setAutoCancel(true);
sounduri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.noti_sound);
}
public void replaceFragment(Fragment fragment) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.frameLayout, fragment).commit();
}
public static void NotificationSomethings() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setSmallIcon(R.drawable.icon);
CharSequence channelName = "channelname";
String description = "description";
int importance = NotificationManager.IMPORTANCE_HIGH;
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
.build();
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName , importance);
channel.setDescription(description);
channel.enableLights(true);
channel.setLightColor(Color.RED);
channel.setSound(sounduri, audioAttributes);
channel.enableVibration(true);
channel.setVibrationPattern(new long[] {100,200,300,200});
assert notificationManager != null;
notificationManager.createNotificationChannel(channel);
}else builder.setSmallIcon(R.mipmap.ic_launcher);
assert notificationManager != null;
notificationManager.notify(1234, builder.build());
}
}
......
package com.example.suemin.smartwindow.view.bluetooth;
import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.app.ListFragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult;
import java.util.LinkedList;
import java.util.List;
import com.example.suemin.smartwindow.R;
import java.util.ArrayList;
import java.util.Queue;
import static android.content.ContentValues.TAG;
public class Bluetooth extends ListFragment {
private BluetoothAdapter mBluetoothAdapter;
private static BluetoothLeService mBluetoothLeService;
private boolean mScanning;
private Handler mhandler;
private BluetoothLeScanner BLEScanner;
private LeDeviceListAdapter leDeviceListAdapter;
private Queue<BluetoothDevice> connectionQueue;
private Thread connectionThread;
private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics =
new ArrayList<ArrayList<BluetoothGattCharacteristic>>();
private BluetoothGattCharacteristic mNotifyCharacteristic;
private static BluetoothGattCharacteristic motor;
private static final long SCAN_PERIOD = 5000;
private static final int REQUEST_ENABLE_BT = 1;
private static final int MY_LOCATION_REQUEST_CODE = 1;
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 100;
private final int moduleNum = 3;
private boolean mConnected = false;
public static boolean WindowState = false;
public Bluetooth() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mCheckPermission();
}
Intent gattServiceIntent = new Intent(getActivity(), BluetoothLeService.class);
getActivity().bindService(gattServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.btmenu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.navigation_bt) {
if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
}
final BluetoothManager bluetoothManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE);
if (bluetoothManager != null) {
mBluetoothAdapter = bluetoothManager.getAdapter();
}
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
BLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
if (BLEScanner == null) {
Toast.makeText(getActivity(), "Can not find BLE Scanner", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), "블루투스가 활성화되었습니다.", Toast.LENGTH_SHORT).show();
}
}
return super.onOptionsItemSelected(item);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bluetooth, container, false);
setHasOptionsMenu(true);
connectionQueue = new LinkedList<BluetoothDevice>();
Button btFindBtn = (Button) view.findViewById(R.id.bt_find_btn);
btFindBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mhandler = new Handler();
leDeviceListAdapter = new LeDeviceListAdapter();
setListAdapter(leDeviceListAdapter);
scanLeDevice(true);
}
});
return view;
}
private void mCheckPermission() {
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
PERMISSION_REQUEST_COARSE_LOCATION);
} else {
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == MY_LOCATION_REQUEST_CODE) {
if (permissions.length == 1 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
}
Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED", Toast.LENGTH_SHORT).show();
}
}
private void scanLeDevice(final boolean enable) {
if (enable) {
mhandler.postDelayed(new Runnable() {
@Override
public void run() {
mScanning = false;
BLEScanner.stopScan(ScanCallback);
Toast.makeText(getActivity(), "기기 탐색 완료", Toast.LENGTH_SHORT).show();
}
}, SCAN_PERIOD);
mScanning = true;
BLEScanner.startScan(ScanCallback);
Toast.makeText(getActivity(), "주변 기기를 탐색중입니다...", Toast.LENGTH_SHORT).show();
} else {
mScanning = false;
BLEScanner.stopScan(ScanCallback);
}
}
private ScanCallback ScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
processResult(result);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
for (ScanResult result : results) {
processResult(result);
}
}
@Override
public void onScanFailed(int errorCode) {
}
private void processResult(final ScanResult result) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
leDeviceListAdapter.addDevice(result.getDevice());
leDeviceListAdapter.notifyDataSetChanged();
}
});
}
};
private class LeDeviceListAdapter extends BaseAdapter {
private ArrayList<BluetoothDevice> mLeDevices;
private LayoutInflater mInflator;
public LeDeviceListAdapter() {
super();
mLeDevices = new ArrayList<BluetoothDevice>();
mInflator = getActivity().getLayoutInflater();
}
public void addDevice(BluetoothDevice device) {
if (!mLeDevices.contains(device)) {
mLeDevices.add(device);
}
}
public BluetoothDevice getDevice(int position) {
return mLeDevices.get(position);
}
public void clear() {
mLeDevices.clear();
}
@Override
public int getCount() {
return mLeDevices.size();
}
@Override
public Object getItem(int i) {
return mLeDevices.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
ViewHolder viewHolder = new ViewHolder();
if (view == null) {
view = mInflator.inflate(R.layout.bt_listview_item, null);
viewHolder.deviceName = (TextView) view.findViewById(R.id.bt_textView);
viewHolder.deviceAddr = (TextView) view.findViewById(R.id.bt_textView_addr);
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
BluetoothDevice device = mLeDevices.get(position);
String deviceName = device.getName();
String deviceAddr = device.getAddress();
if (deviceName != null && deviceName.length() > 0) {
viewHolder.deviceName.setText(deviceName);
viewHolder.deviceAddr.setText(deviceAddr);
} else {
viewHolder.deviceName.setText("Unknown Device");
viewHolder.deviceAddr.setText(deviceAddr);
}
return view;
}
private class ViewHolder {
TextView deviceName;
TextView deviceAddr;
}
}
@Override
public void onResume() {
super.onResume();
getActivity().registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
}
@Override
public void onDestroy() {
super.onDestroy();
getActivity().unregisterReceiver(mGattUpdateReceiver);
getActivity().unbindService(mServiceConnection);
}
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
String currentDeviceAddr = intent.getExtras().getString("extra.mac");
if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
mConnected = true;
Toast.makeText(getActivity(), "연결되었습니다", Toast.LENGTH_SHORT).show();
} else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
mConnected = false;
} else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
Log.d(TAG, "onReceive: Service Discovered" + currentDeviceAddr);
int size = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).size();
if (currentDeviceAddr.equals(getString(R.string.addr_m))) {
motor = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).get(size - 1).getCharacteristic(mBluetoothLeService.HM10);
} else{
getCharacteristics(mBluetoothLeService.getSupportedGattServices(currentDeviceAddr), currentDeviceAddr, size);
}
} else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
String data = intent.getExtras().getString("data");
new SensorResult(getContext()).setData(data, currentDeviceAddr);
}
}
};
public static void setWindowState(String state, String addr) {
if (motor != null && mBluetoothLeService != null) {
if(state == "n"){
WindowState =true; }
else {
WindowState= false;}
motor.setValue(state);
mBluetoothLeService.writeMotorCharacteristic(motor, addr);
mBluetoothLeService.setCharacteristicNotification(motor, addr, true);
}
}
private boolean getCharacteristics(List<BluetoothGattService> gattService, String addr, int size) {
if (size != 0) {
List<BluetoothGattCharacteristic> gattCharacteristics = gattService.get(size - 1).getCharacteristics();
ArrayList<BluetoothGattCharacteristic> charas =
new ArrayList<BluetoothGattCharacteristic>();
for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
charas.add(gattCharacteristic);
}
mGattCharacteristics.add(charas);
if (mGattCharacteristics != null) {
final BluetoothGattCharacteristic characteristic = charas.get(charas.size() - 1);
final int charaProp = characteristic.getProperties();
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
if (mNotifyCharacteristic != null) {
mBluetoothLeService.setCharacteristicNotification(
mNotifyCharacteristic, addr, false);
mNotifyCharacteristic = null;
}
mBluetoothLeService.readCharacteristic(characteristic, addr);
}
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mNotifyCharacteristic = characteristic;
mBluetoothLeService.setCharacteristicNotification(
characteristic, addr, true);
}
return true;
}}
return false;
}
private static IntentFilter makeGattUpdateIntentFilter() {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
return intentFilter;
}
private final ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
if (!mBluetoothLeService.initialize()) {
Log.d("", "Unable to initialize Bluetooth");
}
Log.d("", "onServiceConnected: ");
}
@Override
public void onServiceDisconnected(ComponentName name) {
mBluetoothLeService.close();
mBluetoothLeService.disconnect();
mBluetoothLeService = null;
}
};
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
final BluetoothDevice device = leDeviceListAdapter.getDevice(position);
if (device == null) return;
Toast.makeText(getActivity(), "연결중...", Toast.LENGTH_SHORT).show();
connectionQueue.add(device);
if (mScanning) {
BLEScanner.stopScan(ScanCallback);
mScanning = false;
}
if (connectionQueue.size() == moduleNum) {
initConnection();
}
}
public void initConnection() {
if (connectionThread == null) {
connectionThread = new Thread(new Runnable() {
@Override
public void run() {
connectionloop();
connectionThread.interrupt();
connectionThread = null;
}
});
connectionThread.start();
}
}
private void connectionloop() {
while (!connectionQueue.isEmpty()) {
if(mBluetoothLeService != null) {
mBluetoothLeService.connect(connectionQueue.poll().getAddress());
}
try {
Thread.sleep(250);
} catch (InterruptedException e) {
}
}
}
}
package com.example.suemin.smartwindow.view.bluetooth;
import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.support.v4.app.ListFragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult;
import java.util.LinkedList;
import java.util.List;
import com.example.suemin.smartwindow.R;
import java.util.ArrayList;
import java.util.Queue;
import static android.content.ContentValues.TAG;
public class Bluetooth extends ListFragment {
private BluetoothAdapter mBluetoothAdapter;
private static BluetoothLeService mBluetoothLeService;
private boolean mScanning;
private Handler mhandler;
private BluetoothLeScanner BLEScanner;
private LeDeviceListAdapter leDeviceListAdapter;
private Queue<BluetoothDevice> connectionQueue;
private Thread connectionThread;
private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics =
new ArrayList<ArrayList<BluetoothGattCharacteristic>>();
private BluetoothGattCharacteristic mNotifyCharacteristic;
private static BluetoothGattCharacteristic motor;
private static final long SCAN_PERIOD = 5000;
private static final int REQUEST_ENABLE_BT = 1;
private static final int MY_LOCATION_REQUEST_CODE = 1;
private static final int PERMISSION_REQUEST_COARSE_LOCATION = 100;
private final int moduleNum = 3;
private boolean mConnected = false;
public static boolean WindowState = false;
public Bluetooth() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mCheckPermission();
}
Intent gattServiceIntent = new Intent(getActivity(), BluetoothLeService.class);
getActivity().bindService(gattServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.btmenu, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.navigation_bt) {
if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
}
final BluetoothManager bluetoothManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE);
if (bluetoothManager != null) {
mBluetoothAdapter = bluetoothManager.getAdapter();
}
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
BLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
if (BLEScanner == null) {
Toast.makeText(getActivity(), "Can not find BLE Scanner", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), "블루투스가 활성화되었습니다.", Toast.LENGTH_SHORT).show();
}
}
return super.onOptionsItemSelected(item);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_bluetooth, container, false);
setHasOptionsMenu(true);
connectionQueue = new LinkedList<BluetoothDevice>();
Button btFindBtn = (Button) view.findViewById(R.id.bt_find_btn);
btFindBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mhandler = new Handler();
leDeviceListAdapter = new LeDeviceListAdapter();
setListAdapter(leDeviceListAdapter);
scanLeDevice(true);
}
});
return view;
}
private void mCheckPermission() {
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
PERMISSION_REQUEST_COARSE_LOCATION);
} else {
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == MY_LOCATION_REQUEST_CODE) {
if (permissions.length == 1 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
}
Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED", Toast.LENGTH_SHORT).show();
}
}
private void scanLeDevice(final boolean enable) {
if (enable) {
mhandler.postDelayed(new Runnable() {
@Override
public void run() {
mScanning = false;
BLEScanner.stopScan(ScanCallback);
Toast.makeText(getActivity(), "기기 탐색 완료", Toast.LENGTH_SHORT).show();
}
}, SCAN_PERIOD);
mScanning = true;
BLEScanner.startScan(ScanCallback);
Toast.makeText(getActivity(), "주변 기기를 탐색중입니다...", Toast.LENGTH_SHORT).show();
} else {
mScanning = false;
BLEScanner.stopScan(ScanCallback);
}
}
private ScanCallback ScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
processResult(result);
}
@Override
public void onBatchScanResults(List<ScanResult> results) {
for (ScanResult result : results) {
processResult(result);
}
}
@Override
public void onScanFailed(int errorCode) {
}
private void processResult(final ScanResult result) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
leDeviceListAdapter.addDevice(result.getDevice());
leDeviceListAdapter.notifyDataSetChanged();
}
});
}
};
private class LeDeviceListAdapter extends BaseAdapter {
private ArrayList<BluetoothDevice> mLeDevices;
private LayoutInflater mInflator;
public LeDeviceListAdapter() {
super();
mLeDevices = new ArrayList<BluetoothDevice>();
mInflator = getActivity().getLayoutInflater();
}
public void addDevice(BluetoothDevice device) {
if (!mLeDevices.contains(device)) {
mLeDevices.add(device);
}
}
public BluetoothDevice getDevice(int position) {
return mLeDevices.get(position);
}
public void clear() {
mLeDevices.clear();
}
@Override
public int getCount() {
return mLeDevices.size();
}
@Override
public Object getItem(int i) {
return mLeDevices.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
ViewHolder viewHolder = new ViewHolder();
if (view == null) {
view = mInflator.inflate(R.layout.bt_listview_item, null);
viewHolder.deviceName = (TextView) view.findViewById(R.id.bt_textView);
viewHolder.deviceAddr = (TextView) view.findViewById(R.id.bt_textView_addr);
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
BluetoothDevice device = mLeDevices.get(position);
String deviceName = device.getName();
String deviceAddr = device.getAddress();
if (deviceName != null && deviceName.length() > 0) {
viewHolder.deviceName.setText(deviceName);
viewHolder.deviceAddr.setText(deviceAddr);
} else {
viewHolder.deviceName.setText("Unknown Device");
viewHolder.deviceAddr.setText(deviceAddr);
}
return view;
}
private class ViewHolder {
TextView deviceName;
TextView deviceAddr;
}
}
@Override
public void onResume() {
super.onResume();
getActivity().registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
}
@Override
public void onDestroy() {
super.onDestroy();
getActivity().unregisterReceiver(mGattUpdateReceiver);
getActivity().unbindService(mServiceConnection);
}
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
String currentDeviceAddr = intent.getExtras().getString("extra.mac");
if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
mConnected = true;
Toast.makeText(getActivity(), "연결되었습니다", Toast.LENGTH_SHORT).show();
} else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
mConnected = false;
} else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
Log.d(TAG, "onReceive: Service Discovered" + currentDeviceAddr);
int size = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).size();
if (currentDeviceAddr.equals(getString(R.string.addr_m))) {
motor = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).get(size - 1).getCharacteristic(mBluetoothLeService.HM10);
} else{
getCharacteristics(mBluetoothLeService.getSupportedGattServices(currentDeviceAddr), currentDeviceAddr, size);
}
} else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
String data = intent.getExtras().getString("data");
new SensorResult(getContext()).setData(data, currentDeviceAddr);
}
}
};
public static void setWindowState(String state, String addr) {
if (motor != null && mBluetoothLeService != null) {
if(state == "n"){
WindowState =true; }
else {
WindowState= false;}
motor.setValue(state);
mBluetoothLeService.writeMotorCharacteristic(motor, addr);
mBluetoothLeService.setCharacteristicNotification(motor, addr, true);
}
}
private boolean getCharacteristics(List<BluetoothGattService> gattService, String addr, int size) {
if (size != 0) {
List<BluetoothGattCharacteristic> gattCharacteristics = gattService.get(size - 1).getCharacteristics();
ArrayList<BluetoothGattCharacteristic> charas =
new ArrayList<BluetoothGattCharacteristic>();
for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
charas.add(gattCharacteristic);
}
mGattCharacteristics.add(charas);
if (mGattCharacteristics != null) {
final BluetoothGattCharacteristic characteristic = charas.get(charas.size() - 1);
final int charaProp = characteristic.getProperties();
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
if (mNotifyCharacteristic != null) {
mBluetoothLeService.setCharacteristicNotification(
mNotifyCharacteristic, addr, false);
mNotifyCharacteristic = null;
}
mBluetoothLeService.readCharacteristic(characteristic, addr);
}
if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
mNotifyCharacteristic = characteristic;
mBluetoothLeService.setCharacteristicNotification(
characteristic, addr, true);
}
return true;
}}
return false;
}
private static IntentFilter makeGattUpdateIntentFilter() {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
return intentFilter;
}
private final ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
if (!mBluetoothLeService.initialize()) {
Log.d("", "Unable to initialize Bluetooth");
}
Log.d("", "onServiceConnected: ");
}
@Override
public void onServiceDisconnected(ComponentName name) {
mBluetoothLeService.close();
mBluetoothLeService.disconnect();
mBluetoothLeService = null;
}
};
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
final BluetoothDevice device = leDeviceListAdapter.getDevice(position);
if (device == null) return;
Toast.makeText(getActivity(), "연결중...", Toast.LENGTH_SHORT).show();
connectionQueue.add(device);
if (mScanning) {
BLEScanner.stopScan(ScanCallback);
mScanning = false;
}
if (connectionQueue.size() == moduleNum) {
initConnection();
}
}
public void initConnection() {
if (connectionThread == null) {
connectionThread = new Thread(new Runnable() {
@Override
public void run() {
connectionloop();
connectionThread.interrupt();
connectionThread = null;
}
});
connectionThread.start();
}
}
private void connectionloop() {
while (!connectionQueue.isEmpty()) {
if(mBluetoothLeService != null) {
mBluetoothLeService.connect(connectionQueue.poll().getAddress());
}
try {
Thread.sleep(250);
} catch (InterruptedException e) {
}
}
}
}
......
package com.example.suemin.smartwindow.view.bluetooth;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.UUID;
import static android.content.ContentValues.TAG;
public class BluetoothLeService extends Service{
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private String mBluetoothDeviceAddress;
private BluetoothGatt mBluetoothGatt;
private BluetoothGatt mBluetoothGatt_1;
private BluetoothGatt mBluetoothGatt_2;
private int mConnectionState = STATE_DISCONNECTED;
private static final int STATE_DISCONNECTED = 0;
private static final int STATE_CONNECTING = 1;
private static final int STATE_CONNECTED = 2;
public final static String ACTION_GATT_CONNECTED =
"com.example.bluetooth.le.ACTION_GATT_CONNECTED";
public final static String ACTION_GATT_DISCONNECTED =
"com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
public final static String ACTION_GATT_SERVICES_DISCOVERED =
"com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
public final static String ACTION_DATA_AVAILABLE =
"com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
public final static String EXTRA_DATA =
"com.example.bluetooth.le.EXTRA_DATA";
public final static UUID HM10 =
UUID.fromString(SampleAttributes.HM_10);
private Queue<BluetoothGattCharacteristic> characteristicReadQueue = new LinkedList<BluetoothGattCharacteristic>();
private Queue<BluetoothGatt> serviceDiscoveryQueue = new LinkedList<BluetoothGatt>();
private Thread serviceDiscoveryThread;
private Thread initialisationThread;
private final int moduleNum = 3;
private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction, gatt);
Log.d(TAG, "CONNECTED TO GATT SERVER " + gatt.getDevice().getName());
serviceDiscoveryQueue.add(gatt);
if (serviceDiscoveryQueue.size() == moduleNum) {
initServiceDiscovery();
}
else {
if (serviceDiscoveryQueue.size() == 1) {
mBluetoothGatt_1 = gatt;
} else if (serviceDiscoveryQueue.size() == 2) {
mBluetoothGatt_2 = gatt;
}
}
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "DISCONNECTED FROM GATT SERVER" + gatt.getDevice().getName());
broadcastUpdate(intentAction, gatt);
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
if(status == BluetoothGatt.GATT_SUCCESS){
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED, gatt);
}
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
super.onCharacteristicRead(gatt, characteristic, status);
Log.d(TAG, "onCharacteristicRead: " + gatt.getDevice().getName());
characteristicReadQueue.add(characteristic);
if(status == BluetoothGatt.GATT_SUCCESS ){
initreadThread(gatt);
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt);
}
}
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
super.onCharacteristicChanged(gatt, characteristic);
Log.d(TAG, "onCharacteristicChanged: " + gatt.getDevice().getName());
characteristicReadQueue.add(characteristic);
if(characteristicReadQueue.size() > 0 ) {
initreadThread(gatt);
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt);
}
}
};
public void initServiceDiscovery(){
if(serviceDiscoveryThread == null){
serviceDiscoveryThread = new Thread(new Runnable() {
@Override
public void run() {
serviceDiscovery();
serviceDiscoveryThread.interrupt();
serviceDiscoveryThread = null;
}
});
serviceDiscoveryThread.start();
}
}
private void serviceDiscovery(){
while(!serviceDiscoveryQueue.isEmpty()){
BluetoothGatt p = serviceDiscoveryQueue.poll();
p.discoverServices();
try{
Thread.sleep(250);
}
catch (InterruptedException e){}
}
}
private void broadcastUpdate(String action, BluetoothGatt gatt){
Intent intent = new Intent(action);
intent.putExtra("extra.mac", gatt.getDevice().getAddress());
sendBroadcast(intent);
}
private void broadcastUpdate(String action, BluetoothGattCharacteristic characteristic, BluetoothGatt gatt) {
final Intent intent = new Intent(action);
intent.putExtra("extra.mac", gatt.getDevice().getAddress());
Log.v("AndroidLE", "broadcastUpdate()" + gatt.getDevice().getName());
final byte[] data = characteristic.getValue();
if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new StringBuilder(data.length);
for(byte byteChar : data) {
stringBuilder.append(String.format("%02X ", byteChar));
}
String result = new String(data);
Log.v("AndroidLE", gatt.getDevice().getName() + " ::: " + result);
intent.putExtra("data", result);
sendBroadcast(intent);
}
}
public boolean initialize(){
if(mBluetoothManager == null){
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
if(mBluetoothManager ==null){
Log.e(TAG, "Unable to initialize MANAGER");
return false;
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
if(mBluetoothAdapter == null){
Log.e(TAG, "Unable to initialize ADAPTER");
return false;
}
return true;
}
public boolean connect(final String address){
if(mBluetoothAdapter==null || address ==null){
return false;
}
if(mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null){
Log.d(TAG, "connect: PREVIOUSLY CONNECTED DEVICE.. TRY TO RECONNECT");
if (mBluetoothGatt.connect()){
mConnectionState = STATE_CONNECTING;
return true;
}
else{
return false;
}
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if(device ==null){
Log.w(TAG, "DEVICE NOT FOUND");
return false;
}
mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
Log.d(TAG, "CONNECTING NEW DEVICE : " +device.getName());
mBluetoothDeviceAddress = address;
mConnectionState = STATE_CONNECTING;
return true;
}
public void disconnect(){
if(mBluetoothAdapter ==null || mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){
return;
}
mBluetoothGatt.disconnect();
mBluetoothGatt_1.disconnect();
mBluetoothGatt_2.disconnect();
}
public void close(){
if(mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){
return;
}
mBluetoothGatt.close();
mBluetoothGatt =null;
mBluetoothGatt_1.close();
mBluetoothGatt_1 =null;
mBluetoothGatt_2.close();
mBluetoothGatt_2 =null;
}
private final IBinder mBinder = new LocalBinder();
public class LocalBinder extends Binder{
BluetoothLeService getService(){
return BluetoothLeService.this;
}
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
public boolean onUnBind(Intent intent){
Log.d(TAG, "onUnBind: ");
return super.onUnbind(intent);
}
public void writeMotorCharacteristic(BluetoothGattCharacteristic characteristic, String addr){
if(addr.equals(mBluetoothGatt.getDevice().getAddress())){
mBluetoothGatt.writeCharacteristic(characteristic);
}
else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){
Log.d(TAG, "writeMotorCharacteristic: "+addr );
mBluetoothGatt_1.writeCharacteristic(characteristic);
}
else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){
Log.d(TAG, "writeMotorCharacteristic: "+addr);
mBluetoothGatt_2.writeCharacteristic(characteristic);
}
}
public void readCharacteristic(BluetoothGattCharacteristic characteristic, String addr){
if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) {
mBluetoothGatt.readCharacteristic(characteristic);
}
else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) {
mBluetoothGatt_1.readCharacteristic(characteristic);
}
else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) {
mBluetoothGatt_2.readCharacteristic(characteristic);
}
}
private void initreadThread(final BluetoothGatt gatt){
if(initialisationThread == null) {
initialisationThread = new Thread(new Runnable() {
@Override
public void run() {
readCharacteristics(gatt);
initialisationThread.interrupt();
initialisationThread = null;
}
});
initialisationThread.start();
}
}
private void readCharacteristics(BluetoothGatt gatt) {
while (!characteristicReadQueue.isEmpty()) {
readCharacteristic(characteristicReadQueue.poll(), gatt.getDevice().getAddress());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristics, String addr, boolean enabled) {
if(addr.equals(mBluetoothGatt.getDevice().getAddress())) {
mBluetoothGatt.setCharacteristicNotification(characteristics, true);
if (HM10.equals(characteristics.getUuid())) {
BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
}
}
else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){
mBluetoothGatt_1.setCharacteristicNotification(characteristics, true);
if (HM10.equals(characteristics.getUuid())) {
BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt_1.writeDescriptor(descriptor);
}
}
else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){
mBluetoothGatt_2.setCharacteristicNotification(characteristics, true);
if (HM10.equals(characteristics.getUuid())) {
BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt_2.writeDescriptor(descriptor);
}
}
}
public List<BluetoothGattService> getSupportedGattServices(String addr) {
if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) {
return mBluetoothGatt.getServices();
}
else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) {
return mBluetoothGatt_1.getServices();
}
else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) {
return mBluetoothGatt_2.getServices();
}else{
return mBluetoothGatt.getServices();
}
}
}
package com.example.suemin.smartwindow.view.bluetooth;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.UUID;
import static android.content.ContentValues.TAG;
public class BluetoothLeService extends Service{
private BluetoothManager mBluetoothManager;
private BluetoothAdapter mBluetoothAdapter;
private String mBluetoothDeviceAddress;
private BluetoothGatt mBluetoothGatt;
private BluetoothGatt mBluetoothGatt_1;
private BluetoothGatt mBluetoothGatt_2;
private int mConnectionState = STATE_DISCONNECTED;
private static final int STATE_DISCONNECTED = 0;
private static final int STATE_CONNECTING = 1;
private static final int STATE_CONNECTED = 2;
public final static String ACTION_GATT_CONNECTED =
"com.example.bluetooth.le.ACTION_GATT_CONNECTED";
public final static String ACTION_GATT_DISCONNECTED =
"com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
public final static String ACTION_GATT_SERVICES_DISCOVERED =
"com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
public final static String ACTION_DATA_AVAILABLE =
"com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
public final static String EXTRA_DATA =
"com.example.bluetooth.le.EXTRA_DATA";
public final static UUID HM10 =
UUID.fromString(SampleAttributes.HM_10);
private Queue<BluetoothGattCharacteristic> characteristicReadQueue = new LinkedList<BluetoothGattCharacteristic>();
private Queue<BluetoothGatt> serviceDiscoveryQueue = new LinkedList<BluetoothGatt>();
private Thread serviceDiscoveryThread;
private Thread initialisationThread;
private final int moduleNum = 3;
private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
super.onConnectionStateChange(gatt, status, newState);
String intentAction;
if (newState == BluetoothProfile.STATE_CONNECTED) {
intentAction = ACTION_GATT_CONNECTED;
mConnectionState = STATE_CONNECTED;
broadcastUpdate(intentAction, gatt);
Log.d(TAG, "CONNECTED TO GATT SERVER " + gatt.getDevice().getName());
serviceDiscoveryQueue.add(gatt);
if (serviceDiscoveryQueue.size() == moduleNum) {
initServiceDiscovery();
}
else {
if (serviceDiscoveryQueue.size() == 1) {
mBluetoothGatt_1 = gatt;
} else if (serviceDiscoveryQueue.size() == 2) {
mBluetoothGatt_2 = gatt;
}
}
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
intentAction = ACTION_GATT_DISCONNECTED;
mConnectionState = STATE_DISCONNECTED;
Log.i(TAG, "DISCONNECTED FROM GATT SERVER" + gatt.getDevice().getName());
broadcastUpdate(intentAction, gatt);
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
if(status == BluetoothGatt.GATT_SUCCESS){
broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED, gatt);
}
}
@Override
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
super.onCharacteristicRead(gatt, characteristic, status);
Log.d(TAG, "onCharacteristicRead: " + gatt.getDevice().getName());
characteristicReadQueue.add(characteristic);
if(status == BluetoothGatt.GATT_SUCCESS ){
initreadThread(gatt);
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt);
}
}
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
super.onCharacteristicChanged(gatt, characteristic);
Log.d(TAG, "onCharacteristicChanged: " + gatt.getDevice().getName());
characteristicReadQueue.add(characteristic);
if(characteristicReadQueue.size() > 0 ) {
initreadThread(gatt);
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt);
}
}
};
public void initServiceDiscovery(){
if(serviceDiscoveryThread == null){
serviceDiscoveryThread = new Thread(new Runnable() {
@Override
public void run() {
serviceDiscovery();
serviceDiscoveryThread.interrupt();
serviceDiscoveryThread = null;
}
});
serviceDiscoveryThread.start();
}
}
private void serviceDiscovery(){
while(!serviceDiscoveryQueue.isEmpty()){
BluetoothGatt p = serviceDiscoveryQueue.poll();
p.discoverServices();
try{
Thread.sleep(250);
}
catch (InterruptedException e){}
}
}
private void broadcastUpdate(String action, BluetoothGatt gatt){
Intent intent = new Intent(action);
intent.putExtra("extra.mac", gatt.getDevice().getAddress());
sendBroadcast(intent);
}
private void broadcastUpdate(String action, BluetoothGattCharacteristic characteristic, BluetoothGatt gatt) {
final Intent intent = new Intent(action);
intent.putExtra("extra.mac", gatt.getDevice().getAddress());
Log.v("AndroidLE", "broadcastUpdate()" + gatt.getDevice().getName());
final byte[] data = characteristic.getValue();
if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new StringBuilder(data.length);
for(byte byteChar : data) {
stringBuilder.append(String.format("%02X ", byteChar));
}
String result = new String(data);
Log.v("AndroidLE", gatt.getDevice().getName() + " ::: " + result);
intent.putExtra("data", result);
sendBroadcast(intent);
}
}
public boolean initialize(){
if(mBluetoothManager == null){
mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
if(mBluetoothManager ==null){
Log.e(TAG, "Unable to initialize MANAGER");
return false;
}
}
mBluetoothAdapter = mBluetoothManager.getAdapter();
if(mBluetoothAdapter == null){
Log.e(TAG, "Unable to initialize ADAPTER");
return false;
}
return true;
}
public boolean connect(final String address){
if(mBluetoothAdapter==null || address ==null){
return false;
}
if(mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null){
Log.d(TAG, "connect: PREVIOUSLY CONNECTED DEVICE.. TRY TO RECONNECT");
if (mBluetoothGatt.connect()){
mConnectionState = STATE_CONNECTING;
return true;
}
else{
return false;
}
}
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if(device ==null){
Log.w(TAG, "DEVICE NOT FOUND");
return false;
}
mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
Log.d(TAG, "CONNECTING NEW DEVICE : " +device.getName());
mBluetoothDeviceAddress = address;
mConnectionState = STATE_CONNECTING;
return true;
}
public void disconnect(){
if(mBluetoothAdapter ==null || mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){
return;
}
mBluetoothGatt.disconnect();
mBluetoothGatt_1.disconnect();
mBluetoothGatt_2.disconnect();
}
public void close(){
if(mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){
return;
}
mBluetoothGatt.close();
mBluetoothGatt =null;
mBluetoothGatt_1.close();
mBluetoothGatt_1 =null;
mBluetoothGatt_2.close();
mBluetoothGatt_2 =null;
}
private final IBinder mBinder = new LocalBinder();
public class LocalBinder extends Binder{
BluetoothLeService getService(){
return BluetoothLeService.this;
}
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
public boolean onUnBind(Intent intent){
Log.d(TAG, "onUnBind: ");
return super.onUnbind(intent);
}
public void writeMotorCharacteristic(BluetoothGattCharacteristic characteristic, String addr){
if(addr.equals(mBluetoothGatt.getDevice().getAddress())){
mBluetoothGatt.writeCharacteristic(characteristic);
}
else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){
Log.d(TAG, "writeMotorCharacteristic: "+addr );
mBluetoothGatt_1.writeCharacteristic(characteristic);
}
else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){
Log.d(TAG, "writeMotorCharacteristic: "+addr);
mBluetoothGatt_2.writeCharacteristic(characteristic);
}
}
public void readCharacteristic(BluetoothGattCharacteristic characteristic, String addr){
if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) {
mBluetoothGatt.readCharacteristic(characteristic);
}
else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) {
mBluetoothGatt_1.readCharacteristic(characteristic);
}
else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) {
mBluetoothGatt_2.readCharacteristic(characteristic);
}
}
private void initreadThread(final BluetoothGatt gatt){
if(initialisationThread == null) {
initialisationThread = new Thread(new Runnable() {
@Override
public void run() {
readCharacteristics(gatt);
initialisationThread.interrupt();
initialisationThread = null;
}
});
initialisationThread.start();
}
}
private void readCharacteristics(BluetoothGatt gatt) {
while (!characteristicReadQueue.isEmpty()) {
readCharacteristic(characteristicReadQueue.poll(), gatt.getDevice().getAddress());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristics, String addr, boolean enabled) {
if(addr.equals(mBluetoothGatt.getDevice().getAddress())) {
mBluetoothGatt.setCharacteristicNotification(characteristics, true);
if (HM10.equals(characteristics.getUuid())) {
BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
}
}
else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){
mBluetoothGatt_1.setCharacteristicNotification(characteristics, true);
if (HM10.equals(characteristics.getUuid())) {
BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt_1.writeDescriptor(descriptor);
}
}
else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){
mBluetoothGatt_2.setCharacteristicNotification(characteristics, true);
if (HM10.equals(characteristics.getUuid())) {
BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt_2.writeDescriptor(descriptor);
}
}
}
public List<BluetoothGattService> getSupportedGattServices(String addr) {
if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) {
return mBluetoothGatt.getServices();
}
else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) {
return mBluetoothGatt_1.getServices();
}
else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) {
return mBluetoothGatt_2.getServices();
}else{
return mBluetoothGatt.getServices();
}
}
}
......
package com.example.suemin.smartwindow.view.bluetooth;
import java.util.HashMap;
/**
* This class includes a small subset of standard GATT attributes for demonstration purposes.
*/
public class SampleAttributes {
private static HashMap<String, String> attributes = new HashMap();
public static String HM_10 = "0000ffe1-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
static {
// Sample Services.
attributes.put("0000ffe0-0000-1000-8000-00805f9b34fb", "HM-10 Service");
attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service");
// Sample Characteristics.
attributes.put(HM_10, "HM-10 Module");
attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
}
public static String lookup(String uuid, String defaultName) {
String name = attributes.get(uuid);
return name == null ? defaultName : name;
}
package com.example.suemin.smartwindow.view.bluetooth;
import java.util.HashMap;
/**
* This class includes a small subset of standard GATT attributes for demonstration purposes.
*/
public class SampleAttributes {
private static HashMap<String, String> attributes = new HashMap();
public static String HM_10 = "0000ffe1-0000-1000-8000-00805f9b34fb";
public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
static {
// Sample Services.
attributes.put("0000ffe0-0000-1000-8000-00805f9b34fb", "HM-10 Service");
attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service");
// Sample Characteristics.
attributes.put(HM_10, "HM-10 Module");
attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
}
public static String lookup(String uuid, String defaultName) {
String name = attributes.get(uuid);
return name == null ? defaultName : name;
}
}
\ No newline at end of file
......
package com.example.suemin.smartwindow.view.bluetooth;
import android.content.Context;
import com.example.suemin.smartwindow.R;
import static com.example.suemin.smartwindow.view.MainActivity.NotificationSomethings;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState;
import static com.example.suemin.smartwindow.view.environment.listview.Finedust.getFineDustResult;
public class SensorResult {
static Context mcontext = null;
private static int otfd;
private static int infd;
private static String rain, intr, humd, temp = "0";
private static boolean raining = false, intruder = false;
public SensorResult(Context context){
this.mcontext=context;
}
private void setWindowBySensor() {
if ( "0".equals(otfd) || "0".equals(infd) || "0".equals(humd) || "0".equals(temp) ) { return ;}
else{
// 1. 비가 오거나 침입자 발생, 외부 미세먼지 수치가 높다
if (otfd > 80 || raining || intruder) {
// 열려있으면 닫는다
if (WindowState) {
setWindowState("y", mcontext.getString(R.string.addr_m));
}
}
// 1. 비 안오고 침입자 없고 미세먼지 보통 이하
if (otfd <= 80 && !raining && !intruder) {
// 닫혀있는데 내부 미세먼지 나쁨이상이거나 온도 높거나 습도 높으면 연다
if (!WindowState) {
if (infd > 80 || getTemperatureState() == "높음" || getHumidState() == "높음")
setWindowState("n", mcontext.getString(R.string.addr_m));
}
// 열려있는데 온도가 낮으면 닫는다
else {
if (getTemperatureState() == "낮음") {
setWindowState("y", mcontext.getString(R.string.addr_m));
}
}
}
}
}
public void setData(String data, String addr){
if(addr != null && mcontext != null){
String sensor = data.substring(0,5);
if(addr.equals(mcontext.getString(R.string.addr_r))) {
if (sensor.equals("intr ")) {
intr = data.substring(5);
intruder = true;
NotificationSomethings();
} else {
rain = data.substring(5);
raining = true;
}
}
else if (addr.equals(mcontext.getString(R.string.addr_d))){
if(sensor.equals("temp ")) {
temp = data.substring(5);
}
else if(sensor.equals("humd ")){
humd = data.substring(5);
}
else if(sensor.equals("dust ")){
if(Double.parseDouble(data.substring(5)) > 0) {
infd = Integer.parseInt(data.substring(5));
}
}
else{return;}
}
setWindowBySensor();
}
return ;
}
public static int getInnerDustResult(){
return infd;
}
public static double getHumidResult(){
if(humd == null){return 0;}
else { return Math.floor(Double.parseDouble(humd)*10)/10; }
}
public static double getTemperatureResult(){
if(temp == null){return 0;}
else { return Math.floor(Double.parseDouble(temp)*10)/10; }
}
public static String getRainResult(){
if(raining){
return "내림";
}
else {return "안내림";}
}
public static String getIntruderResult(){
if(intruder){
return "있음";
}
else {return "없음";}
}
public static String getOuterFineDustState(){
otfd = Integer.parseInt(getFineDustResult());
int value = otfd;
String state = null;
if(value <31){ state = "좋음";}
else if (value >30 && value <81){state = "보통";}
else if (value>80 && value <151){state = "나쁨";}
else{ state = "매우나쁨"; }
return state;
}
public static String getInnerFineDustState(){
int value = getInnerDustResult();
String state = null;
if(value <31){ state = "좋음";}
else if (value >30 && value <81){state = "보통";}
else if (value>80 && value <151){state = "나쁨";}
else{ state = "매우나쁨"; }
return state;
}
public static String getTemperatureState() {
double value = getTemperatureResult();
String state = null;
if (value < 18) {
state = "낮음";
} else if (value >= 18 && value <= 25) {
state = "적정";
} else{
state = "높음";
}
return state;
}
public static String getHumidState() {
double value = getHumidResult();
String state = null;
if (value < 40) {
state = "낮음";
} else if (value >= 40 && value <= 60) {
state = "적정";
} else {
state = "높음";
}
return state;
}
}
package com.example.suemin.smartwindow.view.bluetooth;
import android.content.Context;
import com.example.suemin.smartwindow.R;
import static com.example.suemin.smartwindow.view.MainActivity.NotificationSomethings;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState;
import static com.example.suemin.smartwindow.view.environment.listview.Finedust.getFineDustResult;
public class SensorResult {
static Context mcontext = null;
private static int otfd;
private static int infd;
private static String rain, intr, humd, temp = "0";
private static boolean raining = false, intruder = false;
public SensorResult(Context context){
this.mcontext=context;
}
private void setWindowBySensor() {
if ( "0".equals(otfd) || "0".equals(infd) || "0".equals(humd) || "0".equals(temp) ) { return ;}
else{
// 1. 비가 오거나 침입자 발생, 외부 미세먼지 수치가 높다
if (otfd > 80 || raining || intruder) {
// 열려있으면 닫는다
if (WindowState) {
setWindowState("y", mcontext.getString(R.string.addr_m));
}
}
// 1. 비 안오고 침입자 없고 미세먼지 보통 이하
if (otfd <= 80 && !raining && !intruder) {
// 닫혀있는데 내부 미세먼지 나쁨이상이거나 온도 높거나 습도 높으면 연다
if (!WindowState) {
if (infd > 80 || getTemperatureState() == "높음" || getHumidState() == "높음")
setWindowState("n", mcontext.getString(R.string.addr_m));
}
// 열려있는데 온도가 낮으면 닫는다
else {
if (getTemperatureState() == "낮음") {
setWindowState("y", mcontext.getString(R.string.addr_m));
}
}
}
}
}
public void setData(String data, String addr){
if(addr != null && mcontext != null){
String sensor = data.substring(0,5);
if(addr.equals(mcontext.getString(R.string.addr_r))) {
if (sensor.equals("intr ")) {
intr = data.substring(5);
intruder = true;
NotificationSomethings();
} else {
rain = data.substring(5);
raining = true;
}
}
else if (addr.equals(mcontext.getString(R.string.addr_d))){
if(sensor.equals("temp ")) {
temp = data.substring(5);
}
else if(sensor.equals("humd ")){
humd = data.substring(5);
}
else if(sensor.equals("dust ")){
if(Double.parseDouble(data.substring(5)) > 0) {
infd = Integer.parseInt(data.substring(5));
}
}
else{return;}
}
setWindowBySensor();
}
return ;
}
public static int getInnerDustResult(){
return infd;
}
public static double getHumidResult(){
if(humd == null){return 0;}
else { return Math.floor(Double.parseDouble(humd)*10)/10; }
}
public static double getTemperatureResult(){
if(temp == null){return 0;}
else { return Math.floor(Double.parseDouble(temp)*10)/10; }
}
public static String getRainResult(){
if(raining){
return "내림";
}
else {return "안내림";}
}
public static String getIntruderResult(){
if(intruder){
return "있음";
}
else {return "없음";}
}
public static String getOuterFineDustState(){
otfd = Integer.parseInt(getFineDustResult());
int value = otfd;
String state = null;
if(value <31){ state = "좋음";}
else if (value >30 && value <81){state = "보통";}
else if (value>80 && value <151){state = "나쁨";}
else{ state = "매우나쁨"; }
return state;
}
public static String getInnerFineDustState(){
int value = getInnerDustResult();
String state = null;
if(value <31){ state = "좋음";}
else if (value >30 && value <81){state = "보통";}
else if (value>80 && value <151){state = "나쁨";}
else{ state = "매우나쁨"; }
return state;
}
public static String getTemperatureState() {
double value = getTemperatureResult();
String state = null;
if (value < 18) {
state = "낮음";
} else if (value >= 18 && value <= 25) {
state = "적정";
} else{
state = "높음";
}
return state;
}
public static String getHumidState() {
double value = getHumidResult();
String state = null;
if (value < 40) {
state = "낮음";
} else if (value >= 40 && value <= 60) {
state = "적정";
} else {
state = "높음";
}
return state;
}
}
......
package com.example.suemin.smartwindow.view.environment;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable;
import android.location.Address;
import android.location.Geocoder;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.suemin.smartwindow.R;
import com.example.suemin.smartwindow.view.environment.listview.CustomDialog;
import com.example.suemin.smartwindow.view.environment.listview.ListViewAdapter;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
public class Env extends Fragment {
private LocationManager locationManager;
private static final int REQUEST_CODE_LOCATION = 2;
private double lat;
private double lng;
private String addr;
private String subaddr;
public static String subaddr2;
private CustomDialog customDialog;
public Env() {
// Required empty public constructor
}
protected android.location.Location getCurrentLoca() {
android.location.Location currentLocation = null;
if(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_LOCATION);
} }
else {
locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, mLocationListener);
}
return currentLocation;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CODE_LOCATION) {
if (permissions.length == 1 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
}
// Permission was denied. Display an error message.
Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED",Toast.LENGTH_SHORT).show();
}
}
private final LocationListener mLocationListener =new LocationListener() {
@Override
public void onLocationChanged(android.location.Location location) {
lat = location.getLatitude();
lng = location.getLongitude();
addr =getCurrentAddr(lat,lng);
int idx_s = addr.indexOf("시");
int idx_k = addr.indexOf("구");
int idx_g = addr.indexOf("동");
subaddr = addr.substring(idx_s+1, idx_g+1);
subaddr2 = addr.substring(idx_s+2, idx_k+1);
setLocationText(subaddr);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
private String getCurrentAddr(double lat, double lng) {
Geocoder geocoder = new Geocoder(this.getActivity(), Locale.getDefault());
List<Address> addresses =null;
try {
addresses = geocoder.getFromLocation(
lat,
lng,
7);
} catch (IOException ioException) {
} catch (IllegalArgumentException illegalArgumentException) {
}
if (addresses == null) {
Log.d("getCurrentAddr: ","주소 미발견");
}
Address address = addresses.get(0);
return address.getAddressLine(0).toString()+"\n";
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getCurrentLoca();
}
public void setListView(View view) {
ListViewAdapter adapter = new ListViewAdapter();
ListView listView = (ListView) view.findViewById(R.id.list);
listView.setAdapter(adapter);
adapter.addItem("비", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_rain));
adapter.addItem("실외 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_om));
adapter.addItem("실내 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_sm));
adapter.addItem("실내 온도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_t));
adapter.addItem("실내 습도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_s));
adapter.addItem("침입자", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_i));
listView.setOnItemClickListener(listItemClickListener);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_env, container, false);
setListView(view);
return view;
}
private void setLocationText(String subaddr){
final TextView addrTxt = (TextView)getActivity().findViewById(R.id.location_text);
if(subaddr != null) addrTxt.setText(subaddr);
}
private AdapterView.OnItemClickListener listItemClickListener= new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
customDialog = new CustomDialog(getActivity(), positiveListener);
customDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
customDialog.show();
customDialog.setText(position);
}
};
private View.OnClickListener positiveListener = new View.OnClickListener() {
public void onClick(View v) {
customDialog.dismiss();
}
};
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onDestroy() {
super.onDestroy();
locationManager.removeUpdates(mLocationListener);
}
}
package com.example.suemin.smartwindow.view.environment;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable;
import android.location.Address;
import android.location.Geocoder;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.suemin.smartwindow.R;
import com.example.suemin.smartwindow.view.environment.listview.CustomDialog;
import com.example.suemin.smartwindow.view.environment.listview.ListViewAdapter;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
public class Env extends Fragment {
private LocationManager locationManager;
private static final int REQUEST_CODE_LOCATION = 2;
private double lat;
private double lng;
private String addr;
private String subaddr;
public static String subaddr2;
private CustomDialog customDialog;
public Env() {
// Required empty public constructor
}
protected android.location.Location getCurrentLoca() {
android.location.Location currentLocation = null;
if(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_LOCATION);
} }
else {
locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, mLocationListener);
}
return currentLocation;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CODE_LOCATION) {
if (permissions.length == 1 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
}
// Permission was denied. Display an error message.
Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED",Toast.LENGTH_SHORT).show();
}
}
private final LocationListener mLocationListener =new LocationListener() {
@Override
public void onLocationChanged(android.location.Location location) {
lat = location.getLatitude();
lng = location.getLongitude();
addr =getCurrentAddr(lat,lng);
int idx_s = addr.indexOf("시");
int idx_k = addr.indexOf("구");
int idx_g = addr.indexOf("동");
subaddr = addr.substring(idx_s+1, idx_g+1);
subaddr2 = addr.substring(idx_s+2, idx_k+1);
setLocationText(subaddr);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
private String getCurrentAddr(double lat, double lng) {
Geocoder geocoder = new Geocoder(this.getActivity(), Locale.getDefault());
List<Address> addresses =null;
try {
addresses = geocoder.getFromLocation(
lat,
lng,
7);
} catch (IOException ioException) {
} catch (IllegalArgumentException illegalArgumentException) {
}
if (addresses == null) {
Log.d("getCurrentAddr: ","주소 미발견");
}
Address address = addresses.get(0);
return address.getAddressLine(0).toString()+"\n";
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getCurrentLoca();
}
public void setListView(View view) {
ListViewAdapter adapter = new ListViewAdapter();
ListView listView = (ListView) view.findViewById(R.id.list);
listView.setAdapter(adapter);
adapter.addItem("비", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_rain));
adapter.addItem("실외 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_om));
adapter.addItem("실내 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_sm));
adapter.addItem("실내 온도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_t));
adapter.addItem("실내 습도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_s));
adapter.addItem("침입자", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_i));
listView.setOnItemClickListener(listItemClickListener);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_env, container, false);
setListView(view);
return view;
}
private void setLocationText(String subaddr){
final TextView addrTxt = (TextView)getActivity().findViewById(R.id.location_text);
if(subaddr != null) addrTxt.setText(subaddr);
}
private AdapterView.OnItemClickListener listItemClickListener= new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
customDialog = new CustomDialog(getActivity(), positiveListener);
customDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
customDialog.show();
customDialog.setText(position);
}
};
private View.OnClickListener positiveListener = new View.OnClickListener() {
public void onClick(View v) {
customDialog.dismiss();
}
};
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onDestroy() {
super.onDestroy();
locationManager.removeUpdates(mLocationListener);
}
}
......
package com.example.suemin.smartwindow.view.environment.listview;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.example.suemin.smartwindow.R;
import com.example.suemin.smartwindow.view.bluetooth.SensorResult;
public class CustomDialog extends Dialog {
private Button mPositiveButton;
private View.OnClickListener mPositiveListener;
private TextView AlertTitle, AlertNum, AlertState;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
layoutParams.dimAmount = 0.8f;
getWindow().setAttributes(layoutParams);
setContentView(R.layout.custom_dialog);
mPositiveButton=(Button)findViewById(R.id.pbutton);
mPositiveButton.setOnClickListener(mPositiveListener);
AlertTitle = (TextView) findViewById(R.id.dialog_title);
AlertNum = (TextView) findViewById(R.id.dialog_num);
AlertState= (TextView) findViewById(R.id.dialog_state);
}
public CustomDialog(@NonNull Context context, View.OnClickListener positiveListener) {
super(context);
this.mPositiveListener = positiveListener;
}
public boolean setText(int position)
{
switch (position) {
case 0:
AlertTitle.setText("현재 비");
AlertNum.setText(SensorResult.getRainResult());
break;
case 1:
AlertTitle.setText("현재 실외 미세먼지");
AlertNum.setText(Finedust.getFineDustResult()+"");
AlertState.setText("상태 : "+ SensorResult.getOuterFineDustState());
break;
case 2:
AlertTitle.setText("현재 실내 미세먼지");
AlertNum.setText("51");
AlertState.setText("상태 : " + SensorResult.getInnerFineDustState());
break;
case 3:
AlertTitle.setText("현재 실내 온도");
AlertNum.setText(SensorResult.getTemperatureResult() + "℃");
AlertState.setText("상태 : " + SensorResult.getTemperatureState());
break;
case 4:
AlertTitle.setText("현재 실내 습도");
AlertNum.setText(SensorResult.getHumidResult()+ "%");
AlertState.setText("상태 : " + SensorResult.getHumidState());
break;
case 5:
AlertTitle.setText("현재 침입자");
AlertNum.setText(SensorResult.getIntruderResult());
break;
}
return true;
}
}
package com.example.suemin.smartwindow.view.environment.listview;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.example.suemin.smartwindow.R;
import com.example.suemin.smartwindow.view.bluetooth.SensorResult;
public class CustomDialog extends Dialog {
private Button mPositiveButton;
private View.OnClickListener mPositiveListener;
private TextView AlertTitle, AlertNum, AlertState;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
layoutParams.dimAmount = 0.8f;
getWindow().setAttributes(layoutParams);
setContentView(R.layout.custom_dialog);
mPositiveButton=(Button)findViewById(R.id.pbutton);
mPositiveButton.setOnClickListener(mPositiveListener);
AlertTitle = (TextView) findViewById(R.id.dialog_title);
AlertNum = (TextView) findViewById(R.id.dialog_num);
AlertState= (TextView) findViewById(R.id.dialog_state);
}
public CustomDialog(@NonNull Context context, View.OnClickListener positiveListener) {
super(context);
this.mPositiveListener = positiveListener;
}
public boolean setText(int position)
{
switch (position) {
case 0:
AlertTitle.setText("현재 비");
AlertNum.setText(SensorResult.getRainResult());
break;
case 1:
AlertTitle.setText("현재 실외 미세먼지");
AlertNum.setText(Finedust.getFineDustResult()+"");
AlertState.setText("상태 : "+ SensorResult.getOuterFineDustState());
break;
case 2:
AlertTitle.setText("현재 실내 미세먼지");
AlertNum.setText("51");
AlertState.setText("상태 : " + SensorResult.getInnerFineDustState());
break;
case 3:
AlertTitle.setText("현재 실내 온도");
AlertNum.setText(SensorResult.getTemperatureResult() + "℃");
AlertState.setText("상태 : " + SensorResult.getTemperatureState());
break;
case 4:
AlertTitle.setText("현재 실내 습도");
AlertNum.setText(SensorResult.getHumidResult()+ "%");
AlertState.setText("상태 : " + SensorResult.getHumidState());
break;
case 5:
AlertTitle.setText("현재 침입자");
AlertNum.setText(SensorResult.getIntruderResult());
break;
}
return true;
}
}
......
package com.example.suemin.smartwindow.view.environment.listview;
import android.os.StrictMode;
import com.example.suemin.smartwindow.view.environment.Env;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
public class Finedust {
public static String getFineDustResult(){
String Key = "rqkQD0pLMXekuhOonOeI0xpbtEMtgBjTtMD5DZRWhDwQCezQGQsJ8bhg76N8YuihCKhY76QEWgsaZifSyupTDQ%3D%3D";
StrictMode.enableDefaults();
String currentLocation = Env.subaddr2;
boolean inPm10Value = false;
String pm10Value = null;
try{
URL url = new URL("http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getMsrstnAcctoRltmMesureDnsty?numOfRows=1&pageNo=1&stationName="
+ currentLocation +"&dataTerm=DAILY&ver=1.3&ServiceKey="+Key);
XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance();
XmlPullParser parser = parserCreator.newPullParser();
parser.setInput(url.openStream(),null);
int parserEvent = parser.getEventType();
while(parserEvent != XmlPullParser.END_DOCUMENT){
switch(parserEvent){
case XmlPullParser.START_TAG:
if(parser.getName().equals("pm10Value")){
inPm10Value= true;
}
break;
case XmlPullParser.TEXT:
if(inPm10Value){
pm10Value = parser.getText();
inPm10Value = false;
}
break;
case XmlPullParser.END_TAG:
if(parser.getName().equals("item")){
}
break;
}
parserEvent= parser.next();
}
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return pm10Value;
}
}
package com.example.suemin.smartwindow.view.environment.listview;
import android.os.StrictMode;
import com.example.suemin.smartwindow.view.environment.Env;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
public class Finedust {
public static String getFineDustResult(){
String Key = "rqkQD0pLMXekuhOonOeI0xpbtEMtgBjTtMD5DZRWhDwQCezQGQsJ8bhg76N8YuihCKhY76QEWgsaZifSyupTDQ%3D%3D";
StrictMode.enableDefaults();
String currentLocation = Env.subaddr2;
boolean inPm10Value = false;
String pm10Value = null;
try{
URL url = new URL("http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getMsrstnAcctoRltmMesureDnsty?numOfRows=1&pageNo=1&stationName="
+ currentLocation +"&dataTerm=DAILY&ver=1.3&ServiceKey="+Key);
XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance();
XmlPullParser parser = parserCreator.newPullParser();
parser.setInput(url.openStream(),null);
int parserEvent = parser.getEventType();
while(parserEvent != XmlPullParser.END_DOCUMENT){
switch(parserEvent){
case XmlPullParser.START_TAG:
if(parser.getName().equals("pm10Value")){
inPm10Value= true;
}
break;
case XmlPullParser.TEXT:
if(inPm10Value){
pm10Value = parser.getText();
inPm10Value = false;
}
break;
case XmlPullParser.END_TAG:
if(parser.getName().equals("item")){
}
break;
}
parserEvent= parser.next();
}
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return pm10Value;
}
}
......
package com.example.suemin.smartwindow.view.environment.listview;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.suemin.smartwindow.R;
import java.util.ArrayList;
public class ListViewAdapter extends BaseAdapter {
private ArrayList<ListViewItem> listViewItemList= new ArrayList<ListViewItem>();
public ListViewAdapter(){}
@Override
public int getCount() {
return listViewItemList.size();
}
@Override
public Object getItem(int position) {
return listViewItemList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
if(convertView == null){
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.listview_item, parent, false);
}
TextView titleTextView = (TextView) convertView.findViewById(R.id.textView1);
ImageView iconImageView = (ImageView) convertView.findViewById(R.id.imageView1);
ListViewItem listViewItem = listViewItemList.get(position);
titleTextView.setText(listViewItem.getTitle());
iconImageView.setImageDrawable(listViewItem.getIcon());
return convertView;
}
public void addItem(String title, Drawable icon){
ListViewItem item = new ListViewItem();
item.setTitle(title);
item.setIcon(icon);
listViewItemList.add(item);
}
}
package com.example.suemin.smartwindow.view.environment.listview;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.suemin.smartwindow.R;
import java.util.ArrayList;
public class ListViewAdapter extends BaseAdapter {
private ArrayList<ListViewItem> listViewItemList= new ArrayList<ListViewItem>();
public ListViewAdapter(){}
@Override
public int getCount() {
return listViewItemList.size();
}
@Override
public Object getItem(int position) {
return listViewItemList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int pos = position;
final Context context = parent.getContext();
if(convertView == null){
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.listview_item, parent, false);
}
TextView titleTextView = (TextView) convertView.findViewById(R.id.textView1);
ImageView iconImageView = (ImageView) convertView.findViewById(R.id.imageView1);
ListViewItem listViewItem = listViewItemList.get(position);
titleTextView.setText(listViewItem.getTitle());
iconImageView.setImageDrawable(listViewItem.getIcon());
return convertView;
}
public void addItem(String title, Drawable icon){
ListViewItem item = new ListViewItem();
item.setTitle(title);
item.setIcon(icon);
listViewItemList.add(item);
}
}
......
package com.example.suemin.smartwindow.view.environment.listview;
import android.graphics.drawable.Drawable;
public class ListViewItem {
private String titleStr ;
private Drawable iconDrawable ;
public void setIcon(Drawable icon) {
iconDrawable = icon ;
}
public void setTitle(String title) {
titleStr = title ;
}
public Drawable getIcon() {
return this.iconDrawable ;
}
public String getTitle() {
return this.titleStr ;
}
}
package com.example.suemin.smartwindow.view.environment.listview;
import android.graphics.drawable.Drawable;
public class ListViewItem {
private String titleStr ;
private Drawable iconDrawable ;
public void setIcon(Drawable icon) {
iconDrawable = icon ;
}
public void setTitle(String title) {
titleStr = title ;
}
public Drawable getIcon() {
return this.iconDrawable ;
}
public String getTitle() {
return this.titleStr ;
}
}
......
package com.example.suemin.smartwindow.view.home;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import com.example.suemin.smartwindow.R;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState;
public class Home extends Fragment {
int num = 0;
public Home() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
final TextView optionState= (TextView) view.findViewById(R.id.textView_switch);
final ImageView imgState = (ImageView) view.findViewById(R.id.imageView2);
Switch sw = (Switch) view.findViewById(R.id.switch1);
sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
optionState.setText("“ 열림 ”");
imgState.setImageResource(R.drawable.window_open);
if (!WindowState) {
setWindowState("n", getString(R.string.addr_m));
}
}
else{
num = num+1;
optionState.setText("“ 닫힘 ”");
imgState.setImageResource(R.drawable.window_closed);
if(WindowState) {setWindowState("y", getString(R.string.addr_m));
}
}
}
});
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
}
package com.example.suemin.smartwindow.view.home;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import com.example.suemin.smartwindow.R;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState;
import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState;
public class Home extends Fragment {
int num = 0;
public Home() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
final TextView optionState= (TextView) view.findViewById(R.id.textView_switch);
final ImageView imgState = (ImageView) view.findViewById(R.id.imageView2);
Switch sw = (Switch) view.findViewById(R.id.switch1);
sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
optionState.setText("“ 열림 ”");
imgState.setImageResource(R.drawable.window_open);
if (!WindowState) {
setWindowState("n", getString(R.string.addr_m));
}
}
else{
num = num+1;
optionState.setText("“ 닫힘 ”");
imgState.setImageResource(R.drawable.window_closed);
if(WindowState) {setWindowState("y", getString(R.string.addr_m));
}
}
}
});
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
}
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="@color/colorPrimary" />
<gradient
android:startColor="@color/colorPrimary"
android:endColor="#FFFFFF"
android:angle= "270">
</gradient>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="@color/colorPrimary" />
<gradient
android:startColor="@color/colorPrimary"
android:endColor="#FFFFFF"
android:angle= "270">
</gradient>
</shape>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle"
>
<solid android:color="#FFFFFF"></solid>
<corners
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"
android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
<stroke
android:width="2dp"
android:color="@color/colorPrimaryDark" />
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle"
>
<solid android:color="#FFFFFF"></solid>
<corners
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"
android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
<stroke
android:width="2dp"
android:color="@color/colorPrimaryDark" />
</shape>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="@color/colorPrimaryDark" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
<stroke
android:width="1dp"
android:color="@color/colorPrimaryDark" />
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="@color/colorPrimaryDark" />
<corners
android:bottomLeftRadius="20dp"
android:bottomRightRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
<stroke
android:width="1dp"
android:color="@color/colorPrimaryDark" />
</shape>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
......
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle = "normal"
android:fontWeight="400"
android:font = "@font/noto"/>
<font
android:fontStyle = "normal"
android:fontWeight = "400"
android:font = "@font/beba"/>
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle = "normal"
android:fontWeight="400"
android:font = "@font/noto"/>
<font
android:fontStyle = "normal"
android:fontWeight = "400"
android:font = "@font/beba"/>
</font-family>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.suemin.smartwindow.view.MainActivity"
>
<android.support.v7.widget.Toolbar
android:id="@+id/tb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark">
<ImageView
android:layout_width="32dp"
android:layout_height="30dp"
android:src="@drawable/icon"
android:paddingTop="8dp"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:text="@string/app_name"
android:fontFamily="@font/beba"
android:textColor="@color/colorAccent"
android:textSize="21dp"
android:textStyle="bold"
/>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_marginBottom="?attr/actionBarSize"
/>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.suemin.smartwindow.view.MainActivity"
>
<android.support.v7.widget.Toolbar
android:id="@+id/tb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimaryDark">
<ImageView
android:layout_width="32dp"
android:layout_height="30dp"
android:src="@drawable/icon"
android:paddingTop="8dp"
android:layout_marginRight="5dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="left"
android:text="@string/app_name"
android:fontFamily="@font/beba"
android:textColor="@color/colorAccent"
android:textSize="21dp"
android:textStyle="bold"
/>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_marginBottom="?attr/actionBarSize"
/>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="@color/colorPrimaryDark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/bt_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="name"
android:textColor="@color/colorAccent"
android:fontFamily="@font/noto"
android:textSize="21dp"
/>
<TextView
android:id="@+id/bt_textView_addr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="addr"
android:textColor="@color/colorAccent"
android:textSize="14dp"
android:layout_below="@+id/bt_textView"
/>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/bt_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="name"
android:textColor="@color/colorAccent"
android:fontFamily="@font/noto"
android:textSize="21dp"
/>
<TextView
android:id="@+id/bt_textView_addr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="addr"
android:textColor="@color/colorAccent"
android:textSize="14dp"
android:layout_below="@+id/bt_textView"
/>
</RelativeLayout>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="250dp"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:gravity="center"
android:orientation="vertical"
android:background="@drawable/dialog_background">
<TextView
android:id="@+id/dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textSize="20dp" />
<TextView
android:id="@+id/dialog_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textSize="60dp" />
<TextView
android:id="@+id/dialog_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:textSize="15dp" />
<Button
android:id="@+id/pbutton"
android:layout_width="50dp"
android:layout_height="25dp"
android:layout_marginBottom="10dp"
android:background="@drawable/dialog_button_background"
android:text="OK"
android:textColor="@color/colorAccent"/>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="250dp"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:gravity="center"
android:orientation="vertical"
android:background="@drawable/dialog_background">
<TextView
android:id="@+id/dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textSize="20dp" />
<TextView
android:id="@+id/dialog_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textSize="60dp" />
<TextView
android:id="@+id/dialog_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:textSize="15dp" />
<Button
android:id="@+id/pbutton"
android:layout_width="50dp"
android:layout_height="25dp"
android:layout_marginBottom="10dp"
android:background="@drawable/dialog_button_background"
android:text="OK"
android:textColor="@color/colorAccent"/>
</LinearLayout>
</LinearLayout>
......
<?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"
tools:context="com.example.suemin.smartwindow.view.bluetooth.Bluetooth"
android:background="@color/colorPrimaryDark">
<TextView
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="검색된 기기"
android:textSize="12dp"
android:textStyle="bold"
android:textColor="#a04e4e4e"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp">
</ListView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:paddingBottom="15dp">
<Button
android:id="@+id/bt_find_btn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="20dp"
android:background="@drawable/sync"
/>
</RelativeLayout>
<?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"
tools:context="com.example.suemin.smartwindow.view.bluetooth.Bluetooth"
android:background="@color/colorPrimaryDark">
<TextView
android:layout_width="wrap_content"
android:layout_height="22dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="검색된 기기"
android:textSize="12dp"
android:textStyle="bold"
android:textColor="#a04e4e4e"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp">
</ListView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:paddingBottom="15dp">
<Button
android:id="@+id/bt_find_btn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="20dp"
android:background="@drawable/sync"
/>
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
......
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.suemin.smartwindow.view.environment.Env"
android:background="@color/colorPrimaryDark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<!-- TODO: Update blank fragment layout -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginTop="10dp"
>
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginStart="7dp"
android:id="@+id/imageView1"
android:layout_centerVertical="true"
android:src="@drawable/icon_loca"
/>
<TextView
android:id="@+id/location_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:layout_marginStart="2dp"
android:layout_toRightOf="@+id/imageView1"
android:text="위치 확인중..."
android:textColor="@color/colorAccent"
android:textSize="12dp"/>
</RelativeLayout>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.suemin.smartwindow.view.environment.Env"
android:background="@color/colorPrimaryDark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<!-- TODO: Update blank fragment layout -->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginTop="10dp"
>
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginStart="7dp"
android:id="@+id/imageView1"
android:layout_centerVertical="true"
android:src="@drawable/icon_loca"
/>
<TextView
android:id="@+id/location_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:layout_marginStart="2dp"
android:layout_toRightOf="@+id/imageView1"
android:text="위치 확인중..."
android:textColor="@color/colorAccent"
android:textSize="12dp"/>
</RelativeLayout>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.suemin.smartwindow.view.home.Home"
android:background="@color/colorPrimaryDark">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="197dp"
android:layout_height="200dp"
android:layout_marginTop="80dp"
android:layout_marginBottom="50dp"
android:adjustViewBounds="true"
android:src="@drawable/window_closed"
android:layout_centerHorizontal="true"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_below="@id/imageView2"
android:layout_centerHorizontal="true"
>
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/switch1"
android:layout_centerHorizontal="true"
android:textColor="@color/colorAccent"
android:text="현재 창문 상태는"
android:textSize="17dp" />
<TextView
android:id="@+id/textView_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/noto"
android:text="“ 닫힘 ”"
android:textSize="25dp"
android:textStyle="bold"
android:textColor="@color/colorAccent"
android:layout_below="@id/textView2"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.suemin.smartwindow.view.home.Home"
android:background="@color/colorPrimaryDark">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView2"
android:layout_width="197dp"
android:layout_height="200dp"
android:layout_marginTop="80dp"
android:layout_marginBottom="50dp"
android:adjustViewBounds="true"
android:src="@drawable/window_closed"
android:layout_centerHorizontal="true"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="100dp"
android:layout_below="@id/imageView2"
android:layout_centerHorizontal="true"
>
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/switch1"
android:layout_centerHorizontal="true"
android:textColor="@color/colorAccent"
android:text="현재 창문 상태는"
android:textSize="17dp" />
<TextView
android:id="@+id/textView_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/noto"
android:text="“ 닫힘 ”"
android:textSize="25dp"
android:textStyle="bold"
android:textColor="@color/colorAccent"
android:layout_below="@id/textView2"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project
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
http://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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="State : "
android:textSize="18sp"/>
<Space android:layout_width="5dp"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/connection_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="no_data"
android:textSize="18sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data : "
android:id="@+id/device_name"
android:textSize="18sp"/>
<Space android:layout_width="5dp"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/data_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="no_data"
android:textSize="18sp"/>
</LinearLayout>
<ExpandableListView android:id="@+id/gatt_services_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The Android Open Source Project
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
http://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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="State : "
android:textSize="18sp"/>
<Space android:layout_width="5dp"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/connection_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="no_data"
android:textSize="18sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data : "
android:id="@+id/device_name"
android:textSize="18sp"/>
<Space android:layout_width="5dp"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/data_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="no_data"
android:textSize="18sp"/>
</LinearLayout>
<ExpandableListView android:id="@+id/gatt_services_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="fill_horizontal"
android:fontFamily="@font/noto"
android:text="New Text"
android:layout_toRightOf="@id/imageView1"
android:textColor="@color/colorAccent"
android:textSize="21dp" />
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_cloud_queue_black_24dp"
/>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="15dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="fill_horizontal"
android:fontFamily="@font/noto"
android:text="New Text"
android:layout_toRightOf="@id/imageView1"
android:textColor="@color/colorAccent"
android:textSize="21dp" />
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/imageView1"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_cloud_queue_black_24dp"
/>
</RelativeLayout>
</RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/sv_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="name"
android:textColor="@color/colorAccent"
android:fontFamily="@font/noto"
android:textSize="21dp"
/>
<TextView
android:id="@+id/sv_uuid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="addr"
android:textColor="@color/colorAccent"
android:textSize="14dp"
android:layout_below="@+id/sv_textView"
/>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/sv_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="name"
android:textColor="@color/colorAccent"
android:fontFamily="@font/noto"
android:textSize="21dp"
/>
<TextView
android:id="@+id/sv_uuid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:gravity="left"
android:text="addr"
android:textColor="@color/colorAccent"
android:textSize="14dp"
android:layout_below="@+id/sv_textView"
/>
</RelativeLayout>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/navigation_bt"
android:title="BT"
android:icon="@drawable/ic_bluetooth_black_24dp"
app:showAsAction="always"
/>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/navigation_bt"
android:title="BT"
android:icon="@drawable/ic_bluetooth_black_24dp"
app:showAsAction="always"
/>
</menu>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/title_home"
/>
<item
android:id="@+id/navigation_env"
android:icon="@drawable/ic_cloud_queue_black_24dp"
android:title="@string/title_activity_main2" />
<item
android:id="@+id/navigation_bt"
android:icon="@drawable/ic_bluetooth_black_24dp"
android:title="@string/title_activity_main33" />
</menu>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/navigation_home"
android:icon="@drawable/ic_home_black_24dp"
android:title="@string/title_home"
/>
<item
android:id="@+id/navigation_env"
android:icon="@drawable/ic_cloud_queue_black_24dp"
android:title="@string/title_activity_main2" />
<item
android:id="@+id/navigation_bt"
android:icon="@drawable/ic_bluetooth_black_24dp"
android:title="@string/title_activity_main33" />
</menu>
......
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#000000</color>
<color name="colorPrimaryDark">#7899ddff</color>
<color name="colorAccent">#f0646a71</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#000000</color>
<color name="colorPrimaryDark">#7899ddff</color>
<color name="colorAccent">#f0646a71</color>
</resources>
......
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="text_margin">16dp</dimen>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="text_margin">16dp</dimen>
</resources>
......
<resources>
<string name="app_name">SMART WINDOW</string>
<string name="title_home">Home</string>
<string name="title_activity_main2">Environment</string>
<string name="title_activity_main33">Bluetooth</string>
<string name="connected">Connected</string>
<string name="disconnected">Disconnected</string>
<string name="addr_m">90:E2:02:8F:36:70</string>
<string name="addr_d">90:E2:02:8E:1F:21</string>
<string name="addr_r">90:E2:02:92:A9:0E</string>
</resources>
<resources>
<string name="app_name">SMART WINDOW</string>
<string name="title_home">Home</string>
<string name="title_activity_main2">Environment</string>
<string name="title_activity_main33">Bluetooth</string>
<string name="connected">Connected</string>
<string name="disconnected">Disconnected</string>
<string name="addr_m">90:E2:02:8F:36:70</string>
<string name="addr_d">90:E2:02:8E:1F:21</string>
<string name="addr_r">90:E2:02:92:A9:0E</string>
</resources>
......
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
......
package com.example.suemin.smartwindow;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
package com.example.suemin.smartwindow;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
......
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
......
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
......
@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=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
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 init
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
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
: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 %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="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!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@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=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
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 init
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
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
: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 %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="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!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
......