sunnnl

main 수정, timer 구현

Showing 36 changed files with 329 additions and 28 deletions
......@@ -12,19 +12,19 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".ui.SplashActivity"
android:screenOrientation="fullSensor"
android:noHistory="true">
</activity>
<activity android:name=".ui.MainActivity" >
<activity android:name=".ui.VideoCheckActivity"></activity>
<activity android:name=".ui.DeviceManagerActivity" />
<activity android:name=".ui.RemoteControlRecordActivity" />
<activity
android:name=".ui.SplashActivity"
android:noHistory="true"
android:screenOrientation="fullSensor" />
<activity android:name=".ui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
......
package com.sunnni.smartdoorlock.ui;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.sunnni.smartdoorlock.R;
public class DeviceManagerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_manager);
}
}
......@@ -2,32 +2,163 @@ package com.sunnni.smartdoorlock.ui;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
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 Toolbar mToolbar;
private Button mBtnTagControl;
private ImageView mBtnTagControlBackground;
private TextView mTvTagButtonStatus, mTvTagButtonStatusDetail;
TagTimer timer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setToolbar();
Toolbar mToolbar = findViewById(R.id.toolbar_main);
setToolbar(mToolbar);
init();
timer = new TagTimer(5 * 1000, 1000, 5);
}
// 툴바 설정
private void setToolbar(){
mToolbar = findViewById(R.id.toolbar_main);
setSupportActionBar(mToolbar);
private void setToolbar(Toolbar toolbar) {
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.baseline_menu_white_24);
}
private void init() {
mBtnTagControl = findViewById(R.id.btn_tag_control);
mBtnTagControlBackground = findViewById(R.id.btn_tag_control_back);
mTvTagButtonStatus = findViewById(R.id.tv_tag_status);
mTvTagButtonStatusDetail = findViewById(R.id.tv_tag_status_detail);
mBtnTagControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tagControlManage();
}
});
ConstraintLayout mClRemoteControl = findViewById(R.id.container_remote_button);
ConstraintLayout mClRemoteRecord = findViewById(R.id.container_record_button);
ConstraintLayout mClDeviceManager = findViewById(R.id.container_device_button);
ConstraintLayout mClVideoRecord = findViewById(R.id.container_video_button);
mClRemoteControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 원격 잠금해제 팝업
}
});
// 원격 잠금해제 기록 화면으로 이동
mClRemoteRecord.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
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, DeviceManagerActivity.class);
startActivity(intent);
}
});
// 비디오 확인 화면으로 이동
mClVideoRecord.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, VideoCheckActivity.class);
startActivity(intent);
}
});
}
// 도어락 태그 버튼 상태에 따라 뷰 변경
@SuppressLint("SetTextI18n")
private void tagControlManage() {
if (mBtnTagControl.isSelected()) {
// 타이머 종료
timer.cancel();
timer.reset();
mBtnTagControl.setText(R.string.button_on);
mTvTagButtonStatus.setText(R.string.tag_status_off);
mTvTagButtonStatusDetail.setText(R.string.tag_status_off_detail);
} else {
// 타이머 시작
timer.start();
mBtnTagControl.setText(R.string.button_off);
mTvTagButtonStatus.setText(R.string.tag_status_on);
mTvTagButtonStatusDetail.setText(R.string.tag_status_on_detail);
}
mBtnTagControl.setSelected(!mBtnTagControl.isSelected());
mBtnTagControlBackground.setSelected(mBtnTagControl.isSelected());
}
class TagTimer extends CountDownTimer {
int count;
public TagTimer(long millisInFuture, long countDownInterval, int count) {
super(millisInFuture, countDownInterval);
this.count = count;
}
@SuppressLint("SetTextI18n")
@Override
public void onTick(long millisUntilFinished) {
mTvTagButtonStatusDetail.setText(count + getString(R.string.tag_status_on_detail));
count--;
}
@Override
public void onFinish() {
count = 5;
mBtnTagControl.setText(getString(R.string.button_on));
mTvTagButtonStatus.setText(getString(R.string.tag_status_off));
mTvTagButtonStatusDetail.setText(getString(R.string.tag_status_off_detail));
mBtnTagControl.setSelected(!mBtnTagControl.isSelected());
mBtnTagControlBackground.setSelected(mBtnTagControl.isSelected());
}
public void reset() {
count = 5;
}
}
}
\ No newline at end of file
......
package com.sunnni.smartdoorlock.ui;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.os.Bundle;
import android.view.View;
import com.sunnni.smartdoorlock.R;
import java.util.Objects;
public class RemoteControlRecordActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_remote_control_record);
Toolbar mToolbar = findViewById(R.id.toolbar_remote_control_record);
setToolbar(mToolbar);
}
private void setToolbar(Toolbar toolbar){
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.round_chevron_left_white_24);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
package com.sunnni.smartdoorlock.ui;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.sunnni.smartdoorlock.R;
public class VideoCheckActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_check);
}
}
......@@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#F26612" />
<solid android:color="#F2661e" />
<corners android:radius="100dp" />
</shape>
\ No newline at end of file
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M14.71,6.71c-0.39,-0.39 -1.02,-0.39 -1.41,0L8.71,11.3c-0.39,0.39 -0.39,1.02 0,1.41l4.59,4.59c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L10.83,12l3.88,-3.88c0.39,-0.39 0.38,-1.03 0,-1.41z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#F2661e"
android:alpha="0.5">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<item android:state_selected="true" android:drawable="@drawable/bg_btn_off" />
<item android:state_selected="false" android:drawable="@drawable/bg_btn_on" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="false"
android:drawable="@drawable/round_lens_24" />
<item
android:state_selected="true"
android:drawable="@drawable/round_lens_active_24"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.DeviceManagerActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -40,7 +40,7 @@
android:id="@+id/btn_tag_control_back"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/round_lens_24"
android:src="@drawable/selector_btn_tag_back"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -66,8 +66,8 @@
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@drawable/bg_btn_on"
android:text="ON"
android:background="@drawable/selector_btn_tag"
android:text="@string/button_on"
android:textColor="@color/colorMainText"
android:textSize="28sp"
app:layout_constraintBottom_toBottomOf="@+id/btn_tag_control_back"
......@@ -79,12 +79,12 @@
app:layout_constraintWidth_percent="0.3" />
<TextView
android:id="@+id/tv_status"
android:id="@+id/tv_tag_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="도어락 태그 꺼짐"
android:text="@string/tag_status_off"
android:textColor="@color/colorMainText"
android:textSize="17sp"
app:layout_constraintEnd_toEndOf="parent"
......@@ -92,17 +92,17 @@
app:layout_constraintTop_toBottomOf="@+id/btn_tag_control_back" />
<TextView
android:id="@+id/tv_status_detail"
android:id="@+id/tv_tag_status_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:fontFamily="@font/g_market_sans_ttf_light"
android:text="버튼을 누른 후 스캔해주세요"
android:text="@string/tag_status_off_detail"
android:textColor="@color/colorMainText"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_status" />
app:layout_constraintTop_toBottomOf="@+id/tv_tag_status" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -173,7 +173,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="원격 잠금해제"
android:text="@string/menu_remote_control"
android:textColor="@color/colorBackground"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
......@@ -216,7 +216,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="원격 잠금해제 기록"
android:text="@string/menu_remote_control_record"
android:textColor="@color/colorBackground"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
......@@ -259,7 +259,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="기기 관리"
android:text="@string/menu_device_manager"
android:textColor="@color/colorBackground"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
......@@ -302,7 +302,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="비디오 확인"
android:text="@string/menu_video_check"
android:textColor="@color/colorBackground"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.RemoteControlRecordActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_remote_control_record"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:elevation="7dp"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/g_market_sans_ttf_medium"
android:text="@string/menu_remote_control_record"
android:textColor="@color/colorMainText"
android:textSize="15sp" />
</androidx.appcompat.widget.Toolbar>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.VideoCheckActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorPrimary">#090938</color>
<color name="colorPrimaryDark">#090938</color>
<color name="colorAccent">#ffffff</color>
<color name="colorBackground">#090938</color>
......
<resources>
<string name="app_name">SmartDoorLock</string>
<string name="app_name_korean">게이트웨이</string>
<string name="menu_remote_control">원격 잠금해제</string>
<string name="menu_remote_control_record">원격 잠금해제 기록</string>
<string name="menu_device_manager">기기 관리</string>
<string name="menu_video_check">비디오 확인</string>
<string name="button_on">ON</string>
<string name="button_off">OFF</string>
<string name="tag_status_off">도어락 태그 꺼짐</string>
<string name="tag_status_off_detail">버튼을 누른 후 스캔해주세요</string>
<string name="tag_status_on">도어락 태그 켜짐</string>
<string name="tag_status_on_detail">초 후 꺼짐</string>
</resources>
......