이수민

최종보고서 수정

Showing 86 changed files with 2694 additions and 2694 deletions
No preview for this file type
1 -*.iml 1 +*.iml
2 -.gradle 2 +.gradle
3 -/local.properties 3 +/local.properties
4 -/.idea/caches/build_file_checksums.ser 4 +/.idea/caches/build_file_checksums.ser
5 -/.idea/libraries 5 +/.idea/libraries
6 -/.idea/modules.xml 6 +/.idea/modules.xml
7 -/.idea/workspace.xml 7 +/.idea/workspace.xml
8 -.DS_Store 8 +.DS_Store
9 -/build 9 +/build
10 -/captures 10 +/captures
11 -.externalNativeBuild 11 +.externalNativeBuild
......
1 -<component name="ProjectCodeStyleConfiguration"> 1 +<component name="ProjectCodeStyleConfiguration">
2 - <code_scheme name="Project" version="173"> 2 + <code_scheme name="Project" version="173">
3 - <Objective-C-extensions> 3 + <Objective-C-extensions>
4 - <file> 4 + <file>
5 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" /> 5 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
6 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" /> 6 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
7 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" /> 7 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
8 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" /> 8 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
9 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" /> 9 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
10 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" /> 10 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
11 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" /> 11 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
12 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" /> 12 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
13 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" /> 13 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
14 - </file> 14 + </file>
15 - <class> 15 + <class>
16 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" /> 16 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
17 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" /> 17 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
18 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" /> 18 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
19 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" /> 19 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
20 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> 20 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
21 - <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> 21 + <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
22 - </class> 22 + </class>
23 - <extensions> 23 + <extensions>
24 - <pair source="cpp" header="h" fileNamingConvention="NONE" /> 24 + <pair source="cpp" header="h" fileNamingConvention="NONE" />
25 - <pair source="c" header="h" fileNamingConvention="NONE" /> 25 + <pair source="c" header="h" fileNamingConvention="NONE" />
26 - </extensions> 26 + </extensions>
27 - </Objective-C-extensions> 27 + </Objective-C-extensions>
28 - </code_scheme> 28 + </code_scheme>
29 </component> 29 </component>
...\ No newline at end of file ...\ No newline at end of file
......
1 -apply plugin: 'com.android.application' 1 +apply plugin: 'com.android.application'
2 - 2 +
3 -android { 3 +android {
4 - compileSdkVersion 26 4 + compileSdkVersion 26
5 - defaultConfig { 5 + defaultConfig {
6 - applicationId "com.example.suemin.smartwindow" 6 + applicationId "com.example.suemin.smartwindow"
7 - minSdkVersion 24 7 + minSdkVersion 24
8 - targetSdkVersion 26 8 + targetSdkVersion 26
9 - versionCode 1 9 + versionCode 1
10 - versionName "1.0" 10 + versionName "1.0"
11 - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 11 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 - } 12 + }
13 - buildTypes { 13 + buildTypes {
14 - release { 14 + release {
15 - minifyEnabled false 15 + minifyEnabled false
16 - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 - } 17 + }
18 - } 18 + }
19 -} 19 +}
20 - 20 +
21 -dependencies { 21 +dependencies {
22 - implementation fileTree(dir: 'libs', include: ['*.jar']) 22 + implementation fileTree(dir: 'libs', include: ['*.jar'])
23 - implementation 'com.android.support:appcompat-v7:26.+' 23 + implementation 'com.android.support:appcompat-v7:26.+'
24 - implementation 'com.android.support:design:26.+' 24 + implementation 'com.android.support:design:26.+'
25 - implementation 'com.android.support.constraint:constraint-layout:1.1.3' 25 + implementation 'com.android.support.constraint:constraint-layout:1.1.3'
26 - implementation 'com.android.support:support-v4:26.1.0' 26 + implementation 'com.android.support:support-v4:26.1.0'
27 - implementation 'com.android.support:recyclerview-v7:26.1.0' 27 + implementation 'com.android.support:recyclerview-v7:26.1.0'
28 - testImplementation 'junit:junit:4.12' 28 + testImplementation 'junit:junit:4.12'
29 - androidTestImplementation 'com.android.support.test:runner:1.0.2' 29 + androidTestImplementation 'com.android.support.test:runner:1.0.2'
30 - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 30 + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
31 -} 31 +}
......
1 -# Add project specific ProGuard rules here. 1 +# Add project specific ProGuard rules here.
2 -# You can control the set of applied configuration files using the 2 +# You can control the set of applied configuration files using the
3 -# proguardFiles setting in build.gradle. 3 +# proguardFiles setting in build.gradle.
4 -# 4 +#
5 -# For more details, see 5 +# For more details, see
6 -# http://developer.android.com/guide/developing/tools/proguard.html 6 +# http://developer.android.com/guide/developing/tools/proguard.html
7 - 7 +
8 -# If your project uses WebView with JS, uncomment the following 8 +# If your project uses WebView with JS, uncomment the following
9 -# and specify the fully qualified class name to the JavaScript interface 9 +# and specify the fully qualified class name to the JavaScript interface
10 -# class: 10 +# class:
11 -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 -# public *; 12 +# public *;
13 -#} 13 +#}
14 - 14 +
15 -# Uncomment this to preserve the line number information for 15 +# Uncomment this to preserve the line number information for
16 -# debugging stack traces. 16 +# debugging stack traces.
17 -#-keepattributes SourceFile,LineNumberTable 17 +#-keepattributes SourceFile,LineNumberTable
18 - 18 +
19 -# If you keep the line number information, uncomment this to 19 +# If you keep the line number information, uncomment this to
20 -# hide the original source file name. 20 +# hide the original source file name.
21 -#-renamesourcefileattribute SourceFile 21 +#-renamesourcefileattribute SourceFile
......
1 -package com.example.suemin.smartwindow; 1 +package com.example.suemin.smartwindow;
2 - 2 +
3 -import android.content.Context; 3 +import android.content.Context;
4 -import android.support.test.InstrumentationRegistry; 4 +import android.support.test.InstrumentationRegistry;
5 -import android.support.test.runner.AndroidJUnit4; 5 +import android.support.test.runner.AndroidJUnit4;
6 - 6 +
7 -import org.junit.Test; 7 +import org.junit.Test;
8 -import org.junit.runner.RunWith; 8 +import org.junit.runner.RunWith;
9 - 9 +
10 -import static org.junit.Assert.*; 10 +import static org.junit.Assert.*;
11 - 11 +
12 -/** 12 +/**
13 - * Instrumented test, which will execute on an Android device. 13 + * Instrumented test, which will execute on an Android device.
14 - * 14 + *
15 - * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> 15 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16 - */ 16 + */
17 -@RunWith(AndroidJUnit4.class) 17 +@RunWith(AndroidJUnit4.class)
18 -public class ExampleInstrumentedTest { 18 +public class ExampleInstrumentedTest {
19 - @Test 19 + @Test
20 - public void useAppContext() { 20 + public void useAppContext() {
21 - // Context of the app under test. 21 + // Context of the app under test.
22 - Context appContext = InstrumentationRegistry.getTargetContext(); 22 + Context appContext = InstrumentationRegistry.getTargetContext();
23 - 23 +
24 - assertEquals("com.example.suemin.smartwindow", appContext.getPackageName()); 24 + assertEquals("com.example.suemin.smartwindow", appContext.getPackageName());
25 - } 25 + }
26 -} 26 +}
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 - package="com.example.suemin.smartwindow"> 3 + package="com.example.suemin.smartwindow">
4 - 4 +
5 - <uses-permission android:name="android.permission.INTERNET" /> 5 + <uses-permission android:name="android.permission.INTERNET" />
6 - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 6 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
7 - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 7 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
8 - <uses-permission android:name="android.permission.BLUETOOTH" /> 8 + <uses-permission android:name="android.permission.BLUETOOTH" />
9 - <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 9 + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
10 - 10 +
11 - <uses-feature 11 + <uses-feature
12 - android:name="android.hardware.bluetooth_le" 12 + android:name="android.hardware.bluetooth_le"
13 - android:required="true" /> 13 + android:required="true" />
14 - 14 +
15 - <application 15 + <application
16 - android:allowBackup="true" 16 + android:allowBackup="true"
17 - android:icon="@mipmap/ic_launcher" 17 + android:icon="@mipmap/ic_launcher"
18 - android:label="@string/app_name" 18 + android:label="@string/app_name"
19 - android:roundIcon="@mipmap/ic_launcher_round" 19 + android:roundIcon="@mipmap/ic_launcher_round"
20 - android:supportsRtl="true" 20 + android:supportsRtl="true"
21 - android:theme="@style/AppTheme"> 21 + android:theme="@style/AppTheme">
22 - <activity 22 + <activity
23 - android:name="com.example.suemin.smartwindow.view.MainActivity" 23 + android:name="com.example.suemin.smartwindow.view.MainActivity"
24 - android:label="@string/app_name"> 24 + android:label="@string/app_name">
25 - <intent-filter> 25 + <intent-filter>
26 - <action android:name="android.intent.action.MAIN" /> 26 + <action android:name="android.intent.action.MAIN" />
27 - 27 +
28 - <category android:name="android.intent.category.LAUNCHER" /> 28 + <category android:name="android.intent.category.LAUNCHER" />
29 - </intent-filter> 29 + </intent-filter>
30 - </activity> 30 + </activity>
31 - <service android:name="com.example.suemin.smartwindow.view.bluetooth.BluetoothLeService"/> 31 + <service android:name="com.example.suemin.smartwindow.view.bluetooth.BluetoothLeService"/>
32 - </application> 32 + </application>
33 - 33 +
34 </manifest> 34 </manifest>
...\ No newline at end of file ...\ No newline at end of file
......
1 -# Created by .ignore support plugin (hsz.mobi) 1 +# Created by .ignore support plugin (hsz.mobi)
2 -### Android template 2 +### Android template
3 -# Built application files 3 +# Built application files
4 -*.apk 4 +*.apk
5 -*.ap_ 5 +*.ap_
6 -*.aab 6 +*.aab
7 - 7 +
8 -# Files for the ART/Dalvik VM 8 +# Files for the ART/Dalvik VM
9 -*.dex 9 +*.dex
10 - 10 +
11 -# Java class files 11 +# Java class files
12 -*.class 12 +*.class
13 - 13 +
14 -# Generated files 14 +# Generated files
15 -bin/ 15 +bin/
16 -gen/ 16 +gen/
17 -out/ 17 +out/
18 -release/ 18 +release/
19 - 19 +
20 -# Gradle files 20 +# Gradle files
21 -.gradle/ 21 +.gradle/
22 -build/ 22 +build/
23 - 23 +
24 -# Local configuration file (sdk path, etc) 24 +# Local configuration file (sdk path, etc)
25 -local.properties 25 +local.properties
26 - 26 +
27 -# Proguard folder generated by Eclipse 27 +# Proguard folder generated by Eclipse
28 -proguard/ 28 +proguard/
29 - 29 +
30 -# Log Files 30 +# Log Files
31 -*.log 31 +*.log
32 - 32 +
33 -# Android Studio Navigation editor temp files 33 +# Android Studio Navigation editor temp files
34 -.navigation/ 34 +.navigation/
35 - 35 +
36 -# Android Studio captures folder 36 +# Android Studio captures folder
37 -captures/ 37 +captures/
38 - 38 +
39 -# IntelliJ 39 +# IntelliJ
40 -*.iml 40 +*.iml
41 -.idea/workspace.xml 41 +.idea/workspace.xml
42 -.idea/tasks.xml 42 +.idea/tasks.xml
43 -.idea/gradle.xml 43 +.idea/gradle.xml
44 -.idea/assetWizardSettings.xml 44 +.idea/assetWizardSettings.xml
45 -.idea/dictionaries 45 +.idea/dictionaries
46 -.idea/libraries 46 +.idea/libraries
47 -# Android Studio 3 in .gitignore file. 47 +# Android Studio 3 in .gitignore file.
48 -.idea/caches 48 +.idea/caches
49 -.idea/modules.xml 49 +.idea/modules.xml
50 -# Comment next line if keeping position of elements in Navigation Editor is relevant for you 50 +# Comment next line if keeping position of elements in Navigation Editor is relevant for you
51 -.idea/navEditor.xml 51 +.idea/navEditor.xml
52 - 52 +
53 -# Keystore files 53 +# Keystore files
54 -# Uncomment the following lines if you do not want to check your keystore files in. 54 +# Uncomment the following lines if you do not want to check your keystore files in.
55 -#*.jks 55 +#*.jks
56 -#*.keystore 56 +#*.keystore
57 - 57 +
58 -# External native build folder generated in Android Studio 2.2 and later 58 +# External native build folder generated in Android Studio 2.2 and later
59 -.externalNativeBuild 59 +.externalNativeBuild
60 - 60 +
61 -# Google Services (e.g. APIs or Firebase) 61 +# Google Services (e.g. APIs or Firebase)
62 -# google-services.json 62 +# google-services.json
63 - 63 +
64 -# Freeline 64 +# Freeline
65 -freeline.py 65 +freeline.py
66 -freeline/ 66 +freeline/
67 -freeline_project_description.json 67 +freeline_project_description.json
68 - 68 +
69 -# fastlane 69 +# fastlane
70 -fastlane/report.xml 70 +fastlane/report.xml
71 -fastlane/Preview.html 71 +fastlane/Preview.html
72 -fastlane/screenshots 72 +fastlane/screenshots
73 -fastlane/test_output 73 +fastlane/test_output
74 -fastlane/readme.md 74 +fastlane/readme.md
75 - 75 +
76 -# Version control 76 +# Version control
77 -vcs.xml 77 +vcs.xml
78 - 78 +
79 -# lint 79 +# lint
80 -lint/intermediates/ 80 +lint/intermediates/
81 -lint/generated/ 81 +lint/generated/
82 -lint/outputs/ 82 +lint/outputs/
83 -lint/tmp/ 83 +lint/tmp/
84 -# lint/reports/ 84 +# lint/reports/
85 - 85 +
......
1 -package com.example.suemin.smartwindow.view; 1 +package com.example.suemin.smartwindow.view;
2 - 2 +
3 -import android.app.NotificationChannel; 3 +import android.app.NotificationChannel;
4 -import android.app.NotificationManager; 4 +import android.app.NotificationManager;
5 -import android.content.Context; 5 +import android.content.Context;
6 -import android.graphics.BitmapFactory; 6 +import android.graphics.BitmapFactory;
7 -import android.graphics.Color; 7 +import android.graphics.Color;
8 -import android.media.AudioAttributes; 8 +import android.media.AudioAttributes;
9 -import android.net.Uri; 9 +import android.net.Uri;
10 -import android.os.Build; 10 +import android.os.Build;
11 -import android.os.Bundle; 11 +import android.os.Bundle;
12 -import android.support.annotation.NonNull; 12 +import android.support.annotation.NonNull;
13 -import android.support.design.widget.BottomNavigationView; 13 +import android.support.design.widget.BottomNavigationView;
14 -import android.support.v4.app.Fragment; 14 +import android.support.v4.app.Fragment;
15 -import android.support.v4.app.NotificationCompat; 15 +import android.support.v4.app.NotificationCompat;
16 -import android.support.v7.app.AppCompatActivity; 16 +import android.support.v7.app.AppCompatActivity;
17 -import android.support.v4.app.FragmentManager; 17 +import android.support.v4.app.FragmentManager;
18 -import android.support.v4.app.FragmentTransaction; 18 +import android.support.v4.app.FragmentTransaction;
19 -import android.view.MenuItem; 19 +import android.view.MenuItem;
20 -import android.support.v7.widget.Toolbar; 20 +import android.support.v7.widget.Toolbar;
21 - 21 +
22 - 22 +
23 -import com.example.suemin.smartwindow.R; 23 +import com.example.suemin.smartwindow.R;
24 -import com.example.suemin.smartwindow.view.bluetooth.Bluetooth; 24 +import com.example.suemin.smartwindow.view.bluetooth.Bluetooth;
25 -import com.example.suemin.smartwindow.view.environment.Env; 25 +import com.example.suemin.smartwindow.view.environment.Env;
26 -import com.example.suemin.smartwindow.view.home.Home; 26 +import com.example.suemin.smartwindow.view.home.Home;
27 - 27 +
28 -public class MainActivity extends AppCompatActivity { 28 +public class MainActivity extends AppCompatActivity {
29 - FragmentManager fragmentManager = getSupportFragmentManager(); 29 + FragmentManager fragmentManager = getSupportFragmentManager();
30 - FragmentTransaction fragmentTransaction; 30 + FragmentTransaction fragmentTransaction;
31 - Toolbar tb; 31 + Toolbar tb;
32 - 32 +
33 - public static final String NOTIFICATION_CHANNEL_ID = "10001"; 33 + public static final String NOTIFICATION_CHANNEL_ID = "10001";
34 - private int count = 0; 34 + private int count = 0;
35 - public static NotificationManager notificationManager; 35 + public static NotificationManager notificationManager;
36 - public static NotificationCompat.Builder builder; 36 + public static NotificationCompat.Builder builder;
37 - private static Uri sounduri; 37 + private static Uri sounduri;
38 - 38 +
39 - Home homeFragment = new Home(); 39 + Home homeFragment = new Home();
40 - Env envFragment = new Env(); 40 + Env envFragment = new Env();
41 - Bluetooth bluetoothFragment = new Bluetooth(); 41 + Bluetooth bluetoothFragment = new Bluetooth();
42 - 42 +
43 - private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener 43 + private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
44 - = new BottomNavigationView.OnNavigationItemSelectedListener() { 44 + = new BottomNavigationView.OnNavigationItemSelectedListener() {
45 - 45 +
46 - @Override 46 + @Override
47 - public boolean onNavigationItemSelected(@NonNull MenuItem item) { 47 + public boolean onNavigationItemSelected(@NonNull MenuItem item) {
48 - fragmentTransaction = fragmentManager.beginTransaction(); 48 + fragmentTransaction = fragmentManager.beginTransaction();
49 - 49 +
50 - switch (item.getItemId()) { 50 + switch (item.getItemId()) {
51 - case R.id.navigation_home: 51 + case R.id.navigation_home:
52 - replaceFragment(homeFragment); 52 + replaceFragment(homeFragment);
53 - return true; 53 + return true;
54 - case R.id.navigation_env: 54 + case R.id.navigation_env:
55 - replaceFragment(envFragment); 55 + replaceFragment(envFragment);
56 - return true; 56 + return true;
57 - case R.id.navigation_bt: 57 + case R.id.navigation_bt:
58 - replaceFragment(bluetoothFragment); 58 + replaceFragment(bluetoothFragment);
59 - return true; 59 + return true;
60 - } 60 + }
61 - return false; 61 + return false;
62 - } 62 + }
63 - }; 63 + };
64 - @Override 64 + @Override
65 - protected void onCreate(Bundle savedInstanceState) { 65 + protected void onCreate(Bundle savedInstanceState) {
66 - super.onCreate(savedInstanceState); 66 + super.onCreate(savedInstanceState);
67 - setContentView(R.layout.activity_main); 67 + setContentView(R.layout.activity_main);
68 - 68 +
69 - 69 +
70 - tb = (Toolbar) findViewById(R.id.tb); 70 + tb = (Toolbar) findViewById(R.id.tb);
71 - setSupportActionBar(tb); 71 + setSupportActionBar(tb);
72 - 72 +
73 - fragmentTransaction = fragmentManager.beginTransaction(); 73 + fragmentTransaction = fragmentManager.beginTransaction();
74 - fragmentTransaction.replace(R.id.frameLayout, homeFragment).commitAllowingStateLoss(); 74 + fragmentTransaction.replace(R.id.frameLayout, homeFragment).commitAllowingStateLoss();
75 - 75 +
76 - BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation); 76 + BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
77 - 77 +
78 - navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); 78 + navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
79 - 79 +
80 - notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 80 + notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
81 - builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID) 81 + builder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
82 - .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.icon_i2)) 82 + .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.icon_i2))
83 - .setContentTitle("침입자 알림") 83 + .setContentTitle("침입자 알림")
84 - .setContentText("침입자가 감지되었습니다") 84 + .setContentText("침입자가 감지되었습니다")
85 - .setPriority(NotificationCompat.PRIORITY_DEFAULT) 85 + .setPriority(NotificationCompat.PRIORITY_DEFAULT)
86 - .setAutoCancel(true); 86 + .setAutoCancel(true);
87 - sounduri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.noti_sound); 87 + sounduri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.noti_sound);
88 - 88 +
89 - } 89 + }
90 - public void replaceFragment(Fragment fragment) { 90 + public void replaceFragment(Fragment fragment) {
91 - FragmentManager fragmentManager = getSupportFragmentManager(); 91 + FragmentManager fragmentManager = getSupportFragmentManager();
92 - FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 92 + FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
93 - fragmentTransaction.replace(R.id.frameLayout, fragment).commit(); 93 + fragmentTransaction.replace(R.id.frameLayout, fragment).commit();
94 - } 94 + }
95 - 95 +
96 - public static void NotificationSomethings() { 96 + public static void NotificationSomethings() {
97 - 97 +
98 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 98 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
99 - 99 +
100 - builder.setSmallIcon(R.drawable.icon); 100 + builder.setSmallIcon(R.drawable.icon);
101 - CharSequence channelName = "channelname"; 101 + CharSequence channelName = "channelname";
102 - String description = "description"; 102 + String description = "description";
103 - int importance = NotificationManager.IMPORTANCE_HIGH; 103 + int importance = NotificationManager.IMPORTANCE_HIGH;
104 - AudioAttributes audioAttributes = new AudioAttributes.Builder() 104 + AudioAttributes audioAttributes = new AudioAttributes.Builder()
105 - .setUsage(AudioAttributes.USAGE_NOTIFICATION) 105 + .setUsage(AudioAttributes.USAGE_NOTIFICATION)
106 - .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) 106 + .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH)
107 - .build(); 107 + .build();
108 - 108 +
109 - NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName , importance); 109 + NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName , importance);
110 - channel.setDescription(description); 110 + channel.setDescription(description);
111 - channel.enableLights(true); 111 + channel.enableLights(true);
112 - channel.setLightColor(Color.RED); 112 + channel.setLightColor(Color.RED);
113 - channel.setSound(sounduri, audioAttributes); 113 + channel.setSound(sounduri, audioAttributes);
114 - channel.enableVibration(true); 114 + channel.enableVibration(true);
115 - channel.setVibrationPattern(new long[] {100,200,300,200}); 115 + channel.setVibrationPattern(new long[] {100,200,300,200});
116 - 116 +
117 - assert notificationManager != null; 117 + assert notificationManager != null;
118 - notificationManager.createNotificationChannel(channel); 118 + notificationManager.createNotificationChannel(channel);
119 - 119 +
120 - }else builder.setSmallIcon(R.mipmap.ic_launcher); 120 + }else builder.setSmallIcon(R.mipmap.ic_launcher);
121 - assert notificationManager != null; 121 + assert notificationManager != null;
122 - notificationManager.notify(1234, builder.build()); 122 + notificationManager.notify(1234, builder.build());
123 - 123 +
124 - } 124 + }
125 - 125 +
126 -} 126 +}
......
1 -package com.example.suemin.smartwindow.view.bluetooth; 1 +package com.example.suemin.smartwindow.view.bluetooth;
2 - 2 +
3 -import android.Manifest; 3 +import android.Manifest;
4 -import android.bluetooth.BluetoothAdapter; 4 +import android.bluetooth.BluetoothAdapter;
5 -import android.bluetooth.BluetoothDevice; 5 +import android.bluetooth.BluetoothDevice;
6 -import android.bluetooth.BluetoothGattCharacteristic; 6 +import android.bluetooth.BluetoothGattCharacteristic;
7 -import android.bluetooth.BluetoothGattService; 7 +import android.bluetooth.BluetoothGattService;
8 -import android.bluetooth.BluetoothManager; 8 +import android.bluetooth.BluetoothManager;
9 -import android.content.BroadcastReceiver; 9 +import android.content.BroadcastReceiver;
10 -import android.content.ComponentName; 10 +import android.content.ComponentName;
11 -import android.content.Context; 11 +import android.content.Context;
12 -import android.content.Intent; 12 +import android.content.Intent;
13 -import android.content.IntentFilter; 13 +import android.content.IntentFilter;
14 -import android.content.ServiceConnection; 14 +import android.content.ServiceConnection;
15 -import android.content.pm.PackageManager; 15 +import android.content.pm.PackageManager;
16 -import android.os.Build; 16 +import android.os.Build;
17 -import android.os.Bundle; 17 +import android.os.Bundle;
18 -import android.os.Handler; 18 +import android.os.Handler;
19 -import android.os.IBinder; 19 +import android.os.IBinder;
20 -import android.support.v4.app.ListFragment; 20 +import android.support.v4.app.ListFragment;
21 -import android.support.v4.content.ContextCompat; 21 +import android.support.v4.content.ContextCompat;
22 -import android.util.Log; 22 +import android.util.Log;
23 -import android.view.LayoutInflater; 23 +import android.view.LayoutInflater;
24 -import android.view.Menu; 24 +import android.view.Menu;
25 -import android.view.MenuInflater; 25 +import android.view.MenuInflater;
26 -import android.view.MenuItem; 26 +import android.view.MenuItem;
27 -import android.view.View; 27 +import android.view.View;
28 -import android.view.ViewGroup; 28 +import android.view.ViewGroup;
29 -import android.widget.BaseAdapter; 29 +import android.widget.BaseAdapter;
30 -import android.widget.Button; 30 +import android.widget.Button;
31 -import android.widget.ListView; 31 +import android.widget.ListView;
32 -import android.widget.TextView; 32 +import android.widget.TextView;
33 -import android.widget.Toast; 33 +import android.widget.Toast;
34 -import android.bluetooth.le.BluetoothLeScanner; 34 +import android.bluetooth.le.BluetoothLeScanner;
35 -import android.bluetooth.le.ScanCallback; 35 +import android.bluetooth.le.ScanCallback;
36 -import android.bluetooth.le.ScanResult; 36 +import android.bluetooth.le.ScanResult;
37 - 37 +
38 -import java.util.LinkedList; 38 +import java.util.LinkedList;
39 -import java.util.List; 39 +import java.util.List;
40 - 40 +
41 -import com.example.suemin.smartwindow.R; 41 +import com.example.suemin.smartwindow.R;
42 - 42 +
43 -import java.util.ArrayList; 43 +import java.util.ArrayList;
44 -import java.util.Queue; 44 +import java.util.Queue;
45 - 45 +
46 -import static android.content.ContentValues.TAG; 46 +import static android.content.ContentValues.TAG;
47 - 47 +
48 - 48 +
49 -public class Bluetooth extends ListFragment { 49 +public class Bluetooth extends ListFragment {
50 - private BluetoothAdapter mBluetoothAdapter; 50 + private BluetoothAdapter mBluetoothAdapter;
51 - private static BluetoothLeService mBluetoothLeService; 51 + private static BluetoothLeService mBluetoothLeService;
52 - private boolean mScanning; 52 + private boolean mScanning;
53 - private Handler mhandler; 53 + private Handler mhandler;
54 - private BluetoothLeScanner BLEScanner; 54 + private BluetoothLeScanner BLEScanner;
55 - 55 +
56 - private LeDeviceListAdapter leDeviceListAdapter; 56 + private LeDeviceListAdapter leDeviceListAdapter;
57 - private Queue<BluetoothDevice> connectionQueue; 57 + private Queue<BluetoothDevice> connectionQueue;
58 - private Thread connectionThread; 58 + private Thread connectionThread;
59 - 59 +
60 - 60 +
61 - private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics = 61 + private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics =
62 - new ArrayList<ArrayList<BluetoothGattCharacteristic>>(); 62 + new ArrayList<ArrayList<BluetoothGattCharacteristic>>();
63 - private BluetoothGattCharacteristic mNotifyCharacteristic; 63 + private BluetoothGattCharacteristic mNotifyCharacteristic;
64 - private static BluetoothGattCharacteristic motor; 64 + private static BluetoothGattCharacteristic motor;
65 - 65 +
66 - 66 +
67 - private static final long SCAN_PERIOD = 5000; 67 + private static final long SCAN_PERIOD = 5000;
68 - private static final int REQUEST_ENABLE_BT = 1; 68 + private static final int REQUEST_ENABLE_BT = 1;
69 - private static final int MY_LOCATION_REQUEST_CODE = 1; 69 + private static final int MY_LOCATION_REQUEST_CODE = 1;
70 - private static final int PERMISSION_REQUEST_COARSE_LOCATION = 100; 70 + private static final int PERMISSION_REQUEST_COARSE_LOCATION = 100;
71 - private final int moduleNum = 3; 71 + private final int moduleNum = 3;
72 - private boolean mConnected = false; 72 + private boolean mConnected = false;
73 - public static boolean WindowState = false; 73 + public static boolean WindowState = false;
74 - 74 +
75 - public Bluetooth() { 75 + public Bluetooth() {
76 - } 76 + }
77 - 77 +
78 - 78 +
79 - @Override 79 + @Override
80 - public void onCreate(Bundle savedInstanceState) { 80 + public void onCreate(Bundle savedInstanceState) {
81 - super.onCreate(savedInstanceState); 81 + super.onCreate(savedInstanceState);
82 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 82 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
83 - mCheckPermission(); 83 + mCheckPermission();
84 - } 84 + }
85 - Intent gattServiceIntent = new Intent(getActivity(), BluetoothLeService.class); 85 + Intent gattServiceIntent = new Intent(getActivity(), BluetoothLeService.class);
86 - getActivity().bindService(gattServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE); 86 + getActivity().bindService(gattServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { 90 + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
91 - inflater.inflate(R.menu.btmenu, menu); 91 + inflater.inflate(R.menu.btmenu, menu);
92 - super.onCreateOptionsMenu(menu, inflater); 92 + super.onCreateOptionsMenu(menu, inflater);
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public boolean onOptionsItemSelected(MenuItem item) { 96 + public boolean onOptionsItemSelected(MenuItem item) {
97 - if (item.getItemId() == R.id.navigation_bt) { 97 + if (item.getItemId() == R.id.navigation_bt) {
98 - 98 +
99 - if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { 99 + if (!getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
100 - } 100 + }
101 - final BluetoothManager bluetoothManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE); 101 + final BluetoothManager bluetoothManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE);
102 - if (bluetoothManager != null) { 102 + if (bluetoothManager != null) {
103 - mBluetoothAdapter = bluetoothManager.getAdapter(); 103 + mBluetoothAdapter = bluetoothManager.getAdapter();
104 - } 104 + }
105 - if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) { 105 + if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
106 - Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); 106 + Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
107 - startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); 107 + startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
108 - } 108 + }
109 - BLEScanner = mBluetoothAdapter.getBluetoothLeScanner(); 109 + BLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
110 - if (BLEScanner == null) { 110 + if (BLEScanner == null) {
111 - Toast.makeText(getActivity(), "Can not find BLE Scanner", Toast.LENGTH_SHORT).show(); 111 + Toast.makeText(getActivity(), "Can not find BLE Scanner", Toast.LENGTH_SHORT).show();
112 - } else { 112 + } else {
113 - Toast.makeText(getActivity(), "블루투스가 활성화되었습니다.", Toast.LENGTH_SHORT).show(); 113 + Toast.makeText(getActivity(), "블루투스가 활성화되었습니다.", Toast.LENGTH_SHORT).show();
114 - } 114 + }
115 - 115 +
116 - } 116 + }
117 - return super.onOptionsItemSelected(item); 117 + return super.onOptionsItemSelected(item);
118 - } 118 + }
119 - 119 +
120 - @Override 120 + @Override
121 - public View onCreateView(LayoutInflater inflater, ViewGroup container, 121 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
122 - Bundle savedInstanceState) { 122 + Bundle savedInstanceState) {
123 - View view = inflater.inflate(R.layout.fragment_bluetooth, container, false); 123 + View view = inflater.inflate(R.layout.fragment_bluetooth, container, false);
124 - setHasOptionsMenu(true); 124 + setHasOptionsMenu(true);
125 - connectionQueue = new LinkedList<BluetoothDevice>(); 125 + connectionQueue = new LinkedList<BluetoothDevice>();
126 - Button btFindBtn = (Button) view.findViewById(R.id.bt_find_btn); 126 + Button btFindBtn = (Button) view.findViewById(R.id.bt_find_btn);
127 - btFindBtn.setOnClickListener(new View.OnClickListener() { 127 + btFindBtn.setOnClickListener(new View.OnClickListener() {
128 - @Override 128 + @Override
129 - public void onClick(View v) { 129 + public void onClick(View v) {
130 - mhandler = new Handler(); 130 + mhandler = new Handler();
131 - leDeviceListAdapter = new LeDeviceListAdapter(); 131 + leDeviceListAdapter = new LeDeviceListAdapter();
132 - setListAdapter(leDeviceListAdapter); 132 + setListAdapter(leDeviceListAdapter);
133 - scanLeDevice(true); 133 + scanLeDevice(true);
134 - } 134 + }
135 - }); 135 + });
136 - 136 +
137 - return view; 137 + return view;
138 - } 138 + }
139 - 139 +
140 - private void mCheckPermission() { 140 + private void mCheckPermission() {
141 - 141 +
142 - if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(), 142 + if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getActivity(),
143 - Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 143 + Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
144 - requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 144 + requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
145 - PERMISSION_REQUEST_COARSE_LOCATION); 145 + PERMISSION_REQUEST_COARSE_LOCATION);
146 - } else { 146 + } else {
147 - } 147 + }
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { 151 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
152 - super.onRequestPermissionsResult(requestCode, permissions, grantResults); 152 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
153 - if (requestCode == MY_LOCATION_REQUEST_CODE) { 153 + if (requestCode == MY_LOCATION_REQUEST_CODE) {
154 - if (permissions.length == 1 && 154 + if (permissions.length == 1 &&
155 - permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION && 155 + permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION &&
156 - grantResults[0] == PackageManager.PERMISSION_GRANTED) { 156 + grantResults[0] == PackageManager.PERMISSION_GRANTED) {
157 - } else { 157 + } else {
158 - } 158 + }
159 - Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED", Toast.LENGTH_SHORT).show(); 159 + Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED", Toast.LENGTH_SHORT).show();
160 - } 160 + }
161 - } 161 + }
162 - 162 +
163 - 163 +
164 - private void scanLeDevice(final boolean enable) { 164 + private void scanLeDevice(final boolean enable) {
165 - if (enable) { 165 + if (enable) {
166 - mhandler.postDelayed(new Runnable() { 166 + mhandler.postDelayed(new Runnable() {
167 - @Override 167 + @Override
168 - public void run() { 168 + public void run() {
169 - mScanning = false; 169 + mScanning = false;
170 - BLEScanner.stopScan(ScanCallback); 170 + BLEScanner.stopScan(ScanCallback);
171 - Toast.makeText(getActivity(), "기기 탐색 완료", Toast.LENGTH_SHORT).show(); 171 + Toast.makeText(getActivity(), "기기 탐색 완료", Toast.LENGTH_SHORT).show();
172 - } 172 + }
173 - }, SCAN_PERIOD); 173 + }, SCAN_PERIOD);
174 - mScanning = true; 174 + mScanning = true;
175 - BLEScanner.startScan(ScanCallback); 175 + BLEScanner.startScan(ScanCallback);
176 - Toast.makeText(getActivity(), "주변 기기를 탐색중입니다...", Toast.LENGTH_SHORT).show(); 176 + Toast.makeText(getActivity(), "주변 기기를 탐색중입니다...", Toast.LENGTH_SHORT).show();
177 - } else { 177 + } else {
178 - mScanning = false; 178 + mScanning = false;
179 - BLEScanner.stopScan(ScanCallback); 179 + BLEScanner.stopScan(ScanCallback);
180 - } 180 + }
181 - } 181 + }
182 - 182 +
183 - private ScanCallback ScanCallback = new ScanCallback() { 183 + private ScanCallback ScanCallback = new ScanCallback() {
184 - @Override 184 + @Override
185 - public void onScanResult(int callbackType, ScanResult result) { 185 + public void onScanResult(int callbackType, ScanResult result) {
186 - processResult(result); 186 + processResult(result);
187 - } 187 + }
188 - @Override 188 + @Override
189 - public void onBatchScanResults(List<ScanResult> results) { 189 + public void onBatchScanResults(List<ScanResult> results) {
190 - for (ScanResult result : results) { 190 + for (ScanResult result : results) {
191 - processResult(result); 191 + processResult(result);
192 - } 192 + }
193 - } 193 + }
194 - @Override 194 + @Override
195 - public void onScanFailed(int errorCode) { 195 + public void onScanFailed(int errorCode) {
196 - } 196 + }
197 - 197 +
198 - private void processResult(final ScanResult result) { 198 + private void processResult(final ScanResult result) {
199 - getActivity().runOnUiThread(new Runnable() { 199 + getActivity().runOnUiThread(new Runnable() {
200 - @Override 200 + @Override
201 - public void run() { 201 + public void run() {
202 - leDeviceListAdapter.addDevice(result.getDevice()); 202 + leDeviceListAdapter.addDevice(result.getDevice());
203 - leDeviceListAdapter.notifyDataSetChanged(); 203 + leDeviceListAdapter.notifyDataSetChanged();
204 - } 204 + }
205 - }); 205 + });
206 - } 206 + }
207 - }; 207 + };
208 - 208 +
209 - private class LeDeviceListAdapter extends BaseAdapter { 209 + private class LeDeviceListAdapter extends BaseAdapter {
210 - private ArrayList<BluetoothDevice> mLeDevices; 210 + private ArrayList<BluetoothDevice> mLeDevices;
211 - private LayoutInflater mInflator; 211 + private LayoutInflater mInflator;
212 - 212 +
213 - public LeDeviceListAdapter() { 213 + public LeDeviceListAdapter() {
214 - super(); 214 + super();
215 - mLeDevices = new ArrayList<BluetoothDevice>(); 215 + mLeDevices = new ArrayList<BluetoothDevice>();
216 - mInflator = getActivity().getLayoutInflater(); 216 + mInflator = getActivity().getLayoutInflater();
217 - } 217 + }
218 - 218 +
219 - public void addDevice(BluetoothDevice device) { 219 + public void addDevice(BluetoothDevice device) {
220 - if (!mLeDevices.contains(device)) { 220 + if (!mLeDevices.contains(device)) {
221 - mLeDevices.add(device); 221 + mLeDevices.add(device);
222 - } 222 + }
223 - } 223 + }
224 - 224 +
225 - public BluetoothDevice getDevice(int position) { 225 + public BluetoothDevice getDevice(int position) {
226 - return mLeDevices.get(position); 226 + return mLeDevices.get(position);
227 - } 227 + }
228 - 228 +
229 - public void clear() { 229 + public void clear() {
230 - mLeDevices.clear(); 230 + mLeDevices.clear();
231 - } 231 + }
232 - 232 +
233 - @Override 233 + @Override
234 - public int getCount() { 234 + public int getCount() {
235 - return mLeDevices.size(); 235 + return mLeDevices.size();
236 - } 236 + }
237 - 237 +
238 - @Override 238 + @Override
239 - public Object getItem(int i) { 239 + public Object getItem(int i) {
240 - return mLeDevices.get(i); 240 + return mLeDevices.get(i);
241 - } 241 + }
242 - 242 +
243 - @Override 243 + @Override
244 - public long getItemId(int i) { 244 + public long getItemId(int i) {
245 - return i; 245 + return i;
246 - } 246 + }
247 - 247 +
248 - @Override 248 + @Override
249 - public View getView(int position, View view, ViewGroup viewGroup) { 249 + public View getView(int position, View view, ViewGroup viewGroup) {
250 - ViewHolder viewHolder = new ViewHolder(); 250 + ViewHolder viewHolder = new ViewHolder();
251 - if (view == null) { 251 + if (view == null) {
252 - view = mInflator.inflate(R.layout.bt_listview_item, null); 252 + view = mInflator.inflate(R.layout.bt_listview_item, null);
253 - viewHolder.deviceName = (TextView) view.findViewById(R.id.bt_textView); 253 + viewHolder.deviceName = (TextView) view.findViewById(R.id.bt_textView);
254 - viewHolder.deviceAddr = (TextView) view.findViewById(R.id.bt_textView_addr); 254 + viewHolder.deviceAddr = (TextView) view.findViewById(R.id.bt_textView_addr);
255 - view.setTag(viewHolder); 255 + view.setTag(viewHolder);
256 - } else { 256 + } else {
257 - viewHolder = (ViewHolder) view.getTag(); 257 + viewHolder = (ViewHolder) view.getTag();
258 - } 258 + }
259 - 259 +
260 - BluetoothDevice device = mLeDevices.get(position); 260 + BluetoothDevice device = mLeDevices.get(position);
261 - String deviceName = device.getName(); 261 + String deviceName = device.getName();
262 - String deviceAddr = device.getAddress(); 262 + String deviceAddr = device.getAddress();
263 - 263 +
264 - if (deviceName != null && deviceName.length() > 0) { 264 + if (deviceName != null && deviceName.length() > 0) {
265 - viewHolder.deviceName.setText(deviceName); 265 + viewHolder.deviceName.setText(deviceName);
266 - viewHolder.deviceAddr.setText(deviceAddr); 266 + viewHolder.deviceAddr.setText(deviceAddr);
267 - } else { 267 + } else {
268 - viewHolder.deviceName.setText("Unknown Device"); 268 + viewHolder.deviceName.setText("Unknown Device");
269 - viewHolder.deviceAddr.setText(deviceAddr); 269 + viewHolder.deviceAddr.setText(deviceAddr);
270 - } 270 + }
271 - return view; 271 + return view;
272 - } 272 + }
273 - 273 +
274 - private class ViewHolder { 274 + private class ViewHolder {
275 - TextView deviceName; 275 + TextView deviceName;
276 - TextView deviceAddr; 276 + TextView deviceAddr;
277 - } 277 + }
278 - } 278 + }
279 - 279 +
280 - @Override 280 + @Override
281 - public void onResume() { 281 + public void onResume() {
282 - super.onResume(); 282 + super.onResume();
283 - getActivity().registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter()); 283 + getActivity().registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
284 - } 284 + }
285 - 285 +
286 - @Override 286 + @Override
287 - public void onDestroy() { 287 + public void onDestroy() {
288 - super.onDestroy(); 288 + super.onDestroy();
289 - getActivity().unregisterReceiver(mGattUpdateReceiver); 289 + getActivity().unregisterReceiver(mGattUpdateReceiver);
290 - getActivity().unbindService(mServiceConnection); 290 + getActivity().unbindService(mServiceConnection);
291 - } 291 + }
292 - 292 +
293 - private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() { 293 + private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
294 - @Override 294 + @Override
295 - public void onReceive(Context context, Intent intent) { 295 + public void onReceive(Context context, Intent intent) {
296 - final String action = intent.getAction(); 296 + final String action = intent.getAction();
297 - String currentDeviceAddr = intent.getExtras().getString("extra.mac"); 297 + String currentDeviceAddr = intent.getExtras().getString("extra.mac");
298 - if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) { 298 + if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
299 - mConnected = true; 299 + mConnected = true;
300 - Toast.makeText(getActivity(), "연결되었습니다", Toast.LENGTH_SHORT).show(); 300 + Toast.makeText(getActivity(), "연결되었습니다", Toast.LENGTH_SHORT).show();
301 - } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) { 301 + } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
302 - mConnected = false; 302 + mConnected = false;
303 - } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) { 303 + } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
304 - Log.d(TAG, "onReceive: Service Discovered" + currentDeviceAddr); 304 + Log.d(TAG, "onReceive: Service Discovered" + currentDeviceAddr);
305 - int size = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).size(); 305 + int size = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).size();
306 - if (currentDeviceAddr.equals(getString(R.string.addr_m))) { 306 + if (currentDeviceAddr.equals(getString(R.string.addr_m))) {
307 - motor = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).get(size - 1).getCharacteristic(mBluetoothLeService.HM10); 307 + motor = mBluetoothLeService.getSupportedGattServices(currentDeviceAddr).get(size - 1).getCharacteristic(mBluetoothLeService.HM10);
308 - } else{ 308 + } else{
309 - getCharacteristics(mBluetoothLeService.getSupportedGattServices(currentDeviceAddr), currentDeviceAddr, size); 309 + getCharacteristics(mBluetoothLeService.getSupportedGattServices(currentDeviceAddr), currentDeviceAddr, size);
310 - } 310 + }
311 - } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) { 311 + } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
312 - 312 +
313 - String data = intent.getExtras().getString("data"); 313 + String data = intent.getExtras().getString("data");
314 - new SensorResult(getContext()).setData(data, currentDeviceAddr); 314 + new SensorResult(getContext()).setData(data, currentDeviceAddr);
315 - } 315 + }
316 - } 316 + }
317 - }; 317 + };
318 - 318 +
319 - public static void setWindowState(String state, String addr) { 319 + public static void setWindowState(String state, String addr) {
320 - if (motor != null && mBluetoothLeService != null) { 320 + if (motor != null && mBluetoothLeService != null) {
321 - if(state == "n"){ 321 + if(state == "n"){
322 - WindowState =true; } 322 + WindowState =true; }
323 - else { 323 + else {
324 - WindowState= false;} 324 + WindowState= false;}
325 - motor.setValue(state); 325 + motor.setValue(state);
326 - mBluetoothLeService.writeMotorCharacteristic(motor, addr); 326 + mBluetoothLeService.writeMotorCharacteristic(motor, addr);
327 - mBluetoothLeService.setCharacteristicNotification(motor, addr, true); 327 + mBluetoothLeService.setCharacteristicNotification(motor, addr, true);
328 - } 328 + }
329 - } 329 + }
330 - 330 +
331 - private boolean getCharacteristics(List<BluetoothGattService> gattService, String addr, int size) { 331 + private boolean getCharacteristics(List<BluetoothGattService> gattService, String addr, int size) {
332 - if (size != 0) { 332 + if (size != 0) {
333 - List<BluetoothGattCharacteristic> gattCharacteristics = gattService.get(size - 1).getCharacteristics(); 333 + List<BluetoothGattCharacteristic> gattCharacteristics = gattService.get(size - 1).getCharacteristics();
334 - ArrayList<BluetoothGattCharacteristic> charas = 334 + ArrayList<BluetoothGattCharacteristic> charas =
335 - new ArrayList<BluetoothGattCharacteristic>(); 335 + new ArrayList<BluetoothGattCharacteristic>();
336 - for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) { 336 + for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
337 - charas.add(gattCharacteristic); 337 + charas.add(gattCharacteristic);
338 - } 338 + }
339 - mGattCharacteristics.add(charas); 339 + mGattCharacteristics.add(charas);
340 - if (mGattCharacteristics != null) { 340 + if (mGattCharacteristics != null) {
341 - final BluetoothGattCharacteristic characteristic = charas.get(charas.size() - 1); 341 + final BluetoothGattCharacteristic characteristic = charas.get(charas.size() - 1);
342 - final int charaProp = characteristic.getProperties(); 342 + final int charaProp = characteristic.getProperties();
343 - 343 +
344 - if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) { 344 + if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
345 - if (mNotifyCharacteristic != null) { 345 + if (mNotifyCharacteristic != null) {
346 - mBluetoothLeService.setCharacteristicNotification( 346 + mBluetoothLeService.setCharacteristicNotification(
347 - mNotifyCharacteristic, addr, false); 347 + mNotifyCharacteristic, addr, false);
348 - mNotifyCharacteristic = null; 348 + mNotifyCharacteristic = null;
349 - } 349 + }
350 - mBluetoothLeService.readCharacteristic(characteristic, addr); 350 + mBluetoothLeService.readCharacteristic(characteristic, addr);
351 - } 351 + }
352 - if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { 352 + if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
353 - mNotifyCharacteristic = characteristic; 353 + mNotifyCharacteristic = characteristic;
354 - mBluetoothLeService.setCharacteristicNotification( 354 + mBluetoothLeService.setCharacteristicNotification(
355 - characteristic, addr, true); 355 + characteristic, addr, true);
356 - } 356 + }
357 - return true; 357 + return true;
358 - }} 358 + }}
359 - return false; 359 + return false;
360 - 360 +
361 - } 361 + }
362 - 362 +
363 - private static IntentFilter makeGattUpdateIntentFilter() { 363 + private static IntentFilter makeGattUpdateIntentFilter() {
364 - final IntentFilter intentFilter = new IntentFilter(); 364 + final IntentFilter intentFilter = new IntentFilter();
365 - intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED); 365 + intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
366 - intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED); 366 + intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
367 - intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); 367 + intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
368 - intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE); 368 + intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
369 - return intentFilter; 369 + return intentFilter;
370 - } 370 + }
371 - 371 +
372 - 372 +
373 - private final ServiceConnection mServiceConnection = new ServiceConnection() { 373 + private final ServiceConnection mServiceConnection = new ServiceConnection() {
374 - @Override 374 + @Override
375 - public void onServiceConnected(ComponentName name, IBinder service) { 375 + public void onServiceConnected(ComponentName name, IBinder service) {
376 - mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService(); 376 + mBluetoothLeService = ((BluetoothLeService.LocalBinder) service).getService();
377 - if (!mBluetoothLeService.initialize()) { 377 + if (!mBluetoothLeService.initialize()) {
378 - Log.d("", "Unable to initialize Bluetooth"); 378 + Log.d("", "Unable to initialize Bluetooth");
379 - } 379 + }
380 - Log.d("", "onServiceConnected: "); 380 + Log.d("", "onServiceConnected: ");
381 - } 381 + }
382 - 382 +
383 - @Override 383 + @Override
384 - public void onServiceDisconnected(ComponentName name) { 384 + public void onServiceDisconnected(ComponentName name) {
385 - mBluetoothLeService.close(); 385 + mBluetoothLeService.close();
386 - mBluetoothLeService.disconnect(); 386 + mBluetoothLeService.disconnect();
387 - mBluetoothLeService = null; 387 + mBluetoothLeService = null;
388 - } 388 + }
389 - }; 389 + };
390 - 390 +
391 - 391 +
392 - 392 +
393 - public void onListItemClick(ListView l, View v, int position, long id) { 393 + public void onListItemClick(ListView l, View v, int position, long id) {
394 - super.onListItemClick(l, v, position, id); 394 + super.onListItemClick(l, v, position, id);
395 - final BluetoothDevice device = leDeviceListAdapter.getDevice(position); 395 + final BluetoothDevice device = leDeviceListAdapter.getDevice(position);
396 - if (device == null) return; 396 + if (device == null) return;
397 - Toast.makeText(getActivity(), "연결중...", Toast.LENGTH_SHORT).show(); 397 + Toast.makeText(getActivity(), "연결중...", Toast.LENGTH_SHORT).show();
398 - connectionQueue.add(device); 398 + connectionQueue.add(device);
399 - if (mScanning) { 399 + if (mScanning) {
400 - BLEScanner.stopScan(ScanCallback); 400 + BLEScanner.stopScan(ScanCallback);
401 - mScanning = false; 401 + mScanning = false;
402 - } 402 + }
403 - if (connectionQueue.size() == moduleNum) { 403 + if (connectionQueue.size() == moduleNum) {
404 - initConnection(); 404 + initConnection();
405 - } 405 + }
406 - } 406 + }
407 - 407 +
408 - 408 +
409 - 409 +
410 - public void initConnection() { 410 + public void initConnection() {
411 - if (connectionThread == null) { 411 + if (connectionThread == null) {
412 - connectionThread = new Thread(new Runnable() { 412 + connectionThread = new Thread(new Runnable() {
413 - @Override 413 + @Override
414 - public void run() { 414 + public void run() {
415 - connectionloop(); 415 + connectionloop();
416 - connectionThread.interrupt(); 416 + connectionThread.interrupt();
417 - connectionThread = null; 417 + connectionThread = null;
418 - } 418 + }
419 - }); 419 + });
420 - connectionThread.start(); 420 + connectionThread.start();
421 - } 421 + }
422 - } 422 + }
423 - 423 +
424 - private void connectionloop() { 424 + private void connectionloop() {
425 - while (!connectionQueue.isEmpty()) { 425 + while (!connectionQueue.isEmpty()) {
426 - if(mBluetoothLeService != null) { 426 + if(mBluetoothLeService != null) {
427 - mBluetoothLeService.connect(connectionQueue.poll().getAddress()); 427 + mBluetoothLeService.connect(connectionQueue.poll().getAddress());
428 - } 428 + }
429 - try { 429 + try {
430 - Thread.sleep(250); 430 + Thread.sleep(250);
431 - } catch (InterruptedException e) { 431 + } catch (InterruptedException e) {
432 - } 432 + }
433 - } 433 + }
434 - } 434 + }
435 - 435 +
436 -} 436 +}
......
1 -package com.example.suemin.smartwindow.view.bluetooth; 1 +package com.example.suemin.smartwindow.view.bluetooth;
2 - 2 +
3 -import android.app.Service; 3 +import android.app.Service;
4 -import android.bluetooth.BluetoothAdapter; 4 +import android.bluetooth.BluetoothAdapter;
5 -import android.bluetooth.BluetoothDevice; 5 +import android.bluetooth.BluetoothDevice;
6 -import android.bluetooth.BluetoothGatt; 6 +import android.bluetooth.BluetoothGatt;
7 -import android.bluetooth.BluetoothGattCallback; 7 +import android.bluetooth.BluetoothGattCallback;
8 -import android.bluetooth.BluetoothGattCharacteristic; 8 +import android.bluetooth.BluetoothGattCharacteristic;
9 -import android.bluetooth.BluetoothGattDescriptor; 9 +import android.bluetooth.BluetoothGattDescriptor;
10 -import android.bluetooth.BluetoothGattService; 10 +import android.bluetooth.BluetoothGattService;
11 -import android.bluetooth.BluetoothManager; 11 +import android.bluetooth.BluetoothManager;
12 -import android.bluetooth.BluetoothProfile; 12 +import android.bluetooth.BluetoothProfile;
13 -import android.content.Context; 13 +import android.content.Context;
14 -import android.content.Intent; 14 +import android.content.Intent;
15 -import android.os.Binder; 15 +import android.os.Binder;
16 -import android.os.IBinder; 16 +import android.os.IBinder;
17 -import android.util.Log; 17 +import android.util.Log;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.List; 20 +import java.util.List;
21 -import java.util.Queue; 21 +import java.util.Queue;
22 -import java.util.UUID; 22 +import java.util.UUID;
23 - 23 +
24 -import static android.content.ContentValues.TAG; 24 +import static android.content.ContentValues.TAG;
25 - 25 +
26 - 26 +
27 -public class BluetoothLeService extends Service{ 27 +public class BluetoothLeService extends Service{
28 - 28 +
29 - private BluetoothManager mBluetoothManager; 29 + private BluetoothManager mBluetoothManager;
30 - private BluetoothAdapter mBluetoothAdapter; 30 + private BluetoothAdapter mBluetoothAdapter;
31 - private String mBluetoothDeviceAddress; 31 + private String mBluetoothDeviceAddress;
32 - private BluetoothGatt mBluetoothGatt; 32 + private BluetoothGatt mBluetoothGatt;
33 - private BluetoothGatt mBluetoothGatt_1; 33 + private BluetoothGatt mBluetoothGatt_1;
34 - private BluetoothGatt mBluetoothGatt_2; 34 + private BluetoothGatt mBluetoothGatt_2;
35 - private int mConnectionState = STATE_DISCONNECTED; 35 + private int mConnectionState = STATE_DISCONNECTED;
36 - 36 +
37 - private static final int STATE_DISCONNECTED = 0; 37 + private static final int STATE_DISCONNECTED = 0;
38 - private static final int STATE_CONNECTING = 1; 38 + private static final int STATE_CONNECTING = 1;
39 - private static final int STATE_CONNECTED = 2; 39 + private static final int STATE_CONNECTED = 2;
40 - 40 +
41 - public final static String ACTION_GATT_CONNECTED = 41 + public final static String ACTION_GATT_CONNECTED =
42 - "com.example.bluetooth.le.ACTION_GATT_CONNECTED"; 42 + "com.example.bluetooth.le.ACTION_GATT_CONNECTED";
43 - public final static String ACTION_GATT_DISCONNECTED = 43 + public final static String ACTION_GATT_DISCONNECTED =
44 - "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED"; 44 + "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
45 - public final static String ACTION_GATT_SERVICES_DISCOVERED = 45 + public final static String ACTION_GATT_SERVICES_DISCOVERED =
46 - "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED"; 46 + "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
47 - public final static String ACTION_DATA_AVAILABLE = 47 + public final static String ACTION_DATA_AVAILABLE =
48 - "com.example.bluetooth.le.ACTION_DATA_AVAILABLE"; 48 + "com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
49 - public final static String EXTRA_DATA = 49 + public final static String EXTRA_DATA =
50 - "com.example.bluetooth.le.EXTRA_DATA"; 50 + "com.example.bluetooth.le.EXTRA_DATA";
51 - 51 +
52 - public final static UUID HM10 = 52 + public final static UUID HM10 =
53 - UUID.fromString(SampleAttributes.HM_10); 53 + UUID.fromString(SampleAttributes.HM_10);
54 - 54 +
55 - private Queue<BluetoothGattCharacteristic> characteristicReadQueue = new LinkedList<BluetoothGattCharacteristic>(); 55 + private Queue<BluetoothGattCharacteristic> characteristicReadQueue = new LinkedList<BluetoothGattCharacteristic>();
56 - private Queue<BluetoothGatt> serviceDiscoveryQueue = new LinkedList<BluetoothGatt>(); 56 + private Queue<BluetoothGatt> serviceDiscoveryQueue = new LinkedList<BluetoothGatt>();
57 - private Thread serviceDiscoveryThread; 57 + private Thread serviceDiscoveryThread;
58 - private Thread initialisationThread; 58 + private Thread initialisationThread;
59 - private final int moduleNum = 3; 59 + private final int moduleNum = 3;
60 - 60 +
61 - private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() { 61 + private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
62 - @Override 62 + @Override
63 - public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { 63 + public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
64 - super.onConnectionStateChange(gatt, status, newState); 64 + super.onConnectionStateChange(gatt, status, newState);
65 - String intentAction; 65 + String intentAction;
66 - if (newState == BluetoothProfile.STATE_CONNECTED) { 66 + if (newState == BluetoothProfile.STATE_CONNECTED) {
67 - intentAction = ACTION_GATT_CONNECTED; 67 + intentAction = ACTION_GATT_CONNECTED;
68 - mConnectionState = STATE_CONNECTED; 68 + mConnectionState = STATE_CONNECTED;
69 - broadcastUpdate(intentAction, gatt); 69 + broadcastUpdate(intentAction, gatt);
70 - Log.d(TAG, "CONNECTED TO GATT SERVER " + gatt.getDevice().getName()); 70 + Log.d(TAG, "CONNECTED TO GATT SERVER " + gatt.getDevice().getName());
71 - serviceDiscoveryQueue.add(gatt); 71 + serviceDiscoveryQueue.add(gatt);
72 - if (serviceDiscoveryQueue.size() == moduleNum) { 72 + if (serviceDiscoveryQueue.size() == moduleNum) {
73 - initServiceDiscovery(); 73 + initServiceDiscovery();
74 - } 74 + }
75 - else { 75 + else {
76 - if (serviceDiscoveryQueue.size() == 1) { 76 + if (serviceDiscoveryQueue.size() == 1) {
77 - mBluetoothGatt_1 = gatt; 77 + mBluetoothGatt_1 = gatt;
78 - } else if (serviceDiscoveryQueue.size() == 2) { 78 + } else if (serviceDiscoveryQueue.size() == 2) {
79 - mBluetoothGatt_2 = gatt; 79 + mBluetoothGatt_2 = gatt;
80 - } 80 + }
81 - } 81 + }
82 - } else if (newState == BluetoothProfile.STATE_DISCONNECTED) { 82 + } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
83 - intentAction = ACTION_GATT_DISCONNECTED; 83 + intentAction = ACTION_GATT_DISCONNECTED;
84 - mConnectionState = STATE_DISCONNECTED; 84 + mConnectionState = STATE_DISCONNECTED;
85 - Log.i(TAG, "DISCONNECTED FROM GATT SERVER" + gatt.getDevice().getName()); 85 + Log.i(TAG, "DISCONNECTED FROM GATT SERVER" + gatt.getDevice().getName());
86 - broadcastUpdate(intentAction, gatt); 86 + broadcastUpdate(intentAction, gatt);
87 - } 87 + }
88 - } 88 + }
89 - @Override 89 + @Override
90 - public void onServicesDiscovered(BluetoothGatt gatt, int status) { 90 + public void onServicesDiscovered(BluetoothGatt gatt, int status) {
91 - super.onServicesDiscovered(gatt, status); 91 + super.onServicesDiscovered(gatt, status);
92 - if(status == BluetoothGatt.GATT_SUCCESS){ 92 + if(status == BluetoothGatt.GATT_SUCCESS){
93 - broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED, gatt); 93 + broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED, gatt);
94 - 94 +
95 - } 95 + }
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { 99 + public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
100 - super.onCharacteristicRead(gatt, characteristic, status); 100 + super.onCharacteristicRead(gatt, characteristic, status);
101 - Log.d(TAG, "onCharacteristicRead: " + gatt.getDevice().getName()); 101 + Log.d(TAG, "onCharacteristicRead: " + gatt.getDevice().getName());
102 - characteristicReadQueue.add(characteristic); 102 + characteristicReadQueue.add(characteristic);
103 - if(status == BluetoothGatt.GATT_SUCCESS ){ 103 + if(status == BluetoothGatt.GATT_SUCCESS ){
104 - initreadThread(gatt); 104 + initreadThread(gatt);
105 - broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt); 105 + broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt);
106 - } 106 + }
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { 110 + public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
111 - super.onCharacteristicChanged(gatt, characteristic); 111 + super.onCharacteristicChanged(gatt, characteristic);
112 - Log.d(TAG, "onCharacteristicChanged: " + gatt.getDevice().getName()); 112 + Log.d(TAG, "onCharacteristicChanged: " + gatt.getDevice().getName());
113 - characteristicReadQueue.add(characteristic); 113 + characteristicReadQueue.add(characteristic);
114 - if(characteristicReadQueue.size() > 0 ) { 114 + if(characteristicReadQueue.size() > 0 ) {
115 - initreadThread(gatt); 115 + initreadThread(gatt);
116 - broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt); 116 + broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic, gatt);
117 - } 117 + }
118 - } 118 + }
119 - }; 119 + };
120 - 120 +
121 - public void initServiceDiscovery(){ 121 + public void initServiceDiscovery(){
122 - if(serviceDiscoveryThread == null){ 122 + if(serviceDiscoveryThread == null){
123 - serviceDiscoveryThread = new Thread(new Runnable() { 123 + serviceDiscoveryThread = new Thread(new Runnable() {
124 - @Override 124 + @Override
125 - public void run() { 125 + public void run() {
126 - serviceDiscovery(); 126 + serviceDiscovery();
127 - 127 +
128 - serviceDiscoveryThread.interrupt(); 128 + serviceDiscoveryThread.interrupt();
129 - serviceDiscoveryThread = null; 129 + serviceDiscoveryThread = null;
130 - } 130 + }
131 - }); 131 + });
132 - serviceDiscoveryThread.start(); 132 + serviceDiscoveryThread.start();
133 - } 133 + }
134 - } 134 + }
135 - private void serviceDiscovery(){ 135 + private void serviceDiscovery(){
136 - while(!serviceDiscoveryQueue.isEmpty()){ 136 + while(!serviceDiscoveryQueue.isEmpty()){
137 - BluetoothGatt p = serviceDiscoveryQueue.poll(); 137 + BluetoothGatt p = serviceDiscoveryQueue.poll();
138 - p.discoverServices(); 138 + p.discoverServices();
139 - try{ 139 + try{
140 - Thread.sleep(250); 140 + Thread.sleep(250);
141 - } 141 + }
142 - catch (InterruptedException e){} 142 + catch (InterruptedException e){}
143 - } 143 + }
144 - } 144 + }
145 - 145 +
146 - private void broadcastUpdate(String action, BluetoothGatt gatt){ 146 + private void broadcastUpdate(String action, BluetoothGatt gatt){
147 - Intent intent = new Intent(action); 147 + Intent intent = new Intent(action);
148 - intent.putExtra("extra.mac", gatt.getDevice().getAddress()); 148 + intent.putExtra("extra.mac", gatt.getDevice().getAddress());
149 - sendBroadcast(intent); 149 + sendBroadcast(intent);
150 - } 150 + }
151 - 151 +
152 - private void broadcastUpdate(String action, BluetoothGattCharacteristic characteristic, BluetoothGatt gatt) { 152 + private void broadcastUpdate(String action, BluetoothGattCharacteristic characteristic, BluetoothGatt gatt) {
153 - final Intent intent = new Intent(action); 153 + final Intent intent = new Intent(action);
154 - intent.putExtra("extra.mac", gatt.getDevice().getAddress()); 154 + intent.putExtra("extra.mac", gatt.getDevice().getAddress());
155 - 155 +
156 - Log.v("AndroidLE", "broadcastUpdate()" + gatt.getDevice().getName()); 156 + Log.v("AndroidLE", "broadcastUpdate()" + gatt.getDevice().getName());
157 - final byte[] data = characteristic.getValue(); 157 + final byte[] data = characteristic.getValue();
158 - 158 +
159 - if (data != null && data.length > 0) { 159 + if (data != null && data.length > 0) {
160 - final StringBuilder stringBuilder = new StringBuilder(data.length); 160 + final StringBuilder stringBuilder = new StringBuilder(data.length);
161 - for(byte byteChar : data) { 161 + for(byte byteChar : data) {
162 - stringBuilder.append(String.format("%02X ", byteChar)); 162 + stringBuilder.append(String.format("%02X ", byteChar));
163 - } 163 + }
164 - String result = new String(data); 164 + String result = new String(data);
165 - Log.v("AndroidLE", gatt.getDevice().getName() + " ::: " + result); 165 + Log.v("AndroidLE", gatt.getDevice().getName() + " ::: " + result);
166 - intent.putExtra("data", result); 166 + intent.putExtra("data", result);
167 - sendBroadcast(intent); 167 + sendBroadcast(intent);
168 - } 168 + }
169 - } 169 + }
170 - public boolean initialize(){ 170 + public boolean initialize(){
171 - 171 +
172 - if(mBluetoothManager == null){ 172 + if(mBluetoothManager == null){
173 - mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); 173 + mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
174 - if(mBluetoothManager ==null){ 174 + if(mBluetoothManager ==null){
175 - Log.e(TAG, "Unable to initialize MANAGER"); 175 + Log.e(TAG, "Unable to initialize MANAGER");
176 - return false; 176 + return false;
177 - } 177 + }
178 - } 178 + }
179 - mBluetoothAdapter = mBluetoothManager.getAdapter(); 179 + mBluetoothAdapter = mBluetoothManager.getAdapter();
180 - if(mBluetoothAdapter == null){ 180 + if(mBluetoothAdapter == null){
181 - Log.e(TAG, "Unable to initialize ADAPTER"); 181 + Log.e(TAG, "Unable to initialize ADAPTER");
182 - return false; 182 + return false;
183 - } 183 + }
184 - 184 +
185 - return true; 185 + return true;
186 - } 186 + }
187 - 187 +
188 - public boolean connect(final String address){ 188 + public boolean connect(final String address){
189 - if(mBluetoothAdapter==null || address ==null){ 189 + if(mBluetoothAdapter==null || address ==null){
190 - return false; 190 + return false;
191 - } 191 + }
192 - if(mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null){ 192 + if(mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress) && mBluetoothGatt != null){
193 - Log.d(TAG, "connect: PREVIOUSLY CONNECTED DEVICE.. TRY TO RECONNECT"); 193 + Log.d(TAG, "connect: PREVIOUSLY CONNECTED DEVICE.. TRY TO RECONNECT");
194 - if (mBluetoothGatt.connect()){ 194 + if (mBluetoothGatt.connect()){
195 - mConnectionState = STATE_CONNECTING; 195 + mConnectionState = STATE_CONNECTING;
196 - return true; 196 + return true;
197 - } 197 + }
198 - else{ 198 + else{
199 - return false; 199 + return false;
200 - } 200 + }
201 - 201 +
202 - } 202 + }
203 - final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); 203 + final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
204 - if(device ==null){ 204 + if(device ==null){
205 - Log.w(TAG, "DEVICE NOT FOUND"); 205 + Log.w(TAG, "DEVICE NOT FOUND");
206 - return false; 206 + return false;
207 - } 207 + }
208 - mBluetoothGatt = device.connectGatt(this, true, mGattCallback); 208 + mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
209 - Log.d(TAG, "CONNECTING NEW DEVICE : " +device.getName()); 209 + Log.d(TAG, "CONNECTING NEW DEVICE : " +device.getName());
210 - mBluetoothDeviceAddress = address; 210 + mBluetoothDeviceAddress = address;
211 - mConnectionState = STATE_CONNECTING; 211 + mConnectionState = STATE_CONNECTING;
212 - return true; 212 + return true;
213 - } 213 + }
214 - 214 +
215 - public void disconnect(){ 215 + public void disconnect(){
216 - if(mBluetoothAdapter ==null || mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){ 216 + if(mBluetoothAdapter ==null || mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){
217 - return; 217 + return;
218 - } 218 + }
219 - mBluetoothGatt.disconnect(); 219 + mBluetoothGatt.disconnect();
220 - mBluetoothGatt_1.disconnect(); 220 + mBluetoothGatt_1.disconnect();
221 - mBluetoothGatt_2.disconnect(); 221 + mBluetoothGatt_2.disconnect();
222 - } 222 + }
223 - 223 +
224 - public void close(){ 224 + public void close(){
225 - if(mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){ 225 + if(mBluetoothGatt== null || mBluetoothGatt_1 ==null || mBluetoothGatt_2 ==null){
226 - return; 226 + return;
227 - } 227 + }
228 - mBluetoothGatt.close(); 228 + mBluetoothGatt.close();
229 - mBluetoothGatt =null; 229 + mBluetoothGatt =null;
230 - mBluetoothGatt_1.close(); 230 + mBluetoothGatt_1.close();
231 - mBluetoothGatt_1 =null; 231 + mBluetoothGatt_1 =null;
232 - mBluetoothGatt_2.close(); 232 + mBluetoothGatt_2.close();
233 - mBluetoothGatt_2 =null; 233 + mBluetoothGatt_2 =null;
234 - 234 +
235 - } 235 + }
236 - 236 +
237 - private final IBinder mBinder = new LocalBinder(); 237 + private final IBinder mBinder = new LocalBinder();
238 - public class LocalBinder extends Binder{ 238 + public class LocalBinder extends Binder{
239 - BluetoothLeService getService(){ 239 + BluetoothLeService getService(){
240 - return BluetoothLeService.this; 240 + return BluetoothLeService.this;
241 - } 241 + }
242 - } 242 + }
243 - @Override 243 + @Override
244 - public IBinder onBind(Intent intent) { 244 + public IBinder onBind(Intent intent) {
245 - return mBinder; 245 + return mBinder;
246 - } 246 + }
247 - public boolean onUnBind(Intent intent){ 247 + public boolean onUnBind(Intent intent){
248 - Log.d(TAG, "onUnBind: "); 248 + Log.d(TAG, "onUnBind: ");
249 - return super.onUnbind(intent); 249 + return super.onUnbind(intent);
250 - } 250 + }
251 - 251 +
252 - public void writeMotorCharacteristic(BluetoothGattCharacteristic characteristic, String addr){ 252 + public void writeMotorCharacteristic(BluetoothGattCharacteristic characteristic, String addr){
253 - if(addr.equals(mBluetoothGatt.getDevice().getAddress())){ 253 + if(addr.equals(mBluetoothGatt.getDevice().getAddress())){
254 - mBluetoothGatt.writeCharacteristic(characteristic); 254 + mBluetoothGatt.writeCharacteristic(characteristic);
255 - } 255 + }
256 - else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){ 256 + else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){
257 - Log.d(TAG, "writeMotorCharacteristic: "+addr ); 257 + Log.d(TAG, "writeMotorCharacteristic: "+addr );
258 - mBluetoothGatt_1.writeCharacteristic(characteristic); 258 + mBluetoothGatt_1.writeCharacteristic(characteristic);
259 - } 259 + }
260 - else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){ 260 + else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){
261 - Log.d(TAG, "writeMotorCharacteristic: "+addr); 261 + Log.d(TAG, "writeMotorCharacteristic: "+addr);
262 - mBluetoothGatt_2.writeCharacteristic(characteristic); 262 + mBluetoothGatt_2.writeCharacteristic(characteristic);
263 - } 263 + }
264 - } 264 + }
265 - public void readCharacteristic(BluetoothGattCharacteristic characteristic, String addr){ 265 + public void readCharacteristic(BluetoothGattCharacteristic characteristic, String addr){
266 - if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) { 266 + if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) {
267 - mBluetoothGatt.readCharacteristic(characteristic); 267 + mBluetoothGatt.readCharacteristic(characteristic);
268 - } 268 + }
269 - else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) { 269 + else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) {
270 - mBluetoothGatt_1.readCharacteristic(characteristic); 270 + mBluetoothGatt_1.readCharacteristic(characteristic);
271 - } 271 + }
272 - else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) { 272 + else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) {
273 - mBluetoothGatt_2.readCharacteristic(characteristic); 273 + mBluetoothGatt_2.readCharacteristic(characteristic);
274 - } 274 + }
275 - } 275 + }
276 - 276 +
277 - private void initreadThread(final BluetoothGatt gatt){ 277 + private void initreadThread(final BluetoothGatt gatt){
278 - if(initialisationThread == null) { 278 + if(initialisationThread == null) {
279 - initialisationThread = new Thread(new Runnable() { 279 + initialisationThread = new Thread(new Runnable() {
280 - @Override 280 + @Override
281 - public void run() { 281 + public void run() {
282 - readCharacteristics(gatt); 282 + readCharacteristics(gatt);
283 - initialisationThread.interrupt(); 283 + initialisationThread.interrupt();
284 - initialisationThread = null; 284 + initialisationThread = null;
285 - } 285 + }
286 - }); 286 + });
287 - initialisationThread.start(); 287 + initialisationThread.start();
288 - } 288 + }
289 - } 289 + }
290 - 290 +
291 - private void readCharacteristics(BluetoothGatt gatt) { 291 + private void readCharacteristics(BluetoothGatt gatt) {
292 - while (!characteristicReadQueue.isEmpty()) { 292 + while (!characteristicReadQueue.isEmpty()) {
293 - readCharacteristic(characteristicReadQueue.poll(), gatt.getDevice().getAddress()); 293 + readCharacteristic(characteristicReadQueue.poll(), gatt.getDevice().getAddress());
294 - try { 294 + try {
295 - Thread.sleep(1000); 295 + Thread.sleep(1000);
296 - } catch (InterruptedException e) { 296 + } catch (InterruptedException e) {
297 - } 297 + }
298 - } 298 + }
299 - } 299 + }
300 - 300 +
301 - 301 +
302 - public void setCharacteristicNotification(BluetoothGattCharacteristic characteristics, String addr, boolean enabled) { 302 + public void setCharacteristicNotification(BluetoothGattCharacteristic characteristics, String addr, boolean enabled) {
303 - if(addr.equals(mBluetoothGatt.getDevice().getAddress())) { 303 + if(addr.equals(mBluetoothGatt.getDevice().getAddress())) {
304 - mBluetoothGatt.setCharacteristicNotification(characteristics, true); 304 + mBluetoothGatt.setCharacteristicNotification(characteristics, true);
305 - if (HM10.equals(characteristics.getUuid())) { 305 + if (HM10.equals(characteristics.getUuid())) {
306 - BluetoothGattDescriptor descriptor = characteristics.getDescriptor( 306 + BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
307 - UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG)); 307 + UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
308 - descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 308 + descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
309 - mBluetoothGatt.writeDescriptor(descriptor); 309 + mBluetoothGatt.writeDescriptor(descriptor);
310 - } 310 + }
311 - } 311 + }
312 - else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){ 312 + else if (addr.equals(mBluetoothGatt_1.getDevice().getAddress())){
313 - mBluetoothGatt_1.setCharacteristicNotification(characteristics, true); 313 + mBluetoothGatt_1.setCharacteristicNotification(characteristics, true);
314 - if (HM10.equals(characteristics.getUuid())) { 314 + if (HM10.equals(characteristics.getUuid())) {
315 - BluetoothGattDescriptor descriptor = characteristics.getDescriptor( 315 + BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
316 - UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG)); 316 + UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
317 - descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 317 + descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
318 - mBluetoothGatt_1.writeDescriptor(descriptor); 318 + mBluetoothGatt_1.writeDescriptor(descriptor);
319 - } 319 + }
320 - } 320 + }
321 - else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){ 321 + else if (addr.equals(mBluetoothGatt_2.getDevice().getAddress())){
322 - mBluetoothGatt_2.setCharacteristicNotification(characteristics, true); 322 + mBluetoothGatt_2.setCharacteristicNotification(characteristics, true);
323 - if (HM10.equals(characteristics.getUuid())) { 323 + if (HM10.equals(characteristics.getUuid())) {
324 - BluetoothGattDescriptor descriptor = characteristics.getDescriptor( 324 + BluetoothGattDescriptor descriptor = characteristics.getDescriptor(
325 - UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG)); 325 + UUID.fromString(SampleAttributes.CLIENT_CHARACTERISTIC_CONFIG));
326 - descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 326 + descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
327 - mBluetoothGatt_2.writeDescriptor(descriptor); 327 + mBluetoothGatt_2.writeDescriptor(descriptor);
328 - } 328 + }
329 - } 329 + }
330 - } 330 + }
331 - 331 +
332 - public List<BluetoothGattService> getSupportedGattServices(String addr) { 332 + public List<BluetoothGattService> getSupportedGattServices(String addr) {
333 - if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) { 333 + if(addr.equals(mBluetoothGatt.getDevice().getAddress()) && mBluetoothGatt != null) {
334 - return mBluetoothGatt.getServices(); 334 + return mBluetoothGatt.getServices();
335 - } 335 + }
336 - else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) { 336 + else if(mBluetoothGatt_1 != null &&addr.equals(mBluetoothGatt_1.getDevice().getAddress())) {
337 - return mBluetoothGatt_1.getServices(); 337 + return mBluetoothGatt_1.getServices();
338 - } 338 + }
339 - else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) { 339 + else if(mBluetoothGatt_2 != null && addr.equals(mBluetoothGatt_2.getDevice().getAddress())) {
340 - return mBluetoothGatt_2.getServices(); 340 + return mBluetoothGatt_2.getServices();
341 - }else{ 341 + }else{
342 - return mBluetoothGatt.getServices(); 342 + return mBluetoothGatt.getServices();
343 - } 343 + }
344 - 344 +
345 - 345 +
346 - } 346 + }
347 - } 347 + }
348 - 348 +
......
1 -package com.example.suemin.smartwindow.view.bluetooth; 1 +package com.example.suemin.smartwindow.view.bluetooth;
2 - 2 +
3 -import java.util.HashMap; 3 +import java.util.HashMap;
4 - 4 +
5 -/** 5 +/**
6 - * This class includes a small subset of standard GATT attributes for demonstration purposes. 6 + * This class includes a small subset of standard GATT attributes for demonstration purposes.
7 - */ 7 + */
8 -public class SampleAttributes { 8 +public class SampleAttributes {
9 - private static HashMap<String, String> attributes = new HashMap(); 9 + private static HashMap<String, String> attributes = new HashMap();
10 - public static String HM_10 = "0000ffe1-0000-1000-8000-00805f9b34fb"; 10 + public static String HM_10 = "0000ffe1-0000-1000-8000-00805f9b34fb";
11 - public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb"; 11 + public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
12 - 12 +
13 - static { 13 + static {
14 - // Sample Services. 14 + // Sample Services.
15 - attributes.put("0000ffe0-0000-1000-8000-00805f9b34fb", "HM-10 Service"); 15 + attributes.put("0000ffe0-0000-1000-8000-00805f9b34fb", "HM-10 Service");
16 - attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service"); 16 + attributes.put("0000180a-0000-1000-8000-00805f9b34fb", "Device Information Service");
17 - // Sample Characteristics. 17 + // Sample Characteristics.
18 - attributes.put(HM_10, "HM-10 Module"); 18 + attributes.put(HM_10, "HM-10 Module");
19 - attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String"); 19 + attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
20 - } 20 + }
21 - 21 +
22 - public static String lookup(String uuid, String defaultName) { 22 + public static String lookup(String uuid, String defaultName) {
23 - String name = attributes.get(uuid); 23 + String name = attributes.get(uuid);
24 - return name == null ? defaultName : name; 24 + return name == null ? defaultName : name;
25 - } 25 + }
26 } 26 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -package com.example.suemin.smartwindow.view.bluetooth; 1 +package com.example.suemin.smartwindow.view.bluetooth;
2 - 2 +
3 - 3 +
4 -import android.content.Context; 4 +import android.content.Context;
5 - 5 +
6 -import com.example.suemin.smartwindow.R; 6 +import com.example.suemin.smartwindow.R;
7 -import static com.example.suemin.smartwindow.view.MainActivity.NotificationSomethings; 7 +import static com.example.suemin.smartwindow.view.MainActivity.NotificationSomethings;
8 -import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState; 8 +import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState;
9 -import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState; 9 +import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState;
10 -import static com.example.suemin.smartwindow.view.environment.listview.Finedust.getFineDustResult; 10 +import static com.example.suemin.smartwindow.view.environment.listview.Finedust.getFineDustResult;
11 - 11 +
12 -public class SensorResult { 12 +public class SensorResult {
13 - static Context mcontext = null; 13 + static Context mcontext = null;
14 - private static int otfd; 14 + private static int otfd;
15 - private static int infd; 15 + private static int infd;
16 - private static String rain, intr, humd, temp = "0"; 16 + private static String rain, intr, humd, temp = "0";
17 - private static boolean raining = false, intruder = false; 17 + private static boolean raining = false, intruder = false;
18 - public SensorResult(Context context){ 18 + public SensorResult(Context context){
19 - this.mcontext=context; 19 + this.mcontext=context;
20 - } 20 + }
21 - private void setWindowBySensor() { 21 + private void setWindowBySensor() {
22 - if ( "0".equals(otfd) || "0".equals(infd) || "0".equals(humd) || "0".equals(temp) ) { return ;} 22 + if ( "0".equals(otfd) || "0".equals(infd) || "0".equals(humd) || "0".equals(temp) ) { return ;}
23 - else{ 23 + else{
24 - 24 +
25 - // 1. 비가 오거나 침입자 발생, 외부 미세먼지 수치가 높다 25 + // 1. 비가 오거나 침입자 발생, 외부 미세먼지 수치가 높다
26 - if (otfd > 80 || raining || intruder) { 26 + if (otfd > 80 || raining || intruder) {
27 - // 열려있으면 닫는다 27 + // 열려있으면 닫는다
28 - if (WindowState) { 28 + if (WindowState) {
29 - setWindowState("y", mcontext.getString(R.string.addr_m)); 29 + setWindowState("y", mcontext.getString(R.string.addr_m));
30 - } 30 + }
31 - } 31 + }
32 - // 1. 비 안오고 침입자 없고 미세먼지 보통 이하 32 + // 1. 비 안오고 침입자 없고 미세먼지 보통 이하
33 - if (otfd <= 80 && !raining && !intruder) { 33 + if (otfd <= 80 && !raining && !intruder) {
34 - // 닫혀있는데 내부 미세먼지 나쁨이상이거나 온도 높거나 습도 높으면 연다 34 + // 닫혀있는데 내부 미세먼지 나쁨이상이거나 온도 높거나 습도 높으면 연다
35 - if (!WindowState) { 35 + if (!WindowState) {
36 - if (infd > 80 || getTemperatureState() == "높음" || getHumidState() == "높음") 36 + if (infd > 80 || getTemperatureState() == "높음" || getHumidState() == "높음")
37 - setWindowState("n", mcontext.getString(R.string.addr_m)); 37 + setWindowState("n", mcontext.getString(R.string.addr_m));
38 - } 38 + }
39 - // 열려있는데 온도가 낮으면 닫는다 39 + // 열려있는데 온도가 낮으면 닫는다
40 - else { 40 + else {
41 - if (getTemperatureState() == "낮음") { 41 + if (getTemperatureState() == "낮음") {
42 - setWindowState("y", mcontext.getString(R.string.addr_m)); 42 + setWindowState("y", mcontext.getString(R.string.addr_m));
43 - } 43 + }
44 - } 44 + }
45 - } 45 + }
46 - } 46 + }
47 - } 47 + }
48 - public void setData(String data, String addr){ 48 + public void setData(String data, String addr){
49 - if(addr != null && mcontext != null){ 49 + if(addr != null && mcontext != null){
50 - String sensor = data.substring(0,5); 50 + String sensor = data.substring(0,5);
51 - if(addr.equals(mcontext.getString(R.string.addr_r))) { 51 + if(addr.equals(mcontext.getString(R.string.addr_r))) {
52 - if (sensor.equals("intr ")) { 52 + if (sensor.equals("intr ")) {
53 - intr = data.substring(5); 53 + intr = data.substring(5);
54 - intruder = true; 54 + intruder = true;
55 - NotificationSomethings(); 55 + NotificationSomethings();
56 - } else { 56 + } else {
57 - rain = data.substring(5); 57 + rain = data.substring(5);
58 - raining = true; 58 + raining = true;
59 - } 59 + }
60 - } 60 + }
61 - else if (addr.equals(mcontext.getString(R.string.addr_d))){ 61 + else if (addr.equals(mcontext.getString(R.string.addr_d))){
62 - if(sensor.equals("temp ")) { 62 + if(sensor.equals("temp ")) {
63 - temp = data.substring(5); 63 + temp = data.substring(5);
64 - } 64 + }
65 - else if(sensor.equals("humd ")){ 65 + else if(sensor.equals("humd ")){
66 - humd = data.substring(5); 66 + humd = data.substring(5);
67 - } 67 + }
68 - else if(sensor.equals("dust ")){ 68 + else if(sensor.equals("dust ")){
69 - if(Double.parseDouble(data.substring(5)) > 0) { 69 + if(Double.parseDouble(data.substring(5)) > 0) {
70 - infd = Integer.parseInt(data.substring(5)); 70 + infd = Integer.parseInt(data.substring(5));
71 - } 71 + }
72 - } 72 + }
73 - else{return;} 73 + else{return;}
74 - } 74 + }
75 - setWindowBySensor(); 75 + setWindowBySensor();
76 - } 76 + }
77 - return ; 77 + return ;
78 - } 78 + }
79 - public static int getInnerDustResult(){ 79 + public static int getInnerDustResult(){
80 - return infd; 80 + return infd;
81 - } 81 + }
82 - public static double getHumidResult(){ 82 + public static double getHumidResult(){
83 - if(humd == null){return 0;} 83 + if(humd == null){return 0;}
84 - else { return Math.floor(Double.parseDouble(humd)*10)/10; } 84 + else { return Math.floor(Double.parseDouble(humd)*10)/10; }
85 - } 85 + }
86 - public static double getTemperatureResult(){ 86 + public static double getTemperatureResult(){
87 - if(temp == null){return 0;} 87 + if(temp == null){return 0;}
88 - else { return Math.floor(Double.parseDouble(temp)*10)/10; } 88 + else { return Math.floor(Double.parseDouble(temp)*10)/10; }
89 - } 89 + }
90 - public static String getRainResult(){ 90 + public static String getRainResult(){
91 - if(raining){ 91 + if(raining){
92 - return "내림"; 92 + return "내림";
93 - } 93 + }
94 - else {return "안내림";} 94 + else {return "안내림";}
95 - 95 +
96 - } 96 + }
97 - public static String getIntruderResult(){ 97 + public static String getIntruderResult(){
98 - if(intruder){ 98 + if(intruder){
99 - return "있음"; 99 + return "있음";
100 - } 100 + }
101 - else {return "없음";} 101 + else {return "없음";}
102 - } 102 + }
103 - public static String getOuterFineDustState(){ 103 + public static String getOuterFineDustState(){
104 - otfd = Integer.parseInt(getFineDustResult()); 104 + otfd = Integer.parseInt(getFineDustResult());
105 - int value = otfd; 105 + int value = otfd;
106 - String state = null; 106 + String state = null;
107 - if(value <31){ state = "좋음";} 107 + if(value <31){ state = "좋음";}
108 - else if (value >30 && value <81){state = "보통";} 108 + else if (value >30 && value <81){state = "보통";}
109 - else if (value>80 && value <151){state = "나쁨";} 109 + else if (value>80 && value <151){state = "나쁨";}
110 - else{ state = "매우나쁨"; } 110 + else{ state = "매우나쁨"; }
111 - return state; 111 + return state;
112 - } 112 + }
113 - public static String getInnerFineDustState(){ 113 + public static String getInnerFineDustState(){
114 - int value = getInnerDustResult(); 114 + int value = getInnerDustResult();
115 - String state = null; 115 + String state = null;
116 - if(value <31){ state = "좋음";} 116 + if(value <31){ state = "좋음";}
117 - else if (value >30 && value <81){state = "보통";} 117 + else if (value >30 && value <81){state = "보통";}
118 - else if (value>80 && value <151){state = "나쁨";} 118 + else if (value>80 && value <151){state = "나쁨";}
119 - else{ state = "매우나쁨"; } 119 + else{ state = "매우나쁨"; }
120 - return state; 120 + return state;
121 - } 121 + }
122 - public static String getTemperatureState() { 122 + public static String getTemperatureState() {
123 - double value = getTemperatureResult(); 123 + double value = getTemperatureResult();
124 - String state = null; 124 + String state = null;
125 - if (value < 18) { 125 + if (value < 18) {
126 - state = "낮음"; 126 + state = "낮음";
127 - } else if (value >= 18 && value <= 25) { 127 + } else if (value >= 18 && value <= 25) {
128 - state = "적정"; 128 + state = "적정";
129 - } else{ 129 + } else{
130 - state = "높음"; 130 + state = "높음";
131 - } 131 + }
132 - return state; 132 + return state;
133 - } 133 + }
134 - public static String getHumidState() { 134 + public static String getHumidState() {
135 - double value = getHumidResult(); 135 + double value = getHumidResult();
136 - String state = null; 136 + String state = null;
137 - if (value < 40) { 137 + if (value < 40) {
138 - state = "낮음"; 138 + state = "낮음";
139 - } else if (value >= 40 && value <= 60) { 139 + } else if (value >= 40 && value <= 60) {
140 - state = "적정"; 140 + state = "적정";
141 - } else { 141 + } else {
142 - state = "높음"; 142 + state = "높음";
143 - } 143 + }
144 - return state; 144 + return state;
145 - } 145 + }
146 - 146 +
147 -} 147 +}
......
1 -package com.example.suemin.smartwindow.view.environment; 1 +package com.example.suemin.smartwindow.view.environment;
2 - 2 +
3 -import android.Manifest; 3 +import android.Manifest;
4 -import android.content.Context; 4 +import android.content.Context;
5 -import android.content.pm.PackageManager; 5 +import android.content.pm.PackageManager;
6 -import android.graphics.drawable.ColorDrawable; 6 +import android.graphics.drawable.ColorDrawable;
7 -import android.location.Address; 7 +import android.location.Address;
8 -import android.location.Geocoder; 8 +import android.location.Geocoder;
9 -import android.location.LocationListener; 9 +import android.location.LocationListener;
10 -import android.location.LocationManager; 10 +import android.location.LocationManager;
11 -import android.os.Build; 11 +import android.os.Build;
12 -import android.os.Bundle; 12 +import android.os.Bundle;
13 -import android.support.annotation.NonNull; 13 +import android.support.annotation.NonNull;
14 -import android.support.v4.app.Fragment; 14 +import android.support.v4.app.Fragment;
15 -import android.support.v4.content.ContextCompat; 15 +import android.support.v4.content.ContextCompat;
16 -import android.util.Log; 16 +import android.util.Log;
17 -import android.view.LayoutInflater; 17 +import android.view.LayoutInflater;
18 -import android.view.View; 18 +import android.view.View;
19 -import android.view.ViewGroup; 19 +import android.view.ViewGroup;
20 -import android.widget.AdapterView; 20 +import android.widget.AdapterView;
21 -import android.widget.ListView; 21 +import android.widget.ListView;
22 -import android.widget.TextView; 22 +import android.widget.TextView;
23 -import android.widget.Toast; 23 +import android.widget.Toast;
24 - 24 +
25 -import com.example.suemin.smartwindow.R; 25 +import com.example.suemin.smartwindow.R;
26 -import com.example.suemin.smartwindow.view.environment.listview.CustomDialog; 26 +import com.example.suemin.smartwindow.view.environment.listview.CustomDialog;
27 -import com.example.suemin.smartwindow.view.environment.listview.ListViewAdapter; 27 +import com.example.suemin.smartwindow.view.environment.listview.ListViewAdapter;
28 - 28 +
29 -import java.io.IOException; 29 +import java.io.IOException;
30 -import java.util.List; 30 +import java.util.List;
31 -import java.util.Locale; 31 +import java.util.Locale;
32 - 32 +
33 - 33 +
34 -public class Env extends Fragment { 34 +public class Env extends Fragment {
35 - private LocationManager locationManager; 35 + private LocationManager locationManager;
36 - private static final int REQUEST_CODE_LOCATION = 2; 36 + private static final int REQUEST_CODE_LOCATION = 2;
37 - 37 +
38 - private double lat; 38 + private double lat;
39 - private double lng; 39 + private double lng;
40 - 40 +
41 - private String addr; 41 + private String addr;
42 - private String subaddr; 42 + private String subaddr;
43 - public static String subaddr2; 43 + public static String subaddr2;
44 - 44 +
45 - 45 +
46 - private CustomDialog customDialog; 46 + private CustomDialog customDialog;
47 - 47 +
48 - public Env() { 48 + public Env() {
49 - // Required empty public constructor 49 + // Required empty public constructor
50 - } 50 + }
51 - 51 +
52 - protected android.location.Location getCurrentLoca() { 52 + protected android.location.Location getCurrentLoca() {
53 - android.location.Location currentLocation = null; 53 + android.location.Location currentLocation = null;
54 - if(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){ 54 + if(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
55 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 55 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
56 - requestPermissions(new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_LOCATION); 56 + requestPermissions(new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_LOCATION);
57 - } } 57 + } }
58 - else { 58 + else {
59 - locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); 59 + locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
60 - locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, mLocationListener); 60 + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, mLocationListener);
61 - locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, mLocationListener); 61 + locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, mLocationListener);
62 - 62 +
63 - } 63 + }
64 - return currentLocation; 64 + return currentLocation;
65 - } 65 + }
66 - 66 +
67 - @Override 67 + @Override
68 - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 68 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
69 - super.onRequestPermissionsResult(requestCode, permissions, grantResults); 69 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
70 - if (requestCode == REQUEST_CODE_LOCATION) { 70 + if (requestCode == REQUEST_CODE_LOCATION) {
71 - if (permissions.length == 1 && 71 + if (permissions.length == 1 &&
72 - permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION && 72 + permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION &&
73 - grantResults[0] == PackageManager.PERMISSION_GRANTED) { 73 + grantResults[0] == PackageManager.PERMISSION_GRANTED) {
74 - } else { 74 + } else {
75 - } 75 + }
76 - // Permission was denied. Display an error message. 76 + // Permission was denied. Display an error message.
77 - Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED",Toast.LENGTH_SHORT).show(); 77 + Toast.makeText(getActivity(), "LOCATION_ACCESS_PERMISSION_DENIED",Toast.LENGTH_SHORT).show();
78 - } 78 + }
79 - } 79 + }
80 - 80 +
81 - private final LocationListener mLocationListener =new LocationListener() { 81 + private final LocationListener mLocationListener =new LocationListener() {
82 - @Override 82 + @Override
83 - public void onLocationChanged(android.location.Location location) { 83 + public void onLocationChanged(android.location.Location location) {
84 - lat = location.getLatitude(); 84 + lat = location.getLatitude();
85 - lng = location.getLongitude(); 85 + lng = location.getLongitude();
86 - addr =getCurrentAddr(lat,lng); 86 + addr =getCurrentAddr(lat,lng);
87 - int idx_s = addr.indexOf("시"); 87 + int idx_s = addr.indexOf("시");
88 - int idx_k = addr.indexOf("구"); 88 + int idx_k = addr.indexOf("구");
89 - int idx_g = addr.indexOf("동"); 89 + int idx_g = addr.indexOf("동");
90 - subaddr = addr.substring(idx_s+1, idx_g+1); 90 + subaddr = addr.substring(idx_s+1, idx_g+1);
91 - subaddr2 = addr.substring(idx_s+2, idx_k+1); 91 + subaddr2 = addr.substring(idx_s+2, idx_k+1);
92 - setLocationText(subaddr); 92 + setLocationText(subaddr);
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public void onStatusChanged(String provider, int status, Bundle extras) { 96 + public void onStatusChanged(String provider, int status, Bundle extras) {
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public void onProviderEnabled(String provider) { 100 + public void onProviderEnabled(String provider) {
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public void onProviderDisabled(String provider) { 104 + public void onProviderDisabled(String provider) {
105 - 105 +
106 - } 106 + }
107 - }; 107 + };
108 - 108 +
109 - private String getCurrentAddr(double lat, double lng) { 109 + private String getCurrentAddr(double lat, double lng) {
110 - Geocoder geocoder = new Geocoder(this.getActivity(), Locale.getDefault()); 110 + Geocoder geocoder = new Geocoder(this.getActivity(), Locale.getDefault());
111 - List<Address> addresses =null; 111 + List<Address> addresses =null;
112 - try { 112 + try {
113 - addresses = geocoder.getFromLocation( 113 + addresses = geocoder.getFromLocation(
114 - lat, 114 + lat,
115 - lng, 115 + lng,
116 - 7); 116 + 7);
117 - } catch (IOException ioException) { 117 + } catch (IOException ioException) {
118 - } catch (IllegalArgumentException illegalArgumentException) { 118 + } catch (IllegalArgumentException illegalArgumentException) {
119 - } 119 + }
120 - if (addresses == null) { 120 + if (addresses == null) {
121 - Log.d("getCurrentAddr: ","주소 미발견"); 121 + Log.d("getCurrentAddr: ","주소 미발견");
122 - } 122 + }
123 - Address address = addresses.get(0); 123 + Address address = addresses.get(0);
124 - return address.getAddressLine(0).toString()+"\n"; 124 + return address.getAddressLine(0).toString()+"\n";
125 - } 125 + }
126 - 126 +
127 - 127 +
128 - @Override 128 + @Override
129 - public void onCreate(Bundle savedInstanceState) { 129 + public void onCreate(Bundle savedInstanceState) {
130 - super.onCreate(savedInstanceState); 130 + super.onCreate(savedInstanceState);
131 - getCurrentLoca(); 131 + getCurrentLoca();
132 - } 132 + }
133 - 133 +
134 - public void setListView(View view) { 134 + public void setListView(View view) {
135 - ListViewAdapter adapter = new ListViewAdapter(); 135 + ListViewAdapter adapter = new ListViewAdapter();
136 - 136 +
137 - ListView listView = (ListView) view.findViewById(R.id.list); 137 + ListView listView = (ListView) view.findViewById(R.id.list);
138 - listView.setAdapter(adapter); 138 + listView.setAdapter(adapter);
139 - adapter.addItem("비", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_rain)); 139 + adapter.addItem("비", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_rain));
140 - adapter.addItem("실외 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_om)); 140 + adapter.addItem("실외 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_om));
141 - adapter.addItem("실내 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_sm)); 141 + adapter.addItem("실내 미세먼지", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_sm));
142 - adapter.addItem("실내 온도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_t)); 142 + adapter.addItem("실내 온도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_t));
143 - adapter.addItem("실내 습도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_s)); 143 + adapter.addItem("실내 습도", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_s));
144 - adapter.addItem("침입자", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_i)); 144 + adapter.addItem("침입자", ContextCompat.getDrawable(this.getContext(), R.drawable.icon_i));
145 - listView.setOnItemClickListener(listItemClickListener); 145 + listView.setOnItemClickListener(listItemClickListener);
146 - } 146 + }
147 - 147 +
148 - 148 +
149 - @Override 149 + @Override
150 - public View onCreateView(LayoutInflater inflater, ViewGroup container, 150 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
151 - Bundle savedInstanceState) { 151 + Bundle savedInstanceState) {
152 - View view = inflater.inflate(R.layout.fragment_env, container, false); 152 + View view = inflater.inflate(R.layout.fragment_env, container, false);
153 - setListView(view); 153 + setListView(view);
154 - 154 +
155 - return view; 155 + return view;
156 - } 156 + }
157 - private void setLocationText(String subaddr){ 157 + private void setLocationText(String subaddr){
158 - final TextView addrTxt = (TextView)getActivity().findViewById(R.id.location_text); 158 + final TextView addrTxt = (TextView)getActivity().findViewById(R.id.location_text);
159 - if(subaddr != null) addrTxt.setText(subaddr); 159 + if(subaddr != null) addrTxt.setText(subaddr);
160 - } 160 + }
161 - private AdapterView.OnItemClickListener listItemClickListener= new AdapterView.OnItemClickListener(){ 161 + private AdapterView.OnItemClickListener listItemClickListener= new AdapterView.OnItemClickListener(){
162 - @Override 162 + @Override
163 - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 163 + public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
164 - customDialog = new CustomDialog(getActivity(), positiveListener); 164 + customDialog = new CustomDialog(getActivity(), positiveListener);
165 - customDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 165 + customDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
166 - customDialog.show(); 166 + customDialog.show();
167 - customDialog.setText(position); 167 + customDialog.setText(position);
168 - } 168 + }
169 - }; 169 + };
170 - private View.OnClickListener positiveListener = new View.OnClickListener() { 170 + private View.OnClickListener positiveListener = new View.OnClickListener() {
171 - public void onClick(View v) { 171 + public void onClick(View v) {
172 - customDialog.dismiss(); 172 + customDialog.dismiss();
173 - } 173 + }
174 - }; 174 + };
175 - 175 +
176 - 176 +
177 - @Override 177 + @Override
178 - public void onAttach(Context context) { 178 + public void onAttach(Context context) {
179 - super.onAttach(context); 179 + super.onAttach(context);
180 - } 180 + }
181 - 181 +
182 - @Override 182 + @Override
183 - public void onDetach() { 183 + public void onDetach() {
184 - super.onDetach(); 184 + super.onDetach();
185 - } 185 + }
186 - 186 +
187 - @Override 187 + @Override
188 - public void onDestroy() { 188 + public void onDestroy() {
189 - super.onDestroy(); 189 + super.onDestroy();
190 - locationManager.removeUpdates(mLocationListener); 190 + locationManager.removeUpdates(mLocationListener);
191 - } 191 + }
192 - 192 +
193 - 193 +
194 -} 194 +}
......
1 -package com.example.suemin.smartwindow.view.environment.listview; 1 +package com.example.suemin.smartwindow.view.environment.listview;
2 - 2 +
3 -import android.app.Dialog; 3 +import android.app.Dialog;
4 -import android.content.Context; 4 +import android.content.Context;
5 -import android.os.Bundle; 5 +import android.os.Bundle;
6 -import android.support.annotation.NonNull; 6 +import android.support.annotation.NonNull;
7 -import android.view.View; 7 +import android.view.View;
8 -import android.view.WindowManager; 8 +import android.view.WindowManager;
9 -import android.widget.Button; 9 +import android.widget.Button;
10 -import android.widget.TextView; 10 +import android.widget.TextView;
11 - 11 +
12 -import com.example.suemin.smartwindow.R; 12 +import com.example.suemin.smartwindow.R;
13 -import com.example.suemin.smartwindow.view.bluetooth.SensorResult; 13 +import com.example.suemin.smartwindow.view.bluetooth.SensorResult;
14 - 14 +
15 -public class CustomDialog extends Dialog { 15 +public class CustomDialog extends Dialog {
16 - 16 +
17 - private Button mPositiveButton; 17 + private Button mPositiveButton;
18 - 18 +
19 - private View.OnClickListener mPositiveListener; 19 + private View.OnClickListener mPositiveListener;
20 - private TextView AlertTitle, AlertNum, AlertState; 20 + private TextView AlertTitle, AlertNum, AlertState;
21 - 21 +
22 - @Override 22 + @Override
23 - protected void onCreate(Bundle savedInstanceState) { 23 + protected void onCreate(Bundle savedInstanceState) {
24 - super.onCreate(savedInstanceState); 24 + super.onCreate(savedInstanceState);
25 - 25 +
26 - WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); 26 + WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
27 - layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND; 27 + layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
28 - layoutParams.dimAmount = 0.8f; 28 + layoutParams.dimAmount = 0.8f;
29 - 29 +
30 - getWindow().setAttributes(layoutParams); 30 + getWindow().setAttributes(layoutParams);
31 - 31 +
32 - setContentView(R.layout.custom_dialog); 32 + setContentView(R.layout.custom_dialog);
33 - 33 +
34 - mPositiveButton=(Button)findViewById(R.id.pbutton); 34 + mPositiveButton=(Button)findViewById(R.id.pbutton);
35 - 35 +
36 - mPositiveButton.setOnClickListener(mPositiveListener); 36 + mPositiveButton.setOnClickListener(mPositiveListener);
37 - 37 +
38 - AlertTitle = (TextView) findViewById(R.id.dialog_title); 38 + AlertTitle = (TextView) findViewById(R.id.dialog_title);
39 - AlertNum = (TextView) findViewById(R.id.dialog_num); 39 + AlertNum = (TextView) findViewById(R.id.dialog_num);
40 - AlertState= (TextView) findViewById(R.id.dialog_state); 40 + AlertState= (TextView) findViewById(R.id.dialog_state);
41 - } 41 + }
42 - 42 +
43 - public CustomDialog(@NonNull Context context, View.OnClickListener positiveListener) { 43 + public CustomDialog(@NonNull Context context, View.OnClickListener positiveListener) {
44 - super(context); 44 + super(context);
45 - this.mPositiveListener = positiveListener; 45 + this.mPositiveListener = positiveListener;
46 - } 46 + }
47 - public boolean setText(int position) 47 + public boolean setText(int position)
48 - { 48 + {
49 - switch (position) { 49 + switch (position) {
50 - case 0: 50 + case 0:
51 - AlertTitle.setText("현재 비"); 51 + AlertTitle.setText("현재 비");
52 - AlertNum.setText(SensorResult.getRainResult()); 52 + AlertNum.setText(SensorResult.getRainResult());
53 - break; 53 + break;
54 - case 1: 54 + case 1:
55 - AlertTitle.setText("현재 실외 미세먼지"); 55 + AlertTitle.setText("현재 실외 미세먼지");
56 - AlertNum.setText(Finedust.getFineDustResult()+""); 56 + AlertNum.setText(Finedust.getFineDustResult()+"");
57 - AlertState.setText("상태 : "+ SensorResult.getOuterFineDustState()); 57 + AlertState.setText("상태 : "+ SensorResult.getOuterFineDustState());
58 - break; 58 + break;
59 - case 2: 59 + case 2:
60 - AlertTitle.setText("현재 실내 미세먼지"); 60 + AlertTitle.setText("현재 실내 미세먼지");
61 - AlertNum.setText("51"); 61 + AlertNum.setText("51");
62 - AlertState.setText("상태 : " + SensorResult.getInnerFineDustState()); 62 + AlertState.setText("상태 : " + SensorResult.getInnerFineDustState());
63 - break; 63 + break;
64 - case 3: 64 + case 3:
65 - AlertTitle.setText("현재 실내 온도"); 65 + AlertTitle.setText("현재 실내 온도");
66 - AlertNum.setText(SensorResult.getTemperatureResult() + "℃"); 66 + AlertNum.setText(SensorResult.getTemperatureResult() + "℃");
67 - AlertState.setText("상태 : " + SensorResult.getTemperatureState()); 67 + AlertState.setText("상태 : " + SensorResult.getTemperatureState());
68 - break; 68 + break;
69 - case 4: 69 + case 4:
70 - AlertTitle.setText("현재 실내 습도"); 70 + AlertTitle.setText("현재 실내 습도");
71 - AlertNum.setText(SensorResult.getHumidResult()+ "%"); 71 + AlertNum.setText(SensorResult.getHumidResult()+ "%");
72 - AlertState.setText("상태 : " + SensorResult.getHumidState()); 72 + AlertState.setText("상태 : " + SensorResult.getHumidState());
73 - break; 73 + break;
74 - case 5: 74 + case 5:
75 - AlertTitle.setText("현재 침입자"); 75 + AlertTitle.setText("현재 침입자");
76 - AlertNum.setText(SensorResult.getIntruderResult()); 76 + AlertNum.setText(SensorResult.getIntruderResult());
77 - break; 77 + break;
78 - } 78 + }
79 - return true; 79 + return true;
80 - } 80 + }
81 - 81 +
82 -} 82 +}
83 - 83 +
......
1 -package com.example.suemin.smartwindow.view.environment.listview; 1 +package com.example.suemin.smartwindow.view.environment.listview;
2 - 2 +
3 -import android.os.StrictMode; 3 +import android.os.StrictMode;
4 - 4 +
5 -import com.example.suemin.smartwindow.view.environment.Env; 5 +import com.example.suemin.smartwindow.view.environment.Env;
6 - 6 +
7 -import org.xmlpull.v1.XmlPullParser; 7 +import org.xmlpull.v1.XmlPullParser;
8 -import org.xmlpull.v1.XmlPullParserException; 8 +import org.xmlpull.v1.XmlPullParserException;
9 -import org.xmlpull.v1.XmlPullParserFactory; 9 +import org.xmlpull.v1.XmlPullParserFactory;
10 - 10 +
11 -import java.io.IOException; 11 +import java.io.IOException;
12 -import java.net.MalformedURLException; 12 +import java.net.MalformedURLException;
13 -import java.net.URL; 13 +import java.net.URL;
14 - 14 +
15 -public class Finedust { 15 +public class Finedust {
16 - 16 +
17 - public static String getFineDustResult(){ 17 + public static String getFineDustResult(){
18 - String Key = "rqkQD0pLMXekuhOonOeI0xpbtEMtgBjTtMD5DZRWhDwQCezQGQsJ8bhg76N8YuihCKhY76QEWgsaZifSyupTDQ%3D%3D"; 18 + String Key = "rqkQD0pLMXekuhOonOeI0xpbtEMtgBjTtMD5DZRWhDwQCezQGQsJ8bhg76N8YuihCKhY76QEWgsaZifSyupTDQ%3D%3D";
19 - StrictMode.enableDefaults(); 19 + StrictMode.enableDefaults();
20 - String currentLocation = Env.subaddr2; 20 + String currentLocation = Env.subaddr2;
21 - boolean inPm10Value = false; 21 + boolean inPm10Value = false;
22 - String pm10Value = null; 22 + String pm10Value = null;
23 - try{ 23 + try{
24 - URL url = new URL("http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getMsrstnAcctoRltmMesureDnsty?numOfRows=1&pageNo=1&stationName=" 24 + URL url = new URL("http://openapi.airkorea.or.kr/openapi/services/rest/ArpltnInforInqireSvc/getMsrstnAcctoRltmMesureDnsty?numOfRows=1&pageNo=1&stationName="
25 - + currentLocation +"&dataTerm=DAILY&ver=1.3&ServiceKey="+Key); 25 + + currentLocation +"&dataTerm=DAILY&ver=1.3&ServiceKey="+Key);
26 - XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance(); 26 + XmlPullParserFactory parserCreator = XmlPullParserFactory.newInstance();
27 - XmlPullParser parser = parserCreator.newPullParser(); 27 + XmlPullParser parser = parserCreator.newPullParser();
28 - parser.setInput(url.openStream(),null); 28 + parser.setInput(url.openStream(),null);
29 - int parserEvent = parser.getEventType(); 29 + int parserEvent = parser.getEventType();
30 - while(parserEvent != XmlPullParser.END_DOCUMENT){ 30 + while(parserEvent != XmlPullParser.END_DOCUMENT){
31 - switch(parserEvent){ 31 + switch(parserEvent){
32 - case XmlPullParser.START_TAG: 32 + case XmlPullParser.START_TAG:
33 - if(parser.getName().equals("pm10Value")){ 33 + if(parser.getName().equals("pm10Value")){
34 - inPm10Value= true; 34 + inPm10Value= true;
35 - } 35 + }
36 - break; 36 + break;
37 - case XmlPullParser.TEXT: 37 + case XmlPullParser.TEXT:
38 - if(inPm10Value){ 38 + if(inPm10Value){
39 - pm10Value = parser.getText(); 39 + pm10Value = parser.getText();
40 - inPm10Value = false; 40 + inPm10Value = false;
41 - } 41 + }
42 - break; 42 + break;
43 - case XmlPullParser.END_TAG: 43 + case XmlPullParser.END_TAG:
44 - if(parser.getName().equals("item")){ 44 + if(parser.getName().equals("item")){
45 - } 45 + }
46 - break; 46 + break;
47 - } 47 + }
48 - parserEvent= parser.next(); 48 + parserEvent= parser.next();
49 - 49 +
50 - } 50 + }
51 - } catch (XmlPullParserException e) { 51 + } catch (XmlPullParserException e) {
52 - e.printStackTrace(); 52 + e.printStackTrace();
53 - } catch (MalformedURLException e) { 53 + } catch (MalformedURLException e) {
54 - e.printStackTrace(); 54 + e.printStackTrace();
55 - } catch (IOException e) { 55 + } catch (IOException e) {
56 - e.printStackTrace(); 56 + e.printStackTrace();
57 - } 57 + }
58 - return pm10Value; 58 + return pm10Value;
59 - } 59 + }
60 -} 60 +}
......
1 -package com.example.suemin.smartwindow.view.environment.listview; 1 +package com.example.suemin.smartwindow.view.environment.listview;
2 - 2 +
3 -import android.content.Context; 3 +import android.content.Context;
4 -import android.graphics.drawable.Drawable; 4 +import android.graphics.drawable.Drawable;
5 -import android.view.LayoutInflater; 5 +import android.view.LayoutInflater;
6 -import android.view.View; 6 +import android.view.View;
7 -import android.view.ViewGroup; 7 +import android.view.ViewGroup;
8 -import android.widget.BaseAdapter; 8 +import android.widget.BaseAdapter;
9 -import android.widget.ImageView; 9 +import android.widget.ImageView;
10 -import android.widget.TextView; 10 +import android.widget.TextView;
11 - 11 +
12 -import com.example.suemin.smartwindow.R; 12 +import com.example.suemin.smartwindow.R;
13 - 13 +
14 -import java.util.ArrayList; 14 +import java.util.ArrayList;
15 - 15 +
16 -public class ListViewAdapter extends BaseAdapter { 16 +public class ListViewAdapter extends BaseAdapter {
17 - 17 +
18 - private ArrayList<ListViewItem> listViewItemList= new ArrayList<ListViewItem>(); 18 + private ArrayList<ListViewItem> listViewItemList= new ArrayList<ListViewItem>();
19 - 19 +
20 - public ListViewAdapter(){} 20 + public ListViewAdapter(){}
21 - 21 +
22 - @Override 22 + @Override
23 - public int getCount() { 23 + public int getCount() {
24 - return listViewItemList.size(); 24 + return listViewItemList.size();
25 - } 25 + }
26 - 26 +
27 - @Override 27 + @Override
28 - public Object getItem(int position) { 28 + public Object getItem(int position) {
29 - return listViewItemList.get(position); 29 + return listViewItemList.get(position);
30 - } 30 + }
31 - 31 +
32 - @Override 32 + @Override
33 - public long getItemId(int position) { 33 + public long getItemId(int position) {
34 - return position; 34 + return position;
35 - } 35 + }
36 - 36 +
37 - @Override 37 + @Override
38 - public View getView(int position, View convertView, ViewGroup parent) { 38 + public View getView(int position, View convertView, ViewGroup parent) {
39 - final int pos = position; 39 + final int pos = position;
40 - final Context context = parent.getContext(); 40 + final Context context = parent.getContext();
41 - 41 +
42 - if(convertView == null){ 42 + if(convertView == null){
43 - LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 43 + LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
44 - convertView = inflater.inflate(R.layout.listview_item, parent, false); 44 + convertView = inflater.inflate(R.layout.listview_item, parent, false);
45 - } 45 + }
46 - 46 +
47 - TextView titleTextView = (TextView) convertView.findViewById(R.id.textView1); 47 + TextView titleTextView = (TextView) convertView.findViewById(R.id.textView1);
48 - ImageView iconImageView = (ImageView) convertView.findViewById(R.id.imageView1); 48 + ImageView iconImageView = (ImageView) convertView.findViewById(R.id.imageView1);
49 - 49 +
50 - ListViewItem listViewItem = listViewItemList.get(position); 50 + ListViewItem listViewItem = listViewItemList.get(position);
51 - 51 +
52 - titleTextView.setText(listViewItem.getTitle()); 52 + titleTextView.setText(listViewItem.getTitle());
53 - iconImageView.setImageDrawable(listViewItem.getIcon()); 53 + iconImageView.setImageDrawable(listViewItem.getIcon());
54 - 54 +
55 - return convertView; 55 + return convertView;
56 - } 56 + }
57 - public void addItem(String title, Drawable icon){ 57 + public void addItem(String title, Drawable icon){
58 - ListViewItem item = new ListViewItem(); 58 + ListViewItem item = new ListViewItem();
59 - item.setTitle(title); 59 + item.setTitle(title);
60 - item.setIcon(icon); 60 + item.setIcon(icon);
61 - listViewItemList.add(item); 61 + listViewItemList.add(item);
62 - } 62 + }
63 -} 63 +}
......
1 -package com.example.suemin.smartwindow.view.environment.listview; 1 +package com.example.suemin.smartwindow.view.environment.listview;
2 - 2 +
3 -import android.graphics.drawable.Drawable; 3 +import android.graphics.drawable.Drawable;
4 - 4 +
5 -public class ListViewItem { 5 +public class ListViewItem {
6 - private String titleStr ; 6 + private String titleStr ;
7 - private Drawable iconDrawable ; 7 + private Drawable iconDrawable ;
8 - 8 +
9 - public void setIcon(Drawable icon) { 9 + public void setIcon(Drawable icon) {
10 - iconDrawable = icon ; 10 + iconDrawable = icon ;
11 - } 11 + }
12 - public void setTitle(String title) { 12 + public void setTitle(String title) {
13 - titleStr = title ; 13 + titleStr = title ;
14 - } 14 + }
15 - 15 +
16 - public Drawable getIcon() { 16 + public Drawable getIcon() {
17 - return this.iconDrawable ; 17 + return this.iconDrawable ;
18 - } 18 + }
19 - public String getTitle() { 19 + public String getTitle() {
20 - return this.titleStr ; 20 + return this.titleStr ;
21 - } 21 + }
22 -} 22 +}
......
1 -package com.example.suemin.smartwindow.view.home; 1 +package com.example.suemin.smartwindow.view.home;
2 - 2 +
3 - 3 +
4 -import android.content.Context; 4 +import android.content.Context;
5 -import android.os.Bundle; 5 +import android.os.Bundle;
6 -import android.support.v4.app.Fragment; 6 +import android.support.v4.app.Fragment;
7 -import android.view.LayoutInflater; 7 +import android.view.LayoutInflater;
8 -import android.view.View; 8 +import android.view.View;
9 -import android.view.ViewGroup; 9 +import android.view.ViewGroup;
10 -import android.widget.CompoundButton; 10 +import android.widget.CompoundButton;
11 -import android.widget.ImageView; 11 +import android.widget.ImageView;
12 -import android.widget.Switch; 12 +import android.widget.Switch;
13 -import android.widget.TextView; 13 +import android.widget.TextView;
14 - 14 +
15 -import com.example.suemin.smartwindow.R; 15 +import com.example.suemin.smartwindow.R;
16 - 16 +
17 -import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState; 17 +import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.WindowState;
18 -import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState; 18 +import static com.example.suemin.smartwindow.view.bluetooth.Bluetooth.setWindowState;
19 - 19 +
20 - 20 +
21 - 21 +
22 -public class Home extends Fragment { 22 +public class Home extends Fragment {
23 - 23 +
24 - 24 +
25 - int num = 0; 25 + int num = 0;
26 - 26 +
27 - public Home() { 27 + public Home() {
28 - // Required empty public constructor 28 + // Required empty public constructor
29 - } 29 + }
30 - 30 +
31 - @Override 31 + @Override
32 - public void onCreate(Bundle savedInstanceState) { 32 + public void onCreate(Bundle savedInstanceState) {
33 - super.onCreate(savedInstanceState); 33 + super.onCreate(savedInstanceState);
34 - 34 +
35 - } 35 + }
36 - @Override 36 + @Override
37 - public View onCreateView(LayoutInflater inflater, ViewGroup container, 37 + public View onCreateView(LayoutInflater inflater, ViewGroup container,
38 - Bundle savedInstanceState) { 38 + Bundle savedInstanceState) {
39 - View view = inflater.inflate(R.layout.fragment_home, container, false); 39 + View view = inflater.inflate(R.layout.fragment_home, container, false);
40 - final TextView optionState= (TextView) view.findViewById(R.id.textView_switch); 40 + final TextView optionState= (TextView) view.findViewById(R.id.textView_switch);
41 - final ImageView imgState = (ImageView) view.findViewById(R.id.imageView2); 41 + final ImageView imgState = (ImageView) view.findViewById(R.id.imageView2);
42 - Switch sw = (Switch) view.findViewById(R.id.switch1); 42 + Switch sw = (Switch) view.findViewById(R.id.switch1);
43 - sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 43 + sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
44 - @Override 44 + @Override
45 - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 45 + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
46 - if(isChecked) { 46 + if(isChecked) {
47 - optionState.setText("“ 열림 ”"); 47 + optionState.setText("“ 열림 ”");
48 - imgState.setImageResource(R.drawable.window_open); 48 + imgState.setImageResource(R.drawable.window_open);
49 - if (!WindowState) { 49 + if (!WindowState) {
50 - setWindowState("n", getString(R.string.addr_m)); 50 + setWindowState("n", getString(R.string.addr_m));
51 - } 51 + }
52 - } 52 + }
53 - else{ 53 + else{
54 - num = num+1; 54 + num = num+1;
55 - optionState.setText("“ 닫힘 ”"); 55 + optionState.setText("“ 닫힘 ”");
56 - imgState.setImageResource(R.drawable.window_closed); 56 + imgState.setImageResource(R.drawable.window_closed);
57 - if(WindowState) {setWindowState("y", getString(R.string.addr_m)); 57 + if(WindowState) {setWindowState("y", getString(R.string.addr_m));
58 - } 58 + }
59 - } 59 + }
60 - } 60 + }
61 - }); 61 + });
62 - return view; 62 + return view;
63 - } 63 + }
64 - 64 +
65 - 65 +
66 - 66 +
67 - @Override 67 + @Override
68 - public void onAttach(Context context) { 68 + public void onAttach(Context context) {
69 - super.onAttach(context); 69 + super.onAttach(context);
70 - } 70 + }
71 - 71 +
72 - @Override 72 + @Override
73 - public void onDetach() { 73 + public void onDetach() {
74 - super.onDetach(); 74 + super.onDetach();
75 - } 75 + }
76 - 76 +
77 -} 77 +}
......
1 -<vector xmlns:android="http://schemas.android.com/apk/res/android" 1 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
2 - xmlns:aapt="http://schemas.android.com/aapt" 2 + xmlns:aapt="http://schemas.android.com/aapt"
3 - android:width="108dp" 3 + android:width="108dp"
4 - android:height="108dp" 4 + android:height="108dp"
5 - android:viewportWidth="108" 5 + android:viewportWidth="108"
6 - android:viewportHeight="108"> 6 + android:viewportHeight="108">
7 - <path 7 + <path
8 - android:fillType="evenOdd" 8 + android:fillType="evenOdd"
9 - 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" 9 + 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"
10 - android:strokeWidth="1" 10 + android:strokeWidth="1"
11 - android:strokeColor="#00000000"> 11 + android:strokeColor="#00000000">
12 - <aapt:attr name="android:fillColor"> 12 + <aapt:attr name="android:fillColor">
13 - <gradient 13 + <gradient
14 - android:endX="78.5885" 14 + android:endX="78.5885"
15 - android:endY="90.9159" 15 + android:endY="90.9159"
16 - android:startX="48.7653" 16 + android:startX="48.7653"
17 - android:startY="61.0927" 17 + android:startY="61.0927"
18 - android:type="linear"> 18 + android:type="linear">
19 - <item 19 + <item
20 - android:color="#44000000" 20 + android:color="#44000000"
21 - android:offset="0.0" /> 21 + android:offset="0.0" />
22 - <item 22 + <item
23 - android:color="#00000000" 23 + android:color="#00000000"
24 - android:offset="1.0" /> 24 + android:offset="1.0" />
25 - </gradient> 25 + </gradient>
26 - </aapt:attr> 26 + </aapt:attr>
27 - </path> 27 + </path>
28 - <path 28 + <path
29 - android:fillColor="#FFFFFF" 29 + android:fillColor="#FFFFFF"
30 - android:fillType="nonZero" 30 + android:fillType="nonZero"
31 - 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" 31 + 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"
32 - android:strokeWidth="1" 32 + android:strokeWidth="1"
33 - android:strokeColor="#00000000" /> 33 + android:strokeColor="#00000000" />
34 -</vector> 34 +</vector>
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<shape xmlns:android="http://schemas.android.com/apk/res/android" 2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:padding="10dp" 3 + android:padding="10dp"
4 - android:shape="rectangle" > 4 + android:shape="rectangle" >
5 - <solid android:color="@color/colorPrimary" /> 5 + <solid android:color="@color/colorPrimary" />
6 - <gradient 6 + <gradient
7 - android:startColor="@color/colorPrimary" 7 + android:startColor="@color/colorPrimary"
8 - android:endColor="#FFFFFF" 8 + android:endColor="#FFFFFF"
9 - android:angle= "270"> 9 + android:angle= "270">
10 - </gradient> 10 + </gradient>
11 </shape> 11 </shape>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<shape xmlns:android="http://schemas.android.com/apk/res/android" 2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:padding="10dp" 3 + android:padding="10dp"
4 - android:shape="rectangle" 4 + android:shape="rectangle"
5 - > 5 + >
6 - <solid android:color="#FFFFFF"></solid> 6 + <solid android:color="#FFFFFF"></solid>
7 - <corners 7 + <corners
8 - android:bottomLeftRadius="30dp" 8 + android:bottomLeftRadius="30dp"
9 - android:bottomRightRadius="30dp" 9 + android:bottomRightRadius="30dp"
10 - android:topLeftRadius="30dp" 10 + android:topLeftRadius="30dp"
11 - android:topRightRadius="30dp" /> 11 + android:topRightRadius="30dp" />
12 - <stroke 12 + <stroke
13 - android:width="2dp" 13 + android:width="2dp"
14 - android:color="@color/colorPrimaryDark" /> 14 + android:color="@color/colorPrimaryDark" />
15 </shape> 15 </shape>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<shape xmlns:android="http://schemas.android.com/apk/res/android" 2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:padding="10dp" 3 + android:padding="10dp"
4 - android:shape="rectangle" > 4 + android:shape="rectangle" >
5 - <solid android:color="@color/colorPrimaryDark" /> 5 + <solid android:color="@color/colorPrimaryDark" />
6 - <corners 6 + <corners
7 - android:bottomLeftRadius="20dp" 7 + android:bottomLeftRadius="20dp"
8 - android:bottomRightRadius="20dp" 8 + android:bottomRightRadius="20dp"
9 - android:topLeftRadius="20dp" 9 + android:topLeftRadius="20dp"
10 - android:topRightRadius="20dp" /> 10 + android:topRightRadius="20dp" />
11 - <stroke 11 + <stroke
12 - android:width="1dp" 12 + android:width="1dp"
13 - android:color="@color/colorPrimaryDark" /> 13 + android:color="@color/colorPrimaryDark" />
14 </shape> 14 </shape>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<vector xmlns:android="http://schemas.android.com/apk/res/android" 2 +<vector xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:width="108dp" 3 + android:width="108dp"
4 - android:height="108dp" 4 + android:height="108dp"
5 - android:viewportWidth="108" 5 + android:viewportWidth="108"
6 - android:viewportHeight="108"> 6 + android:viewportHeight="108">
7 - <path 7 + <path
8 - android:fillColor="#008577" 8 + android:fillColor="#008577"
9 - android:pathData="M0,0h108v108h-108z" /> 9 + android:pathData="M0,0h108v108h-108z" />
10 - <path 10 + <path
11 - android:fillColor="#00000000" 11 + android:fillColor="#00000000"
12 - android:pathData="M9,0L9,108" 12 + android:pathData="M9,0L9,108"
13 - android:strokeWidth="0.8" 13 + android:strokeWidth="0.8"
14 - android:strokeColor="#33FFFFFF" /> 14 + android:strokeColor="#33FFFFFF" />
15 - <path 15 + <path
16 - android:fillColor="#00000000" 16 + android:fillColor="#00000000"
17 - android:pathData="M19,0L19,108" 17 + android:pathData="M19,0L19,108"
18 - android:strokeWidth="0.8" 18 + android:strokeWidth="0.8"
19 - android:strokeColor="#33FFFFFF" /> 19 + android:strokeColor="#33FFFFFF" />
20 - <path 20 + <path
21 - android:fillColor="#00000000" 21 + android:fillColor="#00000000"
22 - android:pathData="M29,0L29,108" 22 + android:pathData="M29,0L29,108"
23 - android:strokeWidth="0.8" 23 + android:strokeWidth="0.8"
24 - android:strokeColor="#33FFFFFF" /> 24 + android:strokeColor="#33FFFFFF" />
25 - <path 25 + <path
26 - android:fillColor="#00000000" 26 + android:fillColor="#00000000"
27 - android:pathData="M39,0L39,108" 27 + android:pathData="M39,0L39,108"
28 - android:strokeWidth="0.8" 28 + android:strokeWidth="0.8"
29 - android:strokeColor="#33FFFFFF" /> 29 + android:strokeColor="#33FFFFFF" />
30 - <path 30 + <path
31 - android:fillColor="#00000000" 31 + android:fillColor="#00000000"
32 - android:pathData="M49,0L49,108" 32 + android:pathData="M49,0L49,108"
33 - android:strokeWidth="0.8" 33 + android:strokeWidth="0.8"
34 - android:strokeColor="#33FFFFFF" /> 34 + android:strokeColor="#33FFFFFF" />
35 - <path 35 + <path
36 - android:fillColor="#00000000" 36 + android:fillColor="#00000000"
37 - android:pathData="M59,0L59,108" 37 + android:pathData="M59,0L59,108"
38 - android:strokeWidth="0.8" 38 + android:strokeWidth="0.8"
39 - android:strokeColor="#33FFFFFF" /> 39 + android:strokeColor="#33FFFFFF" />
40 - <path 40 + <path
41 - android:fillColor="#00000000" 41 + android:fillColor="#00000000"
42 - android:pathData="M69,0L69,108" 42 + android:pathData="M69,0L69,108"
43 - android:strokeWidth="0.8" 43 + android:strokeWidth="0.8"
44 - android:strokeColor="#33FFFFFF" /> 44 + android:strokeColor="#33FFFFFF" />
45 - <path 45 + <path
46 - android:fillColor="#00000000" 46 + android:fillColor="#00000000"
47 - android:pathData="M79,0L79,108" 47 + android:pathData="M79,0L79,108"
48 - android:strokeWidth="0.8" 48 + android:strokeWidth="0.8"
49 - android:strokeColor="#33FFFFFF" /> 49 + android:strokeColor="#33FFFFFF" />
50 - <path 50 + <path
51 - android:fillColor="#00000000" 51 + android:fillColor="#00000000"
52 - android:pathData="M89,0L89,108" 52 + android:pathData="M89,0L89,108"
53 - android:strokeWidth="0.8" 53 + android:strokeWidth="0.8"
54 - android:strokeColor="#33FFFFFF" /> 54 + android:strokeColor="#33FFFFFF" />
55 - <path 55 + <path
56 - android:fillColor="#00000000" 56 + android:fillColor="#00000000"
57 - android:pathData="M99,0L99,108" 57 + android:pathData="M99,0L99,108"
58 - android:strokeWidth="0.8" 58 + android:strokeWidth="0.8"
59 - android:strokeColor="#33FFFFFF" /> 59 + android:strokeColor="#33FFFFFF" />
60 - <path 60 + <path
61 - android:fillColor="#00000000" 61 + android:fillColor="#00000000"
62 - android:pathData="M0,9L108,9" 62 + android:pathData="M0,9L108,9"
63 - android:strokeWidth="0.8" 63 + android:strokeWidth="0.8"
64 - android:strokeColor="#33FFFFFF" /> 64 + android:strokeColor="#33FFFFFF" />
65 - <path 65 + <path
66 - android:fillColor="#00000000" 66 + android:fillColor="#00000000"
67 - android:pathData="M0,19L108,19" 67 + android:pathData="M0,19L108,19"
68 - android:strokeWidth="0.8" 68 + android:strokeWidth="0.8"
69 - android:strokeColor="#33FFFFFF" /> 69 + android:strokeColor="#33FFFFFF" />
70 - <path 70 + <path
71 - android:fillColor="#00000000" 71 + android:fillColor="#00000000"
72 - android:pathData="M0,29L108,29" 72 + android:pathData="M0,29L108,29"
73 - android:strokeWidth="0.8" 73 + android:strokeWidth="0.8"
74 - android:strokeColor="#33FFFFFF" /> 74 + android:strokeColor="#33FFFFFF" />
75 - <path 75 + <path
76 - android:fillColor="#00000000" 76 + android:fillColor="#00000000"
77 - android:pathData="M0,39L108,39" 77 + android:pathData="M0,39L108,39"
78 - android:strokeWidth="0.8" 78 + android:strokeWidth="0.8"
79 - android:strokeColor="#33FFFFFF" /> 79 + android:strokeColor="#33FFFFFF" />
80 - <path 80 + <path
81 - android:fillColor="#00000000" 81 + android:fillColor="#00000000"
82 - android:pathData="M0,49L108,49" 82 + android:pathData="M0,49L108,49"
83 - android:strokeWidth="0.8" 83 + android:strokeWidth="0.8"
84 - android:strokeColor="#33FFFFFF" /> 84 + android:strokeColor="#33FFFFFF" />
85 - <path 85 + <path
86 - android:fillColor="#00000000" 86 + android:fillColor="#00000000"
87 - android:pathData="M0,59L108,59" 87 + android:pathData="M0,59L108,59"
88 - android:strokeWidth="0.8" 88 + android:strokeWidth="0.8"
89 - android:strokeColor="#33FFFFFF" /> 89 + android:strokeColor="#33FFFFFF" />
90 - <path 90 + <path
91 - android:fillColor="#00000000" 91 + android:fillColor="#00000000"
92 - android:pathData="M0,69L108,69" 92 + android:pathData="M0,69L108,69"
93 - android:strokeWidth="0.8" 93 + android:strokeWidth="0.8"
94 - android:strokeColor="#33FFFFFF" /> 94 + android:strokeColor="#33FFFFFF" />
95 - <path 95 + <path
96 - android:fillColor="#00000000" 96 + android:fillColor="#00000000"
97 - android:pathData="M0,79L108,79" 97 + android:pathData="M0,79L108,79"
98 - android:strokeWidth="0.8" 98 + android:strokeWidth="0.8"
99 - android:strokeColor="#33FFFFFF" /> 99 + android:strokeColor="#33FFFFFF" />
100 - <path 100 + <path
101 - android:fillColor="#00000000" 101 + android:fillColor="#00000000"
102 - android:pathData="M0,89L108,89" 102 + android:pathData="M0,89L108,89"
103 - android:strokeWidth="0.8" 103 + android:strokeWidth="0.8"
104 - android:strokeColor="#33FFFFFF" /> 104 + android:strokeColor="#33FFFFFF" />
105 - <path 105 + <path
106 - android:fillColor="#00000000" 106 + android:fillColor="#00000000"
107 - android:pathData="M0,99L108,99" 107 + android:pathData="M0,99L108,99"
108 - android:strokeWidth="0.8" 108 + android:strokeWidth="0.8"
109 - android:strokeColor="#33FFFFFF" /> 109 + android:strokeColor="#33FFFFFF" />
110 - <path 110 + <path
111 - android:fillColor="#00000000" 111 + android:fillColor="#00000000"
112 - android:pathData="M19,29L89,29" 112 + android:pathData="M19,29L89,29"
113 - android:strokeWidth="0.8" 113 + android:strokeWidth="0.8"
114 - android:strokeColor="#33FFFFFF" /> 114 + android:strokeColor="#33FFFFFF" />
115 - <path 115 + <path
116 - android:fillColor="#00000000" 116 + android:fillColor="#00000000"
117 - android:pathData="M19,39L89,39" 117 + android:pathData="M19,39L89,39"
118 - android:strokeWidth="0.8" 118 + android:strokeWidth="0.8"
119 - android:strokeColor="#33FFFFFF" /> 119 + android:strokeColor="#33FFFFFF" />
120 - <path 120 + <path
121 - android:fillColor="#00000000" 121 + android:fillColor="#00000000"
122 - android:pathData="M19,49L89,49" 122 + android:pathData="M19,49L89,49"
123 - android:strokeWidth="0.8" 123 + android:strokeWidth="0.8"
124 - android:strokeColor="#33FFFFFF" /> 124 + android:strokeColor="#33FFFFFF" />
125 - <path 125 + <path
126 - android:fillColor="#00000000" 126 + android:fillColor="#00000000"
127 - android:pathData="M19,59L89,59" 127 + android:pathData="M19,59L89,59"
128 - android:strokeWidth="0.8" 128 + android:strokeWidth="0.8"
129 - android:strokeColor="#33FFFFFF" /> 129 + android:strokeColor="#33FFFFFF" />
130 - <path 130 + <path
131 - android:fillColor="#00000000" 131 + android:fillColor="#00000000"
132 - android:pathData="M19,69L89,69" 132 + android:pathData="M19,69L89,69"
133 - android:strokeWidth="0.8" 133 + android:strokeWidth="0.8"
134 - android:strokeColor="#33FFFFFF" /> 134 + android:strokeColor="#33FFFFFF" />
135 - <path 135 + <path
136 - android:fillColor="#00000000" 136 + android:fillColor="#00000000"
137 - android:pathData="M19,79L89,79" 137 + android:pathData="M19,79L89,79"
138 - android:strokeWidth="0.8" 138 + android:strokeWidth="0.8"
139 - android:strokeColor="#33FFFFFF" /> 139 + android:strokeColor="#33FFFFFF" />
140 - <path 140 + <path
141 - android:fillColor="#00000000" 141 + android:fillColor="#00000000"
142 - android:pathData="M29,19L29,89" 142 + android:pathData="M29,19L29,89"
143 - android:strokeWidth="0.8" 143 + android:strokeWidth="0.8"
144 - android:strokeColor="#33FFFFFF" /> 144 + android:strokeColor="#33FFFFFF" />
145 - <path 145 + <path
146 - android:fillColor="#00000000" 146 + android:fillColor="#00000000"
147 - android:pathData="M39,19L39,89" 147 + android:pathData="M39,19L39,89"
148 - android:strokeWidth="0.8" 148 + android:strokeWidth="0.8"
149 - android:strokeColor="#33FFFFFF" /> 149 + android:strokeColor="#33FFFFFF" />
150 - <path 150 + <path
151 - android:fillColor="#00000000" 151 + android:fillColor="#00000000"
152 - android:pathData="M49,19L49,89" 152 + android:pathData="M49,19L49,89"
153 - android:strokeWidth="0.8" 153 + android:strokeWidth="0.8"
154 - android:strokeColor="#33FFFFFF" /> 154 + android:strokeColor="#33FFFFFF" />
155 - <path 155 + <path
156 - android:fillColor="#00000000" 156 + android:fillColor="#00000000"
157 - android:pathData="M59,19L59,89" 157 + android:pathData="M59,19L59,89"
158 - android:strokeWidth="0.8" 158 + android:strokeWidth="0.8"
159 - android:strokeColor="#33FFFFFF" /> 159 + android:strokeColor="#33FFFFFF" />
160 - <path 160 + <path
161 - android:fillColor="#00000000" 161 + android:fillColor="#00000000"
162 - android:pathData="M69,19L69,89" 162 + android:pathData="M69,19L69,89"
163 - android:strokeWidth="0.8" 163 + android:strokeWidth="0.8"
164 - android:strokeColor="#33FFFFFF" /> 164 + android:strokeColor="#33FFFFFF" />
165 - <path 165 + <path
166 - android:fillColor="#00000000" 166 + android:fillColor="#00000000"
167 - android:pathData="M79,19L79,89" 167 + android:pathData="M79,19L79,89"
168 - android:strokeWidth="0.8" 168 + android:strokeWidth="0.8"
169 - android:strokeColor="#33FFFFFF" /> 169 + android:strokeColor="#33FFFFFF" />
170 -</vector> 170 +</vector>
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<font-family xmlns:android="http://schemas.android.com/apk/res/android"> 2 +<font-family xmlns:android="http://schemas.android.com/apk/res/android">
3 - <font 3 + <font
4 - android:fontStyle = "normal" 4 + android:fontStyle = "normal"
5 - android:fontWeight="400" 5 + android:fontWeight="400"
6 - android:font = "@font/noto"/> 6 + android:font = "@font/noto"/>
7 - <font 7 + <font
8 - android:fontStyle = "normal" 8 + android:fontStyle = "normal"
9 - android:fontWeight = "400" 9 + android:fontWeight = "400"
10 - android:font = "@font/beba"/> 10 + android:font = "@font/beba"/>
11 </font-family> 11 </font-family>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - xmlns:app="http://schemas.android.com/apk/res-auto" 3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 - xmlns:tools="http://schemas.android.com/tools" 4 + xmlns:tools="http://schemas.android.com/tools"
5 - android:id="@+id/container" 5 + android:id="@+id/container"
6 - android:layout_width="match_parent" 6 + android:layout_width="match_parent"
7 - android:layout_height="match_parent" 7 + android:layout_height="match_parent"
8 - tools:context="com.example.suemin.smartwindow.view.MainActivity" 8 + tools:context="com.example.suemin.smartwindow.view.MainActivity"
9 - > 9 + >
10 - 10 +
11 - 11 +
12 - <android.support.v7.widget.Toolbar 12 + <android.support.v7.widget.Toolbar
13 - android:id="@+id/tb" 13 + android:id="@+id/tb"
14 - android:layout_width="match_parent" 14 + android:layout_width="match_parent"
15 - android:layout_height="wrap_content" 15 + android:layout_height="wrap_content"
16 - android:background="@color/colorPrimaryDark"> 16 + android:background="@color/colorPrimaryDark">
17 - <ImageView 17 + <ImageView
18 - android:layout_width="32dp" 18 + android:layout_width="32dp"
19 - android:layout_height="30dp" 19 + android:layout_height="30dp"
20 - android:src="@drawable/icon" 20 + android:src="@drawable/icon"
21 - android:paddingTop="8dp" 21 + android:paddingTop="8dp"
22 - android:layout_marginRight="5dp"/> 22 + android:layout_marginRight="5dp"/>
23 - 23 +
24 - <TextView 24 + <TextView
25 - android:layout_width="match_parent" 25 + android:layout_width="match_parent"
26 - android:layout_height="match_parent" 26 + android:layout_height="match_parent"
27 - android:gravity="left" 27 + android:gravity="left"
28 - android:text="@string/app_name" 28 + android:text="@string/app_name"
29 - android:fontFamily="@font/beba" 29 + android:fontFamily="@font/beba"
30 - android:textColor="@color/colorAccent" 30 + android:textColor="@color/colorAccent"
31 - android:textSize="21dp" 31 + android:textSize="21dp"
32 - android:textStyle="bold" 32 + android:textStyle="bold"
33 - /> 33 + />
34 - 34 +
35 - </android.support.v7.widget.Toolbar> 35 + </android.support.v7.widget.Toolbar>
36 - 36 +
37 - <FrameLayout 37 + <FrameLayout
38 - android:id="@+id/frameLayout" 38 + android:id="@+id/frameLayout"
39 - android:layout_width="match_parent" 39 + android:layout_width="match_parent"
40 - android:layout_height="match_parent" 40 + android:layout_height="match_parent"
41 - android:layout_marginTop="?attr/actionBarSize" 41 + android:layout_marginTop="?attr/actionBarSize"
42 - android:layout_marginBottom="?attr/actionBarSize" 42 + android:layout_marginBottom="?attr/actionBarSize"
43 - /> 43 + />
44 - 44 +
45 - <android.support.design.widget.BottomNavigationView 45 + <android.support.design.widget.BottomNavigationView
46 - android:id="@+id/navigation" 46 + android:id="@+id/navigation"
47 - android:layout_width="0dp" 47 + android:layout_width="0dp"
48 - android:layout_height="wrap_content" 48 + android:layout_height="wrap_content"
49 - android:layout_marginStart="0dp" 49 + android:layout_marginStart="0dp"
50 - android:layout_marginEnd="0dp" 50 + android:layout_marginEnd="0dp"
51 - android:background="@color/colorPrimaryDark" 51 + android:background="@color/colorPrimaryDark"
52 - app:layout_constraintBottom_toBottomOf="parent" 52 + app:layout_constraintBottom_toBottomOf="parent"
53 - app:layout_constraintLeft_toLeftOf="parent" 53 + app:layout_constraintLeft_toLeftOf="parent"
54 - app:layout_constraintRight_toRightOf="parent" 54 + app:layout_constraintRight_toRightOf="parent"
55 - app:menu="@menu/navigation" /> 55 + app:menu="@menu/navigation" />
56 - 56 +
57 </android.support.constraint.ConstraintLayout> 57 </android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:layout_width="match_parent" 3 + android:layout_width="match_parent"
4 - android:layout_height="wrap_content" 4 + android:layout_height="wrap_content"
5 - > 5 + >
6 - <TextView 6 + <TextView
7 - android:id="@+id/bt_textView" 7 + android:id="@+id/bt_textView"
8 - android:layout_width="wrap_content" 8 + android:layout_width="wrap_content"
9 - android:layout_height="wrap_content" 9 + android:layout_height="wrap_content"
10 - android:layout_marginLeft="16dp" 10 + android:layout_marginLeft="16dp"
11 - android:gravity="left" 11 + android:gravity="left"
12 - android:text="name" 12 + android:text="name"
13 - android:textColor="@color/colorAccent" 13 + android:textColor="@color/colorAccent"
14 - android:fontFamily="@font/noto" 14 + android:fontFamily="@font/noto"
15 - android:textSize="21dp" 15 + android:textSize="21dp"
16 - /> 16 + />
17 - <TextView 17 + <TextView
18 - android:id="@+id/bt_textView_addr" 18 + android:id="@+id/bt_textView_addr"
19 - android:layout_width="wrap_content" 19 + android:layout_width="wrap_content"
20 - android:layout_height="wrap_content" 20 + android:layout_height="wrap_content"
21 - android:layout_marginLeft="16dp" 21 + android:layout_marginLeft="16dp"
22 - android:gravity="left" 22 + android:gravity="left"
23 - android:text="addr" 23 + android:text="addr"
24 - android:textColor="@color/colorAccent" 24 + android:textColor="@color/colorAccent"
25 - android:textSize="14dp" 25 + android:textSize="14dp"
26 - android:layout_below="@+id/bt_textView" 26 + android:layout_below="@+id/bt_textView"
27 - /> 27 + />
28 </RelativeLayout> 28 </RelativeLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:layout_width="match_parent" 3 + android:layout_width="match_parent"
4 - android:layout_height="match_parent" 4 + android:layout_height="match_parent"
5 - android:gravity="center" 5 + android:gravity="center"
6 - android:orientation="vertical" 6 + android:orientation="vertical"
7 - > 7 + >
8 - 8 +
9 - <LinearLayout 9 + <LinearLayout
10 - android:layout_width="250dp" 10 + android:layout_width="250dp"
11 - android:layout_height="wrap_content" 11 + android:layout_height="wrap_content"
12 - android:paddingBottom="15dp" 12 + android:paddingBottom="15dp"
13 - android:paddingTop="15dp" 13 + android:paddingTop="15dp"
14 - android:gravity="center" 14 + android:gravity="center"
15 - android:orientation="vertical" 15 + android:orientation="vertical"
16 - android:background="@drawable/dialog_background"> 16 + android:background="@drawable/dialog_background">
17 - 17 +
18 - <TextView 18 + <TextView
19 - android:id="@+id/dialog_title" 19 + android:id="@+id/dialog_title"
20 - android:layout_width="wrap_content" 20 + android:layout_width="wrap_content"
21 - android:layout_height="wrap_content" 21 + android:layout_height="wrap_content"
22 - android:layout_marginTop="10dp" 22 + android:layout_marginTop="10dp"
23 - android:layout_marginBottom="10dp" 23 + android:layout_marginBottom="10dp"
24 - android:textSize="20dp" /> 24 + android:textSize="20dp" />
25 - 25 +
26 - <TextView 26 + <TextView
27 - android:id="@+id/dialog_num" 27 + android:id="@+id/dialog_num"
28 - android:layout_width="wrap_content" 28 + android:layout_width="wrap_content"
29 - android:layout_height="wrap_content" 29 + android:layout_height="wrap_content"
30 - android:layout_marginTop="5dp" 30 + android:layout_marginTop="5dp"
31 - android:layout_marginBottom="5dp" 31 + android:layout_marginBottom="5dp"
32 - android:textSize="60dp" /> 32 + android:textSize="60dp" />
33 - <TextView 33 + <TextView
34 - android:id="@+id/dialog_state" 34 + android:id="@+id/dialog_state"
35 - android:layout_width="wrap_content" 35 + android:layout_width="wrap_content"
36 - android:layout_height="wrap_content" 36 + android:layout_height="wrap_content"
37 - android:layout_marginBottom="15dp" 37 + android:layout_marginBottom="15dp"
38 - android:textSize="15dp" /> 38 + android:textSize="15dp" />
39 - <Button 39 + <Button
40 - android:id="@+id/pbutton" 40 + android:id="@+id/pbutton"
41 - android:layout_width="50dp" 41 + android:layout_width="50dp"
42 - android:layout_height="25dp" 42 + android:layout_height="25dp"
43 - android:layout_marginBottom="10dp" 43 + android:layout_marginBottom="10dp"
44 - android:background="@drawable/dialog_button_background" 44 + android:background="@drawable/dialog_button_background"
45 - android:text="OK" 45 + android:text="OK"
46 - android:textColor="@color/colorAccent"/> 46 + android:textColor="@color/colorAccent"/>
47 - </LinearLayout> 47 + </LinearLayout>
48 - 48 +
49 - 49 +
50 - 50 +
51 -</LinearLayout> 51 +</LinearLayout>
52 - 52 +
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - xmlns:tools="http://schemas.android.com/tools" 3 + xmlns:tools="http://schemas.android.com/tools"
4 - android:layout_width="match_parent" 4 + android:layout_width="match_parent"
5 - android:layout_height="match_parent" 5 + android:layout_height="match_parent"
6 - tools:context="com.example.suemin.smartwindow.view.bluetooth.Bluetooth" 6 + tools:context="com.example.suemin.smartwindow.view.bluetooth.Bluetooth"
7 - android:background="@color/colorPrimaryDark"> 7 + android:background="@color/colorPrimaryDark">
8 - 8 +
9 - <TextView 9 + <TextView
10 - android:layout_width="wrap_content" 10 + android:layout_width="wrap_content"
11 - android:layout_height="22dp" 11 + android:layout_height="22dp"
12 - android:layout_marginLeft="10dp" 12 + android:layout_marginLeft="10dp"
13 - android:layout_marginTop="5dp" 13 + android:layout_marginTop="5dp"
14 - android:text="검색된 기기" 14 + android:text="검색된 기기"
15 - android:textSize="12dp" 15 + android:textSize="12dp"
16 - android:textStyle="bold" 16 + android:textStyle="bold"
17 - android:textColor="#a04e4e4e"/> 17 + android:textColor="#a04e4e4e"/>
18 - <ListView 18 + <ListView
19 - android:id="@android:id/list" 19 + android:id="@android:id/list"
20 - android:layout_width="match_parent" 20 + android:layout_width="match_parent"
21 - android:layout_height="wrap_content" 21 + android:layout_height="wrap_content"
22 - android:layout_marginTop="24dp"> 22 + android:layout_marginTop="24dp">
23 - 23 +
24 - </ListView> 24 + </ListView>
25 - <RelativeLayout 25 + <RelativeLayout
26 - android:layout_width="wrap_content" 26 + android:layout_width="wrap_content"
27 - android:layout_height="60dp" 27 + android:layout_height="60dp"
28 - android:layout_gravity="bottom" 28 + android:layout_gravity="bottom"
29 - android:paddingBottom="15dp"> 29 + android:paddingBottom="15dp">
30 - 30 +
31 - <Button 31 + <Button
32 - android:id="@+id/bt_find_btn" 32 + android:id="@+id/bt_find_btn"
33 - android:layout_width="50dp" 33 + android:layout_width="50dp"
34 - android:layout_height="50dp" 34 + android:layout_height="50dp"
35 - android:layout_alignParentRight="true" 35 + android:layout_alignParentRight="true"
36 - android:layout_alignParentBottom="true" 36 + android:layout_alignParentBottom="true"
37 - android:layout_marginRight="20dp" 37 + android:layout_marginRight="20dp"
38 - android:background="@drawable/sync" 38 + android:background="@drawable/sync"
39 - /> 39 + />
40 - </RelativeLayout> 40 + </RelativeLayout>
41 - 41 +
42 - 42 +
43 - 43 +
44 </FrameLayout> 44 </FrameLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - xmlns:tools="http://schemas.android.com/tools" 3 + xmlns:tools="http://schemas.android.com/tools"
4 - android:layout_width="match_parent" 4 + android:layout_width="match_parent"
5 - android:layout_height="match_parent" 5 + android:layout_height="match_parent"
6 - xmlns:app="http://schemas.android.com/apk/res-auto" 6 + xmlns:app="http://schemas.android.com/apk/res-auto"
7 - tools:context="com.example.suemin.smartwindow.view.environment.Env" 7 + tools:context="com.example.suemin.smartwindow.view.environment.Env"
8 - android:background="@color/colorPrimaryDark"> 8 + android:background="@color/colorPrimaryDark">
9 - 9 +
10 - <LinearLayout 10 + <LinearLayout
11 - android:layout_width="match_parent" 11 + android:layout_width="match_parent"
12 - android:layout_height="wrap_content" 12 + android:layout_height="wrap_content"
13 - android:orientation="vertical" 13 + android:orientation="vertical"
14 - > 14 + >
15 - <!-- TODO: Update blank fragment layout --> 15 + <!-- TODO: Update blank fragment layout -->
16 - <RelativeLayout 16 + <RelativeLayout
17 - android:layout_width="wrap_content" 17 + android:layout_width="wrap_content"
18 - android:layout_height="20dp" 18 + android:layout_height="20dp"
19 - android:layout_marginTop="10dp" 19 + android:layout_marginTop="10dp"
20 - > 20 + >
21 - <ImageView 21 + <ImageView
22 - android:layout_width="10dp" 22 + android:layout_width="10dp"
23 - android:layout_height="10dp" 23 + android:layout_height="10dp"
24 - android:layout_marginStart="7dp" 24 + android:layout_marginStart="7dp"
25 - android:id="@+id/imageView1" 25 + android:id="@+id/imageView1"
26 - android:layout_centerVertical="true" 26 + android:layout_centerVertical="true"
27 - android:src="@drawable/icon_loca" 27 + android:src="@drawable/icon_loca"
28 - /> 28 + />
29 - 29 +
30 - <TextView 30 + <TextView
31 - android:id="@+id/location_text" 31 + android:id="@+id/location_text"
32 - android:layout_width="wrap_content" 32 + android:layout_width="wrap_content"
33 - android:layout_height="wrap_content" 33 + android:layout_height="wrap_content"
34 - android:layout_marginTop="1dp" 34 + android:layout_marginTop="1dp"
35 - android:layout_marginStart="2dp" 35 + android:layout_marginStart="2dp"
36 - android:layout_toRightOf="@+id/imageView1" 36 + android:layout_toRightOf="@+id/imageView1"
37 - android:text="위치 확인중..." 37 + android:text="위치 확인중..."
38 - android:textColor="@color/colorAccent" 38 + android:textColor="@color/colorAccent"
39 - android:textSize="12dp"/> 39 + android:textSize="12dp"/>
40 - 40 +
41 - </RelativeLayout> 41 + </RelativeLayout>
42 - <ListView 42 + <ListView
43 - android:id="@+id/list" 43 + android:id="@+id/list"
44 - android:layout_width="match_parent" 44 + android:layout_width="match_parent"
45 - android:layout_height="wrap_content" 45 + android:layout_height="wrap_content"
46 - /> 46 + />
47 - </LinearLayout> 47 + </LinearLayout>
48 - 48 +
49 </FrameLayout> 49 </FrameLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - xmlns:tools="http://schemas.android.com/tools" 3 + xmlns:tools="http://schemas.android.com/tools"
4 - android:layout_width="match_parent" 4 + android:layout_width="match_parent"
5 - android:layout_height="match_parent" 5 + android:layout_height="match_parent"
6 - xmlns:app="http://schemas.android.com/apk/res-auto" 6 + xmlns:app="http://schemas.android.com/apk/res-auto"
7 - tools:context="com.example.suemin.smartwindow.view.home.Home" 7 + tools:context="com.example.suemin.smartwindow.view.home.Home"
8 - android:background="@color/colorPrimaryDark"> 8 + android:background="@color/colorPrimaryDark">
9 - 9 +
10 - 10 +
11 - <RelativeLayout 11 + <RelativeLayout
12 - android:layout_width="match_parent" 12 + android:layout_width="match_parent"
13 - android:layout_height="match_parent" 13 + android:layout_height="match_parent"
14 - android:orientation="vertical"> 14 + android:orientation="vertical">
15 - 15 +
16 - <ImageView 16 + <ImageView
17 - android:id="@+id/imageView2" 17 + android:id="@+id/imageView2"
18 - android:layout_width="197dp" 18 + android:layout_width="197dp"
19 - android:layout_height="200dp" 19 + android:layout_height="200dp"
20 - android:layout_marginTop="80dp" 20 + android:layout_marginTop="80dp"
21 - android:layout_marginBottom="50dp" 21 + android:layout_marginBottom="50dp"
22 - android:adjustViewBounds="true" 22 + android:adjustViewBounds="true"
23 - android:src="@drawable/window_closed" 23 + android:src="@drawable/window_closed"
24 - android:layout_centerHorizontal="true" 24 + android:layout_centerHorizontal="true"
25 - /> 25 + />
26 - 26 +
27 - <RelativeLayout 27 + <RelativeLayout
28 - android:layout_width="wrap_content" 28 + android:layout_width="wrap_content"
29 - android:layout_height="wrap_content" 29 + android:layout_height="wrap_content"
30 - android:layout_marginStart="100dp" 30 + android:layout_marginStart="100dp"
31 - android:layout_below="@id/imageView2" 31 + android:layout_below="@id/imageView2"
32 - android:layout_centerHorizontal="true" 32 + android:layout_centerHorizontal="true"
33 - > 33 + >
34 - 34 +
35 - <Switch 35 + <Switch
36 - android:id="@+id/switch1" 36 + android:id="@+id/switch1"
37 - android:layout_width="wrap_content" 37 + android:layout_width="wrap_content"
38 - android:layout_height="wrap_content" 38 + android:layout_height="wrap_content"
39 - android:layout_marginBottom="10dp" 39 + android:layout_marginBottom="10dp"
40 - android:layout_alignParentTop="true" 40 + android:layout_alignParentTop="true"
41 - android:layout_centerHorizontal="true" 41 + android:layout_centerHorizontal="true"
42 - /> 42 + />
43 - 43 +
44 - <TextView 44 + <TextView
45 - android:id="@+id/textView2" 45 + android:id="@+id/textView2"
46 - android:layout_width="wrap_content" 46 + android:layout_width="wrap_content"
47 - android:layout_height="wrap_content" 47 + android:layout_height="wrap_content"
48 - android:layout_below="@id/switch1" 48 + android:layout_below="@id/switch1"
49 - android:layout_centerHorizontal="true" 49 + android:layout_centerHorizontal="true"
50 - android:textColor="@color/colorAccent" 50 + android:textColor="@color/colorAccent"
51 - android:text="현재 창문 상태는" 51 + android:text="현재 창문 상태는"
52 - android:textSize="17dp" /> 52 + android:textSize="17dp" />
53 - 53 +
54 - <TextView 54 + <TextView
55 - android:id="@+id/textView_switch" 55 + android:id="@+id/textView_switch"
56 - android:layout_width="wrap_content" 56 + android:layout_width="wrap_content"
57 - android:layout_height="wrap_content" 57 + android:layout_height="wrap_content"
58 - android:fontFamily="@font/noto" 58 + android:fontFamily="@font/noto"
59 - android:text="“ 닫힘 ”" 59 + android:text="“ 닫힘 ”"
60 - android:textSize="25dp" 60 + android:textSize="25dp"
61 - android:textStyle="bold" 61 + android:textStyle="bold"
62 - android:textColor="@color/colorAccent" 62 + android:textColor="@color/colorAccent"
63 - android:layout_below="@id/textView2" 63 + android:layout_below="@id/textView2"
64 - android:layout_centerHorizontal="true" 64 + android:layout_centerHorizontal="true"
65 - /> 65 + />
66 - </RelativeLayout> 66 + </RelativeLayout>
67 - </RelativeLayout> 67 + </RelativeLayout>
68 - 68 +
69 </FrameLayout> 69 </FrameLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<!-- Copyright (C) 2013 The Android Open Source Project 2 +<!-- Copyright (C) 2013 The Android Open Source Project
3 - Licensed under the Apache License, Version 2.0 (the "License"); 3 + Licensed under the Apache License, Version 2.0 (the "License");
4 - you may not use this file except in compliance with the License. 4 + you may not use this file except in compliance with the License.
5 - You may obtain a copy of the License at 5 + You may obtain a copy of the License at
6 - http://www.apache.org/licenses/LICENSE-2.0 6 + http://www.apache.org/licenses/LICENSE-2.0
7 - Unless required by applicable law or agreed to in writing, software 7 + Unless required by applicable law or agreed to in writing, software
8 - distributed under the License is distributed on an "AS IS" BASIS, 8 + distributed under the License is distributed on an "AS IS" BASIS,
9 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 - See the License for the specific language governing permissions and 10 + See the License for the specific language governing permissions and
11 - limitations under the License. 11 + limitations under the License.
12 ---> 12 +-->
13 -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 13 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
14 - android:orientation="vertical" 14 + android:orientation="vertical"
15 - android:layout_width="match_parent" 15 + android:layout_width="match_parent"
16 - android:layout_height="wrap_content" 16 + android:layout_height="wrap_content"
17 - android:layout_margin="10dp"> 17 + android:layout_margin="10dp">
18 - <LinearLayout android:orientation="horizontal" 18 + <LinearLayout android:orientation="horizontal"
19 - android:layout_width="match_parent" 19 + android:layout_width="match_parent"
20 - android:layout_height="wrap_content" 20 + android:layout_height="wrap_content"
21 - android:layout_margin="10dp"> 21 + android:layout_margin="10dp">
22 - <TextView android:layout_width="wrap_content" 22 + <TextView android:layout_width="wrap_content"
23 - android:layout_height="wrap_content" 23 + android:layout_height="wrap_content"
24 - android:text="State : " 24 + android:text="State : "
25 - android:textSize="18sp"/> 25 + android:textSize="18sp"/>
26 - <Space android:layout_width="5dp" 26 + <Space android:layout_width="5dp"
27 - android:layout_height="wrap_content"/> 27 + android:layout_height="wrap_content"/>
28 - <TextView android:id="@+id/connection_state" 28 + <TextView android:id="@+id/connection_state"
29 - android:layout_width="match_parent" 29 + android:layout_width="match_parent"
30 - android:layout_height="wrap_content" 30 + android:layout_height="wrap_content"
31 - android:text="no_data" 31 + android:text="no_data"
32 - android:textSize="18sp"/> 32 + android:textSize="18sp"/>
33 - </LinearLayout> 33 + </LinearLayout>
34 - <LinearLayout android:orientation="horizontal" 34 + <LinearLayout android:orientation="horizontal"
35 - android:layout_width="match_parent" 35 + android:layout_width="match_parent"
36 - android:layout_height="wrap_content" 36 + android:layout_height="wrap_content"
37 - android:layout_margin="10dp"> 37 + android:layout_margin="10dp">
38 - <TextView android:layout_width="wrap_content" 38 + <TextView android:layout_width="wrap_content"
39 - android:layout_height="wrap_content" 39 + android:layout_height="wrap_content"
40 - android:text="Data : " 40 + android:text="Data : "
41 - android:id="@+id/device_name" 41 + android:id="@+id/device_name"
42 - android:textSize="18sp"/> 42 + android:textSize="18sp"/>
43 - <Space android:layout_width="5dp" 43 + <Space android:layout_width="5dp"
44 - android:layout_height="wrap_content"/> 44 + android:layout_height="wrap_content"/>
45 - <TextView android:id="@+id/data_value" 45 + <TextView android:id="@+id/data_value"
46 - android:layout_width="match_parent" 46 + android:layout_width="match_parent"
47 - android:layout_height="wrap_content" 47 + android:layout_height="wrap_content"
48 - android:text="no_data" 48 + android:text="no_data"
49 - android:textSize="18sp"/> 49 + android:textSize="18sp"/>
50 - </LinearLayout> 50 + </LinearLayout>
51 - <ExpandableListView android:id="@+id/gatt_services_list" 51 + <ExpandableListView android:id="@+id/gatt_services_list"
52 - android:layout_width="match_parent" 52 + android:layout_width="match_parent"
53 - android:layout_height="wrap_content"/> 53 + android:layout_height="wrap_content"/>
54 -</LinearLayout> 54 +</LinearLayout>
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:layout_width="match_parent" 3 + android:layout_width="match_parent"
4 - android:layout_height="wrap_content" 4 + android:layout_height="wrap_content"
5 - > 5 + >
6 - <RelativeLayout 6 + <RelativeLayout
7 - android:layout_width="wrap_content" 7 + android:layout_width="wrap_content"
8 - android:layout_height="wrap_content" 8 + android:layout_height="wrap_content"
9 - android:gravity="start"> 9 + android:gravity="start">
10 - 10 +
11 - <TextView 11 + <TextView
12 - android:id="@+id/textView1" 12 + android:id="@+id/textView1"
13 - android:layout_width="wrap_content" 13 + android:layout_width="wrap_content"
14 - android:layout_height="wrap_content" 14 + android:layout_height="wrap_content"
15 - android:paddingLeft="15dp" 15 + android:paddingLeft="15dp"
16 - android:layout_marginTop="10dp" 16 + android:layout_marginTop="10dp"
17 - android:layout_marginBottom="10dp" 17 + android:layout_marginBottom="10dp"
18 - android:gravity="fill_horizontal" 18 + android:gravity="fill_horizontal"
19 - android:fontFamily="@font/noto" 19 + android:fontFamily="@font/noto"
20 - android:text="New Text" 20 + android:text="New Text"
21 - android:layout_toRightOf="@id/imageView1" 21 + android:layout_toRightOf="@id/imageView1"
22 - android:textColor="@color/colorAccent" 22 + android:textColor="@color/colorAccent"
23 - android:textSize="21dp" /> 23 + android:textSize="21dp" />
24 - 24 +
25 - <ImageView 25 + <ImageView
26 - android:layout_width="50dp" 26 + android:layout_width="50dp"
27 - android:layout_height="50dp" 27 + android:layout_height="50dp"
28 - android:id="@+id/imageView1" 28 + android:id="@+id/imageView1"
29 - android:layout_marginLeft="5dp" 29 + android:layout_marginLeft="5dp"
30 - android:layout_centerVertical="true" 30 + android:layout_centerVertical="true"
31 - android:src="@drawable/ic_cloud_queue_black_24dp" 31 + android:src="@drawable/ic_cloud_queue_black_24dp"
32 - /> 32 + />
33 - </RelativeLayout> 33 + </RelativeLayout>
34 - 34 +
35 - 35 +
36 -</RelativeLayout> 36 +</RelativeLayout>
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:layout_width="match_parent" 3 + android:layout_width="match_parent"
4 - android:layout_height="wrap_content" 4 + android:layout_height="wrap_content"
5 - > 5 + >
6 - <TextView 6 + <TextView
7 - android:id="@+id/sv_textView" 7 + android:id="@+id/sv_textView"
8 - android:layout_width="wrap_content" 8 + android:layout_width="wrap_content"
9 - android:layout_height="wrap_content" 9 + android:layout_height="wrap_content"
10 - android:layout_marginLeft="16dp" 10 + android:layout_marginLeft="16dp"
11 - android:gravity="left" 11 + android:gravity="left"
12 - android:text="name" 12 + android:text="name"
13 - android:textColor="@color/colorAccent" 13 + android:textColor="@color/colorAccent"
14 - android:fontFamily="@font/noto" 14 + android:fontFamily="@font/noto"
15 - android:textSize="21dp" 15 + android:textSize="21dp"
16 - /> 16 + />
17 - <TextView 17 + <TextView
18 - android:id="@+id/sv_uuid" 18 + android:id="@+id/sv_uuid"
19 - android:layout_width="wrap_content" 19 + android:layout_width="wrap_content"
20 - android:layout_height="wrap_content" 20 + android:layout_height="wrap_content"
21 - android:layout_marginLeft="16dp" 21 + android:layout_marginLeft="16dp"
22 - android:gravity="left" 22 + android:gravity="left"
23 - android:text="addr" 23 + android:text="addr"
24 - android:textColor="@color/colorAccent" 24 + android:textColor="@color/colorAccent"
25 - android:textSize="14dp" 25 + android:textSize="14dp"
26 - android:layout_below="@+id/sv_textView" 26 + android:layout_below="@+id/sv_textView"
27 - /> 27 + />
28 </RelativeLayout> 28 </RelativeLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<menu xmlns:android="http://schemas.android.com/apk/res/android" 2 +<menu xmlns:android="http://schemas.android.com/apk/res/android"
3 - xmlns:app="http://schemas.android.com/apk/res-auto"> 3 + xmlns:app="http://schemas.android.com/apk/res-auto">
4 - <item 4 + <item
5 - android:id="@+id/navigation_bt" 5 + android:id="@+id/navigation_bt"
6 - android:title="BT" 6 + android:title="BT"
7 - android:icon="@drawable/ic_bluetooth_black_24dp" 7 + android:icon="@drawable/ic_bluetooth_black_24dp"
8 - app:showAsAction="always" 8 + app:showAsAction="always"
9 - /> 9 + />
10 - 10 +
11 </menu> 11 </menu>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<menu xmlns:android="http://schemas.android.com/apk/res/android" 2 +<menu xmlns:android="http://schemas.android.com/apk/res/android"
3 - xmlns:app="http://schemas.android.com/apk/res-auto"> 3 + xmlns:app="http://schemas.android.com/apk/res-auto">
4 - <item 4 + <item
5 - android:id="@+id/navigation_home" 5 + android:id="@+id/navigation_home"
6 - android:icon="@drawable/ic_home_black_24dp" 6 + android:icon="@drawable/ic_home_black_24dp"
7 - android:title="@string/title_home" 7 + android:title="@string/title_home"
8 - /> 8 + />
9 - 9 +
10 - <item 10 + <item
11 - android:id="@+id/navigation_env" 11 + android:id="@+id/navigation_env"
12 - android:icon="@drawable/ic_cloud_queue_black_24dp" 12 + android:icon="@drawable/ic_cloud_queue_black_24dp"
13 - android:title="@string/title_activity_main2" /> 13 + android:title="@string/title_activity_main2" />
14 - 14 +
15 - <item 15 + <item
16 - android:id="@+id/navigation_bt" 16 + android:id="@+id/navigation_bt"
17 - android:icon="@drawable/ic_bluetooth_black_24dp" 17 + android:icon="@drawable/ic_bluetooth_black_24dp"
18 - android:title="@string/title_activity_main33" /> 18 + android:title="@string/title_activity_main33" />
19 - 19 +
20 -</menu> 20 +</menu>
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> 2 +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3 - <background android:drawable="@drawable/ic_launcher_background" /> 3 + <background android:drawable="@drawable/ic_launcher_background" />
4 - <foreground android:drawable="@drawable/ic_launcher_foreground" /> 4 + <foreground android:drawable="@drawable/ic_launcher_foreground" />
5 </adaptive-icon> 5 </adaptive-icon>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> 2 +<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
3 - <background android:drawable="@drawable/ic_launcher_background" /> 3 + <background android:drawable="@drawable/ic_launcher_background" />
4 - <foreground android:drawable="@drawable/ic_launcher_foreground" /> 4 + <foreground android:drawable="@drawable/ic_launcher_foreground" />
5 </adaptive-icon> 5 </adaptive-icon>
...\ No newline at end of file ...\ No newline at end of file
......
1 -<?xml version="1.0" encoding="utf-8"?> 1 +<?xml version="1.0" encoding="utf-8"?>
2 -<resources> 2 +<resources>
3 - <color name="colorPrimary">#000000</color> 3 + <color name="colorPrimary">#000000</color>
4 - <color name="colorPrimaryDark">#7899ddff</color> 4 + <color name="colorPrimaryDark">#7899ddff</color>
5 - <color name="colorAccent">#f0646a71</color> 5 + <color name="colorAccent">#f0646a71</color>
6 -</resources> 6 +</resources>
......
1 -<resources> 1 +<resources>
2 - <!-- Default screen margins, per the Android Design guidelines. --> 2 + <!-- Default screen margins, per the Android Design guidelines. -->
3 - <dimen name="activity_horizontal_margin">16dp</dimen> 3 + <dimen name="activity_horizontal_margin">16dp</dimen>
4 - <dimen name="activity_vertical_margin">16dp</dimen> 4 + <dimen name="activity_vertical_margin">16dp</dimen>
5 - <dimen name="text_margin">16dp</dimen> 5 + <dimen name="text_margin">16dp</dimen>
6 -</resources> 6 +</resources>
......
1 -<resources> 1 +<resources>
2 - <string name="app_name">SMART WINDOW</string> 2 + <string name="app_name">SMART WINDOW</string>
3 - <string name="title_home">Home</string> 3 + <string name="title_home">Home</string>
4 - <string name="title_activity_main2">Environment</string> 4 + <string name="title_activity_main2">Environment</string>
5 - <string name="title_activity_main33">Bluetooth</string> 5 + <string name="title_activity_main33">Bluetooth</string>
6 - <string name="connected">Connected</string> 6 + <string name="connected">Connected</string>
7 - <string name="disconnected">Disconnected</string> 7 + <string name="disconnected">Disconnected</string>
8 - <string name="addr_m">90:E2:02:8F:36:70</string> 8 + <string name="addr_m">90:E2:02:8F:36:70</string>
9 - <string name="addr_d">90:E2:02:8E:1F:21</string> 9 + <string name="addr_d">90:E2:02:8E:1F:21</string>
10 - <string name="addr_r">90:E2:02:92:A9:0E</string> 10 + <string name="addr_r">90:E2:02:92:A9:0E</string>
11 -</resources> 11 +</resources>
......
1 -<resources> 1 +<resources>
2 - 2 +
3 - <!-- Base application theme. --> 3 + <!-- Base application theme. -->
4 - <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 4 + <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5 - <!-- Customize your theme here. --> 5 + <!-- Customize your theme here. -->
6 - <item name="colorPrimary">@color/colorPrimary</item> 6 + <item name="colorPrimary">@color/colorPrimary</item>
7 - <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 7 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8 - <item name="colorAccent">@color/colorAccent</item> 8 + <item name="colorAccent">@color/colorAccent</item>
9 - </style> 9 + </style>
10 - 10 +
11 -</resources> 11 +</resources>
......
1 -package com.example.suemin.smartwindow; 1 +package com.example.suemin.smartwindow;
2 - 2 +
3 -import org.junit.Test; 3 +import org.junit.Test;
4 - 4 +
5 -import static org.junit.Assert.*; 5 +import static org.junit.Assert.*;
6 - 6 +
7 -/** 7 +/**
8 - * Example local unit test, which will execute on the development machine (host). 8 + * Example local unit test, which will execute on the development machine (host).
9 - * 9 + *
10 - * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> 10 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11 - */ 11 + */
12 -public class ExampleUnitTest { 12 +public class ExampleUnitTest {
13 - @Test 13 + @Test
14 - public void addition_isCorrect() { 14 + public void addition_isCorrect() {
15 - assertEquals(4, 2 + 2); 15 + assertEquals(4, 2 + 2);
16 - } 16 + }
17 } 17 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -// Top-level build file where you can add configuration options common to all sub-projects/modules. 1 +// Top-level build file where you can add configuration options common to all sub-projects/modules.
2 - 2 +
3 -buildscript { 3 +buildscript {
4 - 4 +
5 - repositories { 5 + repositories {
6 - google() 6 + google()
7 - jcenter() 7 + jcenter()
8 - } 8 + }
9 - dependencies { 9 + dependencies {
10 - classpath 'com.android.tools.build:gradle:3.2.1' 10 + classpath 'com.android.tools.build:gradle:3.2.1'
11 - 11 +
12 - 12 +
13 - // NOTE: Do not place your application dependencies here; they belong 13 + // NOTE: Do not place your application dependencies here; they belong
14 - // in the individual module build.gradle files 14 + // in the individual module build.gradle files
15 - } 15 + }
16 -} 16 +}
17 - 17 +
18 -allprojects { 18 +allprojects {
19 - repositories { 19 + repositories {
20 - google() 20 + google()
21 - jcenter() 21 + jcenter()
22 - } 22 + }
23 -} 23 +}
24 - 24 +
25 -task clean(type: Delete) { 25 +task clean(type: Delete) {
26 - delete rootProject.buildDir 26 + delete rootProject.buildDir
27 -} 27 +}
......
1 -# Project-wide Gradle settings. 1 +# Project-wide Gradle settings.
2 -# IDE (e.g. Android Studio) users: 2 +# IDE (e.g. Android Studio) users:
3 -# Gradle settings configured through the IDE *will override* 3 +# Gradle settings configured through the IDE *will override*
4 -# any settings specified in this file. 4 +# any settings specified in this file.
5 -# For more details on how to configure your build environment visit 5 +# For more details on how to configure your build environment visit
6 -# http://www.gradle.org/docs/current/userguide/build_environment.html 6 +# http://www.gradle.org/docs/current/userguide/build_environment.html
7 -# Specifies the JVM arguments used for the daemon process. 7 +# Specifies the JVM arguments used for the daemon process.
8 -# The setting is particularly useful for tweaking memory settings. 8 +# The setting is particularly useful for tweaking memory settings.
9 -org.gradle.jvmargs=-Xmx1536m 9 +org.gradle.jvmargs=-Xmx1536m
10 -# When configured, Gradle will run in incubating parallel mode. 10 +# When configured, Gradle will run in incubating parallel mode.
11 -# This option should only be used with decoupled projects. More details, visit 11 +# This option should only be used with decoupled projects. More details, visit
12 -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 12 +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 -# org.gradle.parallel=true 13 +# org.gradle.parallel=true
14 - 14 +
15 - 15 +
......
1 -@if "%DEBUG%" == "" @echo off 1 +@if "%DEBUG%" == "" @echo off
2 -@rem ########################################################################## 2 +@rem ##########################################################################
3 -@rem 3 +@rem
4 -@rem Gradle startup script for Windows 4 +@rem Gradle startup script for Windows
5 -@rem 5 +@rem
6 -@rem ########################################################################## 6 +@rem ##########################################################################
7 - 7 +
8 -@rem Set local scope for the variables with windows NT shell 8 +@rem Set local scope for the variables with windows NT shell
9 -if "%OS%"=="Windows_NT" setlocal 9 +if "%OS%"=="Windows_NT" setlocal
10 - 10 +
11 -set DIRNAME=%~dp0 11 +set DIRNAME=%~dp0
12 -if "%DIRNAME%" == "" set DIRNAME=. 12 +if "%DIRNAME%" == "" set DIRNAME=.
13 -set APP_BASE_NAME=%~n0 13 +set APP_BASE_NAME=%~n0
14 -set APP_HOME=%DIRNAME% 14 +set APP_HOME=%DIRNAME%
15 - 15 +
16 -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 16 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 -set DEFAULT_JVM_OPTS= 17 +set DEFAULT_JVM_OPTS=
18 - 18 +
19 -@rem Find java.exe 19 +@rem Find java.exe
20 -if defined JAVA_HOME goto findJavaFromJavaHome 20 +if defined JAVA_HOME goto findJavaFromJavaHome
21 - 21 +
22 -set JAVA_EXE=java.exe 22 +set JAVA_EXE=java.exe
23 -%JAVA_EXE% -version >NUL 2>&1 23 +%JAVA_EXE% -version >NUL 2>&1
24 -if "%ERRORLEVEL%" == "0" goto init 24 +if "%ERRORLEVEL%" == "0" goto init
25 - 25 +
26 -echo. 26 +echo.
27 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 -echo. 28 +echo.
29 -echo Please set the JAVA_HOME variable in your environment to match the 29 +echo Please set the JAVA_HOME variable in your environment to match the
30 -echo location of your Java installation. 30 +echo location of your Java installation.
31 - 31 +
32 -goto fail 32 +goto fail
33 - 33 +
34 -:findJavaFromJavaHome 34 +:findJavaFromJavaHome
35 -set JAVA_HOME=%JAVA_HOME:"=% 35 +set JAVA_HOME=%JAVA_HOME:"=%
36 -set JAVA_EXE=%JAVA_HOME%/bin/java.exe 36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 - 37 +
38 -if exist "%JAVA_EXE%" goto init 38 +if exist "%JAVA_EXE%" goto init
39 - 39 +
40 -echo. 40 +echo.
41 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 -echo. 42 +echo.
43 -echo Please set the JAVA_HOME variable in your environment to match the 43 +echo Please set the JAVA_HOME variable in your environment to match the
44 -echo location of your Java installation. 44 +echo location of your Java installation.
45 - 45 +
46 -goto fail 46 +goto fail
47 - 47 +
48 -:init 48 +:init
49 -@rem Get command-line arguments, handling Windows variants 49 +@rem Get command-line arguments, handling Windows variants
50 - 50 +
51 -if not "%OS%" == "Windows_NT" goto win9xME_args 51 +if not "%OS%" == "Windows_NT" goto win9xME_args
52 - 52 +
53 -:win9xME_args 53 +:win9xME_args
54 -@rem Slurp the command line arguments. 54 +@rem Slurp the command line arguments.
55 -set CMD_LINE_ARGS= 55 +set CMD_LINE_ARGS=
56 -set _SKIP=2 56 +set _SKIP=2
57 - 57 +
58 -:win9xME_args_slurp 58 +:win9xME_args_slurp
59 -if "x%~1" == "x" goto execute 59 +if "x%~1" == "x" goto execute
60 - 60 +
61 -set CMD_LINE_ARGS=%* 61 +set CMD_LINE_ARGS=%*
62 - 62 +
63 -:execute 63 +:execute
64 -@rem Setup the command line 64 +@rem Setup the command line
65 - 65 +
66 -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 66 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 - 67 +
68 -@rem Execute Gradle 68 +@rem Execute Gradle
69 -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 69 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 - 70 +
71 -:end 71 +:end
72 -@rem End local scope for the variables with windows NT shell 72 +@rem End local scope for the variables with windows NT shell
73 -if "%ERRORLEVEL%"=="0" goto mainEnd 73 +if "%ERRORLEVEL%"=="0" goto mainEnd
74 - 74 +
75 -:fail 75 +:fail
76 -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 76 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 -rem the _cmd.exe /c_ return code! 77 +rem the _cmd.exe /c_ return code!
78 -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 78 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 -exit /b 1 79 +exit /b 1
80 - 80 +
81 -:mainEnd 81 +:mainEnd
82 -if "%OS%"=="Windows_NT" endlocal 82 +if "%OS%"=="Windows_NT" endlocal
83 - 83 +
84 -:omega 84 +:omega
......