Junyoung, Sung

Added whole project

Showing 271 changed files with 3090 additions and 0 deletions
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
node_modules/
*.out
config/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<<<<<<< HEAD
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<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">
=======
<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">
>>>>>>> 32cfac39b1691cde61fa34203f0b709f605df17d
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/LoLock.iml" filepath="$PROJECT_DIR$/LoLock.iml" />
<module fileurl="file://$PROJECT_DIR$/LoLock-Android.iml" filepath="$PROJECT_DIR$/LoLock-Android.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.gunghi.tgwing.lolock"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
})
repositories {
jcenter() // If not already there
}
dependencies {
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.4@aar'
}
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.roughike:bottom-bar:1.4.0.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.tsengvn:typekit:1.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'com.airbnb.android:lottie:2.1.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'pub.devrel:easypermissions:0.4.2'
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-calendar:v3-rev250-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'realm-android'
{
"project_info": {
"project_number": "1076942403851",
"firebase_url": "https://lolock-5ee55.firebaseio.com",
"project_id": "lolock-5ee55",
"storage_bucket": "lolock-5ee55.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1076942403851:android:bbf5df34ab2eb04a",
"android_client_info": {
"package_name": "com.gunghi.tgwing.lolock"
}
},
"oauth_client": [
{
"client_id": "1076942403851-649errgesgcs53hrfinb3q1q4i331fgk.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.gunghi.tgwing.lolock",
"certificate_hash": "461a4eea1d06d912f5ba34a7122953d8986077ae"
}
},
{
"client_id": "1076942403851-mrt95aun9t87hmjsrgnggb663r27kdbi.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDlcIA8Da_DaDdp9QtWdcjSWeRFM426bvs"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "1076942403851-mrt95aun9t87hmjsrgnggb663r27kdbi.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/joyeongje/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.gunghi.tgwing.lolock;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.gunghi.tgwing.lolock", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gunghi.tgwing.lolock">
<!--
Declare this required feature if you want to make the app available to BLE-capable
devices only. If you want to make your app available to devices that don't support BLE,
you should omit this in the manifest. Instead, determine BLE capability by using
PackageManager.hasSystemFeature(FEATURE_BLUETOOTH_LE)
-->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:name=".util.TypekitSetting"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher_lolock"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.MainActivity" />
<activity android:name=".ui.SettingActivity" />
<service
android:name=".service.BluetoothLeService"
android:enabled="true" />
<!-- [START firebase_service] -->
<service android:name=".service.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- [END firebase_service] -->
<!-- [START firebase_iid_service] -->
<service android:name=".service.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<!-- [END firebase_iid_service] -->
<activity android:name=".ui.RegisterActivity" />
<activity android:name=".ui.Register2Activity"/>
</application>
</manifest>
\ No newline at end of file
This file is too large to display.
package com.gunghi.tgwing.lolock;
/**
* Created by joyeongje on 2017. 7. 1..
*/
/**
* Defines several constants used between {@link BluetoothChatService} and the UI.
*/
public interface Constants {
// Message types sent from the BluetoothChatService Handler
public static final int MESSAGE_STATE_CHANGE = 1;
public static final int MESSAGE_READ = 2;
public static final int MESSAGE_WRITE = 3;
public static final int MESSAGE_DEVICE_NAME = 4;
public static final int MESSAGE_TOAST = 5;
// Key names received from the BluetoothChatService Handler
public static final String DEVICE_NAME = "device_name";
public static final String TOAST = "toast";
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.Response;
/**
* Created by joyeongje on 2017. 7. 21..
*/
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class ResponseDaumAddressAPI {
@SerializedName("type")
@Expose
private String type;
@SerializedName("code")
@Expose
private String code;
@SerializedName("name")
@Expose
private String name;
@SerializedName("fullName")
@Expose
private String fullName;
@SerializedName("regionId")
@Expose
private String regionId;
@SerializedName("name0")
@Expose
private String name0;
@SerializedName("code1")
@Expose
private String code1;
@SerializedName("name1")
@Expose
private String name1;
@SerializedName("code2")
@Expose
private String code2;
@SerializedName("name2")
@Expose
private String name2;
@SerializedName("code3")
@Expose
private String code3;
@SerializedName("name3")
@Expose
private String name3;
@SerializedName("x")
@Expose
private Double x;
@SerializedName("y")
@Expose
private Double y;
/**
* No args constructor for use in serialization
*
*/
public ResponseDaumAddressAPI() {
}
/**
*
* @param code
* @param type
* @param name3
* @param name
* @param code2
* @param code1
* @param fullName
* @param code3
* @param name1
* @param name2
* @param y
* @param x
* @param regionId
* @param name0
*/
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) {
super();
this.type = type;
this.code = code;
this.name = name;
this.fullName = fullName;
this.regionId = regionId;
this.name0 = name0;
this.code1 = code1;
this.name1 = name1;
this.code2 = code2;
this.name2 = name2;
this.code3 = code3;
this.name3 = name3;
this.x = x;
this.y = y;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getRegionId() {
return regionId;
}
public void setRegionId(String regionId) {
this.regionId = regionId;
}
public String getName0() {
return name0;
}
public void setName0(String name0) {
this.name0 = name0;
}
public String getCode1() {
return code1;
}
public void setCode1(String code1) {
this.code1 = code1;
}
public String getName1() {
return name1;
}
public void setName1(String name1) {
this.name1 = name1;
}
public String getCode2() {
return code2;
}
public void setCode2(String code2) {
this.code2 = code2;
}
public String getName2() {
return name2;
}
public void setName2(String name2) {
this.name2 = name2;
}
public String getCode3() {
return code3;
}
public void setCode3(String code3) {
this.code3 = code3;
}
public String getName3() {
return name3;
}
public void setName3(String name3) {
this.name3 = name3;
}
public Double getX() {
return x;
}
public void setX(Double x) {
this.x = x;
}
public Double getY() {
return y;
}
public void setY(Double y) {
this.y = y;
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.Response;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class ResponseInOutLog {
@SerializedName("results")
@Expose
private List<Result> results = null;
/**
* No args constructor for use in serialization
*
*/
public ResponseInOutLog() {
}
/**
*
* @param results
*/
public ResponseInOutLog(List<Result> results) {
super();
this.results = results;
}
public List<Result> getResults() {
return results;
}
public void setResults(List<Result> results) {
this.results = results;
}
public ResponseInOutLog withResults(List<Result> results) {
this.results = results;
return this;
}
public class OutTime {
@SerializedName("month")
@Expose
private Integer month;
@SerializedName("day")
@Expose
private Integer day;
@SerializedName("hour")
@Expose
private Integer hour;
@SerializedName("min")
@Expose
private Integer min;
@SerializedName("dayName")
@Expose
private String dayName;
@SerializedName("timeStamp")
@Expose
private long timeStamp;
/**
* No args constructor for use in serialization
*
*/
public OutTime() {
}
/**
* @param month
* @param day
* @param hour
* @param min
* @param dayName
*/
public OutTime(Integer month, Integer day, Integer hour, Integer min, String dayName) {
super();
this.month = month;
this.day = day;
this.hour = hour;
this.min = min;
this.dayName = dayName;
}
public Integer getMonth() {
return month;
}
public void setMonth(Integer month) {
this.month = month;
}
public OutTime withMonth(Integer month) {
this.month = month;
return this;
}
public Integer getDay() {
return day;
}
public void setDay(Integer day) {
this.day = day;
}
public OutTime withDay(Integer day) {
this.day = day;
return this;
}
public Integer getHour() {
return hour;
}
public void setHour(Integer hour) {
this.hour = hour;
}
public OutTime withHour(Integer hour) {
this.hour = hour;
return this;
}
public Integer getMin() {
return min;
}
public void setMin(Integer min) {
this.min = min;
}
public OutTime withMin(Integer min) {
this.min = min;
return this;
}
public String getDayName() {
return dayName;
}
public void setDayName(String dayName) {
this.dayName = dayName;
}
public long getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
}
public class Result {
@SerializedName("name")
@Expose
private String name;
@SerializedName("outFlag")
@Expose
private Integer outFlag;
@SerializedName("strangeFlag")
@Expose
private Integer strangeFlag;
@SerializedName("outTime")
@Expose
private OutTime outTime;
/**
* No args constructor for use in serialization
*
*/
public Result() {
}
/**
*
* @param name
* @param outFlag
* @param strangeFlag
* @param outTime
*/
public Result(String name, Integer outFlag, Integer strangeFlag, OutTime outTime) {
super();
this.name = name;
this.outFlag = outFlag;
this.strangeFlag = strangeFlag;
this.outTime = outTime;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Result withName(String name) {
this.name = name;
return this;
}
public Integer getOutFlag() {
return outFlag;
}
public void setOutFlag(Integer outFlag) {
this.outFlag = outFlag;
}
public Result withOutFlag(Integer outFlag) {
this.outFlag = outFlag;
return this;
}
public Integer getStrangeFlag() {
return strangeFlag;
}
public void setStrangeFlag(Integer strangeFlag) {
this.strangeFlag = strangeFlag;
}
public Result withStrangeFlag(Integer strangeFlag) {
this.strangeFlag = strangeFlag;
return this;
}
public OutTime getOutTime() {
return outTime;
}
public void setOutTime(OutTime outTime) {
this.outTime = outTime;
}
public Result withOutTime(OutTime outTime) {
this.outTime = outTime;
return this;
}
}
}
package com.gunghi.tgwing.lolock.Response;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by joyeongje on 2017. 7. 21..
*/
public class ResponseLoLockService {
@SerializedName("code")
@Expose
private String code;
@SerializedName("message")
@Expose
private String message;
/**
* No args constructor for use in serialization
*
*/
public ResponseLoLockService() {
}
/**
*
* @param message
* @param code
*/
public ResponseLoLockService(String code, String message) {
super();
this.code = code;
this.message = message;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.gunghi.tgwing.lolock.Response;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.gunghi.tgwing.lolock.model.Mate;
import java.util.List;
public class ResponseMate {
@SerializedName("mates")
@Expose
private List<Mate> mates = null;
@SerializedName("mateNumber")
@Expose
private Integer mateNumber;
/**
* No args constructor for use in serialization
*
*/
public ResponseMate() {
}
/**
*
* @param mateNumber
* @param mates
*/
public ResponseMate(List<Mate> mates, Integer mateNumber) {
super();
this.mates = mates;
this.mateNumber = mateNumber;
}
public List<Mate> getMates() {
return mates;
}
public void setMates(List<Mate> mates) {
this.mates = mates;
}
public Integer getMateNumber() {
return mateNumber;
}
public void setMateNumber(Integer mateNumber) {
this.mateNumber = mateNumber;
}
}
package com.gunghi.tgwing.lolock.Response;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by joyeongje on 2017. 7. 22..
*/
public class ResponseOpenDoorKey {
@SerializedName("link")
@Expose
private String link;
@SerializedName("code")
@Expose
private String code;
/**
* No args constructor for use in serialization
*
*/
public ResponseOpenDoorKey() {
}
/**
*
* @param link
* @param code
*/
public ResponseOpenDoorKey(String link, String code) {
super();
this.link = link;
this.code = code;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.Response;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.gunghi.tgwing.lolock.model.UserInfo;
/**
* Created by joyeongje on 2017. 7. 21..
*/
public class ResponseUserInfo {
@SerializedName("code")
@Expose
private String code;
@SerializedName("userInfo")
@Expose
private UserInfo userInfo;
@SerializedName("message")
@Expose
private String message;
/**
* No args constructor for use in serialization
*
*/
public ResponseUserInfo() {
}
/**
*
* @param message
* @param code
* @param userInfo
*/
public ResponseUserInfo(String code, UserInfo userInfo, String message) {
super();
this.code = code;
this.userInfo = userInfo;
this.message = message;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public UserInfo getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.Response;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by joyeongje on 2017. 7. 22..
*/
public class ResponseWeather {
@SerializedName("baseTime")
@Expose
private Integer baseTime;
@SerializedName("baseDate")
@Expose
private Integer baseDate;
@SerializedName("sky")
@Expose
private String sky;
@SerializedName("temperature")
@Expose
private Double temperature;
@SerializedName("probabilityRain")
@Expose
private Integer probabilityRain;
@SerializedName("minTemperature")
@Expose
private Integer minTemperature;
@SerializedName("maxTemperature")
@Expose
private Integer maxTemperature;
@SerializedName("location")
@Expose
private String location;
/**
* No args constructor for use in serialization
*
*/
public ResponseWeather() {
}
/**
*
* @param sky
* @param minTemperature
* @param baseDate
* @param baseTime
* @param probabilityRain
* @param maxTemperature
* @param temperature
*/
public ResponseWeather(Integer baseTime, Integer baseDate, String sky, Double temperature, Integer probabilityRain, Integer minTemperature, Integer maxTemperature) {
super();
this.baseTime = baseTime;
this.baseDate = baseDate;
this.sky = sky;
this.temperature = temperature;
this.probabilityRain = probabilityRain;
this.minTemperature = minTemperature;
this.maxTemperature = maxTemperature;
}
public Integer getBaseTime() {
return baseTime;
}
public void setBaseTime(Integer baseTime) {
this.baseTime = baseTime;
}
public Integer getBaseDate() {
return baseDate;
}
public void setBaseDate(Integer baseDate) {
this.baseDate = baseDate;
}
public String getSky() {
return sky;
}
public void setSky(String sky) {
this.sky = sky;
}
public Double getTemperature() {
return temperature;
}
public void setTemperature(Double temperature) {
this.temperature = temperature;
}
public Integer getProbabilityRain() {
return probabilityRain;
}
public void setProbabilityRain(Integer probabilityRain) {
this.probabilityRain = probabilityRain;
}
public Integer getMinTemperature() {
return minTemperature;
}
public void setMinTemperature(Integer minTemperature) {
this.minTemperature = minTemperature;
}
public Integer getMaxTemperature() {
return maxTemperature;
}
public void setMaxTemperature(Integer maxTemperature) {
this.maxTemperature = maxTemperature;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.model;
/**
* Created by joyeongje on 2017. 7. 25..
*/
public class GoogleSchedularData {
private String summaryTitle;
private String startTime;
private String googleLink;
public GoogleSchedularData() {
}
public GoogleSchedularData(String summaryTitle,String startTime,String googleLink) {
this.summaryTitle = summaryTitle;
this.startTime = startTime;
this.googleLink = googleLink;
}
public String getSummaryTitle() {
return summaryTitle;
}
public void setSummaryTitle(String summaryTitle) {
this.summaryTitle = summaryTitle;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getGoogleLink() {
return googleLink;
}
public void setGoogleLink(String googleLink) {
this.googleLink = googleLink;
}
}
package com.gunghi.tgwing.lolock.model;
import com.gunghi.tgwing.lolock.Response.ResponseInOutLog;
/**
* Created by joyeongje on 2017. 7. 22..
*/
public class InOutLog {
private String name;
private int outingFlag;
private ResponseInOutLog.OutTime inOutDate;
private int strangeFlag;
public InOutLog() {
}
public InOutLog(String name, int outingFlag, ResponseInOutLog.OutTime inOutDate, int strangeFlag) {
this.name = name;
this.outingFlag = outingFlag;
this.inOutDate = inOutDate;
this.strangeFlag = strangeFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getStrangeFlag() {
return strangeFlag;
}
public void setStrangeFlag(int strangeFlag) {
this.strangeFlag = strangeFlag;
}
public ResponseInOutLog.OutTime getInOutDate() {
return inOutDate;
}
public void setInOutDate(ResponseInOutLog.OutTime inOutDate) {
this.inOutDate = inOutDate;
}
public int getOutingFlag() {
return outingFlag;
}
public void setOutingFlag(int outingFlag) {
this.outingFlag = outingFlag;
}
}
package com.gunghi.tgwing.lolock.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Mate {
@SerializedName("mateImageUrl")
@Expose
private String mateImageUrl;
@SerializedName("mateName")
@Expose
private String mateName;
@SerializedName("mateOutingFlag")
@Expose
private String mateOutingFlag;
@SerializedName("mateDoorOpenTime")
@Expose
private String mateDoorOpenTime;
/**
* No args constructor for use in serialization
*
*/
public Mate() {
}
/**
*
* @param mateOutingFlag
* @param mateDoorOpenTime
* @param mateImageUrl
* @param mateName
*/
public Mate(String mateImageUrl, String mateName, String mateOutingFlag, String mateDoorOpenTime) {
super();
this.mateImageUrl = mateImageUrl;
this.mateName = mateName;
this.mateOutingFlag = mateOutingFlag;
this.mateDoorOpenTime = mateDoorOpenTime;
}
public String getMateImageUrl() {
return mateImageUrl;
}
public void setMateImageUrl(String mateImageUrl) {
this.mateImageUrl = mateImageUrl;
}
public String getMateName() {
return mateName;
}
public void setMateName(String mateName) {
this.mateName = mateName;
}
public String getMateOutingFlag() {
return mateOutingFlag;
}
public void setMateOutingFlag(String mateOutingFlag) {
this.mateOutingFlag = mateOutingFlag;
}
public String getMateDoorOpenTime() {
return mateDoorOpenTime;
}
public void setMateDoorOpenTime(String mateDoorOpenTime) {
this.mateDoorOpenTime = mateDoorOpenTime;
}
}
package com.gunghi.tgwing.lolock.model;
/**
* Created by joyeongje on 2017. 7. 21..
*/
public class RegisterUserInfo {
private String registerUserName;
private String registerDeviceAddr;
private String registerDeviceGPS_lat;
private String registerDeviceGPS_lon;
private String registerDeviceId;
private String registerUserPhoneId;
private static final RegisterUserInfo ourInstance = new RegisterUserInfo();
public static RegisterUserInfo getInstance() {
return ourInstance;
}
private RegisterUserInfo() {
}
public String getRegisterUserName() {
return registerUserName;
}
public void setRegisterUserName(String registerUserName) {
this.registerUserName = registerUserName;
}
public String getRegisterDeviceAddr() {
return registerDeviceAddr;
}
public void setRegisterDeviceAddr(String registerDeviceAddr) {
this.registerDeviceAddr = registerDeviceAddr;
}
public String getRegisterDeviceGPS_lat() {
return registerDeviceGPS_lat;
}
public void setRegisterDeviceGPS_lat(String registerDeviceGPS_lat) {
this.registerDeviceGPS_lat = registerDeviceGPS_lat;
}
public String getRegisterDeviceGPS_lon() {
return registerDeviceGPS_lon;
}
public void setRegisterDeviceGPS_lon(String registerDeviceGPS_lon) {
this.registerDeviceGPS_lon = registerDeviceGPS_lon;
}
public String getRegisterDeviceId() {
return registerDeviceId;
}
public void setRegisterDeviceId(String registerDeviceId) {
this.registerDeviceId = registerDeviceId;
}
public String getRegisterUserPhoneId() {
return registerUserPhoneId;
}
public void setRegisterUserPhoneId(String registerUserPhoneId) {
this.registerUserPhoneId = registerUserPhoneId;
}
}
package com.gunghi.tgwing.lolock.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by joyeongje on 2017. 7. 19..
*/
public class UserInfo {
private static final UserInfo ourInstance = new UserInfo();
public static UserInfo getInstance() {
return ourInstance;
}
@SerializedName("name")
@Expose
private String name;
@SerializedName("lolockLTID")
@Expose
private String lolockLTID;
private String devideId;
/**
* No args constructor for use in serialization
*
*/
public UserInfo() {
}
/**
*
* @param name
* @param lolockLTID
*/
public UserInfo(String name, String lolockLTID) {
super();
this.name = name;
this.lolockLTID = lolockLTID;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLolockLTID() {
return lolockLTID;
}
public void setLolockLTID(String lolockLTID) {
this.lolockLTID = lolockLTID;
}
public String getDevideId() {
return devideId;
}
public void setDevideId(String devideId) {
this.devideId = devideId;
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.network;
import com.gunghi.tgwing.lolock.Response.ResponseDaumAddressAPI;
import java.util.Map;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.QueryMap;
/**
* Created by joyeongje on 2017. 7. 21..
*/
public interface DaumService {
String daumAPIKey = "04b68611d624a48f5a37bf1ad4324600";
String inputCoordSystem="WGS84";
String outputType= "json";
@GET("/local/geo/coord2addr")
Call<ResponseDaumAddressAPI> changeCoordToAddress(
@QueryMap Map<String, String> queryParams
);
}
package com.gunghi.tgwing.lolock.network;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by joyeongje on 2017. 7. 21..
*/
public class DaumServiceGenerator {
private static final String DAUM_API_BASE_URL = "https://apis.daum.net/";
//private static final String DAUM_API_KEY = "04b68611d624a48f5a37bf1ad4324600/";
private static Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(DAUM_API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create());
private static Retrofit retrofit = builder.build();
private static OkHttpClient.Builder httpClient =
new OkHttpClient.Builder();
public static <S> S createService(
Class<S> serviceClass) {
return retrofit.create(serviceClass);
}
}
package com.gunghi.tgwing.lolock.network;
import com.gunghi.tgwing.lolock.Response.ResponseInOutLog;
import com.gunghi.tgwing.lolock.Response.ResponseLoLockService;
import com.gunghi.tgwing.lolock.Response.ResponseMate;
import com.gunghi.tgwing.lolock.Response.ResponseOpenDoorKey;
import com.gunghi.tgwing.lolock.Response.ResponseUserInfo;
import com.gunghi.tgwing.lolock.Response.ResponseWeather;
import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
/**
* Created by joyeongje on 2017. 7. 15..
*/
public interface LoLockService {
// 로라 일련번호 유효성 체크
@GET("/ThingPlug/checkId/{number}")
Call<ResponseLoLockService> checkLoraNumberId(
@Path("number") String number);
@POST("/ThingPlug/register")
Call<ResponseBody> registLoLock(
@Body RegisterUserInfo registerUserInfo);
// 디바이스 아이디로 기존정보 조회
@GET("/ThingPlug/userInfo/{phoneId}")
Call<ResponseUserInfo> getUserInfo(
@Path("phoneId") String phoneId
);
// 원격 문열림
@FormUrlEncoded
@PUT("/ThingPlug/remote-open")
Call<ResponseBody> remoteOnOffLock(
@Field("openDeviceId") String openDeviceId
);
// 문열림 링크 주기
@GET("/ThingPlug/open-url/{deviceId}")
Call<ResponseOpenDoorKey> getDoorOpenCode(
@Path("deviceId") String deviceId);
// 날씨 정보 가져오기
@GET("/ThingPlug/weatherdata/{LTID}")
Call<ResponseWeather> getWeatherData(
@Path("LTID") String LTID);
// 동거인 목록 가져오기.
@GET("/ThingPlug/homemateslist/{LTID}")
Call<ResponseMate> getHomeMateResponse(
@Path("LTID") String LTID);
// 출입기록 알람 가져오기
@GET("/ThingPlug/outing-log/{deviceId}")
Call<ResponseInOutLog> getInOutLog(
@Path("deviceId") String deviceId
);
// 나갈시 유저체크 url
@GET("/ThingPlug/checkout/{deviceId}")
Call<ResponseBody> checkOutURL(
@Path("deviceId") String deviceId
);
// 들어올시 유저체크 url
@GET("/ThingPlug/checkin/{deviceId}")
Call<ResponseBody> checkInURL(
@Path("deviceId") String deviceId
);
}
package com.gunghi.tgwing.lolock.network;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by joyeongje on 2017. 7. 15..
*/
public class LoLockServiceGenarator {
private static final String BASE_URL = "http://52.79.83.113:10080";
private static Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create());
private static Retrofit retrofit = builder.build();
private static OkHttpClient.Builder httpClient =
new OkHttpClient.Builder();
public static <S> S createService(
Class<S> serviceClass) {
return retrofit.create(serviceClass);
}
}
package com.gunghi.tgwing.lolock.service;
import android.content.SharedPreferences;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;
import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
/**
* Created by joyeongje on 2017. 7. 16..
*/
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
/**
* Called if InstanceID token is updated. This may occur if the security of
* the previous token had been compromised. Note that this is called when the InstanceID token
* is initially generated so this is where you would retrieve the token.
*/
// [START refresh_token]
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
final String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
saveTokenInRealmDB(refreshedToken);
}
// [END refresh_token]
private void saveTokenInRealmDB(final String token) {
RegisterUserInfo.getInstance().setRegisterUserPhoneId(token);
SharedPreferences lolockLocalData = getSharedPreferences("lolockLocalData", MODE_PRIVATE);
SharedPreferences.Editor editor = lolockLocalData.edit();
editor.putString("deviceId", token); //First라는 key값으로 infoFirst 데이터를 저장한다.
editor.apply(); //완료한다.
Log.d("토큰 저장","됨");
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.service;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.ui.SplashActivity;
import java.util.Map;
/**
* Created by joyeongje on 2017. 7. 16..
*/
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
public static final String PUSH_WEATHER_PLAN = "0";
public static final String PUSH_IN_OUT_LOG = "1";
public static final String PUSH_STRANGE_ALARM = "2";
public static final String PUSH_OUT_CHECK_USER = "3";
public static final String PUSH_IN_CHECK_USER = "4";
public static boolean IN_OUT_CODE = false;
private LoLockService lolockService;
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// [START_EXCLUDE]
// Notification messages are only received here in onMessageReceived when the app
// is in the foreground. When the app is in the background an automatically generated notification is displayed.
// When the user taps on the notification they are returned to the app.
// Messages containing both notification and data payloads are treated as notification messages.
// The Firebase console always sends notification
// messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
// [END_EXCLUDE]
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
// 백그라운드 포그라운드 둘다됨.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
Map<String, String> getRemoteMessageHash = remoteMessage.getData();
sendNotification(getRemoteMessageHash);
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
// sendNotification(remoteMessage.getNotification().get);
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
// [END receive_message]
/**
* Schedule a job using FirebaseJobDispatcher.
*/
private void scheduleJob() {
// [START dispatch_job]
//FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
//Job myJob = dispatcher.newJobBuilder()
// .setService(MyJobService.class)
// .setTag("my-job-tag")
// .build();
//dispatcher.schedule(myJob);
// [END dispatch_job]
}
/**
* Handle time allotted to BroadcastReceivers.
*/
private void handleNow() {
Log.d(TAG, "Short lived task is done.");
}
/**
* Create and show a simple notification containing the received FCM message.
*
* @param messageBody FCM message body received.
*/
private void sendNotification(Map<String,String> messageBody) {
//intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Log.d("FirebaseMessage Service", messageBody.toString());
String title = "";
String content = messageBody.get("message");
String pushCode = messageBody.get("pushCode");
String pushExtra = "inOutLog";
switch (pushCode) {
// 액티비티 전환
case PUSH_WEATHER_PLAN:
title = "날씨 및 일정";
pushExtra = "weatherPlan";
break;
case PUSH_IN_OUT_LOG:
title = "출입 로그";
pushExtra = "inOutLog";
break;
case PUSH_STRANGE_ALARM:
title = "위험 감지";
pushExtra = "strangeAlarm";
break;
// 걍 인터넷 통신만 해야됨...
case PUSH_OUT_CHECK_USER:
IN_OUT_CODE = true;
break;
case PUSH_IN_CHECK_USER:
IN_OUT_CODE = false;
break;
}
if (pushCode.equals(PUSH_OUT_CHECK_USER) || pushCode.equals(PUSH_IN_CHECK_USER)) {
Intent bleIntent = new Intent(this, BluetoothLeService.class);
startService(bleIntent);
Log.d("start ble scan servcie", "시작");
} else {
Intent intent = new Intent(this, SplashActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("viewFragment", pushExtra);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher_lolock)
.setContentTitle(title)
.setContentText(content)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}
}
}
package com.gunghi.tgwing.lolock.ui;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.Response.ResponseInOutLog;
import com.gunghi.tgwing.lolock.model.InOutLog;
import com.gunghi.tgwing.lolock.model.UserInfo;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
import java.util.ArrayList;
import java.util.Date;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by joyeongje on 2017. 7. 20..
*/
public class FragmentAlarm extends Fragment {
private InOutLogAdapter inOutLogAdapter;
private ArrayList<InOutLog> inOutLogs;
Date date;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_alarm, container, false);
RecyclerView mateRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragmentAlarmRecyclerView);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
mateRecyclerView.setLayoutManager(mLayoutManager);
mateRecyclerView.setHasFixedSize(true);
mateRecyclerView.scrollToPosition(0);
inOutLogs = new ArrayList<>();
//mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
//mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
//mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
inOutLogAdapter = new InOutLogAdapter(inOutLogs,getContext());
mateRecyclerView.setAdapter(inOutLogAdapter);
mateRecyclerView.setItemAnimator(new DefaultItemAnimator());
date = new Date();
getInOutLogList();
// getMateList();
return rootView;
}
private void getInOutLogList() {
LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
Call<ResponseInOutLog> callLolockService = loLockService.getInOutLog(UserInfo.getInstance().getDevideId());
callLolockService.enqueue(new Callback<ResponseInOutLog>() {
@Override
public void onResponse(Call<ResponseInOutLog> call, Response<ResponseInOutLog> response) {
Log.d("Success","Suc");
alramDataMappingUi(response.body());
}
@Override
public void onFailure(Call<ResponseInOutLog> call, Throwable t) {
Log.d("Fail","Fail");
}
});
}
private void alramDataMappingUi(ResponseInOutLog response) {
for(ResponseInOutLog.Result result : response.getResults()) {
String name = result.getName();
int outFlag = result.getOutFlag();
ResponseInOutLog.OutTime outTime = result.getOutTime();
int strangFlag = result.getStrangeFlag();
inOutLogs.add(new InOutLog(name,outFlag,outTime,strangFlag));
}
inOutLogAdapter.notifyDataSetChanged();
}
private class InOutLogAdapter extends RecyclerView.Adapter<InOutLogAdapter.ViewHolder> {
private ArrayList<InOutLog> inoutLogs;
private Context context;
public InOutLogAdapter(ArrayList<InOutLog> inoutLogs, Context context) {
this.inoutLogs = inoutLogs;
this.context = context;
}
@Override
public InOutLogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_alarm, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(InOutLogAdapter.ViewHolder holder, int position) {
final InOutLog inoutLog = inoutLogs.get(position);
String nameText = "";
if(inoutLog.getStrangeFlag() == 1 ) {
holder.inOutContainer.setBackgroundColor(Color.parseColor("#FF9797"));
holder.inOutContainer.setAlpha(0.85f);
holder.inoutImageView.setImageResource(R.drawable.ic_alarm_known);
nameText = "외부인의 침입이 의심됩니다!";
} else {
holder.inoutImageView.setImageResource(R.drawable.ic_alarm_unknown);
nameText = inoutLog.getName() + "님이 ";
// 1일때 나간거
if(inoutLog.getOutingFlag() == 0) {
nameText += "귀가하였습니다.";
} else {
nameText += "외출하셨습니다.";
}
}
holder.inOutNameTextView.setText(nameText);
long diff = inoutLog.getInOutDate().getTimeStamp();
Log.d("timeStamp",String.valueOf(diff));
long diffMinutes = diff / (60 * 1000);
// long diffHours = diff / (60 * 60 * 1000);
String duringTime = diffMinutes/60 + "시간 " +
diffMinutes%60 + "분전";
holder.inOutTime.setText(duringTime);
holder.inOutDate.setText(inoutLog.getInOutDate().getMonth() + "/" +
inoutLog.getInOutDate().getDay() + "(" + inoutLog.getInOutDate().getDayName() + ")");
//Picasso.with(context).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);//Log.d("url",mateInfo.getMateImageUrl());
// holder.mateName.setText(mateInfo.getMateName());
// holder.mateDoorOpenTime.setText(mateInfo.getMateDoorOpenTime());
// holder.mateOutingFlag.setImageResource(R.drawable.ic_out_home);
// Picasso.with(holder.mateProfile.getContext()).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);
}
@Override
public int getItemCount() {
return inoutLogs.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
// public CircleImageView mateProfile;
// public TextView mateName;
// public TextView mateDoorOpenTime;
// public ImageView mateOutingFlag;
public ConstraintLayout inOutContainer;
public TextView inOutNameTextView;
public TextView inOutTime;
public TextView inOutDate;
public ImageView inoutImageView;
public ViewHolder(View itemView) {
super(itemView);
inOutContainer = (ConstraintLayout) itemView.findViewById(R.id.cardAlarm);
inOutNameTextView = (TextView) itemView.findViewById(R.id.inOutName);
inOutTime = (TextView) itemView.findViewById(R.id.inOutTime);
inOutDate = (TextView) itemView.findViewById(R.id.inOutDate);
inoutImageView = (ImageView) itemView.findViewById(R.id.icAlarmImageView);
// mateProfile = (CircleImageView) itemView.findViewById(R.id.mateProfileImageView);
// mateName = (TextView) itemView.findViewById(R.id.mateNameTextView);
// mateDoorOpenTime = (TextView) itemView.findViewById(R.id.mateOutingTimeTextView);
// mateOutingFlag = (ImageView) itemView.findViewById(R.id.mateOutingFlag);
}
}
}
}
package com.gunghi.tgwing.lolock.ui;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.Toast;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.model.UserInfo;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.content.ContentValues.TAG;
/**
* Created by joyeongje on 2017. 7. 1..
*/
public class FragmentDoorOnOff extends Fragment {
private boolean openFlag = false;
ImageButton imageButton;
ImageButton doorKeycodeButton;
LoLockService loLockService;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_door_on_off, container, false);
loLockService = LoLockServiceGenarator.createService(LoLockService.class);
imageButton = (ImageButton) rootView.findViewById(R.id.fragmentDoorOnOffButton);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openDoor();
}
});
doorKeycodeButton = (ImageButton) rootView.findViewById(R.id.fragmentDoorCodeKeyButton);
doorKeycodeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final OpenDoorCodeDialog openDoorCodeDialog =
new OpenDoorCodeDialog(getActivity());
doorKeycodeButton.setImageResource(R.drawable.ic_key_off_new);
openDoorCodeDialog.show();
}
});
return rootView;
}
private void openDoor() {
//Log.d("user token", UserInfo.getInstance().getRegisterUserPhoneId());
//Call<ResponseBody> requestOpenDoor = loLockService.remoteOnOffLock(UserInfo.getInstance().getRegisterUserPhoneId());
Call<ResponseBody> requestOpenDoor = loLockService.remoteOnOffLock(UserInfo.getInstance().getDevideId());
requestOpenDoor.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.d(TAG,"CALL " + call.toString());
Log.d(TAG,"Response" + response.toString());
if(response.isSuccessful()) {
// TODO: 2017. 7. 22. 더해야됨
Log.d(TAG,"door Response Success");
Toast.makeText(getContext(),"문이 열렸습니다.",Toast.LENGTH_SHORT).show();
imageButton.setImageResource(R.drawable.ic_door_closed);
//3초후에 화면 자동변환
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
imageButton.setImageResource(R.drawable.ic_door_open);
}
},2000);
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(getContext(),"서버 상태가 불안정합니다.",Toast.LENGTH_SHORT).show();
imageButton.setImageResource(R.drawable.ic_door_open);
}
});
}
}
package com.gunghi.tgwing.lolock.ui;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.Response.ResponseMate;
import com.gunghi.tgwing.lolock.model.Mate;
import com.gunghi.tgwing.lolock.model.UserInfo;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by joyeongje on 2017. 7. 1..
*/
public class FragmentMate extends Fragment {
private ArrayList<Mate> mates;
private MateAdapter mateAdapter;
private final String TAG = "FragmentMate";
private TextView mateNumberTextView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_mate, container, false);
mateNumberTextView = (TextView)rootView.findViewById(R.id.mateNumberTextView);
RecyclerView mateRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragmentFamiliyRecyclerView);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
mateRecyclerView.setLayoutManager(mLayoutManager);
mateRecyclerView.setHasFixedSize(true);
mateRecyclerView.scrollToPosition(0);
mates = new ArrayList<>();
//mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
//mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
//mates.add(new Mate("http://cfile3.uf.tistory.com/image/246667375764E38E1D1A93","임정연","in","10분"));
mateAdapter = new MateAdapter(mates,getContext());
mateRecyclerView.setAdapter(mateAdapter);
mateRecyclerView.setItemAnimator(new DefaultItemAnimator());
getMateList();
return rootView;
}
private void getMateList() {
LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
String ltid = UserInfo.getInstance().getLolockLTID();
Call<ResponseMate> responseMate = loLockService.getHomeMateResponse(ltid);
responseMate.enqueue(new Callback<ResponseMate>() {
@Override
public void onResponse(Call<ResponseMate> call, Response<ResponseMate> response) {
Log.d(TAG,"Response" + response.toString());
if(response.isSuccessful()) {
Log.d(TAG,"RoomMateList Response Success");
for (Mate mate : response.body().getMates()) {
mates.add(mate);
}
if(response.body().getMateNumber() != null) {
mateNumberTextView.setText("가족(" + response.body().getMateNumber() + ")" );
};
mateAdapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(Call<ResponseMate> call, Throwable t) {
Log.d(TAG,"URL or Server Error");
}
});
}
private class MateAdapter extends RecyclerView.Adapter<MateAdapter.ViewHolder> {
private ArrayList<Mate> mates;
private Context context;
public MateAdapter(ArrayList<Mate> mates, Context context) {
this.mates = mates;
this.context = context;
}
@Override
public MateAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_mate, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(MateAdapter.ViewHolder holder, int position) {
final Mate mateInfo = mates.get(position);
//Picasso.with(context).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);
//Log.d("url",mateInfo.getMateImageUrl());
holder.mateName.setText(mateInfo.getMateName());
holder.mateDoorOpenTime.setText(mateInfo.getMateDoorOpenTime());
if(mateInfo.getMateOutingFlag().equals("0"))
holder.mateOutingFlag.setImageResource(R.drawable.ic_out_home);
else {
holder.mateOutingFlag.setImageResource(R.drawable.ic_in_home);
}
Picasso.with(holder.mateProfile.getContext()).load(mateInfo.getMateImageUrl()).into(holder.mateProfile);
// TODO: 2017. 7. 1. 이미지 수정하는거 추가해야됨.!
}
@Override
public int getItemCount() {
return mates.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public CircleImageView mateProfile;
public TextView mateName;
public TextView mateDoorOpenTime;
public ImageView mateOutingFlag;
public ViewHolder(View itemView) {
super(itemView);
mateProfile = (CircleImageView) itemView.findViewById(R.id.mateProfileImageView);
mateName = (TextView) itemView.findViewById(R.id.mateNameTextView);
mateDoorOpenTime = (TextView) itemView.findViewById(R.id.mateOutingTimeTextView);
mateOutingFlag = (ImageView) itemView.findViewById(R.id.mateOutingFlag);
}
}
}
}
package com.gunghi.tgwing.lolock.ui;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.util.ActivityResultEvent;
import com.gunghi.tgwing.lolock.util.EventBus;
import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnMenuTabClickListener;
import com.tsengvn.typekit.TypekitContextWrapper;
public class MainActivity extends AppCompatActivity {
private final static String TAG = MainActivity.class.getSimpleName();
private BottomBar mBottomBar;
private Fragment currentSelectedFragment;
private TextView mainTitleTextView;
private ImageButton settingButton;
FragmentDoorOnOff fragmentDoorOnOff;
FragmentMate fragmentMate ;
FragmentInfo fragmentInfo;
FragmentAlarm fragmentAlarm;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
}
private void initPushEventReciever() {
String freamgentFlag = getIntent().getStringExtra("viewFragment");
Log.d("initPushEventReciever","연결");
if(freamgentFlag != null) {
Log.d("initPushEventReciever","들어오니니니");
Log.d("initPushEventReciever",freamgentFlag + "ddd");
switch (freamgentFlag) {
case "weatherPlan":
currentSelectedFragment = fragmentInfo;
mainTitleTextView.setText("날씨 및 일정");
mBottomBar.selectTabAtPosition(2, true);
getSupportFragmentManager().beginTransaction().
replace(R.id.mainActivityFragmentContainer, currentSelectedFragment).
commit();
Log.d("freamgentFlag","weatherPlan");
break;
case "inOutLog":
Log.d("freamgentFlag","inOutLog");
case "strangeAlarm":
Log.d("freamgentFlag","strangeAlarm");
currentSelectedFragment = fragmentAlarm;
mainTitleTextView.setText("출입기록");
mBottomBar.selectTabAtPosition(3, true);
getSupportFragmentManager().
beginTransaction().
replace(R.id.mainActivityFragmentContainer, currentSelectedFragment).
commit();
break;
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initFragment();
initView(savedInstanceState);
//checkBLE();
}
@Override
protected void onResume() {
super.onResume();
initPushEventReciever();
// registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter());
}
//private void scanBLE() {
// if (!mBluetoothAdapter.isEnabled()) {
// Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
// } else {
// if (Build.VERSION.SDK_INT >= 21) {
// mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
// settings = new ScanSettings.Builder()
// .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
// .build();
// filters = new ArrayList<ScanFilter>();
// }
// // scanLeDevice(true);
// }
//}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// User chose not to enable Bluetooth.
super.onActivityResult(requestCode, resultCode, data);
EventBus.getInstance().post(new ActivityResultEvent(requestCode, resultCode, data));
//
// if (requestCode == REQUEST_ENABLE_BT && resultCode == Activity.RESULT_CANCELED) {
// Toast.makeText(this,"블루투스를 사용여부를 체크해주세요.",Toast.LENGTH_SHORT).show();
// } else {
//
// }
}
@Override
protected void onPause() {
super.onPause();
// if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
// scanLeDevice(false);
// }
// unregisterReceiver(mGattUpdateReceiver);
//scanLeDevice(false);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
private void initView(Bundle savedInstanceState) {
mainTitleTextView = (TextView) findViewById(R.id.mainActivityTitleTextView);
mBottomBar = BottomBar.attach(this, savedInstanceState);
mBottomBar.useFixedMode();
mBottomBar.setActiveTabColor("#FC7336");
mBottomBar.setItems(R.menu.bottombar_menus);
mBottomBar.setOnMenuTabClickListener(new OnMenuTabClickListener() {
@Override
public void onMenuTabSelected(@IdRes int menuItemId) {
switch (menuItemId) {
case R.id.menu_home:
currentSelectedFragment = fragmentDoorOnOff;
mainTitleTextView.setText("출입문 조작");
break;
case R.id.menu_family:
currentSelectedFragment = fragmentMate;
mainTitleTextView.setText("가족 현황");
break;
case R.id.menu_info:
currentSelectedFragment = fragmentInfo;
mainTitleTextView.setText("날씨 및 일정");
break;
case R.id.menu_alarm:
currentSelectedFragment = fragmentAlarm;
mainTitleTextView.setText("출입기록");
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.mainActivityFragmentContainer,currentSelectedFragment).commit();
}
@Override
public void onMenuTabReSelected(@IdRes int menuItemId) {
}
});
//setting 버튼 누르면 들어가도록 바꿈
settingButton=(ImageButton)findViewById(R.id.mainActivitySettingButton);
final Intent intent=new Intent(this, SettingActivity.class);
settingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(intent);
}
});
}
private void initFragment() {
fragmentDoorOnOff = new FragmentDoorOnOff();
fragmentMate = new FragmentMate();
fragmentInfo = new FragmentInfo();
fragmentAlarm = new FragmentAlarm();
currentSelectedFragment = fragmentDoorOnOff;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// Necessary to restore the BottomBar's state, otherwise we would
// lose the current tab on orientation change.
mBottomBar.onSaveInstanceState(outState);
}
}
package com.gunghi.tgwing.lolock.ui;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.Response.ResponseOpenDoorKey;
import com.gunghi.tgwing.lolock.model.UserInfo;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static android.content.Context.CLIPBOARD_SERVICE;
/**
* Created by joyeongje on 2017. 7. 22..
*/
public class OpenDoorCodeDialog extends Dialog {
private Button shareButton;
private Button sendButton;
private TextView textView;
private Context context;
public OpenDoorCodeDialog(Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.door_open_code_dialog);
initOpenCodeDialogView();
makeOpenDoorCode();
}
private void initOpenCodeDialogView() {
shareButton = (Button)findViewById(R.id.openCodePasteButton);
shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboardManager = (ClipboardManager)getContext().getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("label",textView.getText().toString());
clipboardManager.setPrimaryClip(clipData);
Toast.makeText(getContext(),"일회용키가 복사되었습니다",Toast.LENGTH_SHORT).show();
dismiss();
}
});
sendButton = (Button)findViewById(R.id.openCodeSendButton);
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("sms_body",textView.getText().toString());
intent.setType("vnd.android-dir/mms-sms");
getContext().startActivity(intent);
}
});
textView = (TextView) findViewById(R.id.openCodeTextView);
}
private void makeOpenDoorCode() {
LoLockService loLockService = LoLockServiceGenarator.createService(LoLockService.class);
Call<ResponseOpenDoorKey> requestOpenDoorCode = loLockService.getDoorOpenCode(UserInfo.getInstance().getDevideId());
requestOpenDoorCode.enqueue(new Callback<ResponseOpenDoorKey>() {
@Override
public void onResponse(Call<ResponseOpenDoorKey> call, Response<ResponseOpenDoorKey> response) {
Log.d("response",response.toString());
if(response.isSuccessful() && response.body().getCode().equals("CREATED")) {
textView.setText(response.body().getLink());
}
}
@Override
public void onFailure(Call<ResponseOpenDoorKey> call, Throwable t) {
Log.d("response Failture",call.toString());
}
});
}
}
package com.gunghi.tgwing.lolock.ui;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.Response.ResponseLoLockService;
import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
import com.tsengvn.typekit.TypekitContextWrapper;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class RegisterActivity extends AppCompatActivity {
EditText inputIdText;
TextView checkIdButton;
LoLockService lockService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
inputIdText = (EditText) findViewById(R.id.registerEditText);
checkIdButton = (TextView) findViewById(R.id.checkLoraIdButton);
checkIdButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkLoraId(inputIdText.getText().toString());
}
});
//f0103d
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
}
private void checkLoraId(final String number) {
Log.d("number",number);
lockService = LoLockServiceGenarator.createService(LoLockService.class);
//Call<ResponseBody> requestOpenDoor = lockService.remoteOnOffLock(number);
Call<ResponseLoLockService> checkLoraIdService = lockService.checkLoraNumberId(number);
checkLoraIdService.enqueue(new Callback<ResponseLoLockService>() {
@Override
public void onResponse(Call<ResponseLoLockService> call, Response<ResponseLoLockService> response) {
Log.d("CheckLoraId API", String.valueOf(response.code()));
if(response.isSuccessful() || response.body() != null) {
if (response.body().getCode().equals("DEVICE_ID_AVAILABLE")) {
Toast.makeText(getApplicationContext(),
"인증이 완료되었습니다",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(RegisterActivity.this,Register2Activity.class);
startActivity(intent);
RegisterActivity.this.finish();
RegisterUserInfo.getInstance().setRegisterDeviceId(number);
} else {
Toast.makeText(getApplicationContext(),
"잘못된 일련번호가 입력되었습니다. 다시 입력해주세요",Toast.LENGTH_SHORT).show();
}
}
}
@Override
public void onFailure(Call<ResponseLoLockService> call, Throwable t) {
Toast.makeText(getApplicationContext(),
"서버에서 응답이 오지 않습니다. 서버를 확인해주세요.",Toast.LENGTH_SHORT).show();
}
});
}
}
package com.gunghi.tgwing.lolock.ui;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import com.gunghi.tgwing.lolock.R;
import com.tsengvn.typekit.TypekitContextWrapper;
/**
* Created by InKyung on 2017-07-19.
*/
public class SettingActivity extends Activity {
ImageButton backButton;
Button lolockInfoButton,changeInfoButton,changeGps;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.setting);
initView(savedInstanceState);
}
private void initView(Bundle savedInstanceState) {
backButton=(ImageButton)findViewById(R.id.BackButton);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//3가지 버튼
changeInfoButton=(Button)findViewById(R.id.ChangeInfoButton);
lolockInfoButton=(Button)findViewById(R.id.LolockInfoButton);
changeGps=(Button)findViewById(R.id.ChangeGps);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(TypekitContextWrapper.wrap(newBase));
}
}
package com.gunghi.tgwing.lolock.ui;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import com.gunghi.tgwing.lolock.R;
import com.gunghi.tgwing.lolock.Response.ResponseUserInfo;
import com.gunghi.tgwing.lolock.model.RegisterUserInfo;
import com.gunghi.tgwing.lolock.model.UserInfo;
import com.gunghi.tgwing.lolock.network.LoLockService;
import com.gunghi.tgwing.lolock.network.LoLockServiceGenarator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by InKyung on 2017-07-19.
*/
public class SplashActivity extends Activity {
private String freamgentFlag;
// Code to manage Service lifecycle.
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
freamgentFlag = getIntent().getStringExtra("viewFragment");
Log.d("spalash freamgentFlag",freamgentFlag +"zz");
//상단바 색깔 바꾸기
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.parseColor("#FAAC42"));
// 저장된 데이터 불러온다.!
SharedPreferences sharedPreferences = getSharedPreferences("lolockLocalData", MODE_PRIVATE);
final String deviceId = sharedPreferences.getString("deviceId", "");
Log.d("deviceId",deviceId);
if (deviceId.equals("")) {
Intent registerIntent = new Intent(SplashActivity.this, RegisterActivity.class);
SplashActivity.this.startActivity(registerIntent);
SplashActivity.this.finish();
} else {
getUserInfo(deviceId);
}
}
private void getUserInfo(final String deviceId) {
RegisterUserInfo.getInstance().setRegisterUserPhoneId(deviceId);
LoLockService lolockservice = LoLockServiceGenarator.createService(LoLockService.class);
Call<ResponseUserInfo> responseUserInfo = lolockservice.getUserInfo(deviceId);
responseUserInfo.enqueue(new Callback<ResponseUserInfo>() {
@Override
public void onResponse(Call<ResponseUserInfo> call, Response<ResponseUserInfo> response) {
Log.d("response", String.valueOf(response.code()));
if (response.isSuccessful()) {
if (response.body().getCode().equals("REGISTRED")) {
UserInfo tempUserInfo = response.body().getUserInfo();
UserInfo.getInstance().setName(tempUserInfo.getName());
UserInfo.getInstance().setLolockLTID(tempUserInfo.getLolockLTID());
UserInfo.getInstance().setDevideId(deviceId);
Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
mainIntent.putExtra("viewFragment",freamgentFlag);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
} else {
Intent registerIntent = new Intent(SplashActivity.this, RegisterActivity.class);
SplashActivity.this.startActivity(registerIntent);
SplashActivity.this.finish();
}
} else {
Intent registerIntent = new Intent(SplashActivity.this, RegisterActivity.class);
SplashActivity.this.startActivity(registerIntent);
SplashActivity.this.finish();
}
}
@Override
public void onFailure(Call<ResponseUserInfo> call, Throwable t) {
Toast.makeText(getApplicationContext(),"서버가 응답하지 않습니다.",Toast.LENGTH_SHORT).show();
}
});
}
@Override
protected void onStop() {
super.onStop();
}
}
package com.gunghi.tgwing.lolock.util;
import android.content.Intent;
/**
* Created by joyeongje on 2017. 7. 23..
*/
public class ActivityResultEvent {
private int requestCode;
private int resultCode;
private Intent data;
public ActivityResultEvent(int requestCode, int resultCode, Intent data) {
this.requestCode = requestCode;
this.resultCode = resultCode;
this.data = data;
}
public int getRequestCode() {
return requestCode;
}
public void setRequestCode(int requestCode) {
this.requestCode = requestCode;
}
public int getResultCode() {
return resultCode;
}
public void setResultCode(int resultCode) {
this.resultCode = resultCode;
}
public Intent getData() {
return data;
}
public void setData(Intent data) {
this.data = data;
}
}
package com.gunghi.tgwing.lolock.util;
import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
/**
* Created by joyeongje on 2017. 7. 23..
*/
public class EventBus extends Bus {
private static EventBus instance;
public static EventBus getInstance() {
if (instance == null) {
synchronized (EventBus.class) {
if (instance == null) {
instance = new EventBus();
}
}
}
return instance;
}
private Handler handler = new Handler(Looper.getMainLooper());
@Override
public void post(final Object event) {
if (Looper.myLooper() == Looper.getMainLooper()) {
super.post(event);
} else {
handler.post(new Runnable() {
@Override
public void run() {
EventBus.super.post(event);
}
});
}
}
}
\ No newline at end of file
package com.gunghi.tgwing.lolock.util;
import android.app.Application;
import com.tsengvn.typekit.Typekit;
/**
* Created by young on 2017-07-02.
*/
public class TypekitSetting extends Application {
@Override
public void onCreate() {
super.onCreate();
Typekit.getInstance()
.addNormal(Typekit.createFromAsset(this, "NanumBarunpenR.ttf"))
.addBold(Typekit.createFromAsset(this, "NanumBarunpenB.ttf"));
}
}
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.