Showing
7 changed files
with
149 additions
and
20 deletions
... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
12 | android:roundIcon="@mipmap/ic_launcher_round" | 12 | android:roundIcon="@mipmap/ic_launcher_round" |
13 | android:supportsRtl="true" | 13 | android:supportsRtl="true" |
14 | android:networkSecurityConfig="@xml/network_security_config" | 14 | android:networkSecurityConfig="@xml/network_security_config" |
15 | - android:theme="@style/Theme.AppCompat.NoActionBar"> | 15 | + android:theme="@style/AppTheme"> |
16 | <activity android:name=".ui.VideoCheckActivity"></activity> | 16 | <activity android:name=".ui.VideoCheckActivity"></activity> |
17 | <activity android:name=".ui.DeviceManagerActivity" /> | 17 | <activity android:name=".ui.DeviceManagerActivity" /> |
18 | <activity android:name=".ui.RemoteControlRecordActivity" /> | 18 | <activity android:name=".ui.RemoteControlRecordActivity" /> | ... | ... |
1 | package com.sunnni.smartdoorlock.ui; | 1 | package com.sunnni.smartdoorlock.ui; |
2 | 2 | ||
3 | +import androidx.annotation.NonNull; | ||
4 | +import androidx.appcompat.app.AlertDialog; | ||
3 | import androidx.appcompat.app.AppCompatActivity; | 5 | import androidx.appcompat.app.AppCompatActivity; |
4 | import androidx.appcompat.widget.Toolbar; | 6 | import androidx.appcompat.widget.Toolbar; |
5 | import androidx.constraintlayout.widget.ConstraintLayout; | 7 | import androidx.constraintlayout.widget.ConstraintLayout; |
8 | +import androidx.core.view.GravityCompat; | ||
9 | +import androidx.drawerlayout.widget.DrawerLayout; | ||
6 | 10 | ||
7 | import android.annotation.SuppressLint; | 11 | import android.annotation.SuppressLint; |
12 | +import android.content.DialogInterface; | ||
8 | import android.content.Intent; | 13 | import android.content.Intent; |
9 | import android.os.Bundle; | 14 | import android.os.Bundle; |
10 | import android.os.CountDownTimer; | 15 | import android.os.CountDownTimer; |
16 | +import android.view.MenuItem; | ||
11 | import android.view.View; | 17 | import android.view.View; |
12 | import android.widget.Button; | 18 | import android.widget.Button; |
13 | import android.widget.ImageView; | 19 | import android.widget.ImageView; |
14 | import android.widget.TextView; | 20 | import android.widget.TextView; |
21 | +import android.widget.Toast; | ||
15 | 22 | ||
23 | +import com.google.android.material.navigation.NavigationView; | ||
16 | import com.sunnni.smartdoorlock.R; | 24 | import com.sunnni.smartdoorlock.R; |
17 | 25 | ||
18 | -import org.w3c.dom.Text; | ||
19 | - | ||
20 | import java.util.Objects; | 26 | import java.util.Objects; |
21 | -import java.util.Timer; | ||
22 | -import java.util.TimerTask; | ||
23 | - | ||
24 | -// TODO: 타이머 구현 | ||
25 | -// TODO: drawer layout 구현 | ||
26 | 27 | ||
27 | public class MainActivity extends AppCompatActivity { | 28 | public class MainActivity extends AppCompatActivity { |
28 | 29 | ||
29 | - private Button btnSetting; | ||
30 | private Button mBtnTagControl; | 30 | private Button mBtnTagControl; |
31 | private ImageView mBtnTagControlBackground; | 31 | private ImageView mBtnTagControlBackground; |
32 | private TextView mTvTagButtonStatus, mTvTagButtonStatusDetail; | 32 | private TextView mTvTagButtonStatus, mTvTagButtonStatusDetail; |
33 | + DrawerLayout mDrawerLayout; | ||
34 | + | ||
35 | + AlertDialog alertDialog; | ||
33 | 36 | ||
34 | TagTimer timer; | 37 | TagTimer timer; |
35 | 38 | ||
... | @@ -41,16 +44,10 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -41,16 +44,10 @@ public class MainActivity extends AppCompatActivity { |
41 | Toolbar mToolbar = findViewById(R.id.toolbar_main); | 44 | Toolbar mToolbar = findViewById(R.id.toolbar_main); |
42 | setToolbar(mToolbar); | 45 | setToolbar(mToolbar); |
43 | 46 | ||
47 | + setDrawerLayout(); | ||
48 | + | ||
44 | init(); | 49 | init(); |
45 | timer = new TagTimer(5 * 1000, 1000, 5); | 50 | timer = new TagTimer(5 * 1000, 1000, 5); |
46 | - | ||
47 | - btnSetting = (Button) findViewById(R.id.btn_setting); | ||
48 | - btnSetting.setOnClickListener(new View.OnClickListener() { | ||
49 | - @Override | ||
50 | - public void onClick(View view) { | ||
51 | - startActivity(new Intent(MainActivity.this, SettingActivity.class)); | ||
52 | - } | ||
53 | - }); | ||
54 | } | 51 | } |
55 | 52 | ||
56 | // 툴바 설정 | 53 | // 툴바 설정 |
... | @@ -62,6 +59,49 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -62,6 +59,49 @@ public class MainActivity extends AppCompatActivity { |
62 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.baseline_menu_white_24); | 59 | getSupportActionBar().setHomeAsUpIndicator(R.drawable.baseline_menu_white_24); |
63 | } | 60 | } |
64 | 61 | ||
62 | + @Override | ||
63 | + public boolean onOptionsItemSelected(MenuItem item) { | ||
64 | + switch (item.getItemId()) { | ||
65 | + case android.R.id.home: { | ||
66 | + mDrawerLayout.openDrawer(GravityCompat.START); | ||
67 | + return true; | ||
68 | + } | ||
69 | + } | ||
70 | + return super.onOptionsItemSelected(item); | ||
71 | + } | ||
72 | + | ||
73 | + private void setDrawerLayout() { | ||
74 | + mDrawerLayout = findViewById(R.id.drawer_main); | ||
75 | + NavigationView mNavView = findViewById(R.id.nav_view); | ||
76 | + | ||
77 | + mNavView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { | ||
78 | + @Override | ||
79 | + public boolean onNavigationItemSelected(@NonNull MenuItem item) { | ||
80 | + item.setChecked(true); | ||
81 | + mDrawerLayout.closeDrawers(); | ||
82 | + | ||
83 | + switch (item.getItemId()) { | ||
84 | + case R.id.item_remote_control: | ||
85 | + remoteControlDialog(); | ||
86 | + return true; | ||
87 | + case R.id.item_remote_control_record: | ||
88 | + startActivity(new Intent(MainActivity.this, RemoteControlRecordActivity.class)); | ||
89 | + return true; | ||
90 | + case R.id.item_device_manager: | ||
91 | + startActivity(new Intent(MainActivity.this, DeviceManagerActivity.class)); | ||
92 | + return true; | ||
93 | + case R.id.item_video_check: | ||
94 | + startActivity(new Intent(MainActivity.this, VideoCheckActivity.class)); | ||
95 | + return true; | ||
96 | + case R.id.item_logout: | ||
97 | + startActivity(new Intent(MainActivity.this, SettingActivity.class)); | ||
98 | + return true; | ||
99 | + } | ||
100 | + return false; | ||
101 | + } | ||
102 | + }); | ||
103 | + } | ||
104 | + | ||
65 | private void init() { | 105 | private void init() { |
66 | mBtnTagControl = findViewById(R.id.btn_tag_control); | 106 | mBtnTagControl = findViewById(R.id.btn_tag_control); |
67 | mBtnTagControlBackground = findViewById(R.id.btn_tag_control_back); | 107 | mBtnTagControlBackground = findViewById(R.id.btn_tag_control_back); |
... | @@ -81,10 +121,22 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -81,10 +121,22 @@ public class MainActivity extends AppCompatActivity { |
81 | ConstraintLayout mClDeviceManager = findViewById(R.id.container_device_button); | 121 | ConstraintLayout mClDeviceManager = findViewById(R.id.container_device_button); |
82 | ConstraintLayout mClVideoRecord = findViewById(R.id.container_video_button); | 122 | ConstraintLayout mClVideoRecord = findViewById(R.id.container_video_button); |
83 | 123 | ||
124 | + Button mBtnRemoteControl = findViewById(R.id.btn_back_1); | ||
125 | + Button mBtnRemoteRecord = findViewById(R.id.btn_back_2); | ||
126 | + Button mBtnDeviceManager = findViewById(R.id.btn_back_3); | ||
127 | + Button mBtnVideoRecord = findViewById(R.id.btn_back_4); | ||
128 | + | ||
84 | mClRemoteControl.setOnClickListener(new View.OnClickListener() { | 129 | mClRemoteControl.setOnClickListener(new View.OnClickListener() { |
85 | @Override | 130 | @Override |
86 | public void onClick(View v) { | 131 | public void onClick(View v) { |
87 | - // 원격 잠금해제 팝업 | 132 | + remoteControlDialog(); |
133 | + } | ||
134 | + }); | ||
135 | + | ||
136 | + mBtnRemoteControl.setOnClickListener(new View.OnClickListener() { | ||
137 | + @Override | ||
138 | + public void onClick(View v) { | ||
139 | + remoteControlDialog(); | ||
88 | } | 140 | } |
89 | }); | 141 | }); |
90 | 142 | ||
... | @@ -97,6 +149,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -97,6 +149,14 @@ public class MainActivity extends AppCompatActivity { |
97 | } | 149 | } |
98 | }); | 150 | }); |
99 | 151 | ||
152 | + mBtnRemoteRecord.setOnClickListener(new View.OnClickListener() { | ||
153 | + @Override | ||
154 | + public void onClick(View v) { | ||
155 | + Intent intent = new Intent(MainActivity.this, RemoteControlRecordActivity.class); | ||
156 | + startActivity(intent); | ||
157 | + } | ||
158 | + }); | ||
159 | + | ||
100 | // 기기 관리 화면으로 이동 | 160 | // 기기 관리 화면으로 이동 |
101 | mClDeviceManager.setOnClickListener(new View.OnClickListener() { | 161 | mClDeviceManager.setOnClickListener(new View.OnClickListener() { |
102 | @Override | 162 | @Override |
... | @@ -106,6 +166,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -106,6 +166,14 @@ public class MainActivity extends AppCompatActivity { |
106 | } | 166 | } |
107 | }); | 167 | }); |
108 | 168 | ||
169 | + mBtnDeviceManager.setOnClickListener(new View.OnClickListener() { | ||
170 | + @Override | ||
171 | + public void onClick(View v) { | ||
172 | + Intent intent = new Intent(MainActivity.this, DeviceManagerActivity.class); | ||
173 | + startActivity(intent); | ||
174 | + } | ||
175 | + }); | ||
176 | + | ||
109 | // 비디오 확인 화면으로 이동 | 177 | // 비디오 확인 화면으로 이동 |
110 | mClVideoRecord.setOnClickListener(new View.OnClickListener() { | 178 | mClVideoRecord.setOnClickListener(new View.OnClickListener() { |
111 | @Override | 179 | @Override |
... | @@ -114,6 +182,14 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -114,6 +182,14 @@ public class MainActivity extends AppCompatActivity { |
114 | startActivity(intent); | 182 | startActivity(intent); |
115 | } | 183 | } |
116 | }); | 184 | }); |
185 | + | ||
186 | + mBtnVideoRecord.setOnClickListener(new View.OnClickListener() { | ||
187 | + @Override | ||
188 | + public void onClick(View v) { | ||
189 | + Intent intent = new Intent(MainActivity.this, VideoCheckActivity.class); | ||
190 | + startActivity(intent); | ||
191 | + } | ||
192 | + }); | ||
117 | } | 193 | } |
118 | 194 | ||
119 | // 도어락 태그 버튼 상태에 따라 뷰 변경 | 195 | // 도어락 태그 버튼 상태에 따라 뷰 변경 |
... | @@ -137,6 +213,28 @@ public class MainActivity extends AppCompatActivity { | ... | @@ -137,6 +213,28 @@ public class MainActivity extends AppCompatActivity { |
137 | mBtnTagControlBackground.setSelected(mBtnTagControl.isSelected()); | 213 | mBtnTagControlBackground.setSelected(mBtnTagControl.isSelected()); |
138 | } | 214 | } |
139 | 215 | ||
216 | + private void remoteControlDialog() { | ||
217 | + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme); | ||
218 | + builder.setTitle(getString(R.string.menu_remote_control)) | ||
219 | + .setMessage(getString(R.string.alert_message)); | ||
220 | + builder.setPositiveButton("열기", new DialogInterface.OnClickListener() { | ||
221 | + @Override | ||
222 | + public void onClick(DialogInterface dialog, int which) { | ||
223 | + // 원격 해제 구현 부분 | ||
224 | + Toast.makeText(MainActivity.this, "도어락이 열렸습니다.", Toast.LENGTH_SHORT).show(); | ||
225 | + } | ||
226 | + }); | ||
227 | + builder.setNegativeButton("취소", new DialogInterface.OnClickListener() { | ||
228 | + @Override | ||
229 | + public void onClick(DialogInterface dialog, int which) { | ||
230 | + | ||
231 | + } | ||
232 | + }); | ||
233 | + alertDialog = builder.create(); | ||
234 | + alertDialog.show(); | ||
235 | + } | ||
236 | + | ||
237 | + // 타이머 이너클래스 | ||
140 | class TagTimer extends CountDownTimer { | 238 | class TagTimer extends CountDownTimer { |
141 | 239 | ||
142 | int count; | 240 | int count; | ... | ... |
... | @@ -34,8 +34,6 @@ public class SplashActivity extends AppCompatActivity { | ... | @@ -34,8 +34,6 @@ public class SplashActivity extends AppCompatActivity { |
34 | 34 | ||
35 | private Animation logoAnimation; | 35 | private Animation logoAnimation; |
36 | 36 | ||
37 | - private ImageView test; | ||
38 | - | ||
39 | @SuppressLint("ClickableViewAccessibility") | 37 | @SuppressLint("ClickableViewAccessibility") |
40 | @Override | 38 | @Override |
41 | protected void onCreate(Bundle savedInstanceState) { | 39 | protected void onCreate(Bundle savedInstanceState) { | ... | ... |
This diff is collapsed. Click to expand it.
app/src/main/res/menu/menu_navi.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | + | ||
4 | + <item | ||
5 | + android:id="@+id/item_remote_control" | ||
6 | + style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" | ||
7 | + android:title="@string/menu_remote_control" /> | ||
8 | + <item | ||
9 | + android:id="@+id/item_remote_control_record" | ||
10 | + style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" | ||
11 | + android:title="@string/menu_remote_control_record" /> | ||
12 | + <item | ||
13 | + android:id="@+id/item_device_manager" | ||
14 | + style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" | ||
15 | + android:title="@string/menu_device_manager" /> | ||
16 | + <item | ||
17 | + android:id="@+id/item_video_check" | ||
18 | + style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" | ||
19 | + android:title="@string/menu_video_check" /> | ||
20 | + <item | ||
21 | + android:id="@+id/item_logout" | ||
22 | + style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" | ||
23 | + android:title="설정" /> | ||
24 | + | ||
25 | +</menu> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -14,4 +14,6 @@ | ... | @@ -14,4 +14,6 @@ |
14 | <string name="tag_status_off_detail">버튼을 누른 후 스캔해주세요</string> | 14 | <string name="tag_status_off_detail">버튼을 누른 후 스캔해주세요</string> |
15 | <string name="tag_status_on">도어락 태그 켜짐</string> | 15 | <string name="tag_status_on">도어락 태그 켜짐</string> |
16 | <string name="tag_status_on_detail">초 후 꺼짐</string> | 16 | <string name="tag_status_on_detail">초 후 꺼짐</string> |
17 | + | ||
18 | + <string name="alert_message">버튼을 클릭하시면 원격으로 도어락을 열 수 있습니다.\n\n정말 도어락을 여시겠습니까?\n\n</string> | ||
17 | </resources> | 19 | </resources> | ... | ... |
... | @@ -3,9 +3,15 @@ | ... | @@ -3,9 +3,15 @@ |
3 | <!-- Base application theme. --> | 3 | <!-- Base application theme. --> |
4 | <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | 4 | <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> |
5 | <!-- Customize your theme here. --> | 5 | <!-- Customize your theme here. --> |
6 | + <item name="android:alertDialogTheme">@style/AlertDialogTheme</item> | ||
7 | + | ||
6 | <item name="colorPrimary">@color/colorPrimary</item> | 8 | <item name="colorPrimary">@color/colorPrimary</item> |
7 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | 9 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
8 | <item name="colorAccent">@color/colorAccent</item> | 10 | <item name="colorAccent">@color/colorAccent</item> |
9 | </style> | 11 | </style> |
10 | 12 | ||
13 | + <style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert"> | ||
14 | + <item name="colorAccent">@color/colorPrimary</item> | ||
15 | + </style> | ||
16 | + | ||
11 | </resources> | 17 | </resources> | ... | ... |
-
Please register or login to post a comment