Junyoung, Sung

Added whole project

Showing 271 changed files with 3090 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 +/**
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.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.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.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 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.