Junyoung, Sung

Added whole project

Showing 271 changed files with 7710 additions and 0 deletions
1 +*.iml
2 +.gradle
3 +/local.properties
4 +/.idea/workspace.xml
5 +/.idea/libraries
6 +.DS_Store
7 +/build
8 +/captures
9 +.externalNativeBuild
10 +
11 +node_modules/
12 +*.out
13 +config/
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="CompilerConfiguration">
4 + <resourceExtensions />
5 + <wildcardResourcePatterns>
6 + <entry name="!?*.java" />
7 + <entry name="!?*.form" />
8 + <entry name="!?*.class" />
9 + <entry name="!?*.groovy" />
10 + <entry name="!?*.scala" />
11 + <entry name="!?*.flex" />
12 + <entry name="!?*.kt" />
13 + <entry name="!?*.clj" />
14 + <entry name="!?*.aj" />
15 + </wildcardResourcePatterns>
16 + <annotationProcessing>
17 + <profile default="true" name="Default" enabled="false">
18 + <processorPath useClasspath="true" />
19 + </profile>
20 + </annotationProcessing>
21 + </component>
22 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<component name="CopyrightManager">
2 + <settings default="" />
3 +</component>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="Encoding">
4 + <file url="PROJECT" charset="UTF-8" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="GradleSettings">
4 + <option name="linkedExternalProjectsSettings">
5 + <GradleProjectSettings>
6 + <option name="distributionType" value="DEFAULT_WRAPPED" />
7 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
8 + <option name="modules">
9 + <set>
10 + <option value="$PROJECT_DIR$" />
11 + <option value="$PROJECT_DIR$/app" />
12 + </set>
13 + </option>
14 + <option name="resolveModulePerSourceSet" value="false" />
15 + </GradleProjectSettings>
16 + </option>
17 + </component>
18 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="EntryPointsManager">
4 + <entry_points version="2.0" />
5 + </component>
6 + <component name="NullableNotNullManager">
7 + <option name="myDefaultNullable" value="android.support.annotation.Nullable" />
8 + <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
9 + <option name="myNullables">
10 + <value>
11 + <list size="4">
12 + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
13 + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
14 + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
15 + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
16 + </list>
17 + </value>
18 + </option>
19 + <option name="myNotNulls">
20 + <value>
21 + <list size="4">
22 + <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
23 + <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
24 + <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
25 + <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
26 + </list>
27 + </value>
28 + </option>
29 + </component>
30 +<<<<<<< HEAD
31 + <component name="ProjectLevelVcsManager" settingsEditedManually="false">
32 + <OptionsSetting value="true" id="Add" />
33 + <OptionsSetting value="true" id="Remove" />
34 + <OptionsSetting value="true" id="Checkout" />
35 + <OptionsSetting value="true" id="Update" />
36 + <OptionsSetting value="true" id="Status" />
37 + <OptionsSetting value="true" id="Edit" />
38 + <ConfirmationsSetting value="0" id="Add" />
39 + <ConfirmationsSetting value="0" id="Remove" />
40 + </component>
41 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
42 +=======
43 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
44 +>>>>>>> 32cfac39b1691cde61fa34203f0b709f605df17d
45 + <output url="file://$PROJECT_DIR$/build/classes" />
46 + </component>
47 + <component name="ProjectType">
48 + <option name="id" value="Android" />
49 + </component>
50 + <component name="masterDetails">
51 + <states>
52 + <state key="ProjectJDKs.UI">
53 + <settings>
54 + <last-edited>1.8</last-edited>
55 + <splitter-proportions>
56 + <option name="proportions">
57 + <list>
58 + <option value="0.2" />
59 + </list>
60 + </option>
61 + </splitter-proportions>
62 + </settings>
63 + </state>
64 + </states>
65 + </component>
66 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="ProjectModuleManager">
4 + <modules>
5 + <module fileurl="file://$PROJECT_DIR$/LoLock.iml" filepath="$PROJECT_DIR$/LoLock.iml" />
6 + <module fileurl="file://$PROJECT_DIR$/LoLock-Android.iml" filepath="$PROJECT_DIR$/LoLock-Android.iml" />
7 + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
8 + </modules>
9 + </component>
10 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="RunConfigurationProducerService">
4 + <option name="ignoredProducers">
5 + <set>
6 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
7 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
8 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
9 + </set>
10 + </option>
11 + </component>
12 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="VcsDirectoryMappings">
4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +apply plugin: 'com.android.application'
2 +
3 +android {
4 + compileSdkVersion 25
5 + buildToolsVersion '26.0.2'
6 + defaultConfig {
7 + applicationId "com.gunghi.tgwing.lolock"
8 + minSdkVersion 19
9 + targetSdkVersion 25
10 + versionCode 1
11 + versionName "1.0"
12 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 + }
14 + buildTypes {
15 + release {
16 + minifyEnabled false
17 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 + }
19 + }
20 +}
21 +
22 +dependencies {
23 + compile fileTree(dir: 'libs', include: ['*.jar'])
24 + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 + exclude group: 'com.android.support', module: 'support-annotations'
26 + exclude group: 'com.google.code.findbugs'
27 + })
28 +
29 + repositories {
30 + jcenter() // If not already there
31 + }
32 +
33 + dependencies {
34 + compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'
35 + }
36 +
37 + compile 'com.android.support:appcompat-v7:25.3.1'
38 + compile 'com.android.support:recyclerview-v7:25.3.1'
39 +
40 + compile 'com.android.support.constraint:constraint-layout:1.0.2'
41 + compile 'com.roughike:bottom-bar:1.4.0.1'
42 + compile 'com.google.code.gson:gson:2.7'
43 + compile 'com.squareup.retrofit2:retrofit:2.3.0'
44 + compile 'com.squareup.retrofit2:converter-gson:2.3.0'
45 + compile 'de.hdodenhof:circleimageview:2.1.0'
46 + compile 'com.squareup.picasso:picasso:2.5.2'
47 + compile 'com.tsengvn:typekit:1.0.1'
48 + compile 'com.google.firebase:firebase-core:10.0.1'
49 + compile 'com.google.firebase:firebase-messaging:10.0.1'
50 + compile 'com.firebase:firebase-jobdispatcher:0.6.0'
51 + compile 'com.airbnb.android:lottie:2.1.0'
52 +
53 + compile 'com.squareup:otto:1.3.8'
54 + compile 'com.google.android.gms:play-services-auth:10.0.1'
55 + compile 'pub.devrel:easypermissions:0.4.2'
56 + compile('com.google.api-client:google-api-client-android:1.22.0') {
57 + exclude group: 'org.apache.httpcomponents'
58 + }
59 + compile('com.google.apis:google-api-services-calendar:v3-rev250-1.22.0') {
60 + exclude group: 'org.apache.httpcomponents'
61 + }
62 +
63 +
64 + testCompile 'junit:junit:4.12'
65 +}
66 +apply plugin: 'com.google.gms.google-services'
67 +apply plugin: 'realm-android'
1 +{
2 + "project_info": {
3 + "project_number": "1076942403851",
4 + "firebase_url": "https://lolock-5ee55.firebaseio.com",
5 + "project_id": "lolock-5ee55",
6 + "storage_bucket": "lolock-5ee55.appspot.com"
7 + },
8 + "client": [
9 + {
10 + "client_info": {
11 + "mobilesdk_app_id": "1:1076942403851:android:bbf5df34ab2eb04a",
12 + "android_client_info": {
13 + "package_name": "com.gunghi.tgwing.lolock"
14 + }
15 + },
16 + "oauth_client": [
17 + {
18 + "client_id": "1076942403851-649errgesgcs53hrfinb3q1q4i331fgk.apps.googleusercontent.com",
19 + "client_type": 1,
20 + "android_info": {
21 + "package_name": "com.gunghi.tgwing.lolock",
22 + "certificate_hash": "461a4eea1d06d912f5ba34a7122953d8986077ae"
23 + }
24 + },
25 + {
26 + "client_id": "1076942403851-mrt95aun9t87hmjsrgnggb663r27kdbi.apps.googleusercontent.com",
27 + "client_type": 3
28 + }
29 + ],
30 + "api_key": [
31 + {
32 + "current_key": "AIzaSyDlcIA8Da_DaDdp9QtWdcjSWeRFM426bvs"
33 + }
34 + ],
35 + "services": {
36 + "analytics_service": {
37 + "status": 1
38 + },
39 + "appinvite_service": {
40 + "status": 2,
41 + "other_platform_oauth_client": [
42 + {
43 + "client_id": "1076942403851-mrt95aun9t87hmjsrgnggb663r27kdbi.apps.googleusercontent.com",
44 + "client_type": 3
45 + }
46 + ]
47 + },
48 + "ads_service": {
49 + "status": 2
50 + }
51 + }
52 + }
53 + ],
54 + "configuration_version": "1"
55 +}
...\ No newline at end of file ...\ No newline at end of file
1 +# Add project specific ProGuard rules here.
2 +# By default, the flags in this file are appended to flags specified
3 +# in /Users/joyeongje/Library/Android/sdk/tools/proguard/proguard-android.txt
4 +# You can edit the include path and order by changing the proguardFiles
5 +# directive in build.gradle.
6 +#
7 +# For more details, see
8 +# http://developer.android.com/guide/developing/tools/proguard.html
9 +
10 +# Add any project specific keep options here:
11 +
12 +# If your project uses WebView with JS, uncomment the following
13 +# and specify the fully qualified class name to the JavaScript interface
14 +# class:
15 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 +# public *;
17 +#}
18 +
19 +# Uncomment this to preserve the line number information for
20 +# debugging stack traces.
21 +#-keepattributes SourceFile,LineNumberTable
22 +
23 +# If you keep the line number information, uncomment this to
24 +# hide the original source file name.
25 +#-renamesourcefileattribute SourceFile
1 +package com.gunghi.tgwing.lolock;
2 +
3 +import android.content.Context;
4 +import android.support.test.InstrumentationRegistry;
5 +import android.support.test.runner.AndroidJUnit4;
6 +
7 +import org.junit.Test;
8 +import org.junit.runner.RunWith;
9 +
10 +import static org.junit.Assert.*;
11 +
12 +/**
13 + * Instrumentation test, which will execute on an Android device.
14 + *
15 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16 + */
17 +@RunWith(AndroidJUnit4.class)
18 +public class ExampleInstrumentedTest {
19 + @Test
20 + public void useAppContext() throws Exception {
21 + // Context of the app under test.
22 + Context appContext = InstrumentationRegistry.getTargetContext();
23 +
24 + assertEquals("com.gunghi.tgwing.lolock", appContext.getPackageName());
25 + }
26 +}
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 + package="com.gunghi.tgwing.lolock">
4 +
5 + <!--
6 + Declare this required feature if you want to make the app available to BLE-capable
7 + devices only. If you want to make your app available to devices that don't support BLE,
8 + you should omit this in the manifest. Instead, determine BLE capability by using
9 + PackageManager.hasSystemFeature(FEATURE_BLUETOOTH_LE)
10 + -->
11 + <uses-feature
12 + android:name="android.hardware.bluetooth_le"
13 + android:required="true" />
14 +
15 + <uses-permission android:name="android.permission.BLUETOOTH" />
16 + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
17 + <uses-permission android:name="android.permission.INTERNET" />
18 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
19 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
20 + <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
21 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
22 + <uses-permission android:name="android.permission.SEND_SMS" />
23 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
24 +
25 +
26 + <application
27 + android:name=".util.TypekitSetting"
28 + android:allowBackup="true"
29 + android:icon="@mipmap/ic_launcher_lolock"
30 + android:label="@string/app_name"
31 + android:roundIcon="@mipmap/ic_launcher_round"
32 + android:supportsRtl="true"
33 + android:theme="@style/AppTheme">
34 + <activity android:name=".ui.SplashActivity">
35 + <intent-filter>
36 + <action android:name="android.intent.action.MAIN" />
37 +
38 + <category android:name="android.intent.category.LAUNCHER" />
39 + </intent-filter>
40 + </activity>
41 + <activity android:name=".ui.MainActivity" />
42 + <activity android:name=".ui.SettingActivity" />
43 +
44 + <service
45 + android:name=".service.BluetoothLeService"
46 + android:enabled="true" />
47 +
48 + <!-- [START firebase_service] -->
49 + <service android:name=".service.MyFirebaseMessagingService">
50 + <intent-filter>
51 + <action android:name="com.google.firebase.MESSAGING_EVENT" />
52 + </intent-filter>
53 + </service>
54 + <!-- [END firebase_service] -->
55 + <!-- [START firebase_iid_service] -->
56 + <service android:name=".service.MyFirebaseInstanceIDService">
57 + <intent-filter>
58 + <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
59 + </intent-filter>
60 + </service>
61 + <!-- [END firebase_iid_service] -->
62 +
63 + <activity android:name=".ui.RegisterActivity" />
64 + <activity android:name=".ui.Register2Activity"/>
65 +
66 +
67 + </application>
68 +
69 +</manifest>
...\ No newline at end of file ...\ No newline at end of file
This file is too large to display.
1 +package com.gunghi.tgwing.lolock;
2 +
3 +/**
4 + * Created by joyeongje on 2017. 7. 1..
5 + */
6 +
7 +/**
8 + * Defines several constants used between {@link BluetoothChatService} and the UI.
9 + */
10 +public interface Constants {
11 +
12 + // Message types sent from the BluetoothChatService Handler
13 + public static final int MESSAGE_STATE_CHANGE = 1;
14 + public static final int MESSAGE_READ = 2;
15 + public static final int MESSAGE_WRITE = 3;
16 + public static final int MESSAGE_DEVICE_NAME = 4;
17 + public static final int MESSAGE_TOAST = 5;
18 +
19 + // Key names received from the BluetoothChatService Handler
20 + public static final String DEVICE_NAME = "device_name";
21 + public static final String TOAST = "toast";
22 +
23 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +
6 +import java.util.List;
7 +
8 +/**
9 + * Created by joyeongje on 2017. 7. 23..
10 + */
11 +
12 +public class ResponseCaly {
13 +
14 + @SerializedName("created")
15 + @Expose
16 + private String created;
17 + @SerializedName("creator")
18 + @Expose
19 + private Creator creator;
20 + @SerializedName("end")
21 + @Expose
22 + private End end;
23 + @SerializedName("etag")
24 + @Expose
25 + private String etag;
26 + @SerializedName("htmlLink")
27 + @Expose
28 + private String htmlLink;
29 + @SerializedName("iCalUID")
30 + @Expose
31 + private String iCalUID;
32 + @SerializedName("id")
33 + @Expose
34 + private String id;
35 + @SerializedName("kind")
36 + @Expose
37 + private String kind;
38 + @SerializedName("organizer")
39 + @Expose
40 + private Organizer organizer;
41 + @SerializedName("reminders")
42 + @Expose
43 + private Reminders reminders;
44 + @SerializedName("sequence")
45 + @Expose
46 + private Integer sequence;
47 + @SerializedName("start")
48 + @Expose
49 + private Start start;
50 + @SerializedName("status")
51 + @Expose
52 + private String status;
53 + @SerializedName("summary")
54 + @Expose
55 + private String summary;
56 + @SerializedName("updated")
57 + @Expose
58 + private String updated;
59 +
60 + /**
61 + * No args constructor for use in serialization
62 + *
63 + */
64 + public ResponseCaly() {
65 + }
66 +
67 + /**
68 + *
69 + * @param summary
70 + * @param reminders
71 + * @param etag
72 + * @param status
73 + * @param organizer
74 + * @param kind
75 + * @param creator
76 + * @param id
77 + * @param updated
78 + * @param created
79 + * @param start
80 + * @param sequence
81 + * @param iCalUID
82 + * @param end
83 + * @param htmlLink
84 + */
85 + public ResponseCaly(String created, Creator creator, End end, String etag, String htmlLink, String iCalUID, String id, String kind, Organizer organizer, Reminders reminders, Integer sequence, Start start, String status, String summary, String updated) {
86 + super();
87 + this.created = created;
88 + this.creator = creator;
89 + this.end = end;
90 + this.etag = etag;
91 + this.htmlLink = htmlLink;
92 + this.iCalUID = iCalUID;
93 + this.id = id;
94 + this.kind = kind;
95 + this.organizer = organizer;
96 + this.reminders = reminders;
97 + this.sequence = sequence;
98 + this.start = start;
99 + this.status = status;
100 + this.summary = summary;
101 + this.updated = updated;
102 + }
103 +
104 + public String getCreated() {
105 + return created;
106 + }
107 +
108 + public void setCreated(String created) {
109 + this.created = created;
110 + }
111 +
112 + public ResponseCaly withCreated(String created) {
113 + this.created = created;
114 + return this;
115 + }
116 +
117 + public Creator getCreator() {
118 + return creator;
119 + }
120 +
121 + public void setCreator(Creator creator) {
122 + this.creator = creator;
123 + }
124 +
125 + public ResponseCaly withCreator(Creator creator) {
126 + this.creator = creator;
127 + return this;
128 + }
129 +
130 + public End getEnd() {
131 + return end;
132 + }
133 +
134 + public void setEnd(End end) {
135 + this.end = end;
136 + }
137 +
138 + public ResponseCaly withEnd(End end) {
139 + this.end = end;
140 + return this;
141 + }
142 +
143 + public String getEtag() {
144 + return etag;
145 + }
146 +
147 + public void setEtag(String etag) {
148 + this.etag = etag;
149 + }
150 +
151 + public ResponseCaly withEtag(String etag) {
152 + this.etag = etag;
153 + return this;
154 + }
155 +
156 + public String getHtmlLink() {
157 + return htmlLink;
158 + }
159 +
160 + public void setHtmlLink(String htmlLink) {
161 + this.htmlLink = htmlLink;
162 + }
163 +
164 + public ResponseCaly withHtmlLink(String htmlLink) {
165 + this.htmlLink = htmlLink;
166 + return this;
167 + }
168 +
169 + public String getICalUID() {
170 + return iCalUID;
171 + }
172 +
173 + public void setICalUID(String iCalUID) {
174 + this.iCalUID = iCalUID;
175 + }
176 +
177 + public ResponseCaly withICalUID(String iCalUID) {
178 + this.iCalUID = iCalUID;
179 + return this;
180 + }
181 +
182 + public String getId() {
183 + return id;
184 + }
185 +
186 + public void setId(String id) {
187 + this.id = id;
188 + }
189 +
190 + public ResponseCaly withId(String id) {
191 + this.id = id;
192 + return this;
193 + }
194 +
195 + public String getKind() {
196 + return kind;
197 + }
198 +
199 + public void setKind(String kind) {
200 + this.kind = kind;
201 + }
202 +
203 + public ResponseCaly withKind(String kind) {
204 + this.kind = kind;
205 + return this;
206 + }
207 +
208 + public Organizer getOrganizer() {
209 + return organizer;
210 + }
211 +
212 + public void setOrganizer(Organizer organizer) {
213 + this.organizer = organizer;
214 + }
215 +
216 + public ResponseCaly withOrganizer(Organizer organizer) {
217 + this.organizer = organizer;
218 + return this;
219 + }
220 +
221 + public Reminders getReminders() {
222 + return reminders;
223 + }
224 +
225 + public void setReminders(Reminders reminders) {
226 + this.reminders = reminders;
227 + }
228 +
229 + public ResponseCaly withReminders(Reminders reminders) {
230 + this.reminders = reminders;
231 + return this;
232 + }
233 +
234 + public Integer getSequence() {
235 + return sequence;
236 + }
237 +
238 + public void setSequence(Integer sequence) {
239 + this.sequence = sequence;
240 + }
241 +
242 + public ResponseCaly withSequence(Integer sequence) {
243 + this.sequence = sequence;
244 + return this;
245 + }
246 +
247 + public Start getStart() {
248 + return start;
249 + }
250 +
251 + public void setStart(Start start) {
252 + this.start = start;
253 + }
254 +
255 + public ResponseCaly withStart(Start start) {
256 + this.start = start;
257 + return this;
258 + }
259 +
260 + public String getStatus() {
261 + return status;
262 + }
263 +
264 + public void setStatus(String status) {
265 + this.status = status;
266 + }
267 +
268 + public ResponseCaly withStatus(String status) {
269 + this.status = status;
270 + return this;
271 + }
272 +
273 + public String getSummary() {
274 + return summary;
275 + }
276 +
277 + public void setSummary(String summary) {
278 + this.summary = summary;
279 + }
280 +
281 + public ResponseCaly withSummary(String summary) {
282 + this.summary = summary;
283 + return this;
284 + }
285 +
286 + public String getUpdated() {
287 + return updated;
288 + }
289 +
290 + public void setUpdated(String updated) {
291 + this.updated = updated;
292 + }
293 +
294 + public ResponseCaly withUpdated(String updated) {
295 + this.updated = updated;
296 + return this;
297 + }
298 +
299 +
300 + public class Start {
301 +
302 + @SerializedName("dateTime")
303 + @Expose
304 + private String dateTime;
305 + @SerializedName("timeZone")
306 + @Expose
307 + private String timeZone;
308 +
309 + /**
310 + * No args constructor for use in serialization
311 + *
312 + */
313 + public Start() {
314 + }
315 +
316 + /**
317 + *
318 + * @param dateTime
319 + * @param timeZone
320 + */
321 + public Start(String dateTime, String timeZone) {
322 + super();
323 + this.dateTime = dateTime;
324 + this.timeZone = timeZone;
325 + }
326 +
327 + public String getDateTime() {
328 + return dateTime;
329 + }
330 +
331 + public void setDateTime(String dateTime) {
332 + this.dateTime = dateTime;
333 + }
334 +
335 + public Start withDateTime(String dateTime) {
336 + this.dateTime = dateTime;
337 + return this;
338 + }
339 +
340 + public String getTimeZone() {
341 + return timeZone;
342 + }
343 +
344 + public void setTimeZone(String timeZone) {
345 + this.timeZone = timeZone;
346 + }
347 +
348 + public Start withTimeZone(String timeZone) {
349 + this.timeZone = timeZone;
350 + return this;
351 + }
352 +
353 + }
354 +
355 + public class Reminders {
356 +
357 + @SerializedName("overrides")
358 + @Expose
359 + private List<Override> overrides = null;
360 + @SerializedName("useDefault")
361 + @Expose
362 + private Boolean useDefault;
363 +
364 + /**
365 + * No args constructor for use in serialization
366 + *
367 + */
368 + public Reminders() {
369 + }
370 +
371 + /**
372 + *
373 + * @param useDefault
374 + * @param overrides
375 + */
376 + public Reminders(List<Override> overrides, Boolean useDefault) {
377 + super();
378 + this.overrides = overrides;
379 + this.useDefault = useDefault;
380 + }
381 +
382 + public List<Override> getOverrides() {
383 + return overrides;
384 + }
385 +
386 + public void setOverrides(List<Override> overrides) {
387 + this.overrides = overrides;
388 + }
389 +
390 + public Reminders withOverrides(List<Override> overrides) {
391 + this.overrides = overrides;
392 + return this;
393 + }
394 +
395 + public Boolean getUseDefault() {
396 + return useDefault;
397 + }
398 +
399 + public void setUseDefault(Boolean useDefault) {
400 + this.useDefault = useDefault;
401 + }
402 +
403 + public Reminders withUseDefault(Boolean useDefault) {
404 + this.useDefault = useDefault;
405 + return this;
406 + }
407 + }
408 +
409 + public class Override {
410 +
411 + @SerializedName("method")
412 + @Expose
413 + private String method;
414 + @SerializedName("minutes")
415 + @Expose
416 + private Integer minutes;
417 +
418 + /**
419 + * No args constructor for use in serialization
420 + *
421 + */
422 + public Override() {
423 + }
424 +
425 + /**
426 + *
427 + * @param minutes
428 + * @param method
429 + */
430 + public Override(String method, Integer minutes) {
431 + super();
432 + this.method = method;
433 + this.minutes = minutes;
434 + }
435 +
436 + public String getMethod() {
437 + return method;
438 + }
439 +
440 + public void setMethod(String method) {
441 + this.method = method;
442 + }
443 +
444 + public Override withMethod(String method) {
445 + this.method = method;
446 + return this;
447 + }
448 +
449 + public Integer getMinutes() {
450 + return minutes;
451 + }
452 +
453 + public void setMinutes(Integer minutes) {
454 + this.minutes = minutes;
455 + }
456 +
457 + public Override withMinutes(Integer minutes) {
458 + this.minutes = minutes;
459 + return this;
460 + }
461 +
462 + }
463 +
464 + public class Organizer {
465 +
466 + @SerializedName("displayName")
467 + @Expose
468 + private String displayName;
469 + @SerializedName("email")
470 + @Expose
471 + private String email;
472 + @SerializedName("self")
473 + @Expose
474 + private Boolean self;
475 +
476 + /**
477 + * No args constructor for use in serialization
478 + *
479 + */
480 + public Organizer() {
481 + }
482 +
483 + /**
484 + *
485 + * @param email
486 + * @param self
487 + * @param displayName
488 + */
489 + public Organizer(String displayName, String email, Boolean self) {
490 + super();
491 + this.displayName = displayName;
492 + this.email = email;
493 + this.self = self;
494 + }
495 +
496 + public String getDisplayName() {
497 + return displayName;
498 + }
499 +
500 + public void setDisplayName(String displayName) {
501 + this.displayName = displayName;
502 + }
503 +
504 + public Organizer withDisplayName(String displayName) {
505 + this.displayName = displayName;
506 + return this;
507 + }
508 +
509 + public String getEmail() {
510 + return email;
511 + }
512 +
513 + public void setEmail(String email) {
514 + this.email = email;
515 + }
516 +
517 + public Organizer withEmail(String email) {
518 + this.email = email;
519 + return this;
520 + }
521 +
522 + public Boolean getSelf() {
523 + return self;
524 + }
525 +
526 + public void setSelf(Boolean self) {
527 + this.self = self;
528 + }
529 +
530 + public Organizer withSelf(Boolean self) {
531 + this.self = self;
532 + return this;
533 + }
534 +
535 + }
536 +
537 + public class End {
538 +
539 + @SerializedName("dateTime")
540 + @Expose
541 + private String dateTime;
542 + @SerializedName("timeZone")
543 + @Expose
544 + private String timeZone;
545 +
546 + /**
547 + * No args constructor for use in serialization
548 + *
549 + */
550 + public End() {
551 + }
552 +
553 + /**
554 + *
555 + * @param dateTime
556 + * @param timeZone
557 + */
558 + public End(String dateTime, String timeZone) {
559 + super();
560 + this.dateTime = dateTime;
561 + this.timeZone = timeZone;
562 + }
563 +
564 + public String getDateTime() {
565 + return dateTime;
566 + }
567 +
568 + public void setDateTime(String dateTime) {
569 + this.dateTime = dateTime;
570 + }
571 +
572 + public End withDateTime(String dateTime) {
573 + this.dateTime = dateTime;
574 + return this;
575 + }
576 +
577 + public String getTimeZone() {
578 + return timeZone;
579 + }
580 +
581 + public void setTimeZone(String timeZone) {
582 + this.timeZone = timeZone;
583 + }
584 +
585 + public End withTimeZone(String timeZone) {
586 + this.timeZone = timeZone;
587 + return this;
588 + }
589 +
590 + }
591 +
592 + public class Creator {
593 +
594 + @SerializedName("displayName")
595 + @Expose
596 + private String displayName;
597 + @SerializedName("email")
598 + @Expose
599 + private String email;
600 + @SerializedName("self")
601 + @Expose
602 + private Boolean self;
603 +
604 + /**
605 + * No args constructor for use in serialization
606 + *
607 + */
608 + public Creator() {
609 + }
610 +
611 + /**
612 + *
613 + * @param email
614 + * @param self
615 + * @param displayName
616 + */
617 + public Creator(String displayName, String email, Boolean self) {
618 + super();
619 + this.displayName = displayName;
620 + this.email = email;
621 + this.self = self;
622 + }
623 +
624 + public String getDisplayName() {
625 + return displayName;
626 + }
627 +
628 + public void setDisplayName(String displayName) {
629 + this.displayName = displayName;
630 + }
631 +
632 + public Creator withDisplayName(String displayName) {
633 + this.displayName = displayName;
634 + return this;
635 + }
636 +
637 + public String getEmail() {
638 + return email;
639 + }
640 +
641 + public void setEmail(String email) {
642 + this.email = email;
643 + }
644 +
645 + public Creator withEmail(String email) {
646 + this.email = email;
647 + return this;
648 + }
649 +
650 + public Boolean getSelf() {
651 + return self;
652 + }
653 +
654 + public void setSelf(Boolean self) {
655 + this.self = self;
656 + }
657 +
658 + public Creator withSelf(Boolean self) {
659 + this.self = self;
660 + return this;
661 + }
662 +
663 + }
664 +
665 +
666 +}
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +/**
4 + * Created by joyeongje on 2017. 7. 21..
5 + */
6 +
7 +import com.google.gson.annotations.Expose;
8 +import com.google.gson.annotations.SerializedName;
9 +
10 +public class ResponseDaumAddressAPI {
11 +
12 + @SerializedName("type")
13 + @Expose
14 + private String type;
15 + @SerializedName("code")
16 + @Expose
17 + private String code;
18 + @SerializedName("name")
19 + @Expose
20 + private String name;
21 + @SerializedName("fullName")
22 + @Expose
23 + private String fullName;
24 + @SerializedName("regionId")
25 + @Expose
26 + private String regionId;
27 + @SerializedName("name0")
28 + @Expose
29 + private String name0;
30 + @SerializedName("code1")
31 + @Expose
32 + private String code1;
33 + @SerializedName("name1")
34 + @Expose
35 + private String name1;
36 + @SerializedName("code2")
37 + @Expose
38 + private String code2;
39 + @SerializedName("name2")
40 + @Expose
41 + private String name2;
42 + @SerializedName("code3")
43 + @Expose
44 + private String code3;
45 + @SerializedName("name3")
46 + @Expose
47 + private String name3;
48 + @SerializedName("x")
49 + @Expose
50 + private Double x;
51 + @SerializedName("y")
52 + @Expose
53 + private Double y;
54 +
55 + /**
56 + * No args constructor for use in serialization
57 + *
58 + */
59 + public ResponseDaumAddressAPI() {
60 + }
61 +
62 + /**
63 + *
64 + * @param code
65 + * @param type
66 + * @param name3
67 + * @param name
68 + * @param code2
69 + * @param code1
70 + * @param fullName
71 + * @param code3
72 + * @param name1
73 + * @param name2
74 + * @param y
75 + * @param x
76 + * @param regionId
77 + * @param name0
78 + */
79 + public ResponseDaumAddressAPI(String type, String code, String name, String fullName, String regionId, String name0, String code1, String name1, String code2, String name2, String code3, String name3, Double x, Double y) {
80 + super();
81 + this.type = type;
82 + this.code = code;
83 + this.name = name;
84 + this.fullName = fullName;
85 + this.regionId = regionId;
86 + this.name0 = name0;
87 + this.code1 = code1;
88 + this.name1 = name1;
89 + this.code2 = code2;
90 + this.name2 = name2;
91 + this.code3 = code3;
92 + this.name3 = name3;
93 + this.x = x;
94 + this.y = y;
95 + }
96 +
97 + public String getType() {
98 + return type;
99 + }
100 +
101 + public void setType(String type) {
102 + this.type = type;
103 + }
104 +
105 + public String getCode() {
106 + return code;
107 + }
108 +
109 + public void setCode(String code) {
110 + this.code = code;
111 + }
112 +
113 + public String getName() {
114 + return name;
115 + }
116 +
117 + public void setName(String name) {
118 + this.name = name;
119 + }
120 +
121 + public String getFullName() {
122 + return fullName;
123 + }
124 +
125 + public void setFullName(String fullName) {
126 + this.fullName = fullName;
127 + }
128 +
129 + public String getRegionId() {
130 + return regionId;
131 + }
132 +
133 + public void setRegionId(String regionId) {
134 + this.regionId = regionId;
135 + }
136 +
137 + public String getName0() {
138 + return name0;
139 + }
140 +
141 + public void setName0(String name0) {
142 + this.name0 = name0;
143 + }
144 +
145 + public String getCode1() {
146 + return code1;
147 + }
148 +
149 + public void setCode1(String code1) {
150 + this.code1 = code1;
151 + }
152 +
153 + public String getName1() {
154 + return name1;
155 + }
156 +
157 + public void setName1(String name1) {
158 + this.name1 = name1;
159 + }
160 +
161 + public String getCode2() {
162 + return code2;
163 + }
164 +
165 + public void setCode2(String code2) {
166 + this.code2 = code2;
167 + }
168 +
169 + public String getName2() {
170 + return name2;
171 + }
172 +
173 + public void setName2(String name2) {
174 + this.name2 = name2;
175 + }
176 +
177 + public String getCode3() {
178 + return code3;
179 + }
180 +
181 + public void setCode3(String code3) {
182 + this.code3 = code3;
183 + }
184 +
185 + public String getName3() {
186 + return name3;
187 + }
188 +
189 + public void setName3(String name3) {
190 + this.name3 = name3;
191 + }
192 +
193 + public Double getX() {
194 + return x;
195 + }
196 +
197 + public void setX(Double x) {
198 + this.x = x;
199 + }
200 +
201 + public Double getY() {
202 + return y;
203 + }
204 +
205 + public void setY(Double y) {
206 + this.y = y;
207 + }
208 +
209 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +import java.util.List;
6 +
7 +
8 +public class ResponseInOutLog {
9 +
10 + @SerializedName("results")
11 + @Expose
12 + private List<Result> results = null;
13 +
14 + /**
15 + * No args constructor for use in serialization
16 + *
17 + */
18 + public ResponseInOutLog() {
19 + }
20 +
21 + /**
22 + *
23 + * @param results
24 + */
25 + public ResponseInOutLog(List<Result> results) {
26 + super();
27 + this.results = results;
28 + }
29 +
30 + public List<Result> getResults() {
31 + return results;
32 + }
33 +
34 + public void setResults(List<Result> results) {
35 + this.results = results;
36 + }
37 +
38 + public ResponseInOutLog withResults(List<Result> results) {
39 + this.results = results;
40 + return this;
41 + }
42 +
43 + public class OutTime {
44 +
45 + @SerializedName("month")
46 + @Expose
47 + private Integer month;
48 + @SerializedName("day")
49 + @Expose
50 + private Integer day;
51 + @SerializedName("hour")
52 + @Expose
53 + private Integer hour;
54 + @SerializedName("min")
55 + @Expose
56 + private Integer min;
57 +
58 + @SerializedName("dayName")
59 + @Expose
60 + private String dayName;
61 +
62 + @SerializedName("timeStamp")
63 + @Expose
64 + private long timeStamp;
65 +
66 +
67 +
68 + /**
69 + * No args constructor for use in serialization
70 + *
71 + */
72 + public OutTime() {
73 + }
74 +
75 + /**
76 + * @param month
77 + * @param day
78 + * @param hour
79 + * @param min
80 + * @param dayName
81 + */
82 + public OutTime(Integer month, Integer day, Integer hour, Integer min, String dayName) {
83 + super();
84 + this.month = month;
85 + this.day = day;
86 + this.hour = hour;
87 + this.min = min;
88 + this.dayName = dayName;
89 + }
90 +
91 + public Integer getMonth() {
92 + return month;
93 + }
94 +
95 + public void setMonth(Integer month) {
96 + this.month = month;
97 + }
98 +
99 + public OutTime withMonth(Integer month) {
100 + this.month = month;
101 + return this;
102 + }
103 +
104 + public Integer getDay() {
105 + return day;
106 + }
107 +
108 + public void setDay(Integer day) {
109 + this.day = day;
110 + }
111 +
112 + public OutTime withDay(Integer day) {
113 + this.day = day;
114 + return this;
115 + }
116 +
117 + public Integer getHour() {
118 + return hour;
119 + }
120 +
121 + public void setHour(Integer hour) {
122 + this.hour = hour;
123 + }
124 +
125 + public OutTime withHour(Integer hour) {
126 + this.hour = hour;
127 + return this;
128 + }
129 +
130 + public Integer getMin() {
131 + return min;
132 + }
133 +
134 + public void setMin(Integer min) {
135 + this.min = min;
136 + }
137 +
138 + public OutTime withMin(Integer min) {
139 + this.min = min;
140 + return this;
141 + }
142 +
143 + public String getDayName() {
144 + return dayName;
145 + }
146 +
147 + public void setDayName(String dayName) {
148 + this.dayName = dayName;
149 + }
150 +
151 + public long getTimeStamp() {
152 + return timeStamp;
153 + }
154 +
155 + public void setTimeStamp(long timeStamp) {
156 + this.timeStamp = timeStamp;
157 + }
158 + }
159 +
160 + public class Result {
161 +
162 + @SerializedName("name")
163 + @Expose
164 + private String name;
165 + @SerializedName("outFlag")
166 + @Expose
167 + private Integer outFlag;
168 + @SerializedName("strangeFlag")
169 + @Expose
170 + private Integer strangeFlag;
171 + @SerializedName("outTime")
172 + @Expose
173 + private OutTime outTime;
174 +
175 + /**
176 + * No args constructor for use in serialization
177 + *
178 + */
179 + public Result() {
180 + }
181 +
182 + /**
183 + *
184 + * @param name
185 + * @param outFlag
186 + * @param strangeFlag
187 + * @param outTime
188 + */
189 + public Result(String name, Integer outFlag, Integer strangeFlag, OutTime outTime) {
190 + super();
191 + this.name = name;
192 + this.outFlag = outFlag;
193 + this.strangeFlag = strangeFlag;
194 + this.outTime = outTime;
195 + }
196 +
197 + public String getName() {
198 + return name;
199 + }
200 +
201 + public void setName(String name) {
202 + this.name = name;
203 + }
204 +
205 + public Result withName(String name) {
206 + this.name = name;
207 + return this;
208 + }
209 +
210 + public Integer getOutFlag() {
211 + return outFlag;
212 + }
213 +
214 + public void setOutFlag(Integer outFlag) {
215 + this.outFlag = outFlag;
216 + }
217 +
218 + public Result withOutFlag(Integer outFlag) {
219 + this.outFlag = outFlag;
220 + return this;
221 + }
222 +
223 + public Integer getStrangeFlag() {
224 + return strangeFlag;
225 + }
226 +
227 + public void setStrangeFlag(Integer strangeFlag) {
228 + this.strangeFlag = strangeFlag;
229 + }
230 +
231 + public Result withStrangeFlag(Integer strangeFlag) {
232 + this.strangeFlag = strangeFlag;
233 + return this;
234 + }
235 +
236 + public OutTime getOutTime() {
237 + return outTime;
238 + }
239 +
240 + public void setOutTime(OutTime outTime) {
241 + this.outTime = outTime;
242 + }
243 +
244 + public Result withOutTime(OutTime outTime) {
245 + this.outTime = outTime;
246 + return this;
247 + }
248 +
249 + }
250 +
251 +
252 +}
253 +
254 +
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +
6 +/**
7 + * Created by joyeongje on 2017. 7. 21..
8 + */
9 +
10 +public class ResponseLoLockService {
11 +
12 + @SerializedName("code")
13 + @Expose
14 + private String code;
15 + @SerializedName("message")
16 + @Expose
17 + private String message;
18 +
19 + /**
20 + * No args constructor for use in serialization
21 + *
22 + */
23 + public ResponseLoLockService() {
24 +
25 + }
26 +
27 + /**
28 + *
29 + * @param message
30 + * @param code
31 + */
32 + public ResponseLoLockService(String code, String message) {
33 + super();
34 + this.code = code;
35 + this.message = message;
36 + }
37 +
38 + public String getCode() {
39 + return code;
40 + }
41 +
42 + public void setCode(String code) {
43 + this.code = code;
44 + }
45 +
46 + public String getMessage() {
47 + return message;
48 + }
49 +
50 + public void setMessage(String message) {
51 + this.message = message;
52 + }
53 +
54 +}
1 +
2 +package com.gunghi.tgwing.lolock.Response;
3 +
4 +import com.google.gson.annotations.Expose;
5 +import com.google.gson.annotations.SerializedName;
6 +import com.gunghi.tgwing.lolock.model.Mate;
7 +
8 +import java.util.List;
9 +
10 +public class ResponseMate {
11 +
12 + @SerializedName("mates")
13 + @Expose
14 + private List<Mate> mates = null;
15 + @SerializedName("mateNumber")
16 + @Expose
17 + private Integer mateNumber;
18 +
19 + /**
20 + * No args constructor for use in serialization
21 + *
22 + */
23 + public ResponseMate() {
24 + }
25 +
26 + /**
27 + *
28 + * @param mateNumber
29 + * @param mates
30 + */
31 + public ResponseMate(List<Mate> mates, Integer mateNumber) {
32 + super();
33 + this.mates = mates;
34 + this.mateNumber = mateNumber;
35 + }
36 +
37 + public List<Mate> getMates() {
38 + return mates;
39 + }
40 +
41 + public void setMates(List<Mate> mates) {
42 + this.mates = mates;
43 + }
44 +
45 + public Integer getMateNumber() {
46 + return mateNumber;
47 + }
48 +
49 + public void setMateNumber(Integer mateNumber) {
50 + this.mateNumber = mateNumber;
51 + }
52 +
53 +}
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +
6 +/**
7 + * Created by joyeongje on 2017. 7. 22..
8 + */
9 +
10 +public class ResponseOpenDoorKey {
11 +
12 + @SerializedName("link")
13 + @Expose
14 + private String link;
15 + @SerializedName("code")
16 + @Expose
17 + private String code;
18 +
19 + /**
20 + * No args constructor for use in serialization
21 + *
22 + */
23 + public ResponseOpenDoorKey() {
24 + }
25 +
26 + /**
27 + *
28 + * @param link
29 + * @param code
30 + */
31 + public ResponseOpenDoorKey(String link, String code) {
32 + super();
33 + this.link = link;
34 + this.code = code;
35 + }
36 +
37 + public String getLink() {
38 + return link;
39 + }
40 +
41 + public void setLink(String link) {
42 + this.link = link;
43 + }
44 +
45 + public String getCode() {
46 + return code;
47 + }
48 +
49 + public void setCode(String code) {
50 + this.code = code;
51 + }
52 +
53 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +import com.gunghi.tgwing.lolock.model.UserInfo;
6 +
7 +/**
8 + * Created by joyeongje on 2017. 7. 21..
9 + */
10 +
11 +public class ResponseUserInfo {
12 +
13 + @SerializedName("code")
14 + @Expose
15 + private String code;
16 + @SerializedName("userInfo")
17 + @Expose
18 + private UserInfo userInfo;
19 + @SerializedName("message")
20 + @Expose
21 + private String message;
22 +
23 + /**
24 + * No args constructor for use in serialization
25 + *
26 + */
27 + public ResponseUserInfo() {
28 +
29 + }
30 +
31 + /**
32 + *
33 + * @param message
34 + * @param code
35 + * @param userInfo
36 + */
37 + public ResponseUserInfo(String code, UserInfo userInfo, String message) {
38 + super();
39 + this.code = code;
40 + this.userInfo = userInfo;
41 + this.message = message;
42 + }
43 +
44 + public String getCode() {
45 + return code;
46 + }
47 +
48 + public void setCode(String code) {
49 + this.code = code;
50 + }
51 +
52 + public UserInfo getUserInfo() {
53 + return userInfo;
54 + }
55 +
56 + public void setUserInfo(UserInfo userInfo) {
57 + this.userInfo = userInfo;
58 + }
59 +
60 + public String getMessage() {
61 + return message;
62 + }
63 +
64 + public void setMessage(String message) {
65 + this.message = message;
66 + }
67 +
68 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.Response;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +
6 +/**
7 + * Created by joyeongje on 2017. 7. 22..
8 + */
9 +
10 +public class ResponseWeather {
11 +
12 + @SerializedName("baseTime")
13 + @Expose
14 + private Integer baseTime;
15 + @SerializedName("baseDate")
16 + @Expose
17 + private Integer baseDate;
18 + @SerializedName("sky")
19 + @Expose
20 + private String sky;
21 + @SerializedName("temperature")
22 + @Expose
23 + private Double temperature;
24 + @SerializedName("probabilityRain")
25 + @Expose
26 + private Integer probabilityRain;
27 + @SerializedName("minTemperature")
28 + @Expose
29 + private Integer minTemperature;
30 + @SerializedName("maxTemperature")
31 + @Expose
32 + private Integer maxTemperature;
33 +
34 + @SerializedName("location")
35 + @Expose
36 + private String location;
37 + /**
38 + * No args constructor for use in serialization
39 + *
40 + */
41 + public ResponseWeather() {
42 +
43 + }
44 +
45 + /**
46 + *
47 + * @param sky
48 + * @param minTemperature
49 + * @param baseDate
50 + * @param baseTime
51 + * @param probabilityRain
52 + * @param maxTemperature
53 + * @param temperature
54 + */
55 + public ResponseWeather(Integer baseTime, Integer baseDate, String sky, Double temperature, Integer probabilityRain, Integer minTemperature, Integer maxTemperature) {
56 + super();
57 + this.baseTime = baseTime;
58 + this.baseDate = baseDate;
59 + this.sky = sky;
60 + this.temperature = temperature;
61 + this.probabilityRain = probabilityRain;
62 + this.minTemperature = minTemperature;
63 + this.maxTemperature = maxTemperature;
64 + }
65 +
66 + public Integer getBaseTime() {
67 + return baseTime;
68 + }
69 +
70 + public void setBaseTime(Integer baseTime) {
71 + this.baseTime = baseTime;
72 + }
73 +
74 + public Integer getBaseDate() {
75 + return baseDate;
76 + }
77 +
78 + public void setBaseDate(Integer baseDate) {
79 + this.baseDate = baseDate;
80 + }
81 +
82 + public String getSky() {
83 + return sky;
84 + }
85 +
86 + public void setSky(String sky) {
87 + this.sky = sky;
88 + }
89 +
90 + public Double getTemperature() {
91 + return temperature;
92 + }
93 +
94 + public void setTemperature(Double temperature) {
95 + this.temperature = temperature;
96 + }
97 +
98 + public Integer getProbabilityRain() {
99 + return probabilityRain;
100 + }
101 +
102 + public void setProbabilityRain(Integer probabilityRain) {
103 + this.probabilityRain = probabilityRain;
104 + }
105 +
106 + public Integer getMinTemperature() {
107 + return minTemperature;
108 + }
109 +
110 + public void setMinTemperature(Integer minTemperature) {
111 + this.minTemperature = minTemperature;
112 + }
113 +
114 + public Integer getMaxTemperature() {
115 + return maxTemperature;
116 + }
117 +
118 + public void setMaxTemperature(Integer maxTemperature) {
119 + this.maxTemperature = maxTemperature;
120 + }
121 +
122 + public String getLocation() {
123 + return location;
124 + }
125 +
126 + public void setLocation(String location) {
127 + this.location = location;
128 + }
129 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.model;
2 +
3 +/**
4 + * Created by joyeongje on 2017. 7. 25..
5 + */
6 +
7 +public class GoogleSchedularData {
8 +
9 + private String summaryTitle;
10 + private String startTime;
11 + private String googleLink;
12 +
13 + public GoogleSchedularData() {
14 +
15 + }
16 +
17 + public GoogleSchedularData(String summaryTitle,String startTime,String googleLink) {
18 + this.summaryTitle = summaryTitle;
19 + this.startTime = startTime;
20 + this.googleLink = googleLink;
21 + }
22 +
23 + public String getSummaryTitle() {
24 + return summaryTitle;
25 + }
26 +
27 + public void setSummaryTitle(String summaryTitle) {
28 + this.summaryTitle = summaryTitle;
29 + }
30 +
31 + public String getStartTime() {
32 + return startTime;
33 + }
34 +
35 + public void setStartTime(String startTime) {
36 + this.startTime = startTime;
37 + }
38 +
39 + public String getGoogleLink() {
40 + return googleLink;
41 + }
42 +
43 + public void setGoogleLink(String googleLink) {
44 + this.googleLink = googleLink;
45 + }
46 +}
1 +package com.gunghi.tgwing.lolock.model;
2 +
3 +import com.gunghi.tgwing.lolock.Response.ResponseInOutLog;
4 +
5 +/**
6 + * Created by joyeongje on 2017. 7. 22..
7 + */
8 +
9 +public class InOutLog {
10 +
11 + private String name;
12 + private int outingFlag;
13 + private ResponseInOutLog.OutTime inOutDate;
14 + private int strangeFlag;
15 +
16 +
17 + public InOutLog() {
18 +
19 + }
20 +
21 + public InOutLog(String name, int outingFlag, ResponseInOutLog.OutTime inOutDate, int strangeFlag) {
22 + this.name = name;
23 + this.outingFlag = outingFlag;
24 + this.inOutDate = inOutDate;
25 + this.strangeFlag = strangeFlag;
26 + }
27 +
28 + public String getName() {
29 + return name;
30 + }
31 +
32 + public void setName(String name) {
33 + this.name = name;
34 + }
35 +
36 + public int getStrangeFlag() {
37 + return strangeFlag;
38 + }
39 +
40 + public void setStrangeFlag(int strangeFlag) {
41 + this.strangeFlag = strangeFlag;
42 + }
43 +
44 + public ResponseInOutLog.OutTime getInOutDate() {
45 + return inOutDate;
46 + }
47 +
48 + public void setInOutDate(ResponseInOutLog.OutTime inOutDate) {
49 + this.inOutDate = inOutDate;
50 + }
51 +
52 + public int getOutingFlag() {
53 + return outingFlag;
54 + }
55 +
56 + public void setOutingFlag(int outingFlag) {
57 + this.outingFlag = outingFlag;
58 + }
59 +}
1 +
2 +package com.gunghi.tgwing.lolock.model;
3 +
4 +import com.google.gson.annotations.Expose;
5 +import com.google.gson.annotations.SerializedName;
6 +
7 +public class Mate {
8 +
9 + @SerializedName("mateImageUrl")
10 + @Expose
11 + private String mateImageUrl;
12 + @SerializedName("mateName")
13 + @Expose
14 + private String mateName;
15 + @SerializedName("mateOutingFlag")
16 + @Expose
17 + private String mateOutingFlag;
18 + @SerializedName("mateDoorOpenTime")
19 + @Expose
20 + private String mateDoorOpenTime;
21 +
22 + /**
23 + * No args constructor for use in serialization
24 + *
25 + */
26 + public Mate() {
27 + }
28 +
29 + /**
30 + *
31 + * @param mateOutingFlag
32 + * @param mateDoorOpenTime
33 + * @param mateImageUrl
34 + * @param mateName
35 + */
36 + public Mate(String mateImageUrl, String mateName, String mateOutingFlag, String mateDoorOpenTime) {
37 + super();
38 + this.mateImageUrl = mateImageUrl;
39 + this.mateName = mateName;
40 + this.mateOutingFlag = mateOutingFlag;
41 + this.mateDoorOpenTime = mateDoorOpenTime;
42 + }
43 +
44 + public String getMateImageUrl() {
45 + return mateImageUrl;
46 + }
47 +
48 + public void setMateImageUrl(String mateImageUrl) {
49 + this.mateImageUrl = mateImageUrl;
50 + }
51 +
52 + public String getMateName() {
53 + return mateName;
54 + }
55 +
56 + public void setMateName(String mateName) {
57 + this.mateName = mateName;
58 + }
59 +
60 + public String getMateOutingFlag() {
61 + return mateOutingFlag;
62 + }
63 +
64 + public void setMateOutingFlag(String mateOutingFlag) {
65 + this.mateOutingFlag = mateOutingFlag;
66 + }
67 +
68 + public String getMateDoorOpenTime() {
69 + return mateDoorOpenTime;
70 + }
71 +
72 + public void setMateDoorOpenTime(String mateDoorOpenTime) {
73 + this.mateDoorOpenTime = mateDoorOpenTime;
74 + }
75 +
76 +}
1 +package com.gunghi.tgwing.lolock.model;
2 +
3 +/**
4 + * Created by joyeongje on 2017. 7. 21..
5 + */
6 +
7 +public class RegisterUserInfo {
8 +
9 + private String registerUserName;
10 + private String registerDeviceAddr;
11 + private String registerDeviceGPS_lat;
12 + private String registerDeviceGPS_lon;
13 + private String registerDeviceId;
14 + private String registerUserPhoneId;
15 +
16 + private static final RegisterUserInfo ourInstance = new RegisterUserInfo();
17 +
18 + public static RegisterUserInfo getInstance() {
19 + return ourInstance;
20 + }
21 +
22 + private RegisterUserInfo() {
23 + }
24 +
25 +
26 + public String getRegisterUserName() {
27 + return registerUserName;
28 + }
29 +
30 + public void setRegisterUserName(String registerUserName) {
31 + this.registerUserName = registerUserName;
32 + }
33 +
34 + public String getRegisterDeviceAddr() {
35 + return registerDeviceAddr;
36 + }
37 +
38 + public void setRegisterDeviceAddr(String registerDeviceAddr) {
39 + this.registerDeviceAddr = registerDeviceAddr;
40 + }
41 +
42 + public String getRegisterDeviceGPS_lat() {
43 + return registerDeviceGPS_lat;
44 + }
45 +
46 + public void setRegisterDeviceGPS_lat(String registerDeviceGPS_lat) {
47 + this.registerDeviceGPS_lat = registerDeviceGPS_lat;
48 + }
49 +
50 + public String getRegisterDeviceGPS_lon() {
51 + return registerDeviceGPS_lon;
52 + }
53 +
54 + public void setRegisterDeviceGPS_lon(String registerDeviceGPS_lon) {
55 + this.registerDeviceGPS_lon = registerDeviceGPS_lon;
56 + }
57 +
58 + public String getRegisterDeviceId() {
59 + return registerDeviceId;
60 + }
61 +
62 + public void setRegisterDeviceId(String registerDeviceId) {
63 + this.registerDeviceId = registerDeviceId;
64 + }
65 +
66 + public String getRegisterUserPhoneId() {
67 + return registerUserPhoneId;
68 + }
69 +
70 + public void setRegisterUserPhoneId(String registerUserPhoneId) {
71 + this.registerUserPhoneId = registerUserPhoneId;
72 + }
73 +}
1 +package com.gunghi.tgwing.lolock.model;
2 +
3 +import com.google.gson.annotations.Expose;
4 +import com.google.gson.annotations.SerializedName;
5 +
6 +/**
7 + * Created by joyeongje on 2017. 7. 19..
8 + */
9 +
10 +public class UserInfo {
11 +
12 + private static final UserInfo ourInstance = new UserInfo();
13 + public static UserInfo getInstance() {
14 + return ourInstance;
15 + }
16 +
17 +
18 + @SerializedName("name")
19 + @Expose
20 + private String name;
21 + @SerializedName("lolockLTID")
22 + @Expose
23 + private String lolockLTID;
24 +
25 + private String devideId;
26 +
27 + /**
28 + * No args constructor for use in serialization
29 + *
30 + */
31 + public UserInfo() {
32 +
33 + }
34 +
35 + /**
36 + *
37 + * @param name
38 + * @param lolockLTID
39 + */
40 + public UserInfo(String name, String lolockLTID) {
41 + super();
42 + this.name = name;
43 + this.lolockLTID = lolockLTID;
44 + }
45 +
46 + public String getName() {
47 + return name;
48 + }
49 +
50 + public void setName(String name) {
51 + this.name = name;
52 + }
53 +
54 + public String getLolockLTID() {
55 + return lolockLTID;
56 + }
57 +
58 + public void setLolockLTID(String lolockLTID) {
59 + this.lolockLTID = lolockLTID;
60 + }
61 +
62 + public String getDevideId() {
63 + return devideId;
64 + }
65 +
66 + public void setDevideId(String devideId) {
67 + this.devideId = devideId;
68 + }
69 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.network;
2 +
3 +import com.gunghi.tgwing.lolock.Response.ResponseDaumAddressAPI;
4 +
5 +import java.util.Map;
6 +
7 +import retrofit2.Call;
8 +import retrofit2.http.GET;
9 +import retrofit2.http.QueryMap;
10 +
11 +/**
12 + * Created by joyeongje on 2017. 7. 21..
13 + */
14 +
15 +public interface DaumService {
16 +
17 + String daumAPIKey = "04b68611d624a48f5a37bf1ad4324600";
18 + String inputCoordSystem="WGS84";
19 + String outputType= "json";
20 +
21 + @GET("/local/geo/coord2addr")
22 + Call<ResponseDaumAddressAPI> changeCoordToAddress(
23 + @QueryMap Map<String, String> queryParams
24 + );
25 +
26 +
27 +}
1 +package com.gunghi.tgwing.lolock.network;
2 +
3 +import okhttp3.OkHttpClient;
4 +import retrofit2.Retrofit;
5 +import retrofit2.converter.gson.GsonConverterFactory;
6 +
7 +/**
8 + * Created by joyeongje on 2017. 7. 21..
9 + */
10 +
11 +public class DaumServiceGenerator {
12 + private static final String DAUM_API_BASE_URL = "https://apis.daum.net/";
13 + //private static final String DAUM_API_KEY = "04b68611d624a48f5a37bf1ad4324600/";
14 +
15 +
16 + private static Retrofit.Builder builder =
17 + new Retrofit.Builder()
18 + .baseUrl(DAUM_API_BASE_URL)
19 + .addConverterFactory(GsonConverterFactory.create());
20 +
21 + private static Retrofit retrofit = builder.build();
22 +
23 + private static OkHttpClient.Builder httpClient =
24 + new OkHttpClient.Builder();
25 +
26 +
27 + public static <S> S createService(
28 + Class<S> serviceClass) {
29 + return retrofit.create(serviceClass);
30 + }
31 +}
1 +package com.gunghi.tgwing.lolock.network;
2 +
3 +import com.gunghi.tgwing.lolock.Response.ResponseInOutLog;
4 +import com.gunghi.tgwing.lolock.Response.ResponseLoLockService;
5 +import com.gunghi.tgwing.lolock.Response.ResponseMate;
6 +import com.gunghi.tgwing.lolock.Response.ResponseOpenDoorKey;
7 +import com.gunghi.tgwing.lolock.Response.ResponseUserInfo;
8 +import com.gunghi.tgwing.lolock.Response.ResponseWeather;
9 +import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
10 +
11 +import okhttp3.ResponseBody;
12 +import retrofit2.Call;
13 +import retrofit2.http.Body;
14 +import retrofit2.http.Field;
15 +import retrofit2.http.FormUrlEncoded;
16 +import retrofit2.http.GET;
17 +import retrofit2.http.POST;
18 +import retrofit2.http.PUT;
19 +import retrofit2.http.Path;
20 +
21 +/**
22 + * Created by joyeongje on 2017. 7. 15..
23 + */
24 +
25 +public interface LoLockService {
26 +
27 + // 로라 일련번호 유효성 체크
28 + @GET("/ThingPlug/checkId/{number}")
29 + Call<ResponseLoLockService> checkLoraNumberId(
30 + @Path("number") String number);
31 +
32 + @POST("/ThingPlug/register")
33 + Call<ResponseBody> registLoLock(
34 + @Body RegisterUserInfo registerUserInfo);
35 +
36 + // 디바이스 아이디로 기존정보 조회
37 + @GET("/ThingPlug/userInfo/{phoneId}")
38 + Call<ResponseUserInfo> getUserInfo(
39 + @Path("phoneId") String phoneId
40 + );
41 +
42 + // 원격 문열림
43 + @FormUrlEncoded
44 + @PUT("/ThingPlug/remote-open")
45 + Call<ResponseBody> remoteOnOffLock(
46 + @Field("openDeviceId") String openDeviceId
47 + );
48 +
49 + // 문열림 링크 주기
50 + @GET("/ThingPlug/open-url/{deviceId}")
51 + Call<ResponseOpenDoorKey> getDoorOpenCode(
52 + @Path("deviceId") String deviceId);
53 +
54 + // 날씨 정보 가져오기
55 + @GET("/ThingPlug/weatherdata/{LTID}")
56 + Call<ResponseWeather> getWeatherData(
57 + @Path("LTID") String LTID);
58 +
59 +
60 + // 동거인 목록 가져오기.
61 + @GET("/ThingPlug/homemateslist/{LTID}")
62 + Call<ResponseMate> getHomeMateResponse(
63 + @Path("LTID") String LTID);
64 +
65 + // 출입기록 알람 가져오기
66 + @GET("/ThingPlug/outing-log/{deviceId}")
67 + Call<ResponseInOutLog> getInOutLog(
68 + @Path("deviceId") String deviceId
69 + );
70 +
71 + // 나갈시 유저체크 url
72 + @GET("/ThingPlug/checkout/{deviceId}")
73 + Call<ResponseBody> checkOutURL(
74 + @Path("deviceId") String deviceId
75 + );
76 +
77 + // 들어올시 유저체크 url
78 + @GET("/ThingPlug/checkin/{deviceId}")
79 + Call<ResponseBody> checkInURL(
80 + @Path("deviceId") String deviceId
81 + );
82 +
83 +
84 +}
1 +package com.gunghi.tgwing.lolock.network;
2 +
3 +import okhttp3.OkHttpClient;
4 +import retrofit2.Retrofit;
5 +import retrofit2.converter.gson.GsonConverterFactory;
6 +
7 +/**
8 + * Created by joyeongje on 2017. 7. 15..
9 + */
10 +
11 +public class LoLockServiceGenarator {
12 + private static final String BASE_URL = "http://52.79.83.113:10080";
13 +
14 +
15 + private static Retrofit.Builder builder =
16 + new Retrofit.Builder()
17 + .baseUrl(BASE_URL)
18 + .addConverterFactory(GsonConverterFactory.create());
19 +
20 + private static Retrofit retrofit = builder.build();
21 +
22 + private static OkHttpClient.Builder httpClient =
23 + new OkHttpClient.Builder();
24 +
25 +
26 + public static <S> S createService(
27 + Class<S> serviceClass) {
28 + return retrofit.create(serviceClass);
29 + }
30 +}
1 +package com.gunghi.tgwing.lolock.service;
2 +
3 +import android.app.Service;
4 +import android.bluetooth.BluetoothAdapter;
5 +import android.bluetooth.BluetoothDevice;
6 +import android.bluetooth.BluetoothGatt;
7 +import android.bluetooth.BluetoothManager;
8 +import android.bluetooth.le.BluetoothLeScanner;
9 +import android.bluetooth.le.ScanCallback;
10 +import android.bluetooth.le.ScanFilter;
11 +import android.bluetooth.le.ScanResult;
12 +import android.bluetooth.le.ScanSettings;
13 +import android.content.Context;
14 +import android.content.Intent;
15 +import android.hardware.Sensor;
16 +import android.hardware.SensorEvent;
17 +import android.hardware.SensorEventListener;
18 +import android.hardware.SensorManager;
19 +import android.os.Build;
20 +import android.os.IBinder;
21 +import android.support.annotation.Nullable;
22 +import android.support.annotation.RequiresApi;
23 +import android.util.Log;
24 +import android.widget.Toast;
25 +
26 +import com.gunghi.tgwing.lolock.model.UserInfo;
27 +import com.gunghi.tgwing.lolock.network.LoLockService;
28 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
29 +
30 +import java.util.ArrayList;
31 +import java.util.List;
32 +
33 +import okhttp3.ResponseBody;
34 +import retrofit2.Call;
35 +import retrofit2.Callback;
36 +import retrofit2.Response;
37 +
38 +/**
39 + * Created by joyeongje on 2017. 7. 1..
40 + */
41 +
42 +
43 +/**
44 + * Service for managing connection and data communication with a GATT server hosted on a
45 + * given Bluetooth LE device.
46 + */
47 +public class BluetoothLeService extends Service {
48 + private final static String TAG = BluetoothLeService.class.getSimpleName();
49 +
50 + private BluetoothManager mBluetoothManager;
51 + private BluetoothAdapter mBluetoothAdapter;
52 + private BluetoothGatt mBluetoothGatt;
53 +
54 + private static final int WAITING_TIME_FOR_START = 30;
55 + private static final int NUMBER_OF_GETTING_VALUE = 40;
56 + private static final float THRESHOLD_GRAVITY_HIGH = 1.25F;
57 + private static final float THRESHOLD_GRAVITY_LOW = 0.8F;
58 +
59 + // 가속도 센서 필요 멤버변수
60 + private int delayCount = WAITING_TIME_FOR_START + 1;
61 +
62 + private SensorManager mSensorManager = null;
63 + private SensorEventListener mAccLis;
64 + private Sensor mAccelometerSensor = null;
65 +
66 +
67 + private boolean isMoving = false;
68 +
69 + private boolean bleCheck = false;
70 + private int rssiBle = 0;
71 +
72 + private LoLockService loLockService;
73 +
74 + private static final long SCAN_PERIOD = 10000;
75 + private BluetoothLeScanner mLEScanner;
76 + private ScanSettings settings;
77 + private List<ScanFilter> filters;
78 + private BluetoothGatt mGatt;
79 +
80 + @Override
81 + public void onCreate() {
82 + Log.d("BluetoothLeService","onCreate");
83 + loLockService = LoLockServiceGenarator.createService(LoLockService.class);
84 +
85 + if(!initialize()) {
86 + this.stopSelf();
87 + Toast.makeText(getApplicationContext(),"현재 블루투스 기능을 사용할수 없습니다",Toast.LENGTH_SHORT).show();
88 + } else {
89 + if (Build.VERSION.SDK_INT >= 21) {
90 + mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
91 + settings = new ScanSettings.Builder()
92 + .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
93 + .build();
94 + filters = new ArrayList<ScanFilter>();
95 + }
96 +
97 + startLoraScan(true);
98 + }
99 + // Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
100 + // getApplicationContext().startActivity(enableBtIntent);
101 +
102 + }
103 +
104 + @Override
105 + public void onDestroy() {
106 + Log.d("BluetoothLeService","onDestroy");
107 + close();
108 + startLoraScan(false);
109 + if(mAccLis != null)
110 + mSensorManager.unregisterListener(mAccLis);
111 + // The service is no longer used and is being destroyed
112 + }
113 +
114 + private void startLoraScan(boolean enable) {
115 +
116 +
117 + if (enable) {
118 +
119 + if (Build.VERSION.SDK_INT < 21) {
120 + mBluetoothAdapter.startLeScan(mLeScanCallback);
121 + } else {
122 + mLEScanner.startScan(filters, settings, mScanCallback);
123 + }
124 + } else {
125 + if (Build.VERSION.SDK_INT < 21) {
126 + mBluetoothAdapter.stopLeScan(mLeScanCallback);
127 + } else {
128 + mLEScanner.stopScan(mScanCallback);
129 + }
130 + }
131 +
132 + }
133 +
134 + protected static double calculateDistance(int txPower, double rssi) {
135 + if (rssi == 0) {
136 + return -1.0; // if we cannot determine distance, return -1.
137 + }
138 +
139 + double ratio = rssi*1.0/txPower;
140 + if (ratio < 1.0) {
141 + return Math.pow(ratio,10);
142 + }
143 + else {
144 + double accuracy = (0.89976)*Math.pow(ratio,7.7095) + 0.111;
145 + return accuracy;
146 + }
147 + }
148 +
149 + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
150 + private ScanCallback mScanCallback = new ScanCallback() {
151 +
152 + @Override
153 + public void onScanResult(int callbackType, ScanResult result) {
154 + BluetoothDevice btDevice = result.getDevice();
155 + if(btDevice.getName()!= null) {
156 + String deviceName = btDevice.getName();
157 + if(deviceName.contains("LoLock")) {
158 + startLoraScan(false);
159 +
160 + mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
161 + mAccelometerSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
162 +
163 + Log.d("dddd","ddddddd");
164 + mAccLis = new AccelometerListener();
165 + mSensorManager.registerListener(mAccLis, mAccelometerSensor, SensorManager.SENSOR_DELAY_UI);
166 +
167 +
168 + // Toast.makeText(getApplicationContext(),"추정거리 " +
169 + // calculateDistance(-59,result.getRssi()),Toast.LENGTH_SHORT).show();
170 +
171 + // TODO: 2017. 7. 30. 체크무빙
172 + // if(calculateDistance(4,result.getRssi()) < 1.5) {
173 + // Toast.makeText(getApplicationContext(),"자동 문 열림",Toast.LENGTH_SHORT).show();
174 + // if(UserInfo.getInstance().getDevideId() != null) {
175 + // loLockService.remoteOnOffLock(UserInfo.getInstance().getDevideId()).enqueue(new Callback<ResponseBody>() {
176 + // @Override
177 + // public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
178 + // Toast.makeText(getApplicationContext(),"자동 문 열림 성공",Toast.LENGTH_SHORT).show();
179 + // }
180 +//
181 + // @Override
182 + // public void onFailure(Call<ResponseBody> call, Throwable t) {
183 +//
184 + // }
185 + // });
186 + // }
187 + // }
188 +
189 +
190 + // int rssi = result.getRssi();
191 + // checkMoving();
192 + //WAITING_TIME_FOR_START(30) 이후 NUMBER_OF_GETTING_VALUE(20)개 데이터 수집
193 + //bolean isMoving과 float accelData[0~19]에 저장
194 +
195 + // TODO: 2017. 7. 25. 서버로 보낸다...(이건 내가한다!)
196 + //서버로 보낸후 isMoving=false, accelData[0~19]=0 초기화 필요
197 +
198 + // mDeviceAddress = btDevice.getAddress();
199 + // mBluetoothLeService.connect(mDeviceAddress);
200 + }
201 + }
202 + }
203 +
204 + @Override
205 + public void onBatchScanResults(List<ScanResult> results) {
206 + for (ScanResult sr : results) {
207 + Log.i("ScanResult - Results", sr.toString());
208 + }
209 +
210 + }
211 +
212 + @Override
213 + public void onScanFailed(int errorCode) {
214 + Log.e("Scan Failed", "Error Code: " + errorCode);
215 + }
216 +};
217 +
218 + private BluetoothAdapter.LeScanCallback mLeScanCallback =
219 + new BluetoothAdapter.LeScanCallback() {
220 + @Override
221 + public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
222 + Log.d("mScanCallbackTest","여기들어옴");
223 +
224 + if(device.getName()!= null) {
225 + String deviceName = device.getName();
226 + Log.d("deviceName",deviceName);
227 + if(deviceName.contains("LoLock")) {
228 + rssiBle = rssi;
229 + bleCheck = true;
230 + //Toast.makeText(getApplicationContext(), "rssi신호세기" + rssiBle, Toast.LENGTH_SHORT).show();
231 +
232 + }
233 + }
234 + }
235 + };
236 +
237 + @Nullable
238 + @Override
239 + public IBinder onBind(Intent intent) {
240 + Log.d("BluetoothLeService","onBind");
241 + return null;
242 + }
243 +
244 +
245 + public boolean initialize() {
246 + // For API level 18 and above, get a reference to BluetoothAdapter through
247 + // BluetoothManager.
248 +
249 + if (mBluetoothManager == null) {
250 + mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
251 + if (mBluetoothManager == null) {
252 + Log.e(TAG, "Unable to initialize BluetoothManager.");
253 + return false;
254 + }
255 +
256 + }
257 + mBluetoothAdapter = mBluetoothManager.getAdapter();
258 + if (mBluetoothAdapter == null) {
259 + Log.e(TAG, "Unable to obtain a BluetoothAdapter.");
260 + Toast.makeText(this, "블루투스를 사용할 수 없습니다.", Toast.LENGTH_SHORT).show();
261 + return false;
262 + }
263 +
264 + mBluetoothAdapter.enable();
265 + return true;
266 + }
267 + public void close() {
268 + if (mBluetoothGatt == null) {
269 + return;
270 + }
271 + mBluetoothGatt = null;
272 + }
273 +
274 + private class AccelometerListener implements SensorEventListener {
275 +
276 + @Override
277 + public void onSensorChanged(SensorEvent event) {
278 + if(event.sensor.getType() == Sensor.TYPE_ACCELEROMETER){
279 +
280 + if(delayCount > WAITING_TIME_FOR_START && delayCount <= WAITING_TIME_FOR_START + NUMBER_OF_GETTING_VALUE) {
281 + double accX = event.values[0];
282 + double accY = event.values[1];
283 + double accZ = event.values[2];
284 +
285 + accX = accX / SensorManager.GRAVITY_EARTH;
286 + accY = accY / SensorManager.GRAVITY_EARTH;
287 + accZ = accZ / SensorManager.GRAVITY_EARTH;
288 +
289 + double squaredD = accX * accX + accY * accY + accZ * accZ;
290 + squaredD = Math.sqrt(squaredD);
291 + float gForce = (float) squaredD;
292 + delayCount++;
293 +
294 + if (gForce > THRESHOLD_GRAVITY_HIGH || gForce < THRESHOLD_GRAVITY_LOW) {
295 + isMoving = true;
296 + }
297 +
298 + Log.e("LOG", "Count: " + String.format("%d", delayCount) + " gForce: " + String.format("%f", gForce));
299 + }
300 + if(delayCount == WAITING_TIME_FOR_START + NUMBER_OF_GETTING_VALUE + 1){
301 + delayCount++;
302 + Log.e("LOG", String.valueOf(isMoving));
303 +
304 + if(isMoving) {
305 + sendSensorDataToServer();
306 + }
307 +
308 + else {
309 + initializeSensorValue();
310 + if(mAccLis != null)
311 + mSensorManager.unregisterListener(mAccLis);
312 +
313 + stopSelf();
314 +
315 + }
316 + }
317 + }
318 + }
319 +
320 + @Override
321 + public void onAccuracyChanged(Sensor sensor, int accuracy) {
322 +
323 + }
324 + }
325 +
326 + private void initializeSensorValue() {
327 + isMoving = false;
328 + bleCheck = false;
329 + rssiBle = 0;
330 + }
331 +
332 +
333 + private void sendSensorDataToServer() {
334 +
335 + Call<ResponseBody> responseBodyCall =
336 + MyFirebaseMessagingService.IN_OUT_CODE ?
337 + loLockService.checkOutURL(UserInfo.getInstance().getDevideId())
338 + :loLockService.checkInURL(UserInfo.getInstance().getDevideId());
339 +
340 + // Toast.makeText(getApplicationContext(),"사용자 데이터 전송",Toast.LENGTH_SHORT).show();
341 +
342 + responseBodyCall.enqueue(new Callback<ResponseBody>() {
343 + @Override
344 + public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
345 + initializeSensorValue();
346 +
347 + if(mAccLis != null)
348 + mSensorManager.unregisterListener(mAccLis);
349 +
350 + Log.d("sendSensorDataToServer","들어옴");
351 + stopSelf();
352 + }
353 +
354 + @Override
355 + public void onFailure(Call<ResponseBody> call, Throwable t) {
356 + initializeSensorValue();
357 + }
358 + });
359 +
360 + }
361 +
362 +
363 +}
1 +package com.gunghi.tgwing.lolock.service;
2 +
3 +import android.content.SharedPreferences;
4 +import android.util.Log;
5 +
6 +import com.google.firebase.iid.FirebaseInstanceId;
7 +import com.google.firebase.iid.FirebaseInstanceIdService;
8 +import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
9 +
10 +/**
11 + * Created by joyeongje on 2017. 7. 16..
12 + */
13 +
14 +public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
15 +
16 + private static final String TAG = "MyFirebaseIIDService";
17 +
18 + /**
19 + * Called if InstanceID token is updated. This may occur if the security of
20 + * the previous token had been compromised. Note that this is called when the InstanceID token
21 + * is initially generated so this is where you would retrieve the token.
22 + */
23 + // [START refresh_token]
24 +
25 + @Override
26 + public void onTokenRefresh() {
27 + // Get updated InstanceID token.
28 + final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
29 + Log.d(TAG, "Refreshed token: " + refreshedToken);
30 + saveTokenInRealmDB(refreshedToken);
31 + }
32 + // [END refresh_token]
33 +
34 + private void saveTokenInRealmDB(final String token) {
35 + RegisterUserInfo.getInstance().setRegisterUserPhoneId(token);
36 + SharedPreferences lolockLocalData = getSharedPreferences("lolockLocalData", MODE_PRIVATE);
37 + SharedPreferences.Editor editor = lolockLocalData.edit();
38 + editor.putString("deviceId", token); //First라는 key값으로 infoFirst 데이터를 저장한다.
39 + editor.apply(); //완료한다.
40 + Log.d("토큰 저장","됨");
41 +
42 + }
43 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.service;
2 +
3 +import android.app.NotificationManager;
4 +import android.app.PendingIntent;
5 +import android.content.Context;
6 +import android.content.Intent;
7 +import android.media.RingtoneManager;
8 +import android.net.Uri;
9 +import android.support.v4.app.NotificationCompat;
10 +import android.util.Log;
11 +
12 +import com.google.firebase.messaging.FirebaseMessagingService;
13 +import com.google.firebase.messaging.RemoteMessage;
14 +import com.gunghi.tgwing.lolock.R;
15 +import com.gunghi.tgwing.lolock.network.LoLockService;
16 +import com.gunghi.tgwing.lolock.ui.SplashActivity;
17 +
18 +import java.util.Map;
19 +
20 +/**
21 + * Created by joyeongje on 2017. 7. 16..
22 + */
23 +
24 +public class MyFirebaseMessagingService extends FirebaseMessagingService {
25 + private static final String TAG = "MyFirebaseMsgService";
26 +
27 + public static final String PUSH_WEATHER_PLAN = "0";
28 + public static final String PUSH_IN_OUT_LOG = "1";
29 + public static final String PUSH_STRANGE_ALARM = "2";
30 + public static final String PUSH_OUT_CHECK_USER = "3";
31 + public static final String PUSH_IN_CHECK_USER = "4";
32 +
33 + public static boolean IN_OUT_CODE = false;
34 +
35 + private LoLockService lolockService;
36 +
37 + /**
38 + * Called when message is received.
39 + *
40 + * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
41 + */
42 + // [START receive_message]
43 + @Override
44 + public void onMessageReceived(RemoteMessage remoteMessage) {
45 + // [START_EXCLUDE]
46 + // Notification messages are only received here in onMessageReceived when the app
47 + // is in the foreground. When the app is in the background an automatically generated notification is displayed.
48 + // When the user taps on the notification they are returned to the app.
49 +
50 + // Messages containing both notification and data payloads are treated as notification messages.
51 + // The Firebase console always sends notification
52 + // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
53 + // [END_EXCLUDE]
54 +
55 + // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
56 + Log.d(TAG, "From: " + remoteMessage.getFrom());
57 +
58 + // Check if message contains a data payload.
59 + // 백그라운드 포그라운드 둘다됨.
60 + if (remoteMessage.getData().size() > 0) {
61 + Log.d(TAG, "Message data payload: " + remoteMessage.getData());
62 + Map<String, String> getRemoteMessageHash = remoteMessage.getData();
63 + sendNotification(getRemoteMessageHash);
64 + }
65 +
66 + // Check if message contains a notification payload.
67 + if (remoteMessage.getNotification() != null) {
68 + Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
69 + // sendNotification(remoteMessage.getNotification().get);
70 + }
71 +
72 + // Also if you intend on generating your own notifications as a result of a received FCM
73 + // message, here is where that should be initiated. See sendNotification method below.
74 + }
75 + // [END receive_message]
76 +
77 + /**
78 + * Schedule a job using FirebaseJobDispatcher.
79 + */
80 + private void scheduleJob() {
81 + // [START dispatch_job]
82 + //FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
83 + //Job myJob = dispatcher.newJobBuilder()
84 + // .setService(MyJobService.class)
85 + // .setTag("my-job-tag")
86 + // .build();
87 + //dispatcher.schedule(myJob);
88 + // [END dispatch_job]
89 + }
90 +
91 + /**
92 + * Handle time allotted to BroadcastReceivers.
93 + */
94 + private void handleNow() {
95 + Log.d(TAG, "Short lived task is done.");
96 +
97 + }
98 +
99 +
100 + /**
101 + * Create and show a simple notification containing the received FCM message.
102 + *
103 + * @param messageBody FCM message body received.
104 + */
105 +
106 + private void sendNotification(Map<String,String> messageBody) {
107 +
108 +
109 + //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
110 +
111 + Log.d("FirebaseMessage Service", messageBody.toString());
112 +
113 + String title = "";
114 + String content = messageBody.get("message");
115 + String pushCode = messageBody.get("pushCode");
116 + String pushExtra = "inOutLog";
117 +
118 +
119 + switch (pushCode) {
120 + // 액티비티 전환
121 + case PUSH_WEATHER_PLAN:
122 + title = "날씨 및 일정";
123 + pushExtra = "weatherPlan";
124 + break;
125 + case PUSH_IN_OUT_LOG:
126 + title = "출입 로그";
127 + pushExtra = "inOutLog";
128 + break;
129 + case PUSH_STRANGE_ALARM:
130 + title = "위험 감지";
131 + pushExtra = "strangeAlarm";
132 + break;
133 + // 걍 인터넷 통신만 해야됨...
134 + case PUSH_OUT_CHECK_USER:
135 + IN_OUT_CODE = true;
136 + break;
137 + case PUSH_IN_CHECK_USER:
138 + IN_OUT_CODE = false;
139 + break;
140 + }
141 +
142 + if (pushCode.equals(PUSH_OUT_CHECK_USER) || pushCode.equals(PUSH_IN_CHECK_USER)) {
143 + Intent bleIntent = new Intent(this, BluetoothLeService.class);
144 + startService(bleIntent);
145 + Log.d("start ble scan servcie", "시작");
146 + } else {
147 + Intent intent = new Intent(this, SplashActivity.class);
148 + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
149 + intent.putExtra("viewFragment", pushExtra);
150 +
151 + PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
152 + PendingIntent.FLAG_ONE_SHOT);
153 +
154 + Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
155 + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
156 + .setSmallIcon(R.mipmap.ic_launcher_lolock)
157 + .setContentTitle(title)
158 + .setContentText(content)
159 + .setAutoCancel(true)
160 + .setSound(defaultSoundUri)
161 + .setContentIntent(pendingIntent);
162 +
163 + NotificationManager notificationManager =
164 + (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
165 +
166 + notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
167 + }
168 + }
169 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.content.Context;
4 +import android.graphics.Color;
5 +import android.os.Bundle;
6 +import android.support.annotation.Nullable;
7 +import android.support.constraint.ConstraintLayout;
8 +import android.support.v4.app.Fragment;
9 +import android.support.v7.widget.DefaultItemAnimator;
10 +import android.support.v7.widget.LinearLayoutManager;
11 +import android.support.v7.widget.RecyclerView;
12 +import android.util.Log;
13 +import android.view.LayoutInflater;
14 +import android.view.View;
15 +import android.view.ViewGroup;
16 +import android.widget.ImageView;
17 +import android.widget.TextView;
18 +
19 +import com.gunghi.tgwing.lolock.R;
20 +import com.gunghi.tgwing.lolock.Response.ResponseInOutLog;
21 +import com.gunghi.tgwing.lolock.model.InOutLog;
22 +import com.gunghi.tgwing.lolock.model.UserInfo;
23 +import com.gunghi.tgwing.lolock.network.LoLockService;
24 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
25 +
26 +import java.util.ArrayList;
27 +import java.util.Date;
28 +
29 +import retrofit2.Call;
30 +import retrofit2.Callback;
31 +import retrofit2.Response;
32 +
33 +/**
34 + * Created by joyeongje on 2017. 7. 20..
35 + */
36 +
37 +public class FragmentAlarm extends Fragment {
38 +
39 + private InOutLogAdapter inOutLogAdapter;
40 + private ArrayList<InOutLog> inOutLogs;
41 +
42 + Date date;
43 +
44 + @Nullable
45 + @Override
46 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
47 + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_alarm, container, false);
48 + RecyclerView mateRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragmentAlarmRecyclerView);
49 + RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
50 + mateRecyclerView.setLayoutManager(mLayoutManager);
51 + mateRecyclerView.setHasFixedSize(true);
52 + mateRecyclerView.scrollToPosition(0);
53 +
54 + inOutLogs = new ArrayList<>();
55 + //mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
56 + //mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
57 + //mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
58 +
59 + inOutLogAdapter = new InOutLogAdapter(inOutLogs,getContext());
60 + mateRecyclerView.setAdapter(inOutLogAdapter);
61 + mateRecyclerView.setItemAnimator(new DefaultItemAnimator());
62 + date = new Date();
63 + getInOutLogList();
64 + // getMateList();
65 + return rootView;
66 + }
67 +
68 + private void getInOutLogList() {
69 + LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
70 + Call<ResponseInOutLog> callLolockService = loLockService.getInOutLog(UserInfo.getInstance().getDevideId());
71 + callLolockService.enqueue(new Callback<ResponseInOutLog>() {
72 + @Override
73 + public void onResponse(Call<ResponseInOutLog> call, Response<ResponseInOutLog> response) {
74 + Log.d("Success","Suc");
75 + alramDataMappingUi(response.body());
76 + }
77 +
78 + @Override
79 + public void onFailure(Call<ResponseInOutLog> call, Throwable t) {
80 + Log.d("Fail","Fail");
81 + }
82 + });
83 + }
84 +
85 + private void alramDataMappingUi(ResponseInOutLog response) {
86 +
87 + for(ResponseInOutLog.Result result : response.getResults()) {
88 + String name = result.getName();
89 + int outFlag = result.getOutFlag();
90 + ResponseInOutLog.OutTime outTime = result.getOutTime();
91 + int strangFlag = result.getStrangeFlag();
92 + inOutLogs.add(new InOutLog(name,outFlag,outTime,strangFlag));
93 + }
94 + inOutLogAdapter.notifyDataSetChanged();
95 + }
96 +
97 +
98 + private class InOutLogAdapter extends RecyclerView.Adapter<InOutLogAdapter.ViewHolder> {
99 +
100 + private ArrayList<InOutLog> inoutLogs;
101 + private Context context;
102 +
103 + public InOutLogAdapter(ArrayList<InOutLog> inoutLogs, Context context) {
104 + this.inoutLogs = inoutLogs;
105 + this.context = context;
106 +
107 + }
108 +
109 + @Override
110 + public InOutLogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
111 + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_alarm, parent, false);
112 + return new ViewHolder(v);
113 + }
114 +
115 + @Override
116 + public void onBindViewHolder(InOutLogAdapter.ViewHolder holder, int position) {
117 + final InOutLog inoutLog = inoutLogs.get(position);
118 +
119 + String nameText = "";
120 +
121 + if(inoutLog.getStrangeFlag() == 1 ) {
122 + holder.inOutContainer.setBackgroundColor(Color.parseColor("#FF9797"));
123 + holder.inOutContainer.setAlpha(0.85f);
124 + holder.inoutImageView.setImageResource(R.drawable.ic_alarm_known);
125 + nameText = "외부인의 침입이 의심됩니다!";
126 +
127 + } else {
128 + holder.inoutImageView.setImageResource(R.drawable.ic_alarm_unknown);
129 + nameText = inoutLog.getName() + "님이 ";
130 + // 1일때 나간거
131 + if(inoutLog.getOutingFlag() == 0) {
132 + nameText += "귀가하였습니다.";
133 + } else {
134 + nameText += "외출하셨습니다.";
135 + }
136 + }
137 +
138 + holder.inOutNameTextView.setText(nameText);
139 + long diff = inoutLog.getInOutDate().getTimeStamp();
140 +
141 + Log.d("timeStamp",String.valueOf(diff));
142 + long diffMinutes = diff / (60 * 1000);
143 + // long diffHours = diff / (60 * 60 * 1000);
144 +
145 + String duringTime = diffMinutes/60 + "시간 " +
146 + diffMinutes%60 + "분전";
147 + holder.inOutTime.setText(duringTime);
148 + holder.inOutDate.setText(inoutLog.getInOutDate().getMonth() + "/" +
149 + inoutLog.getInOutDate().getDay() + "(" + inoutLog.getInOutDate().getDayName() + ")");
150 +
151 + //Picasso.with(context).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);//Log.d("url",mateInfo.getMateImageUrl());
152 + // holder.mateName.setText(mateInfo.getMateName());
153 + // holder.mateDoorOpenTime.setText(mateInfo.getMateDoorOpenTime());
154 + // holder.mateOutingFlag.setImageResource(R.drawable.ic_out_home);
155 + // Picasso.with(holder.mateProfile.getContext()).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);
156 +
157 + }
158 +
159 + @Override
160 + public int getItemCount() {
161 + return inoutLogs.size();
162 + }
163 +
164 + public class ViewHolder extends RecyclerView.ViewHolder {
165 + // public CircleImageView mateProfile;
166 + // public TextView mateName;
167 + // public TextView mateDoorOpenTime;
168 + // public ImageView mateOutingFlag;
169 + public ConstraintLayout inOutContainer;
170 + public TextView inOutNameTextView;
171 + public TextView inOutTime;
172 + public TextView inOutDate;
173 + public ImageView inoutImageView;
174 +
175 + public ViewHolder(View itemView) {
176 + super(itemView);
177 + inOutContainer = (ConstraintLayout) itemView.findViewById(R.id.cardAlarm);
178 + inOutNameTextView = (TextView) itemView.findViewById(R.id.inOutName);
179 + inOutTime = (TextView) itemView.findViewById(R.id.inOutTime);
180 + inOutDate = (TextView) itemView.findViewById(R.id.inOutDate);
181 + inoutImageView = (ImageView) itemView.findViewById(R.id.icAlarmImageView);
182 +
183 + // mateProfile = (CircleImageView) itemView.findViewById(R.id.mateProfileImageView);
184 + // mateName = (TextView) itemView.findViewById(R.id.mateNameTextView);
185 + // mateDoorOpenTime = (TextView) itemView.findViewById(R.id.mateOutingTimeTextView);
186 + // mateOutingFlag = (ImageView) itemView.findViewById(R.id.mateOutingFlag);
187 + }
188 + }
189 + }
190 +
191 +
192 +
193 +
194 +
195 +
196 +
197 +
198 +
199 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.os.Bundle;
4 +import android.os.Handler;
5 +import android.support.annotation.Nullable;
6 +import android.support.v4.app.Fragment;
7 +import android.util.Log;
8 +import android.view.LayoutInflater;
9 +import android.view.View;
10 +import android.view.ViewGroup;
11 +import android.widget.ImageButton;
12 +import android.widget.Toast;
13 +
14 +import com.gunghi.tgwing.lolock.R;
15 +import com.gunghi.tgwing.lolock.model.UserInfo;
16 +import com.gunghi.tgwing.lolock.network.LoLockService;
17 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
18 +
19 +import okhttp3.ResponseBody;
20 +import retrofit2.Call;
21 +import retrofit2.Callback;
22 +import retrofit2.Response;
23 +
24 +import static android.content.ContentValues.TAG;
25 +
26 +/**
27 + * Created by joyeongje on 2017. 7. 1..
28 + */
29 +
30 +public class FragmentDoorOnOff extends Fragment {
31 +
32 + private boolean openFlag = false;
33 + ImageButton imageButton;
34 + ImageButton doorKeycodeButton;
35 + LoLockService loLockService;
36 +
37 + @Nullable
38 + @Override
39 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
40 + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_door_on_off, container, false);
41 + loLockService = LoLockServiceGenarator.createService(LoLockService.class);
42 + imageButton = (ImageButton) rootView.findViewById(R.id.fragmentDoorOnOffButton);
43 + imageButton.setOnClickListener(new View.OnClickListener() {
44 + @Override
45 + public void onClick(View v) {
46 + openDoor();
47 + }
48 + });
49 +
50 + doorKeycodeButton = (ImageButton) rootView.findViewById(R.id.fragmentDoorCodeKeyButton);
51 + doorKeycodeButton.setOnClickListener(new View.OnClickListener() {
52 + @Override
53 + public void onClick(View v) {
54 + final OpenDoorCodeDialog openDoorCodeDialog =
55 + new OpenDoorCodeDialog(getActivity());
56 +
57 + doorKeycodeButton.setImageResource(R.drawable.ic_key_off_new);
58 + openDoorCodeDialog.show();
59 + }
60 + });
61 + return rootView;
62 + }
63 +
64 + private void openDoor() {
65 + //Log.d("user token", UserInfo.getInstance().getRegisterUserPhoneId());
66 + //Call<ResponseBody> requestOpenDoor = loLockService.remoteOnOffLock(UserInfo.getInstance().getRegisterUserPhoneId());
67 + Call<ResponseBody> requestOpenDoor = loLockService.remoteOnOffLock(UserInfo.getInstance().getDevideId());
68 + requestOpenDoor.enqueue(new Callback<ResponseBody>() {
69 + @Override
70 + public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
71 + Log.d(TAG,"CALL " + call.toString());
72 + Log.d(TAG,"Response" + response.toString());
73 +
74 + if(response.isSuccessful()) {
75 + // TODO: 2017. 7. 22. 더해야됨
76 + Log.d(TAG,"door Response Success");
77 + Toast.makeText(getContext(),"문이 열렸습니다.",Toast.LENGTH_SHORT).show();
78 + imageButton.setImageResource(R.drawable.ic_door_closed);
79 + //3초후에 화면 자동변환
80 + new Handler().postDelayed(new Runnable() {
81 + @Override
82 + public void run() {
83 + imageButton.setImageResource(R.drawable.ic_door_open);
84 + }
85 + },2000);
86 + }
87 + }
88 +
89 + @Override
90 + public void onFailure(Call<ResponseBody> call, Throwable t) {
91 + Toast.makeText(getContext(),"서버 상태가 불안정합니다.",Toast.LENGTH_SHORT).show();
92 + imageButton.setImageResource(R.drawable.ic_door_open);
93 + }
94 +
95 + });
96 +
97 + }
98 +
99 +
100 +
101 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.Manifest;
4 +import android.accounts.AccountManager;
5 +import android.app.Dialog;
6 +import android.app.ProgressDialog;
7 +import android.content.Context;
8 +import android.content.Intent;
9 +import android.content.SharedPreferences;
10 +import android.net.ConnectivityManager;
11 +import android.net.NetworkInfo;
12 +import android.net.Uri;
13 +import android.os.AsyncTask;
14 +import android.os.Bundle;
15 +import android.support.annotation.Nullable;
16 +import android.support.constraint.ConstraintLayout;
17 +import android.support.v4.app.Fragment;
18 +import android.support.v7.widget.DefaultItemAnimator;
19 +import android.support.v7.widget.LinearLayoutManager;
20 +import android.support.v7.widget.RecyclerView;
21 +import android.util.Log;
22 +import android.view.LayoutInflater;
23 +import android.view.View;
24 +import android.view.ViewGroup;
25 +import android.widget.ImageView;
26 +import android.widget.TextView;
27 +
28 +import com.google.android.gms.common.ConnectionResult;
29 +import com.google.android.gms.common.GoogleApiAvailability;
30 +import com.google.api.client.extensions.android.http.AndroidHttp;
31 +import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential;
32 +import com.google.api.client.googleapis.extensions.android.gms.auth.GooglePlayServicesAvailabilityIOException;
33 +import com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException;
34 +import com.google.api.client.http.HttpTransport;
35 +import com.google.api.client.json.JsonFactory;
36 +import com.google.api.client.json.jackson2.JacksonFactory;
37 +import com.google.api.client.util.DateTime;
38 +import com.google.api.client.util.ExponentialBackOff;
39 +import com.google.api.services.calendar.CalendarScopes;
40 +import com.google.api.services.calendar.model.Event;
41 +import com.google.api.services.calendar.model.Events;
42 +import com.google.common.eventbus.Subscribe;
43 +import com.gunghi.tgwing.lolock.R;
44 +import com.gunghi.tgwing.lolock.Response.ResponseWeather;
45 +import com.gunghi.tgwing.lolock.model.GoogleSchedularData;
46 +import com.gunghi.tgwing.lolock.model.UserInfo;
47 +import com.gunghi.tgwing.lolock.network.LoLockService;
48 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
49 +import com.gunghi.tgwing.lolock.util.ActivityResultEvent;
50 +import com.gunghi.tgwing.lolock.util.EventBus;
51 +
52 +import java.io.IOException;
53 +import java.util.ArrayList;
54 +import java.util.Arrays;
55 +import java.util.List;
56 +
57 +import pub.devrel.easypermissions.AfterPermissionGranted;
58 +import pub.devrel.easypermissions.EasyPermissions;
59 +import retrofit2.Call;
60 +import retrofit2.Callback;
61 +import retrofit2.Response;
62 +
63 +import static android.app.Activity.RESULT_OK;
64 +
65 +/**
66 + * Created by joyeongje on 2017. 7. 20..
67 + */
68 +
69 +public class FragmentInfo extends Fragment {
70 +
71 + static final int REQUEST_ACCOUNT_PICKER = 1000;
72 + static final int REQUEST_AUTHORIZATION = 1001;
73 + static final int REQUEST_GOOGLE_PLAY_SERVICES = 1002;
74 + static final int REQUEST_PERMISSION_GET_ACCOUNTS = 1003;
75 + private static final String PREF_ACCOUNT_NAME = "accountName";
76 + private static final String[] SCOPES = { CalendarScopes.CALENDAR_READONLY };
77 + LoLockService loLockService;
78 + ImageView weatherIconImageView;
79 + TextView currentTempatureTextView;
80 + TextView maxMinTempatureTextView;
81 + TextView currentLocaleTextView;
82 + TextView rainPercentTextView;
83 + TextView cloudAmounTextView;
84 + GoogleAccountCredential mCredential;
85 + ProgressDialog mProgress;
86 + private ArrayList<GoogleSchedularData> googleSchedularDatas;
87 + private GoogleScheularAdapter googleScheularAdapter;
88 +
89 + @Nullable
90 + @Override
91 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
92 + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_info, container, false);
93 +
94 + initFragmentInfo(rootView);
95 + getWeartherInfo();
96 +
97 + EventBus.getInstance().register(this);
98 +
99 + RecyclerView schularRecyclerview = (RecyclerView) rootView.findViewById(R.id.schedularRecyclerView);
100 + RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
101 + schularRecyclerview.setLayoutManager(mLayoutManager);
102 + schularRecyclerview.setHasFixedSize(true);
103 + schularRecyclerview.scrollToPosition(0);
104 +
105 + googleSchedularDatas = new ArrayList<>();
106 + googleScheularAdapter = new GoogleScheularAdapter(googleSchedularDatas,getContext());
107 + schularRecyclerview.setAdapter(googleScheularAdapter);
108 + schularRecyclerview.setItemAnimator(new DefaultItemAnimator());
109 +
110 + getSchedule();
111 +
112 +
113 + return rootView;
114 + }
115 +
116 + @Override
117 + public void onDestroy() {
118 + // EventBus.getDefault().unregister(this);
119 + EventBus.getInstance().unregister(this);
120 + super.onDestroy();
121 + }
122 +
123 + private void initFragmentInfo(ViewGroup viewGroup) {
124 + loLockService = LoLockServiceGenarator.createService(LoLockService.class);
125 +
126 + weatherIconImageView = (ImageView)viewGroup.findViewById(R.id.fragmentInfoWeatherIcon);
127 + currentTempatureTextView = (TextView)viewGroup.findViewById(R.id.fragmentInfoCurrentTemparature);
128 + maxMinTempatureTextView = (TextView)viewGroup.findViewById(R.id.fragmentInfoCurrentMaxMinTemparature);
129 + currentLocaleTextView = (TextView)viewGroup.findViewById(R.id.fragmentInfoWeatherLocale);
130 + rainPercentTextView = (TextView)viewGroup.findViewById(R.id.fragmentInfoRainPercent);
131 + cloudAmounTextView = (TextView)viewGroup.findViewById(R.id.fragmentInfoCloudAmount);
132 +
133 + }
134 +
135 + private void getWeartherInfo() {
136 + String loLockKey = UserInfo.getInstance().getLolockLTID();
137 + // Log.d("lolockey",loLockKey);
138 + Call<ResponseWeather> responseWeatherCall = loLockService.getWeatherData(loLockKey);
139 + responseWeatherCall.enqueue(new Callback<ResponseWeather>() {
140 + @Override
141 + public void onResponse(Call<ResponseWeather> call, Response<ResponseWeather> response) {
142 + if(response.isSuccessful()) {
143 + Log.d("weather", response.toString());
144 + weatherDataMappingUI(response.body());
145 + }
146 + }
147 +
148 + @Override
149 + public void onFailure(Call<ResponseWeather> call, Throwable t) {
150 + Log.d("Weather info get fail",call.toString());
151 +
152 + }
153 + });
154 + }
155 +
156 + private void weatherDataMappingUI(ResponseWeather response) {
157 +
158 + int minTemperature = response.getMinTemperature();
159 + int maxTemperature = response.getMaxTemperature();
160 + maxMinTempatureTextView.setText(minTemperature + "℃ /" + maxTemperature + "℃");
161 +
162 + double curTemperature = response.getTemperature();
163 + currentTempatureTextView.setText((int)curTemperature + "℃");
164 +
165 + int probabilityRain = response.getProbabilityRain();
166 + rainPercentTextView.setText("강수확률 : " + probabilityRain + "%");
167 +
168 + String sky = response.getSky();
169 + cloudAmounTextView.setText(sky);
170 +
171 + String locale = response.getLocation();
172 + currentLocaleTextView.setText(locale);
173 +
174 +
175 + switch (sky) {
176 + case "맑음":
177 + weatherIconImageView.setImageResource(R.drawable.ic_sun);
178 + break;
179 + case "구름조금":
180 + case "구름많음":
181 + case "흐림":
182 + weatherIconImageView.setImageResource(R.drawable.ic_weather_cloud);
183 + break;
184 + case "비":
185 + weatherIconImageView.setImageResource(R.drawable.ic_rain);
186 + break;
187 + case "눈":
188 + weatherIconImageView.setImageResource(R.drawable.ic_snow);
189 + break;
190 + default:
191 + weatherIconImageView.setImageResource(R.drawable.ic_snow);
192 + break;
193 + }
194 + }
195 +
196 + private void getSchedule() {
197 +
198 + // Initialize credentials and service object.
199 + mCredential = GoogleAccountCredential.usingOAuth2(
200 + getContext(), Arrays.asList(SCOPES))
201 + .setBackOff(new ExponentialBackOff());
202 +
203 + mProgress = new ProgressDialog(getContext());
204 + mProgress.setMessage("구글 캘린더 정보를 가져오고 있습니다.");
205 +
206 + getResultsFromApi();
207 +
208 + }
209 +
210 +
211 + private void getResultsFromApi() {
212 + if (!isGooglePlayServicesAvailable()) {
213 + acquireGooglePlayServices();
214 + } else if (mCredential.getSelectedAccountName() == null) {
215 + chooseAccount();
216 + } else if (!isDeviceOnline()) {
217 + // 인터넷 이용 불가 상태
218 + } else {
219 + new MakeRequestTask(mCredential).execute();
220 + }
221 + }
222 +
223 + @AfterPermissionGranted(REQUEST_PERMISSION_GET_ACCOUNTS)
224 + private void chooseAccount() {
225 + if (EasyPermissions.hasPermissions(getContext(), new String[]{Manifest.permission.GET_ACCOUNTS})) {
226 + String accountName = getActivity().getPreferences(Context.MODE_PRIVATE)
227 + .getString(PREF_ACCOUNT_NAME, null);
228 + if (accountName != null) {
229 + mCredential.setSelectedAccountName(accountName);
230 + getResultsFromApi();
231 + } else {
232 + // Start a dialog from which the user can choose an account
233 + startActivityForResult(
234 + mCredential.newChooseAccountIntent(),
235 + REQUEST_ACCOUNT_PICKER);
236 + }
237 + } else {
238 + // Request the GET_ACCOUNTS permission via a user dialog
239 + EasyPermissions.requestPermissions(
240 + this,
241 + "This app needs to access your Google account (via Contacts).",
242 + REQUEST_PERMISSION_GET_ACCOUNTS,
243 + Manifest.permission.GET_ACCOUNTS);
244 + }
245 + }
246 +
247 + private boolean isDeviceOnline() {
248 + ConnectivityManager connMgr =
249 + (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
250 + NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
251 + return (networkInfo != null && networkInfo.isConnected());
252 + }
253 +
254 + /**
255 + * Check that Google Play services APK is installed and up to date.
256 + * @return true if Google Play Services is available and up to
257 + * date on this device; false otherwise.
258 + */
259 +
260 + private boolean isGooglePlayServicesAvailable() {
261 + GoogleApiAvailability apiAvailability =
262 + GoogleApiAvailability.getInstance();
263 + final int connectionStatusCode =
264 + apiAvailability.isGooglePlayServicesAvailable(getContext());
265 + return connectionStatusCode == ConnectionResult.SUCCESS;
266 + }
267 +
268 + /**
269 + * Attempt to resolve a missing, out-of-date, invalid or disabled Google
270 + * Play Services installation via a user dialog, if possible.
271 + */
272 + private void acquireGooglePlayServices() {
273 + GoogleApiAvailability apiAvailability =
274 + GoogleApiAvailability.getInstance();
275 + final int connectionStatusCode =
276 + apiAvailability.isGooglePlayServicesAvailable(getContext());
277 + if (apiAvailability.isUserResolvableError(connectionStatusCode)) {
278 + showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode);
279 + }
280 + }
281 +
282 +
283 + /**
284 + * Display an error dialog showing that Google Play Services is missing
285 + * or out of date.
286 + * @param connectionStatusCode code describing the presence (or lack of)
287 + * Google Play Services on this device.
288 + */
289 + void showGooglePlayServicesAvailabilityErrorDialog(
290 + final int connectionStatusCode) {
291 + GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
292 + Dialog dialog = apiAvailability.getErrorDialog(
293 + getActivity(),
294 + connectionStatusCode,
295 + REQUEST_GOOGLE_PLAY_SERVICES);
296 + dialog.show();
297 + }
298 +
299 + @Subscribe
300 + public void onActivityResultEvent(ActivityResultEvent activityResultEvent) {
301 + onActivityResult(activityResultEvent.getRequestCode(),activityResultEvent.getResultCode(),activityResultEvent.getData());
302 + }
303 +
304 + @Override
305 + public void onActivityResult(
306 + int requestCode, int resultCode, Intent data) {
307 +
308 + Log.d("프래그먼트 리절트", "들어옴");
309 + switch(requestCode) {
310 + case REQUEST_GOOGLE_PLAY_SERVICES:
311 + if (resultCode != RESULT_OK) {
312 + // 구글 플레이 서비스를 이용할수 없음..
313 + } else {
314 + getResultsFromApi();
315 + }
316 + break;
317 + case REQUEST_ACCOUNT_PICKER:
318 + if (resultCode == RESULT_OK && data != null &&
319 + data.getExtras() != null) {
320 + String accountName =
321 + data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
322 + if (accountName != null) {
323 + SharedPreferences settings =
324 + getActivity().getPreferences(Context.MODE_PRIVATE);
325 + SharedPreferences.Editor editor = settings.edit();
326 + editor.putString(PREF_ACCOUNT_NAME, accountName);
327 + editor.apply();
328 + mCredential.setSelectedAccountName(accountName);
329 + getResultsFromApi();
330 + }
331 + }
332 + break;
333 + case REQUEST_AUTHORIZATION:
334 + if (resultCode == RESULT_OK) {
335 + getResultsFromApi();
336 + }
337 + break;
338 + }
339 + }
340 +
341 + /**
342 + * An asynchronous task that handles the Google Calendar API call.
343 + * Placing the API calls in their own task ensures the UI stays responsive.
344 + */
345 + private class MakeRequestTask extends AsyncTask<Void, Void, List<String>> {
346 + private com.google.api.services.calendar.Calendar mService = null;
347 + private Exception mLastError = null;
348 +
349 + MakeRequestTask(GoogleAccountCredential credential) {
350 + HttpTransport transport = AndroidHttp.newCompatibleTransport();
351 + JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
352 + mService = new com.google.api.services.calendar.Calendar.Builder(
353 + transport, jsonFactory, credential)
354 + .setApplicationName("Google Calendar API Android Quickstart")
355 + .build();
356 + }
357 +
358 + /**
359 + * Background task to call Google Calendar API.
360 + * @param params no parameters needed for this task.
361 + */
362 + @Override
363 + protected List<String> doInBackground(Void... params) {
364 + try {
365 + return getDataFromApi();
366 + } catch (Exception e) {
367 + mLastError = e;
368 + cancel(true);
369 + return null;
370 + }
371 + }
372 +
373 + /**
374 + * Fetch a list of the next 10 events from the primary calendar.
375 + * @return List of Strings describing returned events.
376 + * @throws IOException
377 + */
378 + private List<String> getDataFromApi() throws IOException {
379 +
380 + Log.d("getDataFromApi","getDataFromApi");
381 + // 일정 10개가져옴
382 + // List the next 10 events from the primary calendar.
383 + DateTime now = new DateTime(System.currentTimeMillis());
384 + List<String> eventStrings = new ArrayList<String>();
385 + Events events = mService.events().list("primary")
386 + .setMaxResults(10)
387 + .setTimeMin(now)
388 + .setOrderBy("startTime")
389 + .setSingleEvents(true)
390 + .execute();
391 +
392 + List<Event> items = events.getItems();
393 +
394 + for (Event event : items) {
395 + DateTime start = event.getStart().getDateTime();
396 + Log.d("event",event.toString());
397 +
398 +
399 + if (start == null) {
400 + // All-day events don't have start times, so just use
401 + // the start date.
402 + start = event.getStart().getDate();
403 + }
404 +
405 + String eventSummary = event.getSummary();
406 + String startTime = start.toString();
407 + String splitTime = startTime.substring(11,16);
408 +
409 + // TODO: 2017. 7. 25. 월일 가져오기
410 +
411 + GoogleSchedularData googleSchedularData = new GoogleSchedularData();
412 + googleSchedularData.setStartTime(splitTime);
413 + googleSchedularData.setSummaryTitle(eventSummary);
414 + googleSchedularData.setGoogleLink(event.getHtmlLink());
415 + // Log.d("Datas.size(22",String.valueOf(googleSchedularDatas.size()));
416 + googleSchedularDatas.add(googleSchedularData);
417 +
418 + Log.d("Datas.size()",String.valueOf(googleSchedularDatas.size()));
419 + eventStrings.add(
420 + String.format("%s (%s)", event.getSummary(), start));
421 + }
422 +
423 + return eventStrings;
424 + }
425 +
426 +
427 + @Override
428 + protected void onPreExecute() {
429 + mProgress.show();
430 + }
431 +
432 + @Override
433 + protected void onPostExecute(List<String> output) {
434 + mProgress.hide();
435 + googleScheularAdapter.notifyDataSetChanged();
436 + if (output == null || output.size() == 0) {
437 + // 아무런 결과가없때
438 + } else {
439 + output.add(0, "Data retrieved using the Google Calendar API:");
440 + Log.d("dddd","ddd");
441 + // 데이터 가져온건가..?
442 + }
443 + }
444 +
445 + @Override
446 + protected void onCancelled() {
447 + mProgress.hide();
448 + if (mLastError != null) {
449 + if (mLastError instanceof GooglePlayServicesAvailabilityIOException) {
450 + showGooglePlayServicesAvailabilityErrorDialog(
451 + ((GooglePlayServicesAvailabilityIOException) mLastError)
452 + .getConnectionStatusCode());
453 + } else if (mLastError instanceof UserRecoverableAuthIOException) {
454 + startActivityForResult(
455 + ((UserRecoverableAuthIOException) mLastError).getIntent(),
456 + REQUEST_AUTHORIZATION);
457 + } else {
458 + // 에러 발생.
459 + }
460 + } else {
461 + // 요청 취소.
462 + }
463 + }
464 + }
465 +
466 + private class GoogleScheularAdapter extends RecyclerView.Adapter<GoogleScheularAdapter.ViewHolder> {
467 +
468 + private ArrayList<GoogleSchedularData> thisgoogleSchedularDatas;
469 + private Context context;
470 +
471 + public GoogleScheularAdapter(ArrayList<GoogleSchedularData> googleSchedularDatas, Context context) {
472 + this.thisgoogleSchedularDatas = googleSchedularDatas;
473 + this.context = context;
474 + }
475 +
476 + @Override
477 + public GoogleScheularAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
478 + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_scedule, parent, false);
479 + return new ViewHolder(v);
480 + }
481 +
482 + @Override
483 + public void onBindViewHolder(GoogleScheularAdapter.ViewHolder holder, final int position) {
484 + final GoogleSchedularData googleSchedularData =
485 + thisgoogleSchedularDatas.get(position);
486 +
487 + holder.scheularTitle.setText(googleSchedularData.getSummaryTitle());
488 + holder.scheularStartTime.setText(googleSchedularData.getStartTime());
489 + holder.schedularConstraintLayout.setOnClickListener(new View.OnClickListener() {
490 + @Override
491 + public void onClick(View v) {
492 + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(googleSchedularData.getGoogleLink()));
493 + startActivity(intent);
494 + }
495 + });
496 +
497 + }
498 +
499 + @Override
500 + public int getItemCount() {
501 + return thisgoogleSchedularDatas.size();
502 + }
503 +
504 + public class ViewHolder extends RecyclerView.ViewHolder {
505 + public TextView scheularTitle;
506 + public TextView scheularStartTime;
507 + private ConstraintLayout schedularConstraintLayout;
508 +
509 + public ViewHolder(View itemView) {
510 + super(itemView);
511 + scheularTitle = (TextView) itemView.findViewById(R.id.schedularName);
512 + scheularStartTime = (TextView) itemView.findViewById(R.id.schedularTime);
513 + schedularConstraintLayout = (ConstraintLayout) itemView.findViewById(R.id.cardSchedule);
514 + }
515 + }
516 + }
517 +
518 +
519 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.content.Context;
4 +import android.os.Bundle;
5 +import android.support.annotation.Nullable;
6 +import android.support.v4.app.Fragment;
7 +import android.support.v7.widget.DefaultItemAnimator;
8 +import android.support.v7.widget.LinearLayoutManager;
9 +import android.support.v7.widget.RecyclerView;
10 +import android.util.Log;
11 +import android.view.LayoutInflater;
12 +import android.view.View;
13 +import android.view.ViewGroup;
14 +import android.widget.ImageView;
15 +import android.widget.TextView;
16 +
17 +import com.gunghi.tgwing.lolock.R;
18 +import com.gunghi.tgwing.lolock.Response.ResponseMate;
19 +import com.gunghi.tgwing.lolock.model.Mate;
20 +import com.gunghi.tgwing.lolock.model.UserInfo;
21 +import com.gunghi.tgwing.lolock.network.LoLockService;
22 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
23 +import com.squareup.picasso.Picasso;
24 +
25 +import java.util.ArrayList;
26 +
27 +import de.hdodenhof.circleimageview.CircleImageView;
28 +import retrofit2.Call;
29 +import retrofit2.Callback;
30 +import retrofit2.Response;
31 +
32 +/**
33 + * Created by joyeongje on 2017. 7. 1..
34 + */
35 +
36 +public class FragmentMate extends Fragment {
37 +
38 + private ArrayList<Mate> mates;
39 + private MateAdapter mateAdapter;
40 + private final String TAG = "FragmentMate";
41 + private TextView mateNumberTextView;
42 +
43 +
44 + @Nullable
45 + @Override
46 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
47 + ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_mate, container, false);
48 + mateNumberTextView = (TextView)rootView.findViewById(R.id.mateNumberTextView);
49 +
50 + RecyclerView mateRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragmentFamiliyRecyclerView);
51 + RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
52 + mateRecyclerView.setLayoutManager(mLayoutManager);
53 + mateRecyclerView.setHasFixedSize(true);
54 + mateRecyclerView.scrollToPosition(0);
55 +
56 + mates = new ArrayList<>();
57 +
58 +
59 + //mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
60 + //mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
61 + //mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
62 +
63 + mateAdapter = new MateAdapter(mates,getContext());
64 + mateRecyclerView.setAdapter(mateAdapter);
65 + mateRecyclerView.setItemAnimator(new DefaultItemAnimator());
66 +
67 + getMateList();
68 +
69 + return rootView;
70 + }
71 +
72 + private void getMateList() {
73 + LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
74 + String ltid = UserInfo.getInstance().getLolockLTID();
75 + Call<ResponseMate> responseMate = loLockService.getHomeMateResponse(ltid);
76 + responseMate.enqueue(new Callback<ResponseMate>() {
77 + @Override
78 + public void onResponse(Call<ResponseMate> call, Response<ResponseMate> response) {
79 + Log.d(TAG,"Response" + response.toString());
80 +
81 + if(response.isSuccessful()) {
82 + Log.d(TAG,"RoomMateList Response Success");
83 + for (Mate mate : response.body().getMates()) {
84 + mates.add(mate);
85 + }
86 + if(response.body().getMateNumber() != null) {
87 + mateNumberTextView.setText("가족(" + response.body().getMateNumber() + ")" );
88 + };
89 + mateAdapter.notifyDataSetChanged();
90 + }
91 +
92 + }
93 +
94 + @Override
95 + public void onFailure(Call<ResponseMate> call, Throwable t) {
96 + Log.d(TAG,"URL or Server Error");
97 + }
98 + });
99 +
100 + }
101 +
102 + private class MateAdapter extends RecyclerView.Adapter<MateAdapter.ViewHolder> {
103 +
104 + private ArrayList<Mate> mates;
105 + private Context context;
106 +
107 + public MateAdapter(ArrayList<Mate> mates, Context context) {
108 + this.mates = mates;
109 + this.context = context;
110 +
111 + }
112 +
113 + @Override
114 + public MateAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
115 + View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_mate, parent, false);
116 + return new ViewHolder(v);
117 + }
118 +
119 + @Override
120 + public void onBindViewHolder(MateAdapter.ViewHolder holder, int position) {
121 + final Mate mateInfo = mates.get(position);
122 + //Picasso.with(context).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);
123 + //Log.d("url",mateInfo.getMateImageUrl());
124 + holder.mateName.setText(mateInfo.getMateName());
125 + holder.mateDoorOpenTime.setText(mateInfo.getMateDoorOpenTime());
126 + if(mateInfo.getMateOutingFlag().equals("0"))
127 + holder.mateOutingFlag.setImageResource(R.drawable.ic_out_home);
128 + else {
129 + holder.mateOutingFlag.setImageResource(R.drawable.ic_in_home);
130 + }
131 +
132 + Picasso.with(holder.mateProfile.getContext()).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);
133 + // TODO: 2017. 7. 1. 이미지 수정하는거 추가해야됨.!
134 +
135 + }
136 +
137 + @Override
138 + public int getItemCount() {
139 + return mates.size();
140 + }
141 +
142 + public class ViewHolder extends RecyclerView.ViewHolder {
143 + public CircleImageView mateProfile;
144 + public TextView mateName;
145 + public TextView mateDoorOpenTime;
146 + public ImageView mateOutingFlag;
147 +
148 + public ViewHolder(View itemView) {
149 + super(itemView);
150 + mateProfile = (CircleImageView) itemView.findViewById(R.id.mateProfileImageView);
151 + mateName = (TextView) itemView.findViewById(R.id.mateNameTextView);
152 + mateDoorOpenTime = (TextView) itemView.findViewById(R.id.mateOutingTimeTextView);
153 + mateOutingFlag = (ImageView) itemView.findViewById(R.id.mateOutingFlag);
154 + }
155 + }
156 + }
157 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.content.Context;
4 +import android.content.Intent;
5 +import android.os.Bundle;
6 +import android.support.annotation.IdRes;
7 +import android.support.v4.app.Fragment;
8 +import android.support.v7.app.AppCompatActivity;
9 +import android.util.Log;
10 +import android.view.View;
11 +import android.widget.ImageButton;
12 +import android.widget.TextView;
13 +
14 +import com.gunghi.tgwing.lolock.R;
15 +import com.gunghi.tgwing.lolock.util.ActivityResultEvent;
16 +import com.gunghi.tgwing.lolock.util.EventBus;
17 +import com.roughike.bottombar.BottomBar;
18 +import com.roughike.bottombar.OnMenuTabClickListener;
19 +import com.tsengvn.typekit.TypekitContextWrapper;
20 +
21 +
22 +public class MainActivity extends AppCompatActivity {
23 +
24 + private final static String TAG = MainActivity.class.getSimpleName();
25 +
26 + private BottomBar mBottomBar;
27 + private Fragment currentSelectedFragment;
28 + private TextView mainTitleTextView;
29 + private ImageButton settingButton;
30 +
31 + FragmentDoorOnOff fragmentDoorOnOff;
32 + FragmentMate fragmentMate ;
33 + FragmentInfo fragmentInfo;
34 + FragmentAlarm fragmentAlarm;
35 +
36 +
37 + @Override
38 + protected void attachBaseContext(Context newBase) {
39 + super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
40 + }
41 +
42 +
43 + private void initPushEventReciever() {
44 + String freamgentFlag = getIntent().getStringExtra("viewFragment");
45 +
46 + Log.d("initPushEventReciever","연결");
47 + if(freamgentFlag != null) {
48 + Log.d("initPushEventReciever","들어오니니니");
49 + Log.d("initPushEventReciever",freamgentFlag + "ddd");
50 +
51 + switch (freamgentFlag) {
52 + case "weatherPlan":
53 + currentSelectedFragment = fragmentInfo;
54 + mainTitleTextView.setText("날씨 및 일정");
55 + mBottomBar.selectTabAtPosition(2, true);
56 + getSupportFragmentManager().beginTransaction().
57 + replace(R.id.mainActivityFragmentContainer, currentSelectedFragment).
58 + commit();
59 + Log.d("freamgentFlag","weatherPlan");
60 + break;
61 + case "inOutLog":
62 + Log.d("freamgentFlag","inOutLog");
63 + case "strangeAlarm":
64 + Log.d("freamgentFlag","strangeAlarm");
65 + currentSelectedFragment = fragmentAlarm;
66 + mainTitleTextView.setText("출입기록");
67 + mBottomBar.selectTabAtPosition(3, true);
68 + getSupportFragmentManager().
69 + beginTransaction().
70 + replace(R.id.mainActivityFragmentContainer, currentSelectedFragment).
71 + commit();
72 + break;
73 +
74 + }
75 + }
76 + }
77 +
78 +
79 + @Override
80 + protected void onCreate(Bundle savedInstanceState) {
81 + super.onCreate(savedInstanceState);
82 + setContentView(R.layout.activity_main);
83 +
84 + initFragment();
85 + initView(savedInstanceState);
86 + //checkBLE();
87 +
88 + }
89 +
90 + @Override
91 + protected void onResume() {
92 + super.onResume();
93 + initPushEventReciever();
94 + // registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
95 +
96 + }
97 + //private void scanBLE() {
98 + // if (!mBluetoothAdapter.isEnabled()) {
99 + // Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
100 + // startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
101 + // } else {
102 + // if (Build.VERSION.SDK_INT >= 21) {
103 + // mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
104 + // settings = new ScanSettings.Builder()
105 + // .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
106 + // .build();
107 + // filters = new ArrayList<ScanFilter>();
108 + // }
109 + // // scanLeDevice(true);
110 + // }
111 + //}
112 +
113 + @Override
114 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
115 + // User chose not to enable Bluetooth.
116 + super.onActivityResult(requestCode, resultCode, data);
117 + EventBus.getInstance().post(new ActivityResultEvent(requestCode, resultCode, data));
118 +//
119 + // if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
120 + // Toast.makeText(this,"블루투스를 사용여부를 체크해주세요.",Toast.LENGTH_SHORT).show();
121 + // } else {
122 + //
123 + // }
124 + }
125 +
126 + @Override
127 + protected void onPause() {
128 + super.onPause();
129 + // if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
130 + // scanLeDevice(false);
131 + // }
132 + // unregisterReceiver(mGattUpdateReceiver);
133 +
134 + //scanLeDevice(false);
135 + }
136 +
137 +
138 + @Override
139 + protected void onDestroy() {
140 + super.onDestroy();
141 + }
142 +
143 +
144 + private void initView(Bundle savedInstanceState) {
145 + mainTitleTextView = (TextView) findViewById(R.id.mainActivityTitleTextView);
146 +
147 + mBottomBar = BottomBar.attach(this, savedInstanceState);
148 + mBottomBar.useFixedMode();
149 + mBottomBar.setActiveTabColor("#FC7336");
150 + mBottomBar.setItems(R.menu.bottombar_menus);
151 +
152 + mBottomBar.setOnMenuTabClickListener(new OnMenuTabClickListener() {
153 + @Override
154 + public void onMenuTabSelected(@IdRes int menuItemId) {
155 +
156 + switch (menuItemId) {
157 + case R.id.menu_home:
158 + currentSelectedFragment = fragmentDoorOnOff;
159 + mainTitleTextView.setText("출입문 조작");
160 + break;
161 + case R.id.menu_family:
162 + currentSelectedFragment = fragmentMate;
163 + mainTitleTextView.setText("가족 현황");
164 + break;
165 + case R.id.menu_info:
166 + currentSelectedFragment = fragmentInfo;
167 + mainTitleTextView.setText("날씨 및 일정");
168 + break;
169 + case R.id.menu_alarm:
170 + currentSelectedFragment = fragmentAlarm;
171 + mainTitleTextView.setText("출입기록");
172 + break;
173 + }
174 + getSupportFragmentManager().beginTransaction().replace(R.id.mainActivityFragmentContainer,currentSelectedFragment).commit();
175 + }
176 +
177 + @Override
178 + public void onMenuTabReSelected(@IdRes int menuItemId) {
179 +
180 + }
181 + });
182 +
183 + //setting 버튼 누르면 들어가도록 바꿈
184 + settingButton=(ImageButton)findViewById(R.id.mainActivitySettingButton);
185 + final Intent intent=new Intent(this, SettingActivity.class);
186 + settingButton.setOnClickListener(new View.OnClickListener() {
187 + @Override
188 + public void onClick(View v) {
189 + startActivity(intent);
190 + }
191 + });
192 + }
193 +
194 + private void initFragment() {
195 + fragmentDoorOnOff = new FragmentDoorOnOff();
196 + fragmentMate = new FragmentMate();
197 + fragmentInfo = new FragmentInfo();
198 + fragmentAlarm = new FragmentAlarm();
199 +
200 + currentSelectedFragment = fragmentDoorOnOff;
201 + }
202 +
203 +
204 + @Override
205 + protected void onSaveInstanceState(Bundle outState) {
206 + super.onSaveInstanceState(outState);
207 +
208 + // Necessary to restore the BottomBar's state, otherwise we would
209 + // lose the current tab on orientation change.
210 + mBottomBar.onSaveInstanceState(outState);
211 + }
212 +
213 +
214 +
215 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.app.Dialog;
4 +import android.content.ClipData;
5 +import android.content.ClipboardManager;
6 +import android.content.Context;
7 +import android.content.Intent;
8 +import android.os.Bundle;
9 +import android.util.Log;
10 +import android.view.View;
11 +import android.view.Window;
12 +import android.widget.Button;
13 +import android.widget.TextView;
14 +import android.widget.Toast;
15 +
16 +import com.gunghi.tgwing.lolock.R;
17 +import com.gunghi.tgwing.lolock.Response.ResponseOpenDoorKey;
18 +import com.gunghi.tgwing.lolock.model.UserInfo;
19 +import com.gunghi.tgwing.lolock.network.LoLockService;
20 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
21 +
22 +import retrofit2.Call;
23 +import retrofit2.Callback;
24 +import retrofit2.Response;
25 +
26 +import static android.content.Context.CLIPBOARD_SERVICE;
27 +
28 +/**
29 + * Created by joyeongje on 2017. 7. 22..
30 + */
31 +
32 +public class OpenDoorCodeDialog extends Dialog {
33 +
34 + private Button shareButton;
35 + private Button sendButton;
36 + private TextView textView;
37 + private Context context;
38 +
39 +
40 + public OpenDoorCodeDialog(Context context) {
41 + super(context);
42 + }
43 +
44 + @Override
45 + protected void onCreate(Bundle savedInstanceState) {
46 + super.onCreate(savedInstanceState);
47 + requestWindowFeature(Window.FEATURE_NO_TITLE);
48 + setContentView(R.layout.door_open_code_dialog);
49 +
50 + initOpenCodeDialogView();
51 + makeOpenDoorCode();
52 +
53 + }
54 +
55 + private void initOpenCodeDialogView() {
56 + shareButton = (Button)findViewById(R.id.openCodePasteButton);
57 + shareButton.setOnClickListener(new View.OnClickListener() {
58 + @Override
59 + public void onClick(View v) {
60 + ClipboardManager clipboardManager = (ClipboardManager)getContext().getSystemService(CLIPBOARD_SERVICE);
61 + ClipData clipData = ClipData.newPlainText("label",textView.getText().toString());
62 + clipboardManager.setPrimaryClip(clipData);
63 + Toast.makeText(getContext(),"일회용키가 복사되었습니다",Toast.LENGTH_SHORT).show();
64 + dismiss();
65 + }
66 + });
67 + sendButton = (Button)findViewById(R.id.openCodeSendButton);
68 + sendButton.setOnClickListener(new View.OnClickListener() {
69 + @Override
70 + public void onClick(View v) {
71 + Intent intent = new Intent(Intent.ACTION_VIEW);
72 + intent.putExtra("sms_body",textView.getText().toString());
73 + intent.setType("vnd.android-dir/mms-sms");
74 + getContext().startActivity(intent);
75 +
76 + }
77 + });
78 +
79 + textView = (TextView) findViewById(R.id.openCodeTextView);
80 + }
81 +
82 + private void makeOpenDoorCode() {
83 +
84 + LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
85 + Call<ResponseOpenDoorKey> requestOpenDoorCode = loLockService.getDoorOpenCode(UserInfo.getInstance().getDevideId());
86 + requestOpenDoorCode.enqueue(new Callback<ResponseOpenDoorKey>() {
87 +
88 + @Override
89 + public void onResponse(Call<ResponseOpenDoorKey> call, Response<ResponseOpenDoorKey> response) {
90 + Log.d("response",response.toString());
91 + if(response.isSuccessful() && response.body().getCode().equals("CREATED")) {
92 + textView.setText(response.body().getLink());
93 + }
94 +
95 + }
96 +
97 + @Override
98 + public void onFailure(Call<ResponseOpenDoorKey> call, Throwable t) {
99 + Log.d("response Failture",call.toString());
100 + }
101 + });
102 +
103 + }
104 +
105 +
106 +
107 +
108 +
109 +
110 +
111 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.Manifest;
4 +import android.content.Context;
5 +import android.content.DialogInterface;
6 +import android.content.Intent;
7 +import android.content.pm.PackageManager;
8 +import android.location.Location;
9 +import android.location.LocationListener;
10 +import android.location.LocationManager;
11 +import android.os.Bundle;
12 +import android.provider.Settings;
13 +import android.support.v4.app.ActivityCompat;
14 +import android.support.v7.app.AlertDialog;
15 +import android.support.v7.app.AppCompatActivity;
16 +import android.util.Log;
17 +import android.view.View;
18 +import android.widget.Button;
19 +import android.widget.EditText;
20 +import android.widget.Toast;
21 +
22 +import com.gunghi.tgwing.lolock.R;
23 +import com.gunghi.tgwing.lolock.Response.ResponseDaumAddressAPI;
24 +import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
25 +import com.gunghi.tgwing.lolock.model.UserInfo;
26 +import com.gunghi.tgwing.lolock.network.DaumService;
27 +import com.gunghi.tgwing.lolock.network.DaumServiceGenerator;
28 +import com.gunghi.tgwing.lolock.network.LoLockService;
29 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
30 +import com.tsengvn.typekit.TypekitContextWrapper;
31 +
32 +import java.util.HashMap;
33 +import java.util.List;
34 +import java.util.Map;
35 +
36 +import okhttp3.ResponseBody;
37 +import pub.devrel.easypermissions.AfterPermissionGranted;
38 +import pub.devrel.easypermissions.EasyPermissions;
39 +import retrofit2.Call;
40 +import retrofit2.Callback;
41 +import retrofit2.Response;
42 +
43 +public class Register2Activity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {
44 +
45 + EditText nameEditText;
46 + EditText addressEditText;
47 + private LocationManager locationManager;
48 + Button button;
49 +
50 +
51 + @Override
52 + protected void onCreate(Bundle savedInstanceState) {
53 + super.onCreate(savedInstanceState);
54 + setContentView(R.layout.activity_register2);
55 +
56 + nameEditText = (EditText) findViewById(R.id.editTextName);
57 + addressEditText = (EditText) findViewById(R.id.editTextAddress);
58 +
59 + button = (Button) findViewById(R.id.register2ActivityButton);
60 + button.setOnClickListener(new View.OnClickListener() {
61 + @Override
62 + public void onClick(View v) {
63 + String name = nameEditText.getText().toString();
64 + RegisterUserInfo.getInstance().setRegisterUserName(name);
65 +
66 + String address = addressEditText.getText().toString();
67 + RegisterUserInfo.getInstance().setRegisterDeviceAddr(address);
68 +
69 + //final String[] deviceId = {RegisterUserInfo.getInstance().getDeviceId()};
70 +
71 + LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
72 + Call<ResponseBody> callLoLockService = loLockService.registLoLock(RegisterUserInfo.getInstance());
73 + Log.d("callLoLockService", callLoLockService.toString());
74 + callLoLockService.enqueue(new Callback<ResponseBody>() {
75 + @Override
76 + public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
77 + Log.d("response", response.toString());
78 + if (response.isSuccessful()) {
79 + Intent registerIntent = new Intent(Register2Activity.this, MainActivity.class);
80 + startActivity(registerIntent);
81 + Register2Activity.this.finish();
82 + UserInfo.getInstance().setDevideId(RegisterUserInfo.getInstance().getRegisterUserPhoneId());
83 + UserInfo.getInstance().setName(RegisterUserInfo.getInstance().getRegisterUserName());
84 + UserInfo.getInstance().setLolockLTID(RegisterUserInfo.getInstance().getRegisterDeviceId());
85 + } else {
86 + Toast.makeText(getApplicationContext(), "에러", Toast.LENGTH_SHORT).show();
87 + }
88 + }
89 +
90 + @Override
91 + public void onFailure(Call<ResponseBody> call, Throwable t) {
92 + Log.d("response", call.toString());
93 +
94 + }
95 + });
96 +
97 + }
98 + });
99 +
100 + getLocationInfo();
101 + }
102 +
103 + private LocationListener locationListener = new LocationListener() {
104 + public void onLocationChanged(Location location) {
105 + getAddressWithMyCoord(location.getLatitude(), location.getLongitude());
106 + }
107 +
108 + public void onStatusChanged(String provider, int status, Bundle extras) {
109 + }
110 +
111 + public void onProviderEnabled(String provider) {
112 + }
113 +
114 + public void onProviderDisabled(String provider) {
115 + }
116 + };
117 +
118 + @AfterPermissionGranted(1005)
119 + private void methodRequiresPermission() {
120 + String[] perms = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};
121 + if (EasyPermissions.hasPermissions(this, perms)) {
122 + // Already have permission, do the thing
123 + // ...
124 + } else {
125 + // Do not have permissions, request them now
126 + EasyPermissions.requestPermissions(this, "위치 요청을 필요로합니다.",
127 + 1005, perms);
128 + }
129 + }
130 +
131 +
132 + private void getLocationInfo() {
133 +
134 + locationManager =
135 + (LocationManager) getSystemService(Context.LOCATION_SERVICE);
136 +
137 +
138 + boolean isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
139 +
140 + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
141 + != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
142 + methodRequiresPermission();
143 + return;
144 + }
145 +
146 + if (isNetworkEnabled) {
147 +
148 + Location lastKnownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
149 + if (lastKnownLocation == null) {
150 + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, locationListener);
151 + } else {
152 + Log.d("나의 위치", String.valueOf(lastKnownLocation.getLatitude() + "," + lastKnownLocation.getLongitude()));
153 + getAddressWithMyCoord(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());
154 +
155 + }
156 + } else {
157 + onNetworkSetting();
158 + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, locationListener);
159 + //// TODO: 2017. 7. 21. 로직처리.
160 +
161 + }
162 + }
163 +
164 +
165 +
166 +
167 + private void getAddressWithMyCoord(Double lat, Double lon) {
168 +
169 + Map<String, String> queryAddress = new HashMap<>();
170 + queryAddress.put("apikey", "04b68611d624a48f5a37bf1ad4324600");
171 + queryAddress.put("latitude", String.valueOf(lat));
172 + queryAddress.put("longitude", String.valueOf(lon));
173 + queryAddress.put("inputCoordSystem", "WGS84");
174 + queryAddress.put("output", "json");
175 +
176 + RegisterUserInfo.getInstance().setRegisterDeviceGPS_lat(String.valueOf(lat));
177 + RegisterUserInfo.getInstance().setRegisterDeviceGPS_lon(String.valueOf(lon));
178 +
179 + DaumService daumService = DaumServiceGenerator.createService(DaumService.class);
180 + Call<ResponseDaumAddressAPI> responseDaumAddressAPICall = daumService.changeCoordToAddress(queryAddress);
181 + responseDaumAddressAPICall.enqueue(new Callback<ResponseDaumAddressAPI>() {
182 + @Override
183 + public void onResponse(Call<ResponseDaumAddressAPI> call, Response<ResponseDaumAddressAPI> response) {
184 + if (response.isSuccessful()) {
185 + addressEditText.setText(response.body().getFullName());
186 + locationManager.removeUpdates(locationListener);
187 + }
188 + }
189 +
190 + @Override
191 + public void onFailure(Call<ResponseDaumAddressAPI> call, Throwable t) {
192 +
193 + }
194 + });
195 +
196 + }
197 +
198 + private void onNetworkSetting() {
199 +
200 + AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
201 + alertDialog.setTitle("GPS 사용유무셋팅");
202 + alertDialog.setMessage("GPS 셋팅이 되지 않았을수도 있습니다.\n설정창으로 가시겠습니까?");
203 + // OK 를 누르게 되면 설정창으로 이동합니다.
204 + alertDialog.setPositiveButton("Settings",
205 + new DialogInterface.OnClickListener() {
206 + public void onClick(DialogInterface dialog, int which) {
207 + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
208 + startActivity(intent);
209 + }
210 + });
211 + // Cancle 하면 종료 합니다.
212 + alertDialog.setNegativeButton("Cancel",
213 + new DialogInterface.OnClickListener() {
214 + public void onClick(DialogInterface dialog, int which) {
215 + dialog.cancel();
216 + }
217 + });
218 +
219 + alertDialog.show();
220 +
221 + }
222 +
223 +
224 + @Override
225 + protected void onActivityResult(int requestCode, int resultCode, Intent data) {
226 + super.onActivityResult(requestCode, resultCode, data);
227 + Log.d("승락 결과", "여기들어옴");
228 + }
229 +
230 +
231 + @Override
232 + protected void attachBaseContext(Context newBase) {
233 + super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
234 + }
235 +
236 + @Override
237 + protected void onPause() {
238 + super.onPause();
239 +
240 + }
241 +
242 + @Override
243 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
244 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
245 +
246 + // Forward results to EasyPermissions
247 + EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
248 + }
249 +
250 +
251 + @Override
252 + public void onPermissionsGranted(int requestCode, List<String> perms) {
253 +
254 + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
255 + != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
256 + return;
257 + }
258 + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, locationListener);
259 +
260 + }
261 +
262 + @Override
263 + public void onPermissionsDenied(int requestCode, List<String> perms) {
264 +
265 + }
266 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.content.Context;
4 +import android.content.Intent;
5 +import android.os.Bundle;
6 +import android.support.v7.app.AppCompatActivity;
7 +import android.util.Log;
8 +import android.view.View;
9 +import android.widget.EditText;
10 +import android.widget.TextView;
11 +import android.widget.Toast;
12 +
13 +import com.gunghi.tgwing.lolock.R;
14 +import com.gunghi.tgwing.lolock.Response.ResponseLoLockService;
15 +import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
16 +import com.gunghi.tgwing.lolock.network.LoLockService;
17 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
18 +import com.tsengvn.typekit.TypekitContextWrapper;
19 +
20 +import retrofit2.Call;
21 +import retrofit2.Callback;
22 +import retrofit2.Response;
23 +
24 +public class RegisterActivity extends AppCompatActivity {
25 +
26 + EditText inputIdText;
27 + TextView checkIdButton;
28 +
29 + LoLockService lockService;
30 +
31 + @Override
32 + protected void onCreate(Bundle savedInstanceState) {
33 + super.onCreate(savedInstanceState);
34 + setContentView(R.layout.activity_register);
35 +
36 + inputIdText = (EditText) findViewById(R.id.registerEditText);
37 + checkIdButton = (TextView) findViewById(R.id.checkLoraIdButton);
38 + checkIdButton.setOnClickListener(new View.OnClickListener() {
39 + @Override
40 + public void onClick(View v) {
41 + checkLoraId(inputIdText.getText().toString());
42 + }
43 + });
44 + //f0103d
45 + }
46 +
47 + @Override
48 + protected void attachBaseContext(Context newBase) {
49 + super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
50 + }
51 +
52 + private void checkLoraId(final String number) {
53 + Log.d("number",number);
54 + lockService = LoLockServiceGenarator.createService(LoLockService.class);
55 + //Call<ResponseBody> requestOpenDoor = lockService.remoteOnOffLock(number);
56 + Call<ResponseLoLockService> checkLoraIdService = lockService.checkLoraNumberId(number);
57 + checkLoraIdService.enqueue(new Callback<ResponseLoLockService>() {
58 + @Override
59 + public void onResponse(Call<ResponseLoLockService> call, Response<ResponseLoLockService> response) {
60 + Log.d("CheckLoraId API", String.valueOf(response.code()));
61 +
62 + if(response.isSuccessful() || response.body() != null) {
63 + if (response.body().getCode().equals("DEVICE_ID_AVAILABLE")) {
64 +
65 + Toast.makeText(getApplicationContext(),
66 + "인증이 완료되었습니다",Toast.LENGTH_SHORT).show();
67 +
68 + Intent intent = new Intent(RegisterActivity.this,Register2Activity.class);
69 + startActivity(intent);
70 + RegisterActivity.this.finish();
71 + RegisterUserInfo.getInstance().setRegisterDeviceId(number);
72 +
73 +
74 + } else {
75 + Toast.makeText(getApplicationContext(),
76 + "잘못된 일련번호가 입력되었습니다. 다시 입력해주세요",Toast.LENGTH_SHORT).show();
77 + }
78 + }
79 + }
80 +
81 + @Override
82 + public void onFailure(Call<ResponseLoLockService> call, Throwable t) {
83 + Toast.makeText(getApplicationContext(),
84 + "서버에서 응답이 오지 않습니다. 서버를 확인해주세요.",Toast.LENGTH_SHORT).show();
85 + }
86 + });
87 + }
88 +
89 +
90 +
91 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.app.Activity;
4 +import android.content.Context;
5 +import android.os.Bundle;
6 +import android.support.annotation.Nullable;
7 +import android.view.View;
8 +import android.widget.Button;
9 +import android.widget.ImageButton;
10 +
11 +import com.gunghi.tgwing.lolock.R;
12 +import com.tsengvn.typekit.TypekitContextWrapper;
13 +
14 +/**
15 + * Created by InKyung on 2017-07-19.
16 + */
17 +
18 +public class SettingActivity extends Activity {
19 + ImageButton backButton;
20 + Button lolockInfoButton,changeInfoButton,changeGps;
21 + @Override
22 + protected void onCreate(@Nullable Bundle savedInstanceState) {
23 + super.onCreate(savedInstanceState);
24 + setContentView(R.layout.setting);
25 +
26 + initView(savedInstanceState);
27 + }
28 +
29 + private void initView(Bundle savedInstanceState) {
30 + backButton=(ImageButton)findViewById(R.id.BackButton);
31 + backButton.setOnClickListener(new View.OnClickListener() {
32 + @Override
33 + public void onClick(View v) {
34 + finish();
35 + }
36 + });
37 +
38 + //3가지 버튼
39 + changeInfoButton=(Button)findViewById(R.id.ChangeInfoButton);
40 + lolockInfoButton=(Button)findViewById(R.id.LolockInfoButton);
41 + changeGps=(Button)findViewById(R.id.ChangeGps);
42 + }
43 +
44 + @Override
45 + protected void attachBaseContext(Context newBase) {
46 + super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
47 + }
48 +
49 +}
1 +package com.gunghi.tgwing.lolock.ui;
2 +
3 +import android.app.Activity;
4 +import android.content.Intent;
5 +import android.content.SharedPreferences;
6 +import android.graphics.Color;
7 +import android.os.Build;
8 +import android.os.Bundle;
9 +import android.support.annotation.Nullable;
10 +import android.support.annotation.RequiresApi;
11 +import android.util.Log;
12 +import android.view.Window;
13 +import android.view.WindowManager;
14 +import android.widget.Toast;
15 +
16 +import com.gunghi.tgwing.lolock.R;
17 +import com.gunghi.tgwing.lolock.Response.ResponseUserInfo;
18 +import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
19 +import com.gunghi.tgwing.lolock.model.UserInfo;
20 +import com.gunghi.tgwing.lolock.network.LoLockService;
21 +import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
22 +
23 +import retrofit2.Call;
24 +import retrofit2.Callback;
25 +import retrofit2.Response;
26 +
27 +/**
28 + * Created by InKyung on 2017-07-19.
29 + */
30 +
31 +public class SplashActivity extends Activity {
32 +
33 + private String freamgentFlag;
34 + // Code to manage Service lifecycle.
35 +
36 +
37 + @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
38 + @Override
39 + protected void onCreate(@Nullable Bundle savedInstanceState) {
40 + super.onCreate(savedInstanceState);
41 + setContentView(R.layout.splash);
42 + freamgentFlag = getIntent().getStringExtra("viewFragment");
43 + Log.d("spalash freamgentFlag",freamgentFlag +"zz");
44 +
45 + //상단바 색깔 바꾸기
46 + Window window = getWindow();
47 + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
48 + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
49 + window.setStatusBarColor(Color.parseColor("#FAAC42"));
50 +
51 + // 저장된 데이터 불러온다.!
52 + SharedPreferences sharedPreferences = getSharedPreferences("lolockLocalData", MODE_PRIVATE);
53 + final String deviceId = sharedPreferences.getString("deviceId", "");
54 + Log.d("deviceId",deviceId);
55 +
56 + if (deviceId.equals("")) {
57 + Intent registerIntent = new Intent(SplashActivity.this, RegisterActivity.class);
58 + SplashActivity.this.startActivity(registerIntent);
59 + SplashActivity.this.finish();
60 + } else {
61 + getUserInfo(deviceId);
62 + }
63 + }
64 +
65 + private void getUserInfo(final String deviceId) {
66 + RegisterUserInfo.getInstance().setRegisterUserPhoneId(deviceId);
67 + LoLockService lolockservice = LoLockServiceGenarator.createService(LoLockService.class);
68 + Call<ResponseUserInfo> responseUserInfo = lolockservice.getUserInfo(deviceId);
69 + responseUserInfo.enqueue(new Callback<ResponseUserInfo>() {
70 + @Override
71 + public void onResponse(Call<ResponseUserInfo> call, Response<ResponseUserInfo> response) {
72 +
73 + Log.d("response", String.valueOf(response.code()));
74 + if (response.isSuccessful()) {
75 + if (response.body().getCode().equals("REGISTRED")) {
76 + UserInfo tempUserInfo = response.body().getUserInfo();
77 + UserInfo.getInstance().setName(tempUserInfo.getName());
78 + UserInfo.getInstance().setLolockLTID(tempUserInfo.getLolockLTID());
79 + UserInfo.getInstance().setDevideId(deviceId);
80 +
81 + Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
82 + mainIntent.putExtra("viewFragment",freamgentFlag);
83 + SplashActivity.this.startActivity(mainIntent);
84 + SplashActivity.this.finish();
85 + } else {
86 + Intent registerIntent = new Intent(SplashActivity.this, RegisterActivity.class);
87 + SplashActivity.this.startActivity(registerIntent);
88 + SplashActivity.this.finish();
89 + }
90 + } else {
91 + Intent registerIntent = new Intent(SplashActivity.this, RegisterActivity.class);
92 + SplashActivity.this.startActivity(registerIntent);
93 + SplashActivity.this.finish();
94 + }
95 + }
96 +
97 + @Override
98 + public void onFailure(Call<ResponseUserInfo> call, Throwable t) {
99 + Toast.makeText(getApplicationContext(),"서버가 응답하지 않습니다.",Toast.LENGTH_SHORT).show();
100 + }
101 + });
102 + }
103 +
104 +
105 + @Override
106 + protected void onStop() {
107 + super.onStop();
108 + }
109 +
110 +}
1 +package com.gunghi.tgwing.lolock.util;
2 +
3 +import android.content.Intent;
4 +
5 +/**
6 + * Created by joyeongje on 2017. 7. 23..
7 + */
8 +
9 +public class ActivityResultEvent {
10 +
11 + private int requestCode;
12 + private int resultCode;
13 + private Intent data;
14 +
15 + public ActivityResultEvent(int requestCode, int resultCode, Intent data) {
16 + this.requestCode = requestCode;
17 + this.resultCode = resultCode;
18 + this.data = data;
19 + }
20 +
21 + public int getRequestCode() {
22 + return requestCode;
23 + }
24 +
25 + public void setRequestCode(int requestCode) {
26 + this.requestCode = requestCode;
27 + }
28 +
29 + public int getResultCode() {
30 + return resultCode;
31 + }
32 +
33 + public void setResultCode(int resultCode) {
34 + this.resultCode = resultCode;
35 + }
36 +
37 + public Intent getData() {
38 + return data;
39 + }
40 +
41 + public void setData(Intent data) {
42 + this.data = data;
43 + }
44 +}
45 +
1 +package com.gunghi.tgwing.lolock.util;
2 +
3 +import android.os.Handler;
4 +import android.os.Looper;
5 +
6 +import com.squareup.otto.Bus;
7 +
8 +/**
9 + * Created by joyeongje on 2017. 7. 23..
10 + */
11 +
12 +public class EventBus extends Bus {
13 +
14 + private static EventBus instance;
15 +
16 + public static EventBus getInstance() {
17 + if (instance == null) {
18 + synchronized (EventBus.class) {
19 + if (instance == null) {
20 + instance = new EventBus();
21 + }
22 + }
23 + }
24 + return instance;
25 + }
26 +
27 + private Handler handler = new Handler(Looper.getMainLooper());
28 +
29 + @Override
30 + public void post(final Object event) {
31 + if (Looper.myLooper() == Looper.getMainLooper()) {
32 + super.post(event);
33 + } else {
34 + handler.post(new Runnable() {
35 + @Override
36 + public void run() {
37 + EventBus.super.post(event);
38 + }
39 + });
40 + }
41 + }
42 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package com.gunghi.tgwing.lolock.util;
2 +
3 +import android.app.Application;
4 +
5 +import com.tsengvn.typekit.Typekit;
6 +
7 +/**
8 + * Created by young on 2017-07-02.
9 + */
10 +
11 +public class TypekitSetting extends Application {
12 +
13 + @Override
14 + public void onCreate() {
15 + super.onCreate();
16 +
17 + Typekit.getInstance()
18 + .addNormal(Typekit.createFromAsset(this, "NanumBarunpenR.ttf"))
19 + .addBold(Typekit.createFromAsset(this, "NanumBarunpenB.ttf"));
20 + }
21 +}
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
3 + <item>
4 + <shape android:shape="rectangle">
5 + <stroke android:width="1dp" android:color="#95989A" />
6 + <solid android:color="#FFFFFFFF" />
7 + </shape>
8 + </item>
9 +</layer-list>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:shape="rectangle" android:padding="10dp">
4 + <solid android:color="#ffff"/>
5 + <corners
6 + android:bottomRightRadius="5dp"
7 + android:bottomLeftRadius="5dp"
8 + android:topLeftRadius="5dp"
9 + android:topRightRadius="5dp"/>
10 +
11 +</shape>
12 +
13 +
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:orientation="vertical" android:layout_width="match_parent"
4 + android:layout_height="match_parent">
5 +
6 +</LinearLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 +
5 + xmlns:tools="http://schemas.android.com/tools"
6 + android:layout_width="match_parent"
7 + android:layout_height="match_parent"
8 + tools:context="com.gunghi.tgwing.lolock.ui.MainActivity">
9 +
10 + <TextView
11 + android:id="@+id/mainActivityTitleTextView"
12 + android:layout_width="wrap_content"
13 + android:layout_height="wrap_content"
14 + app:layout_constraintTop_toTopOf="parent"
15 + app:layout_constraintBottom_toTopOf="@+id/mainActivityToolbarBottomView"
16 + app:layout_constraintLeft_toLeftOf="parent"
17 + android:layout_marginLeft="18dp"
18 + android:text="출입문 Open/Closed"
19 + android:textColor="#FC7336"
20 + android:textStyle="bold"
21 + />
22 +
23 + <View
24 + android:id="@+id/mainActivityToolbarBottomView"
25 + android:layout_width="0dp"
26 + android:layout_height="2dp"
27 + android:background="#F7D081"
28 + app:layout_constraintTop_toTopOf="parent"
29 + app:layout_constraintLeft_toLeftOf="parent"
30 + app:layout_constraintRight_toRightOf="parent"
31 + android:layout_marginTop="48dp"
32 + />
33 +
34 + <ImageButton
35 + android:id="@+id/mainActivitySettingButton"
36 + android:layout_width="wrap_content"
37 + android:layout_height="wrap_content"
38 + android:background="@null"
39 + android:src="@drawable/ic_setting"
40 + app:layout_constraintTop_toTopOf="parent"
41 + app:layout_constraintBottom_toTopOf="@+id/mainActivityToolbarBottomView"
42 + app:layout_constraintRight_toRightOf="parent"
43 + android:layout_marginRight="18dp"
44 + android:layout_marginEnd="18dp"
45 + />
46 +
47 +
48 + <android.support.constraint.ConstraintLayout
49 + android:id="@+id/mainActivityFragmentContainer"
50 + android:layout_width="0dp"
51 + android:layout_height="0dp"
52 + app:layout_constraintLeft_toLeftOf="parent"
53 + app:layout_constraintRight_toRightOf="parent"
54 + app:layout_constraintTop_toBottomOf="@+id/mainActivityToolbarBottomView"
55 + app:layout_constraintBottom_toBottomOf="parent"
56 + android:layout_marginLeft="0dp"
57 + android:layout_marginRight="0dp"
58 + android:layout_marginTop="0dp"
59 + android:layout_marginBottom="0dp"
60 + >
61 + </android.support.constraint.ConstraintLayout>
62 +
63 +
64 +
65 +</android.support.constraint.ConstraintLayout>
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + xmlns:app="http://schemas.android.com/apk/res-auto">
6 +
7 + <TextView
8 + android:layout_width="wrap_content"
9 + android:layout_height="wrap_content"
10 + android:text="LoLock 기기 등록"
11 + app:layout_constraintLeft_toLeftOf="parent"
12 + app:layout_constraintRight_toRightOf="parent"
13 + app:layout_constraintTop_toTopOf="parent"
14 + android:layout_marginTop="48dp"
15 +
16 + />
17 +
18 + <TextView
19 + android:id="@+id/registActivityTextView"
20 + android:layout_width="wrap_content"
21 + android:layout_height="wrap_content"
22 + android:text="기기에 있는 일련번호를 입력해주세요"
23 + android:textColor="#FC6928"
24 + app:layout_constraintLeft_toLeftOf="parent"
25 + app:layout_constraintRight_toRightOf="parent"
26 + app:layout_constraintTop_toTopOf="parent"
27 + android:layout_marginTop="220dp"
28 + />
29 +
30 + <EditText
31 + android:id="@+id/registActivityDeviceIdTextView"
32 + android:layout_width="wrap_content"
33 + android:layout_height="wrap_content"
34 + android:textColorHighlight="#FC6928"
35 + app:layout_constraintLeft_toLeftOf="parent"
36 + app:layout_constraintRight_toRightOf="parent"
37 + app:layout_constraintTop_toBottomOf="@+id/registActivityTextView"
38 + />
39 +
40 +</android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 + xmlns:tools="http://schemas.android.com/tools"
5 + android:layout_width="match_parent"
6 + android:layout_height="match_parent"
7 + tools:context="com.gunghi.tgwing.lolock.ui.RegisterActivity">
8 +
9 + <TextView
10 + android:id="@+id/checkLoraIdButton"
11 + android:layout_width="wrap_content"
12 + android:layout_height="wrap_content"
13 + android:textColor="#FC7336"
14 + android:text="다음"
15 + android:textSize="20sp"
16 + app:layout_constraintTop_toTopOf="parent"
17 + app:layout_constraintRight_toRightOf="parent"
18 + android:layout_marginTop="17dp"
19 + android:layout_marginEnd="27dp"
20 + />
21 +
22 + <TextView
23 +
24 + android:layout_width="wrap_content"
25 + android:layout_height="wrap_content"
26 + android:textColor="#FC7336"
27 + android:text="LOLOCK 기기등록"
28 + android:textSize="24sp"
29 + android:textStyle="bold"
30 + app:layout_constraintLeft_toLeftOf="parent"
31 + app:layout_constraintRight_toRightOf="parent"
32 + app:layout_constraintTop_toTopOf="parent"
33 + android:layout_marginTop="110dp"
34 + />
35 +
36 + <ImageView
37 + android:id="@+id/registerCircleImageView"
38 + android:layout_width="wrap_content"
39 + android:layout_height="wrap_content"
40 + android:src="@drawable/ic_circle"
41 + app:layout_constraintLeft_toLeftOf="parent"
42 + app:layout_constraintRight_toRightOf="parent"
43 + app:layout_constraintTop_toTopOf="parent"
44 + android:layout_marginTop="165dp"
45 + />
46 +
47 + <TextView
48 + android:layout_width="wrap_content"
49 + android:layout_height="wrap_content"
50 + app:layout_constraintTop_toTopOf="@+id/registerCircleImageView"
51 + app:layout_constraintLeft_toLeftOf="@+id/registerCircleImageView"
52 + app:layout_constraintRight_toRightOf="@+id/registerCircleImageView"
53 + android:layout_marginTop="110dp"
54 + android:textColor="#FC7336"
55 + android:textSize="25sp"
56 + android:text="일련번호입력"
57 + />
58 +
59 + <EditText
60 + android:id="@+id/registerEditText"
61 + android:layout_width="wrap_content"
62 + android:layout_height="wrap_content"
63 + android:textColorHighlight="#FC7336"
64 + android:hint="6~8자리 숫자를 입력해주세요"
65 + android:textColorHint="#FC7336"
66 + android:layout_marginTop="160dp"
67 + android:textAlignment="center"
68 + app:layout_constraintTop_toTopOf="@+id/registerCircleImageView"
69 + app:layout_constraintLeft_toLeftOf="@+id/registerCircleImageView"
70 + app:layout_constraintRight_toRightOf="@+id/registerCircleImageView"
71 + />
72 +
73 +</android.support.constraint.ConstraintLayout>
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 + xmlns:tools="http://schemas.android.com/tools"
5 + android:layout_width="match_parent"
6 + android:layout_height="match_parent"
7 + tools:context="com.gunghi.tgwing.lolock.ui.Register2Activity">
8 +
9 + <TextView
10 + android:layout_width="wrap_content"
11 + android:layout_height="wrap_content"
12 + app:layout_constraintLeft_toLeftOf="parent"
13 + app:layout_constraintRight_toRightOf="parent"
14 + app:layout_constraintTop_toTopOf="parent"
15 + android:text="프로필 입력"
16 + android:textSize="20sp"
17 + android:textStyle="bold"
18 + android:textColor="#FC6928"
19 + android:layout_marginTop="35dp"
20 + />
21 +
22 + <ImageView
23 + android:layout_width="wrap_content"
24 + android:layout_height="wrap_content"
25 + app:layout_constraintLeft_toLeftOf="parent"
26 + app:layout_constraintRight_toRightOf="parent"
27 + app:layout_constraintTop_toTopOf="parent"
28 + android:layout_marginTop="100dp"
29 + android:src="@drawable/ic_profile_basic"
30 + />
31 +
32 + <TextView
33 + android:layout_width="wrap_content"
34 + android:layout_height="wrap_content"
35 + app:layout_constraintLeft_toLeftOf="parent"
36 + app:layout_constraintRight_toRightOf="parent"
37 + app:layout_constraintTop_toTopOf="parent"
38 + android:layout_marginTop="220dp"
39 + android:textStyle="bold"
40 + android:text="이름"
41 + android:textSize="20sp"
42 +
43 + />
44 +
45 + <EditText
46 + android:id="@+id/editTextName"
47 + android:layout_width="0dp"
48 + android:layout_height="wrap_content"
49 + android:hint="이름을 입력해주세요"
50 + android:textAlignment="center"
51 + android:textSize="20sp"
52 + app:layout_constraintLeft_toLeftOf="parent"
53 + app:layout_constraintRight_toRightOf="parent"
54 + app:layout_constraintTop_toTopOf="parent"
55 + android:layout_marginTop="260dp"
56 + android:layout_marginLeft="96.5dp"
57 + android:layout_marginRight="96.5dp"
58 +
59 + />
60 +
61 + <TextView
62 + android:layout_width="wrap_content"
63 + android:layout_height="wrap_content"
64 + app:layout_constraintLeft_toLeftOf="parent"
65 + app:layout_constraintRight_toRightOf="parent"
66 + app:layout_constraintTop_toTopOf="parent"
67 + android:text="주소"
68 + android:textSize="20sp"
69 + android:textStyle="bold"
70 + android:layout_marginTop="310dp"
71 + />
72 +
73 + <EditText
74 + android:id="@+id/editTextAddress"
75 + android:layout_width="0dp"
76 + android:layout_height="wrap_content"
77 + android:hint="주소를 입력해주세요"
78 + android:textAlignment="center"
79 + android:textSize="20sp"
80 + app:layout_constraintLeft_toLeftOf="parent"
81 + app:layout_constraintRight_toRightOf="parent"
82 + app:layout_constraintTop_toTopOf="parent"
83 + android:layout_marginTop="345dp"
84 + android:layout_marginLeft="46.5dp"
85 + android:layout_marginRight="46.5dp"
86 + />
87 +
88 + <Button
89 + android:id="@+id/register2ActivityButton"
90 + android:layout_width="wrap_content"
91 + android:layout_height="wrap_content"
92 + android:text="완료"
93 + app:layout_constraintRight_toRightOf="parent"
94 + app:layout_constraintTop_toTopOf="parent"
95 + android:layout_marginTop="20dp"
96 + android:layout_marginRight="20dp"
97 + />
98 +
99 +
100 +</android.support.constraint.ConstraintLayout>
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 + xmlns:tools="http://schemas.android.com/tools"
5 + android:layout_width="match_parent"
6 + android:layout_height="match_parent"
7 + tools:context="com.gunghi.tgwing.lolock.ui.TutorialActivity">
8 +
9 +</android.support.constraint.ConstraintLayout>
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="72dp"
5 + xmlns:app="http://schemas.android.com/apk/res-auto"
6 + android:background="#FFFFFF"
7 + android:id="@+id/cardAlarm"
8 + android:layout_marginBottom="0.5dp">
9 +
10 +
11 + <ImageView
12 + android:id="@+id/icAlarmImageView"
13 + android:layout_width="wrap_content"
14 + android:layout_height="wrap_content"
15 + android:src="@drawable/ic_alarm_unknown"
16 + app:layout_constraintTop_toTopOf="parent"
17 + app:layout_constraintBottom_toBottomOf="parent"
18 + app:layout_constraintLeft_toLeftOf="parent"
19 + android:layout_marginStart="16dp"
20 + />
21 +
22 + <TextView
23 + android:id="@+id/inOutName"
24 + android:layout_width="wrap_content"
25 + android:layout_height="wrap_content"
26 + android:text="이종구(아들)이 외출하셨습니다."
27 + app:layout_constraintLeft_toLeftOf="parent"
28 + app:layout_constraintTop_toTopOf="parent"
29 + android:layout_marginStart="72dp"
30 + android:layout_marginTop="15dp"
31 +
32 +
33 + />
34 +
35 + <TextView
36 + android:id="@+id/inOutTime"
37 + android:layout_width="wrap_content"
38 + android:layout_height="wrap_content"
39 + android:text="12분전"
40 + app:layout_constraintLeft_toLeftOf="parent"
41 + app:layout_constraintTop_toTopOf="parent"
42 + android:layout_marginStart="72dp"
43 + android:layout_marginTop="40dp"
44 + />
45 +
46 + <TextView
47 + android:id="@+id/inOutDate"
48 + android:layout_width="wrap_content"
49 + android:layout_height="wrap_content"
50 + android:text="05/12 (수)"
51 + app:layout_constraintTop_toTopOf="parent"
52 + app:layout_constraintBottom_toBottomOf="parent"
53 + app:layout_constraintRight_toRightOf="parent"
54 + android:layout_marginEnd="16dp"
55 + />
56 +
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"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="72dp"
5 + xmlns:app="http://schemas.android.com/apk/res-auto"
6 + android:background="#FFFFFF"
7 + android:layout_marginBottom="0.5dp"
8 + >
9 +
10 + <de.hdodenhof.circleimageview.CircleImageView
11 + android:id="@+id/mateProfileImageView"
12 + android:layout_width="54dp"
13 + android:layout_height="54dp"
14 + app:layout_constraintTop_toTopOf="parent"
15 + app:layout_constraintBottom_toBottomOf="parent"
16 + app:layout_constraintLeft_toLeftOf="parent"
17 + android:layout_marginLeft="16dp"
18 + android:layout_marginStart="16dp"
19 + android:src="@drawable/ic_sample_profile"
20 + />
21 +
22 + <TextView
23 + android:id="@+id/mateNameTextView"
24 + android:layout_width="wrap_content"
25 + android:layout_height="wrap_content"
26 + android:text="큰 딸"
27 + android:textSize="16sp"
28 + android:textColor="#FC7336"
29 + app:layout_constraintTop_toTopOf="@+id/mateProfileImageView"
30 + app:layout_constraintLeft_toRightOf="@+id/mateProfileImageView"
31 + android:layout_marginLeft="8dp"
32 + />
33 +
34 + <TextView
35 + android:id="@+id/mateOutingTimeTextView"
36 + android:layout_width="wrap_content"
37 + android:layout_height="wrap_content"
38 + android:text="20분 전에 출입했습니다."
39 + android:textSize="14sp"
40 + android:textColor="#313131"
41 + app:layout_constraintBottom_toBottomOf="@+id/mateProfileImageView"
42 + app:layout_constraintLeft_toRightOf="@+id/mateProfileImageView"
43 + android:layout_marginLeft="8dp"
44 + />
45 +
46 + <ImageView
47 + android:id="@+id/mateOutingFlag"
48 + android:layout_width="wrap_content"
49 + android:layout_height="wrap_content"
50 + android:src="@drawable/ic_out_home"
51 + app:layout_constraintTop_toTopOf="parent"
52 + app:layout_constraintRight_toRightOf="parent"
53 + android:layout_marginRight="16dp"
54 + android:layout_marginTop="16dp"
55 + />
56 +
57 +
58 +</android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="35dp"
5 + android:id="@+id/cardSchedule"
6 + xmlns:app="http://schemas.android.com/apk/res-auto">
7 +
8 + <TextView
9 + android:id="@+id/schedularName"
10 + android:layout_width="0dp"
11 + android:layout_height="wrap_content"
12 + app:layout_constraintLeft_toLeftOf="parent"
13 + app:layout_constraintTop_toTopOf="parent"
14 + android:layout_marginStart="27dp"
15 + android:layout_marginTop="10dp"
16 + android:text="SKT LoLock 회의"
17 + android:textSize="14sp"
18 + android:textColor="#95989A"
19 + />
20 +
21 + <TextView
22 + android:id="@+id/schedularTime"
23 + android:layout_width="0dp"
24 + android:layout_height="wrap_content"
25 + app:layout_constraintRight_toRightOf="parent"
26 + app:layout_constraintTop_toTopOf="parent"
27 + android:layout_marginEnd="29dp"
28 + android:layout_marginTop="10dp"
29 + android:text="7:30"
30 + android:textSize="14sp"
31 + android:textColor="#95989A"
32 + />
33 +
34 + <View
35 + android:layout_width="0dp"
36 + android:layout_height="1dp"
37 + android:background="#95989A"
38 + app:layout_constraintLeft_toLeftOf="parent"
39 + app:layout_constraintRight_toRightOf="parent"
40 + app:layout_constraintTop_toTopOf="parent"
41 + android:layout_marginTop="33dp"
42 + android:layout_marginLeft="25dp"
43 + android:layout_marginRight="25dp"
44 + />
45 +
46 +</android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + xmlns:app="http://schemas.android.com/apk/res-auto">
6 +
7 +
8 + <View
9 + android:id="@+id/dialog_open_code_view"
10 + android:layout_width="325dp"
11 + android:layout_height="160dp"
12 + app:layout_constraintLeft_toLeftOf="parent"
13 + app:layout_constraintRight_toRightOf="parent"
14 + app:layout_constraintBottom_toBottomOf="parent"
15 + app:layout_constraintTop_toTopOf="parent"
16 + android:background="@drawable/rounded_rectangle"
17 + />
18 +
19 + <TextView
20 + android:layout_width="wrap_content"
21 + android:layout_height="wrap_content"
22 + android:text="일회용 키 발급"
23 + android:textSize="18sp"
24 + android:textColor="#FC7336"
25 + app:layout_constraintTop_toTopOf="@+id/dialog_open_code_view"
26 + app:layout_constraintRight_toRightOf="@+id/dialog_open_code_view"
27 + app:layout_constraintLeft_toLeftOf="@+id/dialog_open_code_view"
28 + android:layout_marginTop="14dp"
29 + />
30 +
31 + <TextView
32 + android:id="@+id/openCodeTextView"
33 + android:layout_width="wrap_content"
34 + android:layout_height="wrap_content"
35 + app:layout_constraintTop_toTopOf="@+id/dialog_open_code_view"
36 + app:layout_constraintRight_toRightOf="@+id/dialog_open_code_view"
37 + app:layout_constraintLeft_toLeftOf="@+id/dialog_open_code_view"
38 + android:paddingLeft="10dp"
39 + android:paddingRight="10dp"
40 + android:layout_marginTop="50dp"
41 + android:textSize="16sp"
42 + android:textColor="#4D5051"
43 + android:text="새로운 링크를 받아오고 있습니다."
44 + />
45 +
46 + <View
47 + android:id="@+id/openCodeDialogHorizonGuide"
48 + android:layout_width="0dp"
49 + android:layout_height="1dp"
50 + android:background="#95989A"
51 + app:layout_constraintTop_toTopOf="@+id/dialog_open_code_view"
52 + app:layout_constraintRight_toRightOf="@+id/dialog_open_code_view"
53 + app:layout_constraintLeft_toLeftOf="@+id/dialog_open_code_view"
54 + android:layout_marginTop="100dp"
55 + android:layout_marginLeft="17.5dp"
56 + android:layout_marginRight="17.5dp"/>
57 +
58 + <View
59 + android:id="@+id/openCodeDialogVerticalGuide"
60 + android:layout_width="1dp"
61 + android:layout_height="45dp"
62 + android:background="#4D5051"
63 + app:layout_constraintTop_toBottomOf="@+id/openCodeDialogHorizonGuide"
64 + app:layout_constraintBottom_toBottomOf="@+id/dialog_open_code_view"
65 + app:layout_constraintRight_toRightOf="@+id/dialog_open_code_view"
66 + app:layout_constraintLeft_toLeftOf="@+id/dialog_open_code_view"/>
67 +
68 + <Button
69 + android:id="@+id/openCodePasteButton"
70 + android:layout_width="wrap_content"
71 + android:layout_height="wrap_content"
72 + app:layout_constraintTop_toBottomOf="@+id/openCodeDialogHorizonGuide"
73 + app:layout_constraintBottom_toBottomOf="@+id/dialog_open_code_view"
74 + app:layout_constraintRight_toRightOf="@+id/openCodeDialogVerticalGuide"
75 + app:layout_constraintLeft_toLeftOf="@+id/dialog_open_code_view"
76 + android:layout_marginTop="0dp"
77 + android:layout_marginLeft="0dp"
78 + android:layout_marginRight="0dp"
79 + android:layout_marginBottom="0dp"
80 + android:background="@null"
81 + android:text="복사하기"
82 + android:textSize="20sp"
83 + android:textColor="#FC7336"/>
84 +
85 + <Button
86 + android:id="@+id/openCodeSendButton"
87 + android:layout_width="wrap_content"
88 + android:layout_height="wrap_content"
89 + app:layout_constraintTop_toBottomOf="@+id/openCodeDialogHorizonGuide"
90 + app:layout_constraintBottom_toBottomOf="@+id/dialog_open_code_view"
91 + app:layout_constraintRight_toRightOf="@+id/dialog_open_code_view"
92 + app:layout_constraintLeft_toLeftOf="@+id/openCodeDialogVerticalGuide"
93 + android:layout_marginTop="0dp"
94 + android:layout_marginLeft="0dp"
95 + android:layout_marginRight="0dp"
96 + android:layout_marginBottom="0dp"
97 + android:background="@null"
98 + android:text="보내기"
99 + android:textSize="20sp"
100 + android:textColor="#FC7336"/>
101 +
102 +</android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.v4.widget.NestedScrollView
3 + xmlns:android="http://schemas.android.com/apk/res/android"
4 + xmlns:tools="http://schemas.android.com/tools"
5 + android:layout_width="match_parent"
6 + android:layout_height="wrap_content"
7 + android:fillViewport="true">
8 +
9 + <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
10 + android:layout_width="match_parent"
11 + android:layout_height="match_parent"
12 + xmlns:app="http://schemas.android.com/apk/res-auto">
13 + <android.support.v7.widget.RecyclerView
14 + android:id="@+id/fragmentAlarmRecyclerView"
15 + android:layout_width="0dp"
16 + android:layout_height="wrap_content"
17 + app:layout_constraintLeft_toLeftOf="parent"
18 + app:layout_constraintRight_toRightOf="parent"
19 + app:layout_constraintTop_toTopOf="parent"
20 + >
21 + </android.support.v7.widget.RecyclerView>
22 +
23 + </android.support.constraint.ConstraintLayout>
24 +
25 +</android.support.v4.widget.NestedScrollView>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + xmlns:app="http://schemas.android.com/apk/res-auto">
6 +
7 + <ImageButton
8 + android:id="@+id/fragmentDoorOnOffButton"
9 + android:layout_width="wrap_content"
10 + android:layout_height="wrap_content"
11 + app:layout_constraintLeft_toLeftOf="parent"
12 + app:layout_constraintRight_toRightOf="parent"
13 + app:layout_constraintTop_toTopOf="parent"
14 + app:layout_constraintBottom_toBottomOf="parent"
15 + android:background="@null"
16 + android:src="@drawable/ic_door_open"
17 + />
18 +
19 + <ImageButton
20 + android:id="@+id/fragmentDoorCodeKeyButton"
21 + android:layout_width="wrap_content"
22 + android:layout_height="wrap_content"
23 + android:src="@drawable/ic_key_on_new"
24 + app:layout_constraintBottom_toBottomOf="parent"
25 + app:layout_constraintRight_toRightOf="parent"
26 + android:layout_marginEnd="25dp"
27 + android:layout_marginBottom="70dp"
28 + android:background="@null"
29 + />
30 +
31 +
32 +</android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + xmlns:app="http://schemas.android.com/apk/res-auto">
6 +
7 +
8 + <ImageView
9 + android:id="@+id/fragmentInfoWeatherMiniIcon"
10 + android:layout_width="wrap_content"
11 + android:layout_height="wrap_content"
12 + android:src="@drawable/ic_weather_mini"
13 + app:layout_constraintTop_toTopOf="parent"
14 + app:layout_constraintLeft_toLeftOf="parent"
15 + android:layout_marginTop="40dp"
16 + android:layout_marginStart="32dp"
17 + />
18 +
19 + <TextView
20 + android:layout_width="wrap_content"
21 + android:layout_height="wrap_content"
22 + android:textSize="16sp"
23 + android:text="날씨"
24 + android:textColor="#424241"
25 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherMiniIcon"
26 + app:layout_constraintBottom_toBottomOf="@+id/fragmentInfoWeatherMiniIcon"
27 + app:layout_constraintLeft_toLeftOf="parent"
28 + android:layout_marginStart="65dp"
29 + />
30 +
31 + <View
32 + android:id="@+id/fragmentInfoWeatherView"
33 + android:layout_width="0dp"
34 + android:layout_height="100dp"
35 + android:background="@drawable/fragment_info_view_holder"
36 + app:layout_constraintLeft_toLeftOf="parent"
37 + app:layout_constraintRight_toRightOf="parent"
38 + app:layout_constraintTop_toTopOf="parent"
39 + android:layout_marginTop="75dp"
40 + android:layout_marginLeft="25dp"
41 + android:layout_marginRight="25dp"
42 + />
43 +
44 + <ImageView
45 + android:id="@+id/fragmentInfoWeatherIcon"
46 + android:layout_width="wrap_content"
47 + android:layout_height="wrap_content"
48 + app:layout_constraintLeft_toLeftOf="@+id/fragmentInfoWeatherView"
49 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherView"
50 + app:layout_constraintBottom_toBottomOf="@+id/fragmentInfoWeatherView"
51 + android:layout_marginStart="16dp"
52 + android:src="@drawable/ic_weather_cloud"
53 + />
54 +
55 + <TextView
56 + android:id="@+id/fragmentInfoWeatherLocale"
57 + android:layout_width="wrap_content"
58 + android:layout_height="wrap_content"
59 + android:text="수원시"
60 + app:layout_constraintLeft_toLeftOf="@+id/fragmentInfoWeatherView"
61 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherView"
62 + android:layout_marginTop="18dp"
63 + android:layout_marginStart="90dp"
64 + android:textColor="#FC6828"
65 + android:textSize="20dp"
66 + />
67 +
68 + <TextView
69 + android:id="@+id/fragmentInfoCloudAmount"
70 + android:layout_width="wrap_content"
71 + android:layout_height="wrap_content"
72 + android:text="흐림"
73 + android:textSize="14sp"
74 + android:textColor="#95989A"
75 + app:layout_constraintLeft_toLeftOf="@+id/fragmentInfoWeatherView"
76 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherView"
77 + android:layout_marginTop="50dp"
78 + android:layout_marginStart="90dp"
79 + />
80 +
81 + <TextView
82 + android:id="@+id/fragmentInfoRainPercent"
83 + android:layout_width="wrap_content"
84 + android:layout_height="wrap_content"
85 + android:text="강수확률 : 10%"
86 + android:textSize="14sp"
87 + android:textColor="#95989A"
88 + app:layout_constraintLeft_toLeftOf="@+id/fragmentInfoWeatherView"
89 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherView"
90 + android:layout_marginTop="65dp"
91 + android:layout_marginStart="90dp"
92 + />
93 +
94 + <TextView
95 + android:id="@+id/fragmentInfoCurrentTemparature"
96 + android:layout_width="wrap_content"
97 + android:layout_height="wrap_content"
98 + android:textColor="#FC6928"
99 + android:textSize="40dp"
100 + android:textStyle="bold"
101 + android:text= "21℃"
102 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherView"
103 + app:layout_constraintRight_toRightOf="@+id/fragmentInfoWeatherView"
104 + android:layout_marginTop="15dp"
105 + android:layout_marginEnd="17dp"
106 + />
107 +
108 + <TextView
109 + android:id="@+id/fragmentInfoCurrentMaxMinTemparature"
110 + android:layout_width="wrap_content"
111 + android:layout_height="wrap_content"
112 + android:text="11℃ / 22℃"
113 + android:textSize="14sp"
114 + android:textColor="#95989A"
115 + app:layout_constraintTop_toTopOf="@+id/fragmentInfoWeatherView"
116 + app:layout_constraintRight_toRightOf="@+id/fragmentInfoWeatherView"
117 + android:layout_marginTop="64dp"
118 + android:layout_marginEnd="22dp"
119 + />
120 +
121 + <ImageView
122 + android:id="@+id/imageViewminiAlarm"
123 + android:layout_width="wrap_content"
124 + android:layout_height="wrap_content"
125 + android:src="@drawable/ic_alarm_mini"
126 + app:layout_constraintTop_toTopOf="parent"
127 + app:layout_constraintLeft_toLeftOf="parent"
128 + android:layout_marginStart="32dp"
129 + android:layout_marginTop="210dp"
130 + />
131 +
132 + <TextView
133 + android:layout_width="wrap_content"
134 + android:layout_height="wrap_content"
135 + android:text="오늘의 일정"
136 + android:textSize="16sp"
137 + android:textColor="#424241"
138 + android:layout_marginStart="65dp"
139 + app:layout_constraintTop_toTopOf="@+id/imageViewminiAlarm"
140 + app:layout_constraintBottom_toBottomOf="@+id/imageViewminiAlarm"
141 + app:layout_constraintLeft_toLeftOf="parent"
142 + />
143 +
144 + <View
145 + android:layout_width="0dp"
146 + android:layout_height="2dp"
147 + android:background="#95989A"
148 + app:layout_constraintLeft_toLeftOf="parent"
149 + app:layout_constraintRight_toRightOf="parent"
150 + app:layout_constraintTop_toBottomOf="@+id/imageViewminiAlarm"
151 + android:layout_marginTop="12dp"
152 + android:layout_marginLeft="25dp"
153 + android:layout_marginRight="25dp"
154 + />
155 +
156 + <TextView
157 + android:id="@+id/infoDateTextView"
158 + android:layout_width="wrap_content"
159 + android:layout_height="wrap_content"
160 + android:text="7월 30일 일요일"
161 + app:layout_constraintLeft_toLeftOf="parent"
162 + app:layout_constraintTop_toBottomOf="@+id/imageViewminiAlarm"
163 + android:layout_marginStart="27dp"
164 + android:layout_marginTop="28dp"
165 + />
166 +
167 +
168 + <android.support.v7.widget.RecyclerView
169 + android:id="@+id/schedularRecyclerView"
170 + android:layout_width="0dp"
171 + android:layout_height="wrap_content"
172 + app:layout_constraintLeft_toLeftOf="parent"
173 + app:layout_constraintRight_toRightOf="parent"
174 + app:layout_constraintTop_toBottomOf="@+id/imageViewminiAlarm"
175 + android:layout_marginTop="60dp"
176 + >
177 + </android.support.v7.widget.RecyclerView>
178 +
179 +
180 +</android.support.constraint.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<android.support.v4.widget.NestedScrollView
3 + xmlns:android="http://schemas.android.com/apk/res/android"
4 + xmlns:tools="http://schemas.android.com/tools"
5 + android:layout_width="match_parent"
6 + android:layout_height="wrap_content"
7 + android:fillViewport="true">
8 +
9 +<android.support.constraint.ConstraintLayout
10 + android:layout_width="match_parent"
11 + android:layout_height="match_parent"
12 + android:background="#FFFFFF"
13 + xmlns:app="http://schemas.android.com/apk/res-auto">
14 +
15 + <TextView
16 + android:id="@+id/mateNumberTextView"
17 + android:layout_width="wrap_content"
18 + android:layout_height="wrap_content"
19 + android:text="가족"
20 + android:textSize="14sp"
21 + android:textColor="#95989A"
22 + app:layout_constraintTop_toTopOf="parent"
23 + app:layout_constraintBottom_toTopOf="@+id/fragmentMateGuideline"
24 + app:layout_constraintLeft_toLeftOf="parent"
25 + android:layout_marginStart="16dp"
26 + />
27 +
28 + <View
29 + android:id="@+id/fragmentMateGuideline"
30 + android:layout_width="0dp"
31 + android:layout_height="1dp"
32 + android:background="#95989A"
33 + app:layout_constraintTop_toTopOf="parent"
34 + app:layout_constraintLeft_toLeftOf="parent"
35 + app:layout_constraintRight_toRightOf="parent"
36 + android:layout_marginTop="50dp"
37 + />
38 +
39 + <android.support.v7.widget.RecyclerView
40 + android:id="@+id/fragmentFamiliyRecyclerView"
41 + android:layout_width="0dp"
42 + android:layout_height="wrap_content"
43 + app:layout_constraintLeft_toLeftOf="parent"
44 + app:layout_constraintRight_toRightOf="parent"
45 + app:layout_constraintTop_toBottomOf="@+id/fragmentMateGuideline"
46 + android:background="#95989A"
47 + >
48 +
49 + </android.support.v7.widget.RecyclerView>
50 +
51 +
52 +</android.support.constraint.ConstraintLayout>
53 +</android.support.v4.widget.NestedScrollView>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent">
5 +
6 +<ImageButton
7 + android:id="@+id/BackButton"
8 + android:layout_width="wrap_content"
9 + android:layout_height="wrap_content"
10 + android:layout_marginLeft="25.5dp"
11 + android:layout_marginTop="20.5dp"
12 + android:background="@drawable/setting_back"
13 + />
14 + <TextView
15 + android:layout_width="wrap_content"
16 + android:layout_height="wrap_content"
17 + android:layout_marginLeft="65dp"
18 + android:layout_marginTop="18dp"
19 + android:text="설정하기"
20 + android:textColor="#FAAC42"
21 + android:textSize="20sp"
22 + />
23 + <ImageView
24 + android:layout_width="wrap_content"
25 + android:layout_height="wrap_content"
26 + android:layout_marginTop="53dp"
27 + android:background="@drawable/setting_long_line"
28 + />
29 + <ImageView
30 + android:id="@+id/settingpeople"
31 + android:layout_width="wrap_content"
32 + android:layout_height="wrap_content"
33 + android:layout_marginTop="132dp"
34 + android:layout_centerHorizontal="true"
35 + android:background="@drawable/setting_people"
36 + />
37 + <TextView
38 + android:layout_width="wrap_content"
39 + android:layout_height="wrap_content"
40 + android:layout_below="@+id/settingpeople"
41 + android:layout_centerHorizontal="true"
42 + android:layout_marginTop="12dp"
43 + android:id="@+id/name"
44 + android:text="김지윤"
45 + android:textSize="20sp"
46 + />
47 +
48 + <ImageView
49 + android:id="@+id/settingshortline1"
50 + android:layout_width="wrap_content"
51 + android:layout_height="wrap_content"
52 + android:layout_marginTop="310.5dp"
53 + android:layout_marginLeft="20dp"
54 + android:background="@drawable/setting_short_line"
55 + />
56 +
57 + <ImageView
58 + android:id="@+id/setting_login2"
59 + android:layout_width="wrap_content"
60 + android:layout_height="wrap_content"
61 + android:layout_below="@+id/settingshortline1"
62 +
63 + android:layout_marginTop="15.5dp"
64 + android:layout_marginLeft="26.4dp"
65 + android:background="@drawable/setting_login2"
66 + />
67 + <ImageView
68 + android:id="@+id/setting_login"
69 + android:layout_width="wrap_content"
70 + android:layout_height="wrap_content"
71 + android:layout_alignLeft="@+id/settingshortline1"
72 + android:layout_below="@+id/setting_login2"
73 + android:background="@drawable/setting_login"
74 + />
75 + <Button
76 + android:layout_width="wrap_content"
77 + android:layout_height="wrap_content"
78 + android:layout_marginLeft="70dp"
79 + android:layout_below="@+id/settingshortline1"
80 + android:layout_alignBottom="@+id/settingshortline2"
81 + android:text="자동 문열림 on/off"
82 + android:background="#00ff0000"
83 + android:textSize="20sp"
84 + />
85 +
86 +
87 + <Switch
88 + android:layout_width="wrap_content"
89 + android:layout_height="wrap_content"
90 + android:layout_marginLeft="297dp"
91 + android:layout_marginTop="329dp"
92 + />
93 +
94 + <ImageView
95 + android:id="@+id/settingshortline2"
96 + android:layout_width="wrap_content"
97 + android:layout_height="wrap_content"
98 + android:layout_marginTop="365.5dp"
99 + android:layout_marginLeft="20dp"
100 + android:background="@drawable/setting_blcak_short_line"
101 + />
102 + <ImageView
103 + android:layout_width="wrap_content"
104 + android:layout_height="wrap_content"
105 + android:layout_below="@+id/settingshortline2"
106 + android:layout_marginTop="15.5dp"
107 + android:layout_alignLeft="@+id/settingshortline2"
108 + android:background="@drawable/setting_info"
109 + />
110 + <Button
111 + android:id="@+id/ChangeInfoButton"
112 + android:layout_width="wrap_content"
113 + android:layout_height="wrap_content"
114 + android:layout_marginLeft="70dp"
115 + android:layout_below="@+id/settingshortline2"
116 + android:layout_alignBottom="@+id/settingshortline3"
117 + android:text="동거인 정보수정"
118 + android:background="#00ff0000"
119 + android:textSize="20sp"
120 + />
121 +
122 +
123 +
124 + <ImageView
125 + android:id="@+id/settingshortline3"
126 + android:layout_width="wrap_content"
127 + android:layout_height="wrap_content"
128 + android:layout_marginTop="420.5dp"
129 + android:layout_marginLeft="20dp"
130 + android:background="@drawable/setting_blcak_short_line"
131 + />
132 +
133 + <ImageView
134 + android:id="@+id/pencil"
135 + android:layout_width="wrap_content"
136 + android:layout_height="wrap_content"
137 + android:layout_below="@+id/settingshortline3"
138 + android:layout_marginTop="15.5dp"
139 + android:layout_alignLeft="@+id/settingshortline3"
140 + android:background="@drawable/setting_pencil"
141 + />
142 + <Button
143 + android:id="@+id/LolockInfoButton"
144 + android:layout_width="wrap_content"
145 + android:layout_height="wrap_content"
146 + android:layout_marginLeft="70dp"
147 + android:layout_below="@+id/settingshortline3"
148 + android:layout_alignBottom="@+id/settingshortline4"
149 + android:text="LOLOCK정보"
150 + android:background="#00ff0000"
151 + android:textSize="20sp"
152 + />
153 +
154 +
155 + <ImageView
156 + android:id="@+id/settingshortline4"
157 + android:layout_width="wrap_content"
158 + android:layout_height="wrap_content"
159 + android:layout_marginTop="470.5dp"
160 + android:layout_marginLeft="20dp"
161 + android:background="@drawable/setting_blcak_short_line"
162 + />
163 + <ImageView
164 + android:layout_width="wrap_content"
165 + android:layout_height="wrap_content"
166 + android:layout_below="@+id/settingshortline4"
167 + android:layout_marginTop="15.5dp"
168 + android:layout_alignLeft="@+id/settingshortline4"
169 + android:background="@drawable/setting_gps"
170 + />
171 + <Button
172 + android:id="@+id/ChangeGps"
173 + android:layout_width="wrap_content"
174 + android:layout_height="wrap_content"
175 + android:layout_marginLeft="70dp"
176 + android:layout_below="@+id/settingshortline4"
177 + android:layout_alignBottom="@+id/settingshortline5"
178 + android:background="#00ff0000"
179 + android:text="LOLOCK 위치 수정"
180 + android:textSize="20sp"
181 + />
182 +
183 + <ImageView
184 + android:id="@+id/settingshortline5"
185 + android:layout_width="wrap_content"
186 + android:layout_height="wrap_content"
187 + android:layout_marginTop="529dp"
188 + android:layout_marginLeft="20dp"
189 + android:background="@drawable/setting_blcak_short_line"
190 + />
191 +
192 +</RelativeLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:layout_width="match_parent"
4 + android:layout_height="match_parent"
5 + android:background="#FAAC42"
6 + >
7 +<ImageView
8 + android:layout_width="wrap_content"
9 + android:layout_height="wrap_content"
10 + android:layout_centerInParent="true"
11 + android:background="@drawable/splash_circle"
12 + />
13 + <ImageView
14 + android:layout_width="wrap_content"
15 + android:layout_height="wrap_content"
16 + android:layout_alignLeft="@+id/lolock"
17 + android:layout_above="@+id/lolock"
18 + android:background="@drawable/splash_lora"
19 + />
20 + <ImageView
21 + android:layout_width="wrap_content"
22 + android:layout_height="wrap_content"
23 + android:layout_alignRight="@+id/lolock"
24 + android:layout_above="@+id/lolock"
25 + android:layout_marginBottom="16.5dp"
26 + android:background="@drawable/splash_line"
27 + />
28 + <ImageView
29 + android:id="@+id/lolock"
30 + android:layout_width="wrap_content"
31 + android:layout_height="wrap_content"
32 + android:layout_centerInParent="true"
33 + android:background="@drawable/splash_lolock"
34 + />
35 + <ImageView
36 + android:layout_width="wrap_content"
37 + android:layout_height="wrap_content"
38 + android:layout_alignRight="@+id/lolock"
39 + android:layout_below="@+id/lolock"
40 + android:background="@drawable/splash_lora"
41 + />
42 + <ImageView
43 + android:layout_width="wrap_content"
44 + android:layout_height="wrap_content"
45 + android:layout_alignLeft="@+id/lolock"
46 + android:layout_below="@+id/lolock"
47 + android:layout_marginTop="16.5dp"
48 + android:background="@drawable/splash_line"
49 + />
50 +</RelativeLayout>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<menu xmlns:android="http://schemas.android.com/apk/res/android">
3 + <item
4 + android:id="@+id/menu_home"
5 + android:icon="@drawable/ic_home_unselected"
6 + android:title="Home" />
7 + <item
8 + android:id="@+id/menu_family"
9 + android:icon="@drawable/ic_familiy"
10 + android:title="familiy" />
11 + <item
12 + android:id="@+id/menu_info"
13 + android:icon="@drawable/ic_information"
14 + android:title="info" />
15 + <item
16 + android:id="@+id/menu_alarm"
17 + android:icon="@drawable/ic_alarm"
18 + android:title="alarm" />
19 +</menu>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<resources>
3 + <color name="colorPrimary">#3F51B5</color>
4 + <color name="colorPrimaryDark">#303F9F</color>
5 + <color name="colorAccent">#FF4081</color>
6 +</resources>
1 +<resources>
2 + <string name="app_name">LoLock</string>
3 + <string name="google_map_key">AIzaSyBQMlcoIX5CM6w7Kt-6wdkz-u4IMQ7zZh4</string>
4 + <string name="daum_api_key">04b68611d624a48f5a37bf1ad4324600</string>
5 +</resources>
1 +<resources>
2 +
3 + <!-- Base application theme. -->
4 + <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5 + <!-- Customize your theme here. -->
6 + <item name="colorPrimary">@color/colorPrimary</item>
7 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8 + <item name="colorAccent">@color/colorAccent</item>
9 + <item name="windowActionBar">true</item>
10 + </style>
11 +
12 +</resources>
1 +package com.gunghi.tgwing.lolock;
2 +
3 +import org.junit.Test;
4 +
5 +import static org.junit.Assert.*;
6 +
7 +/**
8 + * Example local unit test, which will execute on the development machine (host).
9 + *
10 + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11 + */
12 +public class ExampleUnitTest {
13 + @Test
14 + public void addition_isCorrect() throws Exception {
15 + assertEquals(4, 2 + 2);
16 + }
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.
2 +
3 +buildscript {
4 + repositories {
5 + jcenter()
6 + }
7 + dependencies {
8 + classpath 'com.android.tools.build:gradle:3.0.1'
9 + classpath 'com.google.gms:google-services:3.1.0'
10 + classpath "io.realm:realm-gradle-plugin:3.5.0"
11 +
12 + // NOTE: Do not place your application dependencies here; they belong
13 + // in the individual module build.gradle files
14 + }
15 +}
16 +
17 +
18 +allprojects {
19 + repositories {
20 + jcenter()
21 + }
22 +}
23 +
24 +task clean(type: Delete) {
25 + delete rootProject.buildDir
26 +}
1 +# Project-wide Gradle settings.
2 +
3 +# IDE (e.g. Android Studio) users:
4 +# Gradle settings configured through the IDE *will override*
5 +# any settings specified in this file.
6 +
7 +# For more details on how to configure your build environment visit
8 +# http://www.gradle.org/docs/current/userguide/build_environment.html
9 +
10 +# Specifies the JVM arguments used for the daemon process.
11 +# The setting is particularly useful for tweaking memory settings.
12 +org.gradle.jvmargs=-Xmx1536m
13 +
14 +# When configured, Gradle will run in incubating parallel mode.
15 +# This option should only be used with decoupled projects. More details, visit
16 +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 +# org.gradle.parallel=true
1 +<<<<<<< HEAD
2 +#Sat Dec 02 19:36:58 KST 2017
3 +=======
4 +#Fri Dec 01 14:35:45 KST 2017
5 +>>>>>>> 8cfff5581700c82016cd0953625915a1e8e67cf1
6 +distributionBase=GRADLE_USER_HOME
7 +distributionPath=wrapper/dists
8 +zipStoreBase=GRADLE_USER_HOME
9 +zipStorePath=wrapper/dists
10 +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
1 +#!/usr/bin/env bash
2 +
3 +##############################################################################
4 +##
5 +## Gradle start up script for UN*X
6 +##
7 +##############################################################################
8 +
9 +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 +DEFAULT_JVM_OPTS=""
11 +
12 +APP_NAME="Gradle"
13 +APP_BASE_NAME=`basename "$0"`
14 +
15 +# Use the maximum available, or set MAX_FD != -1 to use that value.
16 +MAX_FD="maximum"
17 +
18 +warn ( ) {
19 + echo "$*"
20 +}
21 +
22 +die ( ) {
23 + echo
24 + echo "$*"
25 + echo
26 + exit 1
27 +}
28 +
29 +# OS specific support (must be 'true' or 'false').
30 +cygwin=false
31 +msys=false
32 +darwin=false
33 +case "`uname`" in
34 + CYGWIN* )
35 + cygwin=true
36 + ;;
37 + Darwin* )
38 + darwin=true
39 + ;;
40 + MINGW* )
41 + msys=true
42 + ;;
43 +esac
44 +
45 +# Attempt to set APP_HOME
46 +# Resolve links: $0 may be a link
47 +PRG="$0"
48 +# Need this for relative symlinks.
49 +while [ -h "$PRG" ] ; do
50 + ls=`ls -ld "$PRG"`
51 + link=`expr "$ls" : '.*-> \(.*\)$'`
52 + if expr "$link" : '/.*' > /dev/null; then
53 + PRG="$link"
54 + else
55 + PRG=`dirname "$PRG"`"/$link"
56 + fi
57 +done
58 +SAVED="`pwd`"
59 +cd "`dirname \"$PRG\"`/" >/dev/null
60 +APP_HOME="`pwd -P`"
61 +cd "$SAVED" >/dev/null
62 +
63 +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 +
65 +# Determine the Java command to use to start the JVM.
66 +if [ -n "$JAVA_HOME" ] ; then
67 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 + # IBM's JDK on AIX uses strange locations for the executables
69 + JAVACMD="$JAVA_HOME/jre/sh/java"
70 + else
71 + JAVACMD="$JAVA_HOME/bin/java"
72 + fi
73 + if [ ! -x "$JAVACMD" ] ; then
74 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 +
76 +Please set the JAVA_HOME variable in your environment to match the
77 +location of your Java installation."
78 + fi
79 +else
80 + JAVACMD="java"
81 + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 +
83 +Please set the JAVA_HOME variable in your environment to match the
84 +location of your Java installation."
85 +fi
86 +
87 +# Increase the maximum file descriptors if we can.
88 +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 + MAX_FD_LIMIT=`ulimit -H -n`
90 + if [ $? -eq 0 ] ; then
91 + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 + MAX_FD="$MAX_FD_LIMIT"
93 + fi
94 + ulimit -n $MAX_FD
95 + if [ $? -ne 0 ] ; then
96 + warn "Could not set maximum file descriptor limit: $MAX_FD"
97 + fi
98 + else
99 + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 + fi
101 +fi
102 +
103 +# For Darwin, add options to specify how the application appears in the dock
104 +if $darwin; then
105 + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 +fi
107 +
108 +# For Cygwin, switch paths to Windows format before running java
109 +if $cygwin ; then
110 + APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 + JAVACMD=`cygpath --unix "$JAVACMD"`
113 +
114 + # We build the pattern for arguments to be converted via cygpath
115 + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 + SEP=""
117 + for dir in $ROOTDIRSRAW ; do
118 + ROOTDIRS="$ROOTDIRS$SEP$dir"
119 + SEP="|"
120 + done
121 + OURCYGPATTERN="(^($ROOTDIRS))"
122 + # Add a user-defined pattern to the cygpath arguments
123 + if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 + fi
126 + # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 + i=0
128 + for arg in "$@" ; do
129 + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 +
132 + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 + else
135 + eval `echo args$i`="\"$arg\""
136 + fi
137 + i=$((i+1))
138 + done
139 + case $i in
140 + (0) set -- ;;
141 + (1) set -- "$args0" ;;
142 + (2) set -- "$args0" "$args1" ;;
143 + (3) set -- "$args0" "$args1" "$args2" ;;
144 + (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 + esac
151 +fi
152 +
153 +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 +function splitJvmOpts() {
155 + JVM_OPTS=("$@")
156 +}
157 +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 +
160 +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
1 +@if "%DEBUG%" == "" @echo off
2 +@rem ##########################################################################
3 +@rem
4 +@rem Gradle startup script for Windows
5 +@rem
6 +@rem ##########################################################################
7 +
8 +@rem Set local scope for the variables with windows NT shell
9 +if "%OS%"=="Windows_NT" setlocal
10 +
11 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 +set DEFAULT_JVM_OPTS=
13 +
14 +set DIRNAME=%~dp0
15 +if "%DIRNAME%" == "" set DIRNAME=.
16 +set APP_BASE_NAME=%~n0
17 +set APP_HOME=%DIRNAME%
18 +
19 +@rem Find java.exe
20 +if defined JAVA_HOME goto findJavaFromJavaHome
21 +
22 +set JAVA_EXE=java.exe
23 +%JAVA_EXE% -version >NUL 2>&1
24 +if "%ERRORLEVEL%" == "0" goto init
25 +
26 +echo.
27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 +echo.
29 +echo Please set the JAVA_HOME variable in your environment to match the
30 +echo location of your Java installation.
31 +
32 +goto fail
33 +
34 +:findJavaFromJavaHome
35 +set JAVA_HOME=%JAVA_HOME:"=%
36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 +
38 +if exist "%JAVA_EXE%" goto init
39 +
40 +echo.
41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 +echo.
43 +echo Please set the JAVA_HOME variable in your environment to match the
44 +echo location of your Java installation.
45 +
46 +goto fail
47 +
48 +:init
49 +@rem Get command-line arguments, handling Windowz variants
50 +
51 +if not "%OS%" == "Windows_NT" goto win9xME_args
52 +if "%@eval[2+2]" == "4" goto 4NT_args
53 +
54 +:win9xME_args
55 +@rem Slurp the command line arguments.
56 +set CMD_LINE_ARGS=
57 +set _SKIP=2
58 +
59 +:win9xME_args_slurp
60 +if "x%~1" == "x" goto execute
61 +
62 +set CMD_LINE_ARGS=%*
63 +goto execute
64 +
65 +:4NT_args
66 +@rem Get arguments from the 4NT Shell from JP Software
67 +set CMD_LINE_ARGS=%$
68 +
69 +:execute
70 +@rem Setup the command line
71 +
72 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 +
74 +@rem Execute Gradle
75 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 +
77 +:end
78 +@rem End local scope for the variables with windows NT shell
79 +if "%ERRORLEVEL%"=="0" goto mainEnd
80 +
81 +:fail
82 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 +rem the _cmd.exe /c_ return code!
84 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 +exit /b 1
86 +
87 +:mainEnd
88 +if "%OS%"=="Windows_NT" endlocal
89 +
90 +:omega
1 +# LoLock_API
2 +
3 +### Intro
4 +- SKT IoT 플랫폼인 ThingPlug와 LoRa를 활용한 LoLock 안드로이드 앱 간의 중계 서버 구현
5 +- 주요 기능은 [lolock_api/route/api.js](https://github.com/Crazy0416/lolock_api/blob/master/lolock_api/routes/api.js)에 구현 됨
6 +- 서버는 aws를 활용, node js를 이용해 구현
7 +- REST적 설계
...\ No newline at end of file ...\ No newline at end of file
1 +var express = require('express');
2 +var path = require('path');
3 +var favicon = require('serve-favicon');
4 +var logger = require('morgan');
5 +var cookieParser = require('cookie-parser');
6 +var bodyParser = require('body-parser');
7 +require('body-parser-xml')(bodyParser);
8 +
9 +var index = require('./routes/index');
10 +var users = require('./routes/users');
11 +var apis = require('./routes/api');
12 +
13 +var app = express();
14 +
15 +// view engine setup
16 +app.set('views', path.join(__dirname, 'views'));
17 +app.set('view engine', 'ejs');
18 +
19 +// uncomment after placing your favicon in /public
20 +//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
21 +app.use(logger('dev'));
22 +app.use(bodyParser.json());
23 +app.use(bodyParser.xml());
24 +// false -> true로 값을 바꿈
25 +app.use(bodyParser.urlencoded({ extended: true }));
26 +app.use(cookieParser());
27 +//app.use(express.json());
28 +app.use(express.static(path.join(__dirname, 'public')));
29 +
30 +app.use('/', index);
31 +app.use('/users', users);
32 +app.use('/Thingplug',apis);
33 +
34 +// catch 404 and forward to error handler
35 +app.use(function(req, res, next) {
36 + var err = new Error('Not Found');
37 + err.status = 404;
38 + next(err);
39 +});
40 +
41 +// error handler
42 +app.use(function(err, req, res, next) {
43 + // set locals, only providing error in development
44 + res.locals.message = err.message;
45 + res.locals.error = req.app.get('env') === 'development' ? err : {};
46 +
47 + // render the error page
48 + res.status(err.status || 500);
49 + res.render('error');
50 +});
51 +
52 +module.exports = app;
1 +<!DOCTYPE html>
2 +<html lang="en">
3 +<head>
4 + <meta charset="UTF-8">
5 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 + <title>원격 문 열림</title>
7 + <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
8 + <style>
9 + @media (max-width: 760px) {
10 + .container {
11 + display: flex;
12 + flex-direction: column;
13 + align-items: center;
14 + }
15 + .container .main-img {
16 + flex:7;
17 + border-radius: 70px;
18 + }
19 + .main-text {
20 + display: flex;
21 + flex-direction: column;
22 + align-items: center;
23 + flex:3;
24 + font-size: 24px;
25 + margin-top: 14px;
26 + }
27 + }
28 + </style>
29 +</head>
30 +<body>
31 + <div class = "container">
32 + <img src="http://i.imgur.com/TqtBCqr.jpg" height="300" id="openImg" class="main-img">
33 + </div>
34 + <div class="main-text">
35 + 이미지를 클릭하면 문이 열립니다.
36 + </div>
37 + <script>
38 + var openEvent = document.getElementById('openImg');
39 + var currentAdd = location.href;
40 + openEvent.addEventListener('click', function(event){
41 + var xhr = new XMLHttpRequest();
42 + xhr.open('DELETE', currentAdd);
43 + xhr.onreadystatechange = function(){
44 + if(xhr.readyState === 4 && xhr.status === 200){
45 + var resJson = JSON.parse(xhr.responseText);
46 + if(resJson.code == "SUCCESS"){
47 + var _str = '';
48 + _str = '<img src=\"http:\/\/i.imgur.com\/TWUMQxj.jpg\" height=\"300\" alt=\"산이미지\" class=\"main-img\">';
49 + document.querySelector('.container').innerHTML = _str;
50 + document.querySelector('.main-text').innerHTML = "문이 열렸습니다! 확인해 주세요.";
51 + }
52 + else{
53 + document.querySelector('.main-text').innerHTML = "오류로 인해 문이 열리지 않았습니다.";
54 + }
55 + }
56 + }
57 + xhr.send();
58 + });
59 +</script>
60 +</body>
61 +</html>
...\ No newline at end of file ...\ No newline at end of file
1 +#!/usr/bin/env node
2 +
3 +/**
4 + * Module dependencies.
5 + */
6 +
7 +var app = require('../app');
8 +var debug = require('debug')('lolock-api:server');
9 +var http = require('http');
10 +
11 +
12 +/**
13 + * Get port from environment and store in Express.
14 + */
15 +
16 +var port = normalizePort(process.env.PORT || '10080');
17 +app.set('port', port);
18 +
19 +/**
20 + * Create HTTP server.
21 + */
22 +
23 +var server = http.createServer(app);
24 +
25 +/**
26 + * Listen on provided port, on all network interfaces.
27 + */
28 +
29 +server.listen(port);
30 +server.on('error', onError);
31 +server.on('listening', onListening);
32 +
33 +/**
34 + * Normalize a port into a number, string, or false.
35 + */
36 +
37 +function normalizePort(val) {
38 + var port = parseInt(val, 10);
39 +
40 + if (isNaN(port)) {
41 + // named pipe
42 + return val;
43 + }
44 +
45 + if (port >= 0) {
46 + // port number
47 + return port;
48 + }
49 +
50 + return false;
51 +}
52 +
53 +/**
54 + * Event listener for HTTP server "error" event.
55 + */
56 +
57 +function onError(error) {
58 + if (error.syscall !== 'listen') {
59 + throw error;
60 + }
61 +
62 + var bind = typeof port === 'string'
63 + ? 'Pipe ' + port
64 + : 'Port ' + port;
65 +
66 + // handle specific listen errors with friendly messages
67 + switch (error.code) {
68 + case 'EACCES':
69 + console.error(bind + ' requires elevated privileges');
70 + process.exit(1);
71 + break;
72 + case 'EADDRINUSE':
73 + console.error(bind + ' is already in use');
74 + process.exit(1);
75 + break;
76 + default:
77 + throw error;
78 + }
79 +}
80 +
81 +/**
82 + * Event listener for HTTP server "listening" event.
83 + */
84 +
85 +function onListening() {
86 + var addr = server.address();
87 + var bind = typeof addr === 'string'
88 + ? 'pipe ' + addr
89 + : 'port ' + addr.port;
90 + debug('Listening on ' + bind);
91 +}
1 +{
2 + "name": "lolock-api",
3 + "version": "0.0.0",
4 + "private": true,
5 + "scripts": {
6 + "start": "node ./bin/www"
7 + },
8 + "dependencies": {
9 + "body-parser": "~1.17.1",
10 + "body-parser-xml": "^1.1.0",
11 + "child_process": "^1.0.2",
12 + "cookie-parser": "~1.4.3",
13 + "cron": "^1.2.1",
14 + "debug": "~2.6.3",
15 + "ejs": "~2.5.6",
16 + "express": "~4.15.2",
17 + "fcm-push": "^1.1.2",
18 + "moment": "^2.18.1",
19 + "mongoose": "^4.11.1",
20 + "morgan": "~1.8.1",
21 + "multer": "^1.3.0",
22 + "mysql": "^2.13.0",
23 + "mysql-promise": "^4.1.0",
24 + "node-url-shorter": "0.0.4",
25 + "request": "^2.81.0",
26 + "serve-favicon": "~2.4.2",
27 + "xml2js": "^0.4.17"
28 + }
29 +}
1 +body {
2 + padding: 50px;
3 + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
4 +}
5 +
6 +a {
7 + color: #00B7FF;
8 +}
1 +var express = require('express');
2 +var router = express.Router();
3 +var request = require('request');
4 +var xml2js = require('xml2js');
5 +var parser = new xml2js.Parser();
6 +var mysql = require('mysql-promise')();
7 +var mysqlConfig = require('../config/db_config.json');
8 +var FCM = require('fcm-push');
9 +mysql.configure(mysqlConfig);
10 +var moment = require('moment');
11 +var weatherService = require('./weatherService');
12 +var reqFcm = require('./reqFcm');
13 +
14 +router.use(function(res, req, next) {
15 + console.log(moment().format());
16 + next();
17 +})
18 +
19 +/*
20 + 전제 조건
21 + 1. 로락 디바이스를 판매자(우리)가 먼저 DB의 lolock_devices에 등록을 해둔다
22 + 2. lolock_devices 등록과 동시에 subscribe를 해둔다. subscribe 이름 : AlldataNoti;
23 + 3. 사용자가 로락 디바이스를 구매한 뒤 앱으로 등록을 하게 되면 앱에서 POST 방식으로 /register로 데이터전송
24 + 그리고 DB table인 lolock_users와 lolock_register에 등록한다.
25 + 4. 문이 열리거나 특정 상황에 lolock이 Thingplug에 데이터를 전송하면 POST방식으로 /loradata로 데이터가 전송됨
26 + 5. 기기가 꺼졌다가 다시 켜졌을 시에 lolock에 필요한 동거인 데이터를 전송
27 + 6. 동거인이 추가될 때 마다 lolock에 블루투스 address?를 전송해야함(첫 기기등록시에도)
28 +*/
29 +
30 +
31 +//디바이스 controll Module 실행시킬 명령 code와 호출한 곳의 res를 인자로 넘겨준다.
32 +function sendControllMessage(code, device_id, res) {
33 + var headers = {
34 + 'Accept': 'application/xml',
35 + 'X-M2M-RI': device_id + '_0012', // LoLock_1 / LoLock_2 : 00000174d02544fffef0100d
36 + 'X-M2M-Origin': device_id,
37 + 'uKey': 'STRqQWE5a28zTlJ0QWQ0d0JyZVlBL1lWTkxCOFlTYm4raE5uSXJKTC95eG9NeUxoS3d4ejY2RWVIYStlQkhNSA==',
38 + 'Content-Type': 'application/xml'
39 + }
40 +
41 + var options = { // 0240771000000174 : AppEUI 와 LTID 는 사용자마다 달라야한다. HOW? / 지금은 테스트라서 직접 입력헀다
42 + url: 'https://thingplugpf.sktiot.com:9443/0240771000000174/v1_0/mgmtCmd-' + device_id + '_extDevMgmt',
43 + method: 'PUT',
44 + headers: headers,
45 + body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><m2m:mgc xmlns:m2m=\"http://www.onem2m.org/xml/protocols\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><exe>true</exe><exra>" + code + "</exra></m2m:mgc>"
46 + }
47 + request(options, function(error, response, body) {
48 + if (!error && response.statusCode == 200) {
49 + parser.parseString(body, function(err, result) {
50 + // console.log(JSON.stringify(result));
51 + //console.log(result.ThingPlug.result_code);
52 + //console.log(result.ThingPlug.user[0].uKey);
53 + });
54 + console.log(body);
55 + return res.json({
56 + code: 'SUCCESS',
57 + message: '작성 성공'
58 + });
59 + }
60 + });
61 +}
62 +
63 +/* GET home page. */
64 +router.get('/', function(req, res, next) {
65 + console.log("HI");
66 + res.send("HI");
67 +});
68 +
69 +/* GET ukey in xml / uKey를 xml 형식으로 받아서 리턴*/
70 +router.get('/userids/:user_id/passwords/:passwd', function(req, res, next) {
71 + var headers = {
72 + 'user_id': req.params.user_id,
73 + 'password': req.params.passwd
74 + }
75 + var options = {
76 + url: 'http://onem2m.sktiot.com:9000/ThingPlug?division=user&function=login',
77 + method: 'PUT',
78 + headers: headers
79 + }
80 + request(options, function(error, response, body) {
81 + if (!error && response.statusCode == 200) {
82 + parser.parseString(body, function(err, result) {
83 + // result를 JSON 형식으로 log
84 + /*
85 + {"ThingPlug":{"result_code":["200"],"result_msg":[""],"user":[{"admin_yn":["N"],"password":[""],"user_id":["nowniz93"],"uKey":["bjBwOXpCTUdxUFZ3UEZFR3lZTUZOeDlzdVl1OWpRdUdxTVg0Zmo5UHBIdFJOa2FObUJOTVNsamt1K00yYWRPTA=="]}]}}
86 + */
87 + console.log(JSON.stringify(result));
88 + // [ '200' ]
89 + console.log(result.ThingPlug.result_code);
90 + //[ 'bjBwOXpCTUdxUFZ3UEZFR3lZTUZOeDlzdVl1OWpRdUdxTVg0Zmo5UHBIdFJOa2FObUJOTVNsamt1K00yYWRPTA==' ]
91 + console.log(result.ThingPlug.user[0].uKey);
92 + });
93 + }
94 + // 이대로 보내면 웹브라우져에선 text밖에 보이지 않음(구분되지 않고 문자만 나옴)
95 + res.send(body);
96 + });
97 +})
98 +
99 +/* GET 로그인 시에 유저의 정보를 받아옴 */
100 +router.get('/userInfo/:phoneId', function(req, res, next) {
101 + var userPhoneId = req.params.phoneId;
102 + var userName;
103 + mysql.query("SELECT * FROM lolock_users WHERE phone_id=?", [userPhoneId])
104 + .spread(function(rows) {
105 + console.log(rows.length);
106 + if (rows.length == 0) {
107 + res.json({
108 + code: 'NOT REGISTRED',
109 + message: '미등록 핸드폰',
110 + userInfo: {
111 +
112 + }
113 + });
114 + } else {
115 + userName = rows[0].name;
116 + mysql.query("SELECT device_id FROM lolock_register WHERE user_id = ?", [rows[0].id])
117 + .spread(function(rows) {
118 + console.log(rows.length);
119 + if (rows.length != 0) {
120 + return mysql.query("SELECT * FROM lolock_devices WHERE id = ?", [rows[0].device_id]);
121 + }
122 + })
123 + .spread(function(rows) {
124 + console.log(rows.length);
125 + if (rows.length != 0) {
126 + res.json({
127 + code: 'REGISTRED',
128 + messaege: "등록된 핸드폰",
129 + userInfo: {
130 + name: userName,
131 + lolockLTID: rows[0].device_id.substring(rows[0].device_id.length - 6, rows[0].device_id.length)
132 + }
133 + })
134 + }
135 + });
136 + }
137 + });
138 +});
139 +
140 +
141 +/* GET housemate list and response to app */
142 +router.get('/homemateslist/:LTID', function(req, res, next) {
143 + console.log(JSON.stringify(req.headers.ltid)); // "Headers 의 LTID 키를 가져옴"
144 + var LoLockId = "00000174d02544fffe" + req.params.LTID;
145 + console.log(LoLockId);
146 + mysql.query("SELECT id FROM lolock_devices WHERE device_id=?", [LoLockId])
147 + .spread(function(rows) {
148 + if (rows[0] == null) {
149 + res.json({
150 + code: 'DEVICE_ID_ERR',
151 + message: '등록되지 않은 기기'
152 + });
153 + } else {
154 + getDeviceIdFromDB = rows[0].id;
155 + mysql.query("SELECT * FROM lolock_users WHERE id IN (SELECT user_id FROM lolock_register WHERE device_id=?)", [getDeviceIdFromDB])
156 + .spread(function(rows) {
157 + var jsonArray = new Array();
158 + var count = 0;
159 + for (var i in rows) {
160 + var jsonObj = {
161 + "mateImageUrl": rows[i].profile_url,
162 + "mateName": rows[i].name,
163 + "mateOutingFlag": rows[i].flag,
164 + "mateDoorOpenTime": rows[i].time
165 + };
166 + jsonArray.push(jsonObj);
167 + count++;
168 + }
169 + var result = {
170 + "mates": jsonArray,
171 + "mateNumber": count
172 + }
173 + res.json(result);
174 + //res.send(rows);
175 + });
176 + }
177 + })
178 +})
179 +
180 +/* PUT 로락 원격으로 문을 여는 요청을 ThingPlug를 통해 요청 */
181 +router.put('/remote-open', function(req, res, next) {
182 + var jsonRes = req.body;
183 + var openDeviceId = jsonRes.openDeviceId;
184 + console.log(openDeviceId);
185 + mysql.query("SELECT id FROM lolock_users WHERE phone_id=?", [openDeviceId])
186 + .spread(function(rows) {
187 + console.log(rows);
188 + return mysql.query("SELECT device_id FROM lolock_register WHERE user_id = ? ", [rows[0].id]);
189 + })
190 + .spread(function(rows) {
191 + console.log(rows);
192 + return mysql.query("SELECT device_id FROM lolock_devices WHERE id = ? ", [rows[0].device_id]);
193 +
194 + })
195 + .spread(function(rows) {
196 + console.log(rows);
197 + sendControllMessage("26", rows[0].device_id, res);
198 + })
199 +})
200 +
201 +/* POST 핸드폰에서 자신이 나갔다고 서버에 로그 등록을 요청 */
202 +router.get('/checkout/:phone_id', function(req, res, next) {
203 + console.log(req.params.phone_id + "가 나갔음")
204 + var name = "";
205 +
206 + mysql.query("UPDATE lolock_users SET flag = 0 WHERE phone_id = ? ", [req.params.phone_id]);
207 + mysql.query("SELECT id, name FROM lolock_users WHERE phone_id=?", req.params.phone_id)
208 + .spread(function(idrows) {
209 + name = idrows[0].name;
210 + return mysql.query("SELECT * FROM lolock_register AS R LEFT JOIN lolock_users AS U ON R.user_id = U.id WHERE R.device_id = (SELECT device_id FROM lolock_register WHERE user_id = ?)", idrows[0].id)
211 + })
212 + .spread(function(roommateRows) {
213 + for (var j in roommateRows) {
214 + var pushData = {}
215 + if (roommateRows[j].phone_id == req.params.phone_id) {
216 + var reqPhone_id = roommateRows[j].phone_id;
217 + mysql.query("SELECT * FROM lolock_devices WHERE id=?", roommateRows[j].device_id)
218 + .spread(function(deviceRows) {
219 + var timeArr = moment().format().split('T');
220 + var dateArr = timeArr[0].split('-');
221 + var timeArr = timeArr[1].split(':');
222 + var time = dateArr[0] + dateArr[1] + dateArr[2] + timeArr[0] + timeArr[1]; // 201707232325
223 + weatherService.receiveWeatherInfo(deviceRows[0].gps_lon, deviceRows[0].gps_lat, deviceRows[0].addr, moment().format(), "NULL", function(data) {
224 + pushData.pushCode = "0";
225 + pushData.message = "날씨:" + data.sky + " 온도:" + data.temperature + " / 오늘 일정 : 4개입니다.";
226 + mysql.query("UPDATE lolock_devices SET temp_out_flag='1' WHERE id=?", roommateRows[j].device_id);
227 + mysql.query("INSERT INTO lolock_logs (device_id, user_id, time, out_flag) VALUES (?,?,?,?)", [roommateRows[j].device_id, roommateRows[j].user_id, time, 1])
228 + .then(function(fin){
229 + console.log("출입로그 기록 완료 in /checkout");
230 + })
231 + .catch(function(err) {
232 + console.log("출입로그 기록 실패 in /checkout");
233 + })
234 + reqFcm.sendPushMessage(reqPhone_id, pushData)
235 + .then(function(text) {
236 + console.log(text);
237 + }, function(err) {
238 + console.log(err);
239 + });
240 + })
241 + })
242 + } else {
243 + pushData.pushCode = "1";
244 + pushData.message = name + "님이 나갔습니다.";
245 + reqFcm.sendPushMessage(roommateRows[j].phone_id, pushData)
246 + .then(function(text) {
247 + console.log(text);
248 + }, function(err) {
249 + console.log(err);
250 + });
251 + }
252 + }
253 + var sendObj = {
254 + "code": "SUCCESS",
255 + "message": "OKAY"
256 + }
257 + res.json(sendObj);
258 + })
259 + .catch(function(err) {
260 + console.log(err);
261 + console.log("DB_ERR in /checkout");
262 + var sendObj = {
263 + "code": "FAIL",
264 + "message": "ID DOESN'T EXIST IN DB"
265 + }
266 + res.json(sendObj);
267 + })
268 +})
269 +
270 +
271 +/* POST 핸드폰에서 자신이 들어왔다고 서버에 로그 등록을 요청 */
272 +router.get('/checkin/:phone_id', function(req, res, next) {
273 + console.log(req.params.phone_id + "가 들어왔음")
274 + var name = "";
275 + mysql.query("UPDATE lolock_users SET flag = 1 WHERE phone_id = ? ", [req.params.phone_id]);
276 + mysql.query("SELECT id, name FROM lolock_users WHERE phone_id=?", req.params.phone_id)
277 + .spread(function(idrows) {
278 + name = idrows[0].name;
279 + return mysql.query("SELECT * FROM lolock_register AS R LEFT JOIN lolock_users AS U ON R.user_id = U.id WHERE R.device_id = (SELECT device_id FROM lolock_register WHERE user_id = ?)", idrows[0].id)
280 + })
281 + .spread(function(roommateRows) {
282 + for (var j in roommateRows) {
283 + var pushData = {};
284 + if (roommateRows[j].phone_id == req.params.phone_id) {
285 + var timeArr = moment().format().split('T');
286 + var dateArr = timeArr[0].split('-');
287 + var timeArr = timeArr[1].split(':');
288 + var time = dateArr[0] + dateArr[1] + dateArr[2] + timeArr[0] + timeArr[1]; // 201707232325
289 + console.log(roommateRows[j].device_id + " " + roommateRows[j].user_id + " " + time + " " + 1);
290 + mysql.query("UPDATE lolock_devices SET temp_out_flag='1' WHERE id=?", roommateRows[j].device_id);
291 + mysql.query("INSERT INTO lolock_logs (device_id, user_id, time, out_flag) VALUES (?,?,?,?)", [roommateRows[j].device_id, roommateRows[j].user_id, time, 0])
292 + .then(function(fin){
293 + console.log("출입로그 기록 완료 in /checkin");
294 + })
295 + .catch(function(err) {
296 + console.log("출입로그 기록 실패 in /checkin");
297 + })
298 + } else {
299 + pushData.pushCode = "1";
300 + pushData.message = name + "님이 들어왔습니다."
301 + reqFcm.sendPushMessage(roommateRows[j].phone_id, pushData)
302 + .then(function(text) {
303 + console.log(text)
304 + }, function(err) {
305 + console.log(err)
306 + });
307 + }
308 + }
309 + var sendObj = {
310 + "code": "SUCCESS",
311 + "message": "OKAY"
312 + }
313 + res.json(sendObj);
314 + })
315 + .catch(function(err) {
316 + console.log(err);
317 + console.log("DB_ERR in /checkout");
318 + var sendObj = {
319 + "code": "FAIL",
320 + "message": "ID DOESN'T EXIST IN DB"
321 + }
322 + res.json(sendObj);
323 + })
324 +})
325 +
326 +
327 +/* POST loRa subscribe한 데이터 전달받는다.*/
328 +router.post('/loradata', function(req, res, next) {
329 +
330 + var notificationMessage = req.body['m2m:cin'];
331 + var content = notificationMessage.con[0]; // lora 명령어
332 + var lastModifiedTime = notificationMessage.lt[0]; // Thingplug에 전송된 시간
333 + var uri = notificationMessage.sr[0].split('/');
334 + var LTID = uri[3].substring(10);
335 +
336 + console.log(content, lastModifiedTime); // content 2017-07-16T21:35:14+09:00
337 + console.log(LTID);
338 +
339 + console.log("typeof content : " + typeof content);
340 + if (content[0] == "3" && content[1] == "0") // 누군가 나갈때
341 + {
342 + console.log("누군가 나갈때 시작");
343 + reqFcm.sendPushToRoommate(LTID, "3", "");
344 + setTimeout(checkTrespassing, 10000, LTID);
345 + } else if (content[0] == "3" && content[1] == "1") // 누군가 들어올 떄
346 + {
347 + console.log("누군가 들어올 때 시작");
348 + reqFcm.sendPushToRoommate(LTID, "4", "");
349 + setTimeout(checkTrespassing, 10000, LTID);
350 + } else if (content[0] == "3" && content[1] == "2") // 진동센서에 의해 불법침입이 감지될 때
351 + {
352 + console.log("불법침입감지 시작");
353 + reqFcm.sendPushToRoommate(LTID, "2", "비정상적인 충격이 감지되었습니다.");
354 + }
355 + res.send();
356 +});
357 +
358 +/* GET 서버에 등록된 기기인지 아닌지 확인 */
359 +router.get('/checkId/:deviceId', function(req, res, next) {
360 + var deviceId = "00000174d02544fffe" + req.params.deviceId;
361 + mysql.query("SELECT id FROM lolock_devices WHERE device_id=?", [deviceId])
362 + .spread(function(rows) {
363 + if (rows.length == 0) {
364 + res.json({
365 + code: 'DEVICE_ID_ERR',
366 + message: '등록되지 않은 기기'
367 + });
368 + } else {
369 + res.json({
370 + code: 'DEVICE_ID_AVAILABLE',
371 + message: '등록된 기기'
372 + });
373 + }
374 + });
375 +});
376 +
377 +/* POST 회원가입 및 기기등록 */
378 +router.post('/register', function(req, res, next) {
379 + var jsonRes = req.body;
380 + console.log(jsonRes);
381 + var deviceId = "00000174d02544fffe" + jsonRes.registerDeviceId;
382 + var userName = jsonRes.registerUserName;
383 + var userPhoneId = jsonRes.registerUserPhoneId;
384 + var deviceGPS_lat = jsonRes.registerDeviceGPS_lat;
385 + var deviceGPS_lon = jsonRes.registerDeviceGPS_lon;
386 + var deviceAddr = jsonRes.registerDeviceAddr;
387 + var getDeviceIdFromDB;
388 + var getUserIdFromDB;
389 + console.log(deviceId);
390 + console.log(userName);
391 + mysql.query("UPDATE lolock_devices SET gps_lat=?,gps_lon=?,addr=? WHERE device_id = ? AND gps_lat IS NULL", [deviceGPS_lat, deviceGPS_lon, deviceAddr, deviceId]);
392 + mysql.query("SELECT id FROM lolock_devices WHERE device_id=?", [deviceId])
393 + .spread(function(rows) {
394 + getDeviceIdFromDB = rows[0].id;
395 + console.log(getDeviceIdFromDB);
396 + return mysql.query("INSERT INTO lolock_users (name,phone_id) VALUES (?,?)", [userName, userPhoneId]);
397 +
398 + }).then(function() {
399 + console.log(userPhoneId);
400 + return mysql.query("SELECT id FROM lolock_users WHERE phone_id=?", [userPhoneId]);
401 + })
402 + .spread(function(rows) {
403 + getUserIdFromDB = rows[0].id;
404 + console.log(getUserIdFromDB);
405 + return mysql.query("INSERT INTO lolock_register (user_id,device_id) VALUES (?,?)", [getUserIdFromDB, getDeviceIdFromDB]);
406 + })
407 + .then(function() {
408 + console.log(getUserIdFromDB);
409 + return mysql.query("SELECT * FROM lolock_register WHERE device_id = ?", [getDeviceIdFromDB]);
410 + })
411 + .spread(function(rows) {
412 + res.status(200);
413 + res.json({
414 + code: 'SUCCESS',
415 + message: '등록 성공'
416 + });
417 + })
418 + .catch(function(err) {
419 + console.log(err);
420 + res.status(500);
421 + res.json({
422 + code: 'DB_ERR',
423 + message: '데이터베이스 에러'
424 + });
425 + // TODO : LoLock Device에 새로운 사용자 정보 전송
426 + });
427 +});
428 +
429 +
430 +/* GET 출입 기록 관리 */
431 +router.get('/outing-log/:phoneId', function(req, res, next) {
432 + var phoneId = req.params.phoneId;
433 + var randomStr;
434 + mysql.query("SELECT id FROM lolock_users WHERE phone_id=?", [phoneId])
435 + .spread(function(rows) {
436 + console.log(rows);
437 + return mysql.query("SELECT device_id FROM lolock_register WHERE user_id = ? ", [rows[0].id]);
438 + })
439 + .spread(function(rows) {
440 + return mysql.query("SELECT * FROM lolock_logs AS L LEFT JOIN lolock_users AS U ON L.user_id = U.id WHERE device_id = ? ORDER BY L.time DESC", [rows[0].device_id]);
441 + })
442 + .spread(function(rows) {
443 + console.log(rows);
444 + if (rows.length == 0) {
445 + res.send();
446 + } else {
447 + var jsonArray = new Array();
448 + // private String name;
449 + // private String time;
450 + // private String strangeFlag;
451 + // outFlag;
452 + for (var i in rows) {
453 + var resName;
454 + var strangeFlag;
455 + if (rows[i].id != null) {
456 + resName = rows[i].name;
457 + strangeFlag = 0;
458 + } else {
459 + resName = "외부인";
460 + strangeFlag = 1;
461 + }
462 + var resTime = rows[i].time;
463 + var week = new Array('일', '월', '화', '수', '목', '금', '토');
464 + var today = new Date(resTime.substring(0, 4) + '-' + resTime.substring(4, 6) * 1 + '-' + resTime.substring(6, 8) * 1 + " " + resTime.substring(8, 10) * 1 + ":" + resTime.substring(10, 12) * 1);
465 + var todayLabel = week[today.getDay()];
466 + console.log(today.getTime() + " " + resTime.substring(0, 4) + '-' + resTime.substring(4, 6) * 1 + '-' + resTime.substring(6, 8) * 1);
467 + console.log(new Date().getTime());
468 + var jsonObj = {
469 + "name": resName,
470 + "outFlag": rows[i].out_flag,
471 + "strangeFlag": strangeFlag,
472 + "outTime": {
473 + "month": resTime.substring(4, 6) * 1,
474 + "day": resTime.substring(6, 8) * 1,
475 + "hour": resTime.substring(8, 10) * 1,
476 + "min": resTime.substring(10, 12) * 1,
477 + "dayName": todayLabel,
478 + "timeStamp": new Date().getTime() - today.getTime()
479 + }
480 + }
481 + jsonArray.push(jsonObj);
482 + }
483 + var jsonRes = {
484 + "results": jsonArray
485 + }
486 + res.json(jsonRes);
487 + }
488 + })
489 +});
490 +
491 +/* GET 기상청 API를 이용하여 현재 날씨 정보를 받고 JSON 데이터를 수정해 response */
492 +router.get('/weatherdata/:LTID', function(req, res, next) {
493 + var LTID = "00000174d02544fffe" + req.params.LTID;
494 + var gps_lat;
495 + var gps_lon;
496 + var addr;
497 + mysql.query("SELECT id, gps_lat, gps_lon, addr FROM lolock_devices WHERE device_id=?", LTID)
498 + .spread(function(rows) {
499 + console.log("id : " + rows[0].id + "device id : " + LTID);
500 + gps_lat = rows[0].gps_lat;
501 + gps_lon = rows[0].gps_lon;
502 + var addrArr = rows[0].addr.split(' ');
503 + addr = addrArr[1] + " " + addrArr[2];
504 + return mysql.query("SELECT phone_id FROM lolock_users WHERE id IN (SELECT user_id FROM lolock_register WHERE device_id=?)", rows[0].id);
505 + })
506 + .spread(function(roommateRows) {
507 + var roommateTokenArray = new Array();
508 + for (var j in roommateRows) {
509 + roommateTokenArray.push(roommateRows[j].phone_id);
510 + }
511 + weatherService.receiveWeatherInfo(gps_lon, gps_lat, addr, moment().format('YYYY-MM-DDTHH:mm:ssZ'), res);
512 + })
513 + .catch(function(err) {
514 + console.log(err);
515 + var sendObj = {
516 + "code": "FAIL",
517 + "message": "DB_ERR"
518 + }
519 + res.json(sendObj);
520 + })
521 +})
522 +
523 +/* GET 일회용 키 발급 */
524 +router.get('/open-url/:phoneId', function(req, res, next) {
525 + var phoneId = req.params.phoneId;
526 + var randomStr;
527 + mysql.query("SELECT id FROM lolock_users WHERE phone_id=?", [phoneId])
528 + .spread(function(rows) {
529 + console.log(rows);
530 + return mysql.query("SELECT device_id FROM lolock_register WHERE user_id = ? ", [rows[0].id]);
531 + })
532 + .spread(function(rows) {
533 + console.log(rows);
534 + return mysql.query("SELECT device_id FROM lolock_devices WHERE id = ? ", [rows[0].device_id]);
535 +
536 + })
537 + .spread(function(rows) {
538 + console.log(rows);
539 + console.log();
540 + randomStr = Math.random().toString(36).substring(20);
541 + return mysql.query("INSERT INTO lolock_open_url (device_id,url) VALUES(?,?)", [rows[0].device_id, randomStr]);
542 + })
543 + .then(function() {
544 + res.json({
545 + code: 'CREATED',
546 + link: "http://13.124.94.67:10080/Thingplug/disposable-link/" + randomStr
547 + });
548 + })
549 + .catch(function(err) {
550 + console.log(err);
551 + res.status(500);
552 + res.json({
553 + code: 'DB_ERR',
554 + message: '데이터베이스 에러'
555 + });
556 + });
557 +});
558 +
559 +/* DELETE 발급 받은 일회용 키를 DB에서 삭제함과 동시에 원격 문열림 요청 */
560 +router.delete('/disposable-link/:linkId', function(req, res, next) {
561 + var linkId = req.params.linkId;
562 + var device_id;
563 + mysql.query("SELECT * FROM lolock_open_url WHERE url = ?", [linkId])
564 + .spread(function(rows) {
565 + console.log(rows.length);
566 + if (rows.length == 0) {
567 + res.json({
568 + code: 'UNDEFINED',
569 + message: '존재하지 않는 주소'
570 + });
571 + } else {
572 + device_id = rows[0].device_id;
573 + mysql.query("DELETE FROM lolock_open_url WHERE url = ?", [linkId])
574 + .then(function() {
575 + var timeArr = moment().format().split('T');
576 + var dateArr = timeArr[0].split('-');
577 + var timeArr = timeArr[1].split(':');
578 + var time = dateArr[0] + dateArr[1] + dateArr[2] + timeArr[0] + timeArr[1]; // 201707232325
579 + sendControllMessage("26", device_id, res);
580 + // TODO : open_url을 통해 누가 문을 열었다고 동거인에게 알려줌
581 + reqFcm.sendPushToRoommate(device_id, "1", "임시키를 통해 누군가 들어왔습니다.");
582 + mysql.query("SELECT id FROM lolock_devices WHERE device_id=?", device_id)
583 + .spread(function(rows){
584 + return mysql.query("INSERT INTO lolock_logs (device_id, time, out_flag) VALUES (?,?,?)", [rows[0].id, time, 1]);
585 + })
586 + .catch(function(err){
587 + console.log(err);
588 + console.log("임시키 로그 등록 실패");
589 + })
590 + })
591 + .catch(function(err) {
592 + console.log(err);
593 + res.status(500);
594 + res.json({
595 + code: 'DB_ERR',
596 + message: '데이터베이스 에러'
597 + });
598 + });
599 + }
600 + })
601 +})
602 +
603 +/* GET 받은 일회용 키로 접속했을때 open_url.html을 response 한다. */
604 +router.get('/disposable-link/:linkId', function(req, res, next) {
605 + res.sendfile('open_url.html');
606 +});
607 +
608 +
609 +
610 +//불법침임 감지
611 +var checkTrespassing = function(arg) {
612 + mysql.query("SELECT temp_out_flag FROM lolock_devices WHERE device_id = ?", [arg])
613 + .spread(function(rows) {
614 + console.log(rows);
615 + if (rows[0].temp_out_flag == null) {
616 + reqFcm.sendPushToRoommate(arg, "2", "등록되지 않은 사용자가 침입했습니다.");
617 + }
618 + mysql.query("UPDATE lolock_devices SET temp_out_flag = NULL WHERE device_id = ? ", [arg]);
619 + }).catch(function(err) {
620 + console.log("출입로그 기록 실패 in /checkout");
621 + })
622 +};
623 +module.exports = router;
1 +var express = require('express');
2 +var router = express.Router();
3 +
4 +/* GET home page. */
5 +router.get('/', function(req, res, next) {
6 + res.render('index', { title: 'Express' });
7 +});
8 +
9 +module.exports = router;
1 +/*
2 + FCM 서버에 안드로이드 푸시 메세지 보내기 요청 기능 모듈
3 + 관련 정보 : https://firebase.google.com/docs/cloud-messaging/server?hl=ko
4 +*/
5 +var mysql = require('mysql-promise')();
6 +var request = require('request');
7 +var reqFcm = require('./reqFcm');
8 +module.exports.sendPushMessage = function(androidToken, dataObj) {
9 + return new Promise(function(resolve, reject) {
10 + // TODO
11 + var headers = {
12 + 'Content-Type': 'application/json',
13 + 'Authorization': 'key=AAAA-r7E-Qs:APA91bGtjGiMIKAnGL7kF9OedU-ffFttm5rXcaizpAM-hWAUjKme-w4mP2b__NbcH6JbiKHP2A_YpiVTqiLnleCMZIYyt8i20RvxUNPv8U25yMeYrPv6YsWbyZ_OllxniyplDBJqmevO'
14 + }
15 + var options = {
16 + url: 'https://fcm.googleapis.com/fcm/send',
17 + method: 'POST',
18 + headers: headers
19 + }
20 + var toAppBody = {}; // push 메세지 body
21 +
22 + console.log("PushMessage 내용 : " + JSON.stringify(dataObj));
23 +
24 + toAppBody.data = dataObj;
25 + toAppBody.to = androidToken;
26 + options.body = JSON.stringify(toAppBody);
27 + // TODO : 동기화 할 것 promise 사용
28 + request(options, function(error, response, body) {
29 + var bodyobj = eval("(" + response.body + ")");
30 + // TODO : 지금 모든 인원에게 기상 데이터를 보내고 있다. 다른 인원은 log를 보내야함
31 + if (bodyobj.success === 1) {
32 + resolve(androidToken + " 푸시 메세지 보내기 완료");
33 + } else {
34 + reject(androidToken + " 푸시 메세지 실패!!!");
35 + }
36 + })
37 + });
38 +}
39 +
40 +module.exports.sendPushToRoommate = function(LTID, pushCode, pushMessage) {
41 + mysql.query("SELECT id FROM lolock_devices WHERE device_id=?", LTID)
42 + .spread(function(rows) {
43 + console.log("lolock id : " + rows[0].id);
44 + return mysql.query("SELECT phone_id FROM lolock_users WHERE id IN (SELECT user_id FROM lolock_register WHERE device_id=?)", rows[0].id);
45 + })
46 + .spread(function(roommateRows) {
47 + for (var j in roommateRows) {
48 + var pushData = {}
49 + pushData.pushCode = pushCode;
50 + pushData.message = pushMessage;
51 + reqFcm.sendPushMessage(roommateRows[j].phone_id, pushData)
52 + .then(function(text) {
53 + console.log(text)
54 + }, function(err) {
55 + console.log(err)
56 + });
57 + }
58 + })
59 + .catch(function(err) {
60 + console.log(err);
61 + console.log("DB_ERR");
62 + })
63 +}
1 +var express = require('express');
2 +var router = express.Router();
3 +
4 +/* GET users listing. */
5 +router.get('/', function(req, res, next) {
6 + res.send('respond with a resource');
7 +});
8 +
9 +module.exports = router;
1 +var exec = require('child_process').exec,
2 + child;
3 +var moment = require('moment');
4 +var request = require('request');
5 +
6 +
7 +/* 기상청 api를 사용해 현재 지역의 기상정보를 가져옴 */
8 +// 경도 위도 날짜+시간
9 +module.exports.receiveWeatherInfo = function(gps_long, gps_lat, addr, lastModifiedTime, responseToReq, callback) {
10 + var dateArr = lastModifiedTime.split('T')[0].split('-');
11 + var timeArr = lastModifiedTime.split('T')[1].split(':');
12 + var date = dateArr[0] + dateArr[1] + dateArr[2];
13 + var time = Number(timeArr[0] + timeArr[1]);
14 + time = time - (time % 100) - 100;
15 +
16 + // TODO : 동기화 보장
17 + if (time < 0) { // time이 00시--분이라면 하루 빼고 2300만들기
18 + time = '2300'
19 + date = moment(date).add(-1, 'days').format('YYYYMMDD'); // 하루 빼고 2300
20 + } else { // 그 외
21 + var tmp = '0000';
22 + time += "";
23 + tmp = tmp.substring(time.length);
24 + tmp += time;
25 + time = tmp;
26 + }
27 + console.log("date : " + date);
28 + console.log("time : " + time);
29 + child = exec("../../a.out 0 " + gps_long + " " + gps_lat, function(error, stdout, stderr) {
30 + if (error !== null) {
31 + console.log('exec error: ' + error);
32 + }
33 + var nx = stdout.split(' = ')[1].split(',')[0]; // '62, Y'
34 + var ny = stdout.split(' = ')[2].split('\n')[0];
35 + console.log("nx : " + nx + " ny : " + ny);
36 +
37 + var GETuri = 'http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastGrib?';
38 + GETuri += 'ServiceKey=fnu5UNOGf0qmYIWbwbWTW8vtKs5JAJqQdo9afbZwmQM6WPx6B97QxohwO7TI3S9Msx0BFFlfJxfE%2BSJ5OEtf3w%3D%3D';
39 + GETuri += '&base_date=' + date;
40 + GETuri += '&base_time=' + time;
41 + GETuri += '&nx=' + nx;
42 + GETuri += '&ny=' + ny;
43 + GETuri += '&numOfRows=15';
44 + GETuri += '&pageNo=1';
45 + GETuri += '&_type=json';
46 + var options = {
47 + url: GETuri,
48 + method: 'GET',
49 + }
50 + if (Number(time) <= 100 && timeArr[1] < 10)
51 + date = moment(date).add(-1, 'days').format('YYYYMMDD'); // 하루 빼고 2300
52 + var GETforecasturi = 'http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastSpaceData?';
53 + GETforecasturi += 'ServiceKey=fnu5UNOGf0qmYIWbwbWTW8vtKs5JAJqQdo9afbZwmQM6WPx6B97QxohwO7TI3S9Msx0BFFlfJxfE%2BSJ5OEtf3w%3D%3D';
54 + GETforecasturi += '&base_date=' + date;
55 + GETforecasturi += '&base_time=0200';
56 + GETforecasturi += '&nx=' + nx;
57 + GETforecasturi += '&ny=' + ny;
58 + GETforecasturi += '&numOfRows=62';
59 + GETforecasturi += '&pageNo=1';
60 + GETforecasturi += '&_type=json';
61 + var forecastoptions = {
62 + url: GETforecasturi,
63 + method: 'GET',
64 + }
65 + request(options, function(error, response, body) {
66 + if (response.statusCode == 200) {
67 + weatherdataModifyRequiredData(body, addr, forecastoptions, function(data) {
68 + if (responseToReq != "NULL") {
69 + responseToReq.send(JSON.stringify(data));
70 + console.log("날씨 response 성공");
71 + } else {
72 + callback(data);
73 + }
74 + });
75 + } else {
76 + responseToReq.send("기상청 API 에러!")
77 + }
78 + // else if (flag === 0 && !error && response.statusCode == 200) {
79 + // // TODO : fcm연결 서버에 각 토큰마다 RequiredData 전송 동기화 보장!!!!! 콜백함수 사용하기
80 + // weatherdataModifyRequiredData(body, roommateTokenArray, forecastoptions, 0, sendPushMessageToRoommate)
81 + // }
82 + });
83 + })
84 +};
85 +
86 +var weatherdataModifyRequiredData = function(weatherData, addr, forecastoptions, callback) {
87 + var time = moment().format().split('T')[1].split(':')[0];
88 + time += "00";
89 +
90 + var weatherDataobj = eval("(" + weatherData + ")");
91 + var weatherDataItemArray = weatherDataobj['response']['body']['items']['item'];
92 + var data = new Object();
93 + data.baseTime = weatherDataItemArray[0].baseTime;
94 + data.baseDate = weatherDataItemArray[0].baseDate;
95 + data.probabilityRain = 0;
96 + data.location = addr;
97 + console.log("addr : " + data.location);
98 + for (var i in weatherDataItemArray) {
99 + if (weatherDataItemArray[i].category === "PTY") {
100 + data.pty = weatherDataItemArray[i].obsrValue;
101 + } else if (weatherDataItemArray[i].category === "SKY") {
102 + data.sky = weatherDataItemArray[i].obsrValue;
103 + } else if (weatherDataItemArray[i].category === "T1H") {
104 + data.temperature = weatherDataItemArray[i].obsrValue;
105 + }
106 + }
107 + if (data.pty == 0) {
108 + if (data.sky == 1)
109 + data.sky = "맑음";
110 + else if (data.sky == 2)
111 + data.sky = "구름조금"
112 + else if (data.sky == 3)
113 + data.sky = "구름많음"
114 + else if (data.sky == 4)
115 + data.sky = "흐림"
116 + } else if (data.pty == 1)
117 + data.sky = "비";
118 + else if (data.pty == 2)
119 + data.sky = "비와눈";
120 + else if (data.pty == 3)
121 + data.sky = "눈";
122 + delete data.pty;
123 +
124 + request(forecastoptions, function(error, response, body) {
125 + var weatherDataobj = eval("(" + body + ")");
126 + if (response.statusCode == 200) {
127 + if (weatherDataobj['response']['header']['resultCode'] == "0000") {
128 + var weatherDataItemArray = weatherDataobj['response']['body']['items']['item'];
129 + for (var i in weatherDataItemArray) {
130 + if (weatherDataItemArray[i].category === "TMN") {
131 + data.minTemperature = weatherDataItemArray[i].fcstValue;
132 + } else if (weatherDataItemArray[i].category === "TMX") {
133 + data.maxTemperature = weatherDataItemArray[i].fcstValue;
134 + }
135 + if (weatherDataItemArray[i].category === "POP" && Number(weatherDataItemArray[i].fcstValue) > data.probabilityRain)
136 + data.probabilityRain = weatherDataItemArray[i].fcstValue;
137 + }
138 + data.code = "SUCCESS";
139 + console.log("data : " + JSON.stringify(data));
140 + callback(data);
141 + } else {
142 + var sendObj = {
143 + "code": "FAIL",
144 + "message": "WRONG_DATE"
145 + }
146 + console.log("기상청 API 날짜 에러!");
147 + }
148 + } else {
149 + var sendObj = {
150 + "code": "FAIL",
151 + "message": "National Weather Service API ERR"
152 + }
153 + console.log("기상청 API 에러!");
154 + }
155 + });
156 +};
1 +<h1><%= message %></h1>
2 +<h2><%= error.status %></h2>
3 +<pre><%= error.stack %></pre>
1 +<!DOCTYPE html>
2 +<html>
3 + <head>
4 + <title><%= title %></title>
5 + <link rel='stylesheet' href='/stylesheets/style.css' />
6 + </head>
7 + <body>
8 + <h1><%= title %></h1>
9 + <p>Welcome to <%= title %></p>
10 + </body>
11 +</html>
1 +#include <stdio.h>
2 +#include <stdlib.h>
3 +#include <string.h>
4 +#include <signal.h>
5 +#include <sys/types.h>
6 +#include <sys/stat.h>
7 +#include <dirent.h>
8 +#include <time.h>
9 +#include <math.h>
10 +
11 +#define NX 149 /* X축 격자점 수 */
12 +#define NY 253 /* Y축 격자점 수 */
13 +
14 +struct lamc_parameter {
15 + float Re; /* 사용할 지구반경 [ km ] */
16 + float grid; /* 격자간격 [ km ] */
17 + float slat1; /* 표준위도 [degree] */
18 + float slat2; /* 표준위도 [degree] */
19 + float olon; /* 기준점의 경도 [degree] */
20 + float olat; /* 기준점의 위도 [degree] */
21 + float xo; /* 기준점의 X좌표 [격자거리] */
22 + float yo; /* 기준점의 Y좌표 [격자거리] */
23 + int first; /* 시작여부 (0 = 시작) */
24 +};
25 +
26 +/******************************************************************************
27 +*
28 +* MAIN
29 +*
30 +******************************************************************************/
31 +int main(int argc, char *argv[])
32 +{
33 + float lon, lat, x, y;
34 + struct lamc_parameter map;
35 +
36 + //
37 + // 인수 확인
38 + //
39 +
40 + if (argc != 4)
41 + {
42 + printf("[Usage] %s 1 <X-grid><Y-grid>\n", argv[0]);
43 + printf(" %s 0 <longitude><latitude>\n", argv[0]);
44 + exit(0);
45 + }
46 +
47 + if (atoi(argv[1]) == 1)
48 + {
49 + x = atof(argv[2]);
50 + y = atof(argv[3]);
51 +
52 + if (x < 1 || x > NX || y < 1 || y > NY)
53 + {
54 + printf("X-grid range [1,%d] / Y-grid range [1,%d]\n", NX, NY);
55 + exit(0);
56 + }
57 + }
58 + else if (atoi(argv[1]) == 0)
59 + {
60 + lon = atof(argv[2]);
61 + lat = atof(argv[3]);
62 + }
63 +
64 + //
65 + // 동네예보 지도 정보
66 + //
67 +
68 + map.Re = 6371.00877; // 지도반경
69 + map.grid = 5.0; // 격자간격 (km)
70 + map.slat1 = 30.0; // 표준위도 1
71 + map.slat2 = 60.0; // 표준위도 2
72 + map.olon = 126.0; // 기준점 경도
73 + map.olat = 38.0; // 기준점 위도
74 + map.xo = 210 / map.grid; // 기준점 X좌표
75 + map.yo = 675 / map.grid; // 기준점 Y좌표
76 + map.first = 0;
77 +
78 + //
79 + // 동네예보
80 + //
81 +
82 + map_conv(&lon, &lat, &x, &y, atoi(argv[1]), map);
83 +
84 + if (atoi(argv[1]))
85 + printf("X = %d, Y = %d --->lon.= %f, lat.= %f\n", (int)x, (int)y, lon, lat);
86 + else
87 + printf("lon.= %f, lat.= %f ---> X = %d, Y = %d\n", lon, lat, (int)x, (int)y);
88 +
89 + return 0;
90 +}
91 +
92 +/*============================================================================*
93 +* 좌표변환
94 +*============================================================================*/
95 +int
96 +map_conv
97 +(
98 + float *lon, // 경도(degree)
99 + float *lat, // 위도(degree)
100 + float *x, // X격자 (grid)
101 + float *y, // Y격자 (grid)
102 + int code, // 0 (격자->위경도), 1 (위경도->격자)
103 + struct lamc_parameter map // 지도정보
104 +)
105 +{
106 + float lon1, lat1, x1, y1;
107 +
108 + //
109 + // 위경도 -> (X,Y)
110 + //
111 +
112 + if (code == 0)
113 + {
114 + lon1 = *lon;
115 + lat1 = *lat;
116 + lamcproj(&lon1, &lat1, &x1, &y1, 0, &map);
117 + *x = (int)(x1 + 1.5);
118 + *y = (int)(y1 + 1.5);
119 + }
120 +
121 + //
122 + // (X,Y) -> 위경도
123 + //
124 +
125 + if (code == 1)
126 + {
127 + x1 = *x - 1;
128 + y1 = *y - 1;
129 + lamcproj(&lon1, &lat1, &x1, &y1, 1, &map);
130 + *lon = lon1;
131 + *lat = lat1;
132 + }
133 + return 0;
134 +}
135 +
136 +/***************************************************************************
137 +*
138 +* [ Lambert Conformal Conic Projection ]
139 +*
140 +* olon, lat : (longitude,latitude) at earth [degree]
141 +* o x, y : (x,y) cordinate in map [grid]
142 +* o code = 0 : (lon,lat) --> (x,y)
143 +* 1 : (x,y) --> (lon,lat)
144 +*
145 +***************************************************************************/
146 +
147 +int lamcproj(lon, lat, x, y, code, map)
148 +
149 +float *lon, *lat; /* Longitude, Latitude [degree] */
150 +float *x, *y; /* Coordinate in Map [grid] */
151 +int code; /* (0) lon,lat ->x,y (1) x,y ->lon,lat */
152 +struct lamc_parameter *map;
153 +{
154 + static double PI, DEGRAD, RADDEG;
155 + static double re, olon, olat, sn, sf, ro;
156 + double slat1, slat2, alon, alat, xn, yn, ra, theta;
157 +
158 + if ((*map).first == 0) {
159 + PI = asin(1.0)*2.0;
160 + DEGRAD = PI / 180.0;
161 + RADDEG = 180.0 / PI;
162 +
163 + re = (*map).Re / (*map).grid;
164 + slat1 = (*map).slat1 * DEGRAD;
165 + slat2 = (*map).slat2 * DEGRAD;
166 + olon = (*map).olon * DEGRAD;
167 + olat = (*map).olat * DEGRAD;
168 +
169 + sn = tan(PI*0.25 + slat2*0.5) / tan(PI*0.25 + slat1*0.5);
170 + sn = log(cos(slat1) / cos(slat2)) / log(sn);
171 + sf = tan(PI*0.25 + slat1*0.5);
172 + sf = pow(sf, sn)*cos(slat1) / sn;
173 + ro = tan(PI*0.25 + olat*0.5);
174 + ro = re*sf / pow(ro, sn);
175 + (*map).first = 1;
176 + }
177 +
178 + if (code == 0) {
179 + ra = tan(PI*0.25 + (*lat)*DEGRAD*0.5);
180 + ra = re*sf / pow(ra, sn);
181 + theta = (*lon)*DEGRAD - olon;
182 + if (theta > PI) theta -= 2.0*PI;
183 + if (theta < -PI) theta += 2.0*PI;
184 + theta *= sn;
185 + *x = (float)(ra*sin(theta)) + (*map).xo;
186 + *y = (float)(ro - ra*cos(theta)) + (*map).yo;
187 + }
188 + else {
189 + xn = *x - (*map).xo;
190 + yn = ro - *y + (*map).yo;
191 + ra = sqrt(xn*xn + yn*yn);
192 + if (sn< 0.0) - ra;
193 + alat = pow((re*sf / ra), (1.0 / sn));
194 + alat = 2.0*atan(alat) - PI*0.5;
195 + if (fabs(xn) <= 0.0) {
196 + theta = 0.0;
197 + }
198 + else {
199 + if (fabs(yn) <= 0.0) {
200 + theta = PI*0.5;
201 + if (xn< 0.0) - theta;
202 + }
203 + else
204 + theta = atan2(xn, yn);
205 + }
206 + alon = theta / sn + olon;
207 + *lat = (float)(alat*RADDEG);
208 + *lon = (float)(alon*RADDEG);
209 + }
210 + return 0;
211 +}