Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sunnnl
2020-11-12 15:16:35 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d4d121317ec9071549b25bb4289ed1d32d861518
d4d12131
1 parent
d0df0373
drawer 구현, 원격 잠금해제 구현
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
20 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/sunnni/smartdoorlock/ui/MainActivity.java
app/src/main/java/com/sunnni/smartdoorlock/ui/SplashActivity.java
app/src/main/res/layout/activity_main.xml
app/src/main/res/menu/menu_navi.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
app/src/main/AndroidManifest.xml
View file @
d4d1213
...
...
@@ -12,7 +12,7 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:networkSecurityConfig=
"@xml/network_security_config"
android:theme=
"@style/
Theme.AppCompat.NoActionBar
"
>
android:theme=
"@style/
AppTheme
"
>
<activity
android:name=
".ui.VideoCheckActivity"
></activity>
<activity
android:name=
".ui.DeviceManagerActivity"
/>
<activity
android:name=
".ui.RemoteControlRecordActivity"
/>
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/MainActivity.java
View file @
d4d1213
package
com
.
sunnni
.
smartdoorlock
.
ui
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.constraintlayout.widget.ConstraintLayout
;
import
androidx.core.view.GravityCompat
;
import
androidx.drawerlayout.widget.DrawerLayout
;
import
android.annotation.SuppressLint
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.CountDownTimer
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.google.android.material.navigation.NavigationView
;
import
com.sunnni.smartdoorlock.R
;
import
org.w3c.dom.Text
;
import
java.util.Objects
;
import
java.util.Timer
;
import
java.util.TimerTask
;
// TODO: 타이머 구현
// TODO: drawer layout 구현
public
class
MainActivity
extends
AppCompatActivity
{
private
Button
btnSetting
;
private
Button
mBtnTagControl
;
private
ImageView
mBtnTagControlBackground
;
private
TextView
mTvTagButtonStatus
,
mTvTagButtonStatusDetail
;
DrawerLayout
mDrawerLayout
;
AlertDialog
alertDialog
;
TagTimer
timer
;
...
...
@@ -41,16 +44,10 @@ public class MainActivity extends AppCompatActivity {
Toolbar
mToolbar
=
findViewById
(
R
.
id
.
toolbar_main
);
setToolbar
(
mToolbar
);
setDrawerLayout
();
init
();
timer
=
new
TagTimer
(
5
*
1000
,
1000
,
5
);
btnSetting
=
(
Button
)
findViewById
(
R
.
id
.
btn_setting
);
btnSetting
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
startActivity
(
new
Intent
(
MainActivity
.
this
,
SettingActivity
.
class
));
}
});
}
// 툴바 설정
...
...
@@ -62,6 +59,49 @@ public class MainActivity extends AppCompatActivity {
getSupportActionBar
().
setHomeAsUpIndicator
(
R
.
drawable
.
baseline_menu_white_24
);
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
android
.
R
.
id
.
home
:
{
mDrawerLayout
.
openDrawer
(
GravityCompat
.
START
);
return
true
;
}
}
return
super
.
onOptionsItemSelected
(
item
);
}
private
void
setDrawerLayout
()
{
mDrawerLayout
=
findViewById
(
R
.
id
.
drawer_main
);
NavigationView
mNavView
=
findViewById
(
R
.
id
.
nav_view
);
mNavView
.
setNavigationItemSelectedListener
(
new
NavigationView
.
OnNavigationItemSelectedListener
()
{
@Override
public
boolean
onNavigationItemSelected
(
@NonNull
MenuItem
item
)
{
item
.
setChecked
(
true
);
mDrawerLayout
.
closeDrawers
();
switch
(
item
.
getItemId
())
{
case
R
.
id
.
item_remote_control
:
remoteControlDialog
();
return
true
;
case
R
.
id
.
item_remote_control_record
:
startActivity
(
new
Intent
(
MainActivity
.
this
,
RemoteControlRecordActivity
.
class
));
return
true
;
case
R
.
id
.
item_device_manager
:
startActivity
(
new
Intent
(
MainActivity
.
this
,
DeviceManagerActivity
.
class
));
return
true
;
case
R
.
id
.
item_video_check
:
startActivity
(
new
Intent
(
MainActivity
.
this
,
VideoCheckActivity
.
class
));
return
true
;
case
R
.
id
.
item_logout
:
startActivity
(
new
Intent
(
MainActivity
.
this
,
SettingActivity
.
class
));
return
true
;
}
return
false
;
}
});
}
private
void
init
()
{
mBtnTagControl
=
findViewById
(
R
.
id
.
btn_tag_control
);
mBtnTagControlBackground
=
findViewById
(
R
.
id
.
btn_tag_control_back
);
...
...
@@ -81,10 +121,22 @@ public class MainActivity extends AppCompatActivity {
ConstraintLayout
mClDeviceManager
=
findViewById
(
R
.
id
.
container_device_button
);
ConstraintLayout
mClVideoRecord
=
findViewById
(
R
.
id
.
container_video_button
);
Button
mBtnRemoteControl
=
findViewById
(
R
.
id
.
btn_back_1
);
Button
mBtnRemoteRecord
=
findViewById
(
R
.
id
.
btn_back_2
);
Button
mBtnDeviceManager
=
findViewById
(
R
.
id
.
btn_back_3
);
Button
mBtnVideoRecord
=
findViewById
(
R
.
id
.
btn_back_4
);
mClRemoteControl
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
// 원격 잠금해제 팝업
remoteControlDialog
();
}
});
mBtnRemoteControl
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
remoteControlDialog
();
}
});
...
...
@@ -97,6 +149,14 @@ public class MainActivity extends AppCompatActivity {
}
});
mBtnRemoteRecord
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
RemoteControlRecordActivity
.
class
);
startActivity
(
intent
);
}
});
// 기기 관리 화면으로 이동
mClDeviceManager
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -106,6 +166,14 @@ public class MainActivity extends AppCompatActivity {
}
});
mBtnDeviceManager
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
DeviceManagerActivity
.
class
);
startActivity
(
intent
);
}
});
// 비디오 확인 화면으로 이동
mClVideoRecord
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
...
...
@@ -114,6 +182,14 @@ public class MainActivity extends AppCompatActivity {
startActivity
(
intent
);
}
});
mBtnVideoRecord
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
MainActivity
.
this
,
VideoCheckActivity
.
class
);
startActivity
(
intent
);
}
});
}
// 도어락 태그 버튼 상태에 따라 뷰 변경
...
...
@@ -137,6 +213,28 @@ public class MainActivity extends AppCompatActivity {
mBtnTagControlBackground
.
setSelected
(
mBtnTagControl
.
isSelected
());
}
private
void
remoteControlDialog
()
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
,
R
.
style
.
AlertDialogTheme
);
builder
.
setTitle
(
getString
(
R
.
string
.
menu_remote_control
))
.
setMessage
(
getString
(
R
.
string
.
alert_message
));
builder
.
setPositiveButton
(
"열기"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
// 원격 해제 구현 부분
Toast
.
makeText
(
MainActivity
.
this
,
"도어락이 열렸습니다."
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
builder
.
setNegativeButton
(
"취소"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
}
});
alertDialog
=
builder
.
create
();
alertDialog
.
show
();
}
// 타이머 이너클래스
class
TagTimer
extends
CountDownTimer
{
int
count
;
...
...
app/src/main/java/com/sunnni/smartdoorlock/ui/SplashActivity.java
View file @
d4d1213
...
...
@@ -34,8 +34,6 @@ public class SplashActivity extends AppCompatActivity {
private
Animation
logoAnimation
;
private
ImageView
test
;
@SuppressLint
(
"ClickableViewAccessibility"
)
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
app/src/main/res/layout/activity_main.xml
View file @
d4d1213
This diff is collapsed. Click to expand it.
app/src/main/res/menu/menu_navi.xml
0 → 100644
View file @
d4d1213
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:id=
"@+id/item_remote_control"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:title=
"@string/menu_remote_control"
/>
<item
android:id=
"@+id/item_remote_control_record"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:title=
"@string/menu_remote_control_record"
/>
<item
android:id=
"@+id/item_device_manager"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:title=
"@string/menu_device_manager"
/>
<item
android:id=
"@+id/item_video_check"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:title=
"@string/menu_video_check"
/>
<item
android:id=
"@+id/item_logout"
style=
"@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:title=
"설정"
/>
</menu>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
d4d1213
...
...
@@ -14,4 +14,6 @@
<string
name=
"tag_status_off_detail"
>
버튼을 누른 후 스캔해주세요
</string>
<string
name=
"tag_status_on"
>
도어락 태그 켜짐
</string>
<string
name=
"tag_status_on_detail"
>
초 후 꺼짐
</string>
<string
name=
"alert_message"
>
버튼을 클릭하시면 원격으로 도어락을 열 수 있습니다.\n\n정말 도어락을 여시겠습니까?\n\n
</string>
</resources>
...
...
app/src/main/res/values/styles.xml
View file @
d4d1213
...
...
@@ -3,9 +3,15 @@
<!-- Base application theme. -->
<style
name=
"AppTheme"
parent=
"Theme.AppCompat.Light.NoActionBar"
>
<!-- Customize your theme here. -->
<item
name=
"android:alertDialogTheme"
>
@style/AlertDialogTheme
</item>
<item
name=
"colorPrimary"
>
@color/colorPrimary
</item>
<item
name=
"colorPrimaryDark"
>
@color/colorPrimaryDark
</item>
<item
name=
"colorAccent"
>
@color/colorAccent
</item>
</style>
<style
name=
"AlertDialogTheme"
parent=
"Theme.AppCompat.Light.Dialog.Alert"
>
<item
name=
"colorAccent"
>
@color/colorPrimary
</item>
</style>
</resources>
...
...
Please
register
or
login
to post a comment