sunnnl

setting 페이지 퍼블리싱, 메인 화면 수정

1 package com.sunnni.smartdoorlock.ui; 1 package com.sunnni.smartdoorlock.ui;
2 2
3 +import android.content.DialogInterface;
3 import android.content.Intent; 4 import android.content.Intent;
4 import android.content.SharedPreferences; 5 import android.content.SharedPreferences;
5 import android.os.Bundle; 6 import android.os.Bundle;
...@@ -13,25 +14,31 @@ import com.sunnni.smartdoorlock.R; ...@@ -13,25 +14,31 @@ import com.sunnni.smartdoorlock.R;
13 import com.sunnni.smartdoorlock.api.Api; 14 import com.sunnni.smartdoorlock.api.Api;
14 import com.sunnni.smartdoorlock.api.Setting; 15 import com.sunnni.smartdoorlock.api.Setting;
15 16
17 +import androidx.appcompat.app.AlertDialog;
16 import androidx.appcompat.app.AppCompatActivity; 18 import androidx.appcompat.app.AppCompatActivity;
19 +import androidx.appcompat.widget.Toolbar;
20 +
21 +import java.util.Objects;
17 22
18 public class SettingActivity extends AppCompatActivity { 23 public class SettingActivity extends AppCompatActivity {
19 private Switch swcRecording; 24 private Switch swcRecording;
20 private Button btnLogout; 25 private Button btnLogout;
21 26
27 + AlertDialog alertDialog;
28 +
22 @Override 29 @Override
23 protected void onCreate(Bundle savedInstanceState) { 30 protected void onCreate(Bundle savedInstanceState) {
24 super.onCreate(savedInstanceState); 31 super.onCreate(savedInstanceState);
25 setContentView(R.layout.activity_setting); 32 setContentView(R.layout.activity_setting);
33 +
34 + Toolbar mToolbar = findViewById(R.id.toolbar_settings);
35 + setToolbar(mToolbar);
36 +
26 btnLogout = (Button) findViewById(R.id.btn_logout); 37 btnLogout = (Button) findViewById(R.id.btn_logout);
27 btnLogout.setOnClickListener(new View.OnClickListener() { 38 btnLogout.setOnClickListener(new View.OnClickListener() {
28 @Override 39 @Override
29 public void onClick(View view) { 40 public void onClick(View view) {
30 - SharedPreferences pref = getSharedPreferences("gateway", MODE_PRIVATE); 41 + logoutDialog();
31 - SharedPreferences.Editor editor = pref.edit();
32 - editor.remove("accessToken");
33 - editor.commit();
34 - startActivity(new Intent(SettingActivity.this, SplashActivity.class));
35 } 42 }
36 }); 43 });
37 44
...@@ -42,8 +49,8 @@ public class SettingActivity extends AppCompatActivity { ...@@ -42,8 +49,8 @@ public class SettingActivity extends AppCompatActivity {
42 Api.setSetting(new Setting(true), new Api.Callback() { 49 Api.setSetting(new Setting(true), new Api.Callback() {
43 @Override 50 @Override
44 public void callbackMethod(Object obj) { 51 public void callbackMethod(Object obj) {
45 - if(obj == null) { 52 + if (obj == null) {
46 - Toast.makeText(getApplicationContext(),"연결 상태가 불안정합니다.",Toast.LENGTH_SHORT).show(); 53 + Toast.makeText(getApplicationContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show();
47 } 54 }
48 } 55 }
49 }); 56 });
...@@ -54,8 +61,8 @@ public class SettingActivity extends AppCompatActivity { ...@@ -54,8 +61,8 @@ public class SettingActivity extends AppCompatActivity {
54 @Override 61 @Override
55 public void callbackMethod(Object obj) { 62 public void callbackMethod(Object obj) {
56 Setting setting = (Setting) obj; 63 Setting setting = (Setting) obj;
57 - if(setting == null) { 64 + if (setting == null) {
58 - Toast.makeText(getApplicationContext(),"연결 상태가 불안정합니다.",Toast.LENGTH_SHORT).show(); 65 + Toast.makeText(getApplicationContext(), "연결 상태가 불안정합니다.", Toast.LENGTH_SHORT).show();
59 return; 66 return;
60 } 67 }
61 68
...@@ -63,4 +70,44 @@ public class SettingActivity extends AppCompatActivity { ...@@ -63,4 +70,44 @@ public class SettingActivity extends AppCompatActivity {
63 } 70 }
64 }); 71 });
65 } 72 }
73 +
74 + private void setToolbar(Toolbar toolbar) {
75 + setSupportActionBar(toolbar);
76 + Objects.requireNonNull(getSupportActionBar()).setDisplayShowCustomEnabled(true);
77 + getSupportActionBar().setDisplayShowTitleEnabled(false);
78 + getSupportActionBar().setDisplayHomeAsUpEnabled(true);
79 + getSupportActionBar().setHomeAsUpIndicator(R.drawable.round_chevron_left_white_24);
80 +
81 + toolbar.setNavigationOnClickListener(new View.OnClickListener() {
82 + @Override
83 + public void onClick(View v) {
84 + finish();
85 + }
86 + });
87 + }
88 +
89 + private void logoutDialog() {
90 + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AlertDialogTheme);
91 + builder.setTitle(getString(R.string.logout_dialog_title))
92 + .setMessage(getString(R.string.logout_dialog));
93 + builder.setPositiveButton("로그아웃", new DialogInterface.OnClickListener() {
94 + @Override
95 + public void onClick(DialogInterface dialog, int which) {
96 + SharedPreferences pref = getSharedPreferences("gateway", MODE_PRIVATE);
97 + SharedPreferences.Editor editor = pref.edit();
98 + editor.remove("accessToken");
99 + editor.commit();
100 + startActivity(new Intent(SettingActivity.this, SplashActivity.class));
101 + finish();
102 + }
103 + });
104 + builder.setNegativeButton("취소", new DialogInterface.OnClickListener() {
105 + @Override
106 + public void onClick(DialogInterface dialog, int which) {
107 +
108 + }
109 + });
110 + alertDialog = builder.create();
111 + alertDialog.show();
112 + }
66 } 113 }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
3 android:height="24dp" 3 android:height="24dp"
4 android:viewportWidth="24" 4 android:viewportWidth="24"
5 android:viewportHeight="24" 5 android:viewportHeight="24"
6 - android:tint="?attr/colorControlNormal"> 6 + android:tint="#111111">
7 <path 7 <path
8 android:fillColor="@android:color/white" 8 android:fillColor="@android:color/white"
9 android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12zM16,11l-7,4L9,7z"/> 9 android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12zM16,11l-7,4L9,7z"/>
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:shape="rectangle">
4 +
5 + <solid android:color="#ff1744" />
6 + <corners android:radius="10dp" />
7 +
8 +</shape>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
3 + android:shape="rectangle">
4 +
5 + <solid android:color="@color/colorAccent" />
6 + <corners android:radius="10dp" />
7 + <stroke
8 + android:width="1dp"
9 + android:color="@color/colorLine" />
10 +
11 +</shape>
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 - android:layout_width="match_parent" 3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 - android:layout_height="match_parent"
5 android:id="@+id/drawer_main" 4 android:id="@+id/drawer_main"
6 - xmlns:app="http://schemas.android.com/apk/res-auto"> 5 + android:layout_width="match_parent"
6 + android:layout_height="match_parent">
7 7
8 <androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" 8 <androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
9 xmlns:tools="http://schemas.android.com/tools" 9 xmlns:tools="http://schemas.android.com/tools"
...@@ -243,8 +243,8 @@ ...@@ -243,8 +243,8 @@
243 243
244 <androidx.constraintlayout.widget.ConstraintLayout 244 <androidx.constraintlayout.widget.ConstraintLayout
245 android:id="@+id/container_device_button" 245 android:id="@+id/container_device_button"
246 - android:layout_width="wrap_content" 246 + android:layout_width="0dp"
247 - android:layout_height="wrap_content" 247 + android:layout_height="0dp"
248 android:background="@color/colorAccent" 248 android:background="@color/colorAccent"
249 app:layout_constraintBottom_toBottomOf="parent" 249 app:layout_constraintBottom_toBottomOf="parent"
250 app:layout_constraintEnd_toStartOf="@id/line_vertical" 250 app:layout_constraintEnd_toStartOf="@id/line_vertical"
...@@ -257,9 +257,11 @@ ...@@ -257,9 +257,11 @@
257 android:layout_width="48dp" 257 android:layout_width="48dp"
258 android:layout_height="48dp" 258 android:layout_height="48dp"
259 android:background="@drawable/bg_btn_circle_main" 259 android:background="@drawable/bg_btn_circle_main"
260 + app:layout_constraintBottom_toTopOf="@+id/tv_device"
260 app:layout_constraintEnd_toEndOf="parent" 261 app:layout_constraintEnd_toEndOf="parent"
261 app:layout_constraintStart_toStartOf="parent" 262 app:layout_constraintStart_toStartOf="parent"
262 - app:layout_constraintTop_toTopOf="parent" /> 263 + app:layout_constraintTop_toTopOf="parent"
264 + app:layout_constraintVertical_chainStyle="packed" />
263 265
264 <ImageView 266 <ImageView
265 android:layout_width="wrap_content" 267 android:layout_width="wrap_content"
...@@ -271,6 +273,7 @@ ...@@ -271,6 +273,7 @@
271 app:layout_constraintTop_toTopOf="@id/btn_back_3" /> 273 app:layout_constraintTop_toTopOf="@id/btn_back_3" />
272 274
273 <TextView 275 <TextView
276 + android:id="@+id/tv_device"
274 android:layout_width="wrap_content" 277 android:layout_width="wrap_content"
275 android:layout_height="wrap_content" 278 android:layout_height="wrap_content"
276 android:layout_marginTop="10dp" 279 android:layout_marginTop="10dp"
...@@ -278,16 +281,18 @@ ...@@ -278,16 +281,18 @@
278 android:text="@string/menu_device_manager" 281 android:text="@string/menu_device_manager"
279 android:textColor="@color/colorBackground" 282 android:textColor="@color/colorBackground"
280 android:textSize="15sp" 283 android:textSize="15sp"
284 + app:layout_constraintBottom_toBottomOf="parent"
281 app:layout_constraintEnd_toEndOf="parent" 285 app:layout_constraintEnd_toEndOf="parent"
282 app:layout_constraintStart_toStartOf="parent" 286 app:layout_constraintStart_toStartOf="parent"
283 - app:layout_constraintTop_toBottomOf="@id/btn_back_3" /> 287 + app:layout_constraintTop_toBottomOf="@id/btn_back_3"
288 + app:layout_constraintVertical_chainStyle="packed" />
284 289
285 </androidx.constraintlayout.widget.ConstraintLayout> 290 </androidx.constraintlayout.widget.ConstraintLayout>
286 291
287 <androidx.constraintlayout.widget.ConstraintLayout 292 <androidx.constraintlayout.widget.ConstraintLayout
288 android:id="@+id/container_video_button" 293 android:id="@+id/container_video_button"
289 - android:layout_width="wrap_content" 294 + android:layout_width="0dp"
290 - android:layout_height="wrap_content" 295 + android:layout_height="0dp"
291 android:background="@color/colorAccent" 296 android:background="@color/colorAccent"
292 app:layout_constraintBottom_toBottomOf="parent" 297 app:layout_constraintBottom_toBottomOf="parent"
293 app:layout_constraintEnd_toEndOf="parent" 298 app:layout_constraintEnd_toEndOf="parent"
...@@ -300,9 +305,11 @@ ...@@ -300,9 +305,11 @@
300 android:layout_width="48dp" 305 android:layout_width="48dp"
301 android:layout_height="48dp" 306 android:layout_height="48dp"
302 android:background="@drawable/bg_btn_circle_main" 307 android:background="@drawable/bg_btn_circle_main"
308 + app:layout_constraintBottom_toTopOf="@+id/tv_video"
303 app:layout_constraintEnd_toEndOf="parent" 309 app:layout_constraintEnd_toEndOf="parent"
304 app:layout_constraintStart_toStartOf="parent" 310 app:layout_constraintStart_toStartOf="parent"
305 - app:layout_constraintTop_toTopOf="parent" /> 311 + app:layout_constraintTop_toTopOf="parent"
312 + app:layout_constraintVertical_chainStyle="packed" />
306 313
307 <ImageView 314 <ImageView
308 android:layout_width="wrap_content" 315 android:layout_width="wrap_content"
...@@ -314,6 +321,7 @@ ...@@ -314,6 +321,7 @@
314 app:layout_constraintTop_toTopOf="@id/btn_back_4" /> 321 app:layout_constraintTop_toTopOf="@id/btn_back_4" />
315 322
316 <TextView 323 <TextView
324 + android:id="@+id/tv_video"
317 android:layout_width="wrap_content" 325 android:layout_width="wrap_content"
318 android:layout_height="wrap_content" 326 android:layout_height="wrap_content"
319 android:layout_marginTop="10dp" 327 android:layout_marginTop="10dp"
...@@ -321,9 +329,11 @@ ...@@ -321,9 +329,11 @@
321 android:text="@string/menu_video_check" 329 android:text="@string/menu_video_check"
322 android:textColor="@color/colorBackground" 330 android:textColor="@color/colorBackground"
323 android:textSize="15sp" 331 android:textSize="15sp"
332 + app:layout_constraintBottom_toBottomOf="parent"
324 app:layout_constraintEnd_toEndOf="parent" 333 app:layout_constraintEnd_toEndOf="parent"
325 app:layout_constraintStart_toStartOf="parent" 334 app:layout_constraintStart_toStartOf="parent"
326 - app:layout_constraintTop_toBottomOf="@id/btn_back_4" /> 335 + app:layout_constraintTop_toBottomOf="@id/btn_back_4"
336 + app:layout_constraintVertical_chainStyle="packed" />
327 337
328 </androidx.constraintlayout.widget.ConstraintLayout> 338 </androidx.constraintlayout.widget.ConstraintLayout>
329 339
......
...@@ -5,23 +5,111 @@ ...@@ -5,23 +5,111 @@
5 android:layout_width="match_parent" 5 android:layout_width="match_parent"
6 android:layout_height="match_parent"> 6 android:layout_height="match_parent">
7 7
8 - <Button 8 + <androidx.appcompat.widget.Toolbar
9 - android:id="@+id/btn_logout" 9 + android:id="@+id/toolbar_settings"
10 + android:layout_width="0dp"
11 + android:layout_height="?attr/actionBarSize"
12 + android:background="@color/colorBackground"
13 + android:elevation="7dp"
14 + app:layout_constraintEnd_toEndOf="parent"
15 + app:layout_constraintStart_toStartOf="parent"
16 + app:layout_constraintTop_toTopOf="parent">
17 +
18 + <TextView
19 + android:layout_width="wrap_content"
20 + android:layout_height="wrap_content"
21 + android:fontFamily="@font/g_market_sans_ttf_medium"
22 + android:text="@string/menu_settings"
23 + android:textColor="@color/colorMainText"
24 + android:textSize="15sp" />
25 +
26 + </androidx.appcompat.widget.Toolbar>
27 +
28 + <androidx.constraintlayout.widget.Guideline
29 + android:id="@+id/gl_start"
10 android:layout_width="wrap_content" 30 android:layout_width="wrap_content"
11 android:layout_height="wrap_content" 31 android:layout_height="wrap_content"
12 - android:layout_marginStart="22dp" 32 + android:orientation="vertical"
13 - android:layout_marginTop="9dp" 33 + app:layout_constraintBottom_toBottomOf="parent"
14 - android:text="btn_logout" 34 + app:layout_constraintGuide_percent="0.05"
15 - app:layout_constraintStart_toStartOf="@+id/swc_recording" 35 + app:layout_constraintStart_toStartOf="parent"
16 - app:layout_constraintTop_toBottomOf="@+id/swc_recording" /> 36 + app:layout_constraintTop_toTopOf="parent" />
17 - 37 +
18 - <Switch 38 + <androidx.constraintlayout.widget.Guideline
19 - android:id="@+id/swc_recording" 39 + android:id="@+id/gl_end"
20 android:layout_width="wrap_content" 40 android:layout_width="wrap_content"
21 android:layout_height="wrap_content" 41 android:layout_height="wrap_content"
22 - android:layout_marginEnd="117dp" 42 + android:orientation="vertical"
23 - android:layout_marginTop="151dp" 43 + app:layout_constraintBottom_toBottomOf="parent"
24 - android:text="swc_recording" 44 + app:layout_constraintGuide_percent="0.95"
25 - app:layout_constraintEnd_toEndOf="parent" 45 + app:layout_constraintStart_toStartOf="parent"
26 app:layout_constraintTop_toTopOf="parent" /> 46 app:layout_constraintTop_toTopOf="parent" />
47 +
48 + <ImageView
49 + android:id="@+id/img_icon_settings"
50 + android:layout_width="wrap_content"
51 + android:layout_height="wrap_content"
52 + android:layout_marginTop="20dp"
53 + android:src="@drawable/baseline_ondemand_video_24"
54 + app:layout_constraintStart_toStartOf="@id/gl_start"
55 + app:layout_constraintTop_toBottomOf="@+id/toolbar_settings" />
56 +
57 + <TextView
58 + android:layout_width="wrap_content"
59 + android:layout_height="wrap_content"
60 + android:layout_marginStart="3dp"
61 + android:fontFamily="@font/g_market_sans_ttf_medium"
62 + android:text="@string/video_settings"
63 + android:textColor="#111111"
64 + android:textSize="17sp"
65 + app:layout_constraintBottom_toBottomOf="@id/img_icon_settings"
66 + app:layout_constraintStart_toEndOf="@id/img_icon_settings"
67 + app:layout_constraintTop_toTopOf="@+id/img_icon_settings" />
68 +
69 + <androidx.constraintlayout.widget.ConstraintLayout
70 + android:id="@+id/cl_auto_recording"
71 + android:layout_width="0dp"
72 + android:layout_height="wrap_content"
73 + android:layout_marginTop="10dp"
74 + android:background="@drawable/bg_white_radius10_line"
75 + app:layout_constraintEnd_toEndOf="@id/gl_end"
76 + app:layout_constraintStart_toStartOf="@id/gl_start"
77 + app:layout_constraintTop_toBottomOf="@+id/img_icon_settings">
78 +
79 + <TextView
80 + android:layout_width="wrap_content"
81 + android:layout_height="wrap_content"
82 + android:layout_marginVertical="15dp"
83 + android:layout_marginStart="13dp"
84 + android:text="@string/video_auto_record"
85 + android:textColor="#111111"
86 + app:layout_constraintBottom_toBottomOf="parent"
87 + app:layout_constraintStart_toStartOf="parent"
88 + app:layout_constraintTop_toTopOf="parent" />
89 +
90 + <Switch
91 + android:id="@+id/swc_recording"
92 + android:layout_width="wrap_content"
93 + android:layout_height="wrap_content"
94 + android:layout_marginEnd="20dp"
95 + app:layout_constraintBottom_toBottomOf="parent"
96 + app:layout_constraintEnd_toEndOf="parent"
97 + app:layout_constraintTop_toTopOf="parent" />
98 +
99 + </androidx.constraintlayout.widget.ConstraintLayout>
100 +
101 + <Button
102 + android:id="@+id/btn_logout"
103 + style="?android:attr/borderlessButtonStyle"
104 + android:layout_width="0dp"
105 + android:layout_height="wrap_content"
106 + android:layout_marginTop="40dp"
107 + android:background="@drawable/bg_btn_logout"
108 + android:text="@string/logout"
109 + android:textColor="@color/colorAccent"
110 + android:textStyle="bold"
111 + app:layout_constraintEnd_toEndOf="@id/gl_end"
112 + app:layout_constraintStart_toStartOf="@id/gl_start"
113 + app:layout_constraintTop_toBottomOf="@+id/cl_auto_recording" />
114 +
27 </androidx.constraintlayout.widget.ConstraintLayout> 115 </androidx.constraintlayout.widget.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
6 <string name="menu_remote_control_record">원격 잠금해제 기록</string> 6 <string name="menu_remote_control_record">원격 잠금해제 기록</string>
7 <string name="menu_device_manager">기기 관리</string> 7 <string name="menu_device_manager">기기 관리</string>
8 <string name="menu_video_check">비디오 확인</string> 8 <string name="menu_video_check">비디오 확인</string>
9 + <string name="menu_settings">설정</string>
9 10
10 <string name="button_on">ON</string> 11 <string name="button_on">ON</string>
11 <string name="button_off">OFF</string> 12 <string name="button_off">OFF</string>
...@@ -26,4 +27,13 @@ ...@@ -26,4 +27,13 @@
26 27
27 <string name="sample_device_name">Galaxy Note 10</string> 28 <string name="sample_device_name">Galaxy Note 10</string>
28 <string name="sample_remote_date">2020.10.07(수) 17:50:00</string> 29 <string name="sample_remote_date">2020.10.07(수) 17:50:00</string>
30 +
31 + <string name="video_settings">비디오 설정</string>
32 + <string name="video_auto_record">비디오 자동 녹화</string>
33 +
34 + <string name="logout">로그아웃</string>
35 +
36 + <string name="logout_dialog_title">확인</string>
37 + <string name="logout_dialog">정말 로그아웃하시겠습니까?\n\n</string>
38 +
29 </resources> 39 </resources>
......