로그인 화면 수정
계정 등록 화면 추가
This commit is contained in:
@@ -32,7 +32,10 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.5.0'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.room:room-common:2.4.3'
|
||||
implementation 'androidx.room:room-runtime:2.4.3'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.4.3'
|
||||
}
|
||||
@@ -31,6 +31,12 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.QTagger"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".Activity.AccountAdd"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Activity.AccountList"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
|
||||
64
app/src/main/java/com/qtagger/Activity/AccountAdd.java
Normal file
64
app/src/main/java/com/qtagger/Activity/AccountAdd.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.qtagger.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.utils.widget.ImageFilterButton;
|
||||
import androidx.room.Room;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.qtagger.Database.Account;
|
||||
import com.qtagger.Database.AppDatabase;
|
||||
import com.qtagger.R;
|
||||
|
||||
public class AccountAdd extends AppCompatActivity {
|
||||
private EditText editAccountId, editAccountName, editAccountDapt;
|
||||
private ImageFilterButton backBtn;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_account_add);
|
||||
|
||||
editAccountId = (EditText) findViewById(R.id.textView_AccountId);
|
||||
editAccountName = (EditText) findViewById(R.id.textView_AccountName);
|
||||
editAccountDapt = (EditText) findViewById(R.id.textView_AccountDapt);
|
||||
backBtn = (ImageFilterButton) findViewById(R.id.imageFilterButton_Back);
|
||||
|
||||
AppDatabase db = Room.databaseBuilder(this,AppDatabase.class,"AccountDB").allowMainThreadQueries().build();
|
||||
|
||||
|
||||
findViewById(R.id.button_save).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String acId = editAccountId.getText().toString();
|
||||
String acName = editAccountId.getText().toString();
|
||||
String acDapt = editAccountId.getText().toString();
|
||||
|
||||
if(acId.isEmpty() || acName.isEmpty() || acDapt.isEmpty())
|
||||
{
|
||||
Toast.makeText(AccountAdd.this, "모두 입력해주세요", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//DB에 저장
|
||||
db.accountDao().insert(new Account(acId,acName,acDapt));
|
||||
|
||||
Toast.makeText(AccountAdd.this, "계정 생성 성공", Toast.LENGTH_SHORT).show();
|
||||
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
backBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
16
app/src/main/java/com/qtagger/Activity/AccountList.java
Normal file
16
app/src/main/java/com/qtagger/Activity/AccountList.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.qtagger.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.qtagger.R;
|
||||
|
||||
public class AccountList extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_account_list);
|
||||
}
|
||||
}
|
||||
59
app/src/main/java/com/qtagger/Database/Account.java
Normal file
59
app/src/main/java/com/qtagger/Database/Account.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.qtagger.Database;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
@Entity
|
||||
public class Account {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int id;
|
||||
private String accountId;
|
||||
private String accountName;
|
||||
private String accountDapt;
|
||||
|
||||
public Account(String accountId, String accountName, String accountDapt) {
|
||||
this.accountId = accountId;
|
||||
this.accountName = accountName;
|
||||
this.accountDapt = accountDapt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Account{" +
|
||||
"id=" + id +
|
||||
", accountId='" + accountId + '\'' +
|
||||
", accountName='" + accountName + '\'' +
|
||||
", accountDapt='" + accountDapt + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public String getAccountDapt() {
|
||||
return accountDapt;
|
||||
}
|
||||
|
||||
public void setAccountDapt(String accountDapt) {
|
||||
this.accountDapt = accountDapt;
|
||||
}
|
||||
}
|
||||
25
app/src/main/java/com/qtagger/Database/AccountDao.java
Normal file
25
app/src/main/java/com/qtagger/Database/AccountDao.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.qtagger.Database;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface AccountDao {
|
||||
@Query("SELECT * FROM Account")
|
||||
List<Account> getAll();
|
||||
|
||||
@Insert
|
||||
void insert(Account account);
|
||||
|
||||
@Update
|
||||
void update(Account account);
|
||||
|
||||
@Delete
|
||||
void delete(Account account);
|
||||
|
||||
}
|
||||
10
app/src/main/java/com/qtagger/Database/AppDatabase.java
Normal file
10
app/src/main/java/com/qtagger/Database/AppDatabase.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.qtagger.Database;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
@Database(entities = {Account.class}, version = 1)
|
||||
public abstract class AppDatabase extends RoomDatabase{
|
||||
public abstract AccountDao accountDao();
|
||||
|
||||
}
|
||||
@@ -1,19 +1,65 @@
|
||||
package com.qtagger;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.room.Room;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.qtagger.Activity.AccountAdd;
|
||||
import com.qtagger.Activity.AccountList;
|
||||
import com.qtagger.Database.Account;
|
||||
import com.qtagger.Database.AppDatabase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private Spinner mSpinner;
|
||||
private Button btnLogin;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mSpinner = findViewById(R.id.spinner_account);
|
||||
|
||||
//로그인
|
||||
findViewById(R.id.button_login).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//로그인 정보 확인
|
||||
//로그인 처리
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//계정 추가
|
||||
findViewById(R.id.text_accountInsert).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//계정추가 페이지 이동
|
||||
Intent intent = new Intent(getApplicationContext(), AccountAdd.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
//계정 목록 보는 페이지
|
||||
findViewById(R.id.text_accountList).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getApplicationContext(), AccountList.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
if(getConnectStatus())//온라인 모드
|
||||
{
|
||||
|
||||
@@ -24,6 +70,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
ArrayAdapter<String> aa_items = new ArrayAdapter<String>(this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item);
|
||||
aa_items.add("사용자를 선택해주세요");
|
||||
AppDatabase db = Room.databaseBuilder(this,AppDatabase.class,"AccountDB").allowMainThreadQueries().build();
|
||||
|
||||
//초기 데이터 세팅
|
||||
List<Account> accountList = db.accountDao().getAll();
|
||||
for (Account ac: accountList) {
|
||||
aa_items.add(ac.getAccountName());
|
||||
}
|
||||
|
||||
mSpinner.setAdapter(aa_items);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//인터넷이 연결 되이있는지 확인하는 함수
|
||||
private boolean getConnectStatus()
|
||||
{
|
||||
|
||||
BIN
app/src/main/res/drawable/_11.png
Normal file
BIN
app/src/main/res/drawable/_11.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/drawable/back_arrow_5821.png
Normal file
BIN
app/src/main/res/drawable/back_arrow_5821.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 186 B |
18
app/src/main/res/drawable/spinner_background.xml
Normal file
18
app/src/main/res/drawable/spinner_background.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<!-- #f5f5f5" 색으로 채움 -->
|
||||
<solid
|
||||
android:color="#ffffff"/>
|
||||
<corners
|
||||
android:bottomLeftRadius="6dp"
|
||||
android:bottomRightRadius="6dp"
|
||||
android:topLeftRadius="6dp"
|
||||
android:topRightRadius="6dp" />
|
||||
<!-- 1dp 크기의 #000000 색 테두리 -->
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#000000"/>
|
||||
|
||||
</shape>
|
||||
4
app/src/main/res/font/font.xml
Normal file
4
app/src/main/res/font/font.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</font-family>
|
||||
BIN
app/src/main/res/font/segoe_ui.ttf
Normal file
BIN
app/src/main/res/font/segoe_ui.ttf
Normal file
Binary file not shown.
99
app/src/main/res/layout/activity_account_add.xml
Normal file
99
app/src/main/res/layout/activity_account_add.xml
Normal file
@@ -0,0 +1,99 @@
|
||||
<?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=".Activity.AccountAdd">
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:background="#000000"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
|
||||
<TextView
|
||||
android:id="@+id/textViewAccountAccTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="사용자 등록"
|
||||
android:textAlignment="center"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterButton
|
||||
android:id="@+id/imageFilterButton_Back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="#FFFFFF"
|
||||
android:minWidth="48dp"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/back_arrow_5821" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textView_AccountId"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:hint="아이디를 입력해주세요"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textView_AccountName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="132dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:hint="이름을 입력해주세요"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textView_AccountDapt"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="200dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:hint="소속을 입력해주세요"
|
||||
android:minHeight="48dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
|
||||
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_save"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="100dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="등록"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView_AccountDapt" />
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
8
app/src/main/res/layout/activity_account_list.xml
Normal file
8
app/src/main/res/layout/activity_account_list.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?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=".Activity.AccountList"/>
|
||||
@@ -36,6 +36,8 @@
|
||||
android:layout_marginTop="48dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:background="@drawable/spinner_background"
|
||||
|
||||
app:layout_constraintBottom_toTopOf="@+id/button_login"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
@@ -50,8 +52,11 @@
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@color/black"
|
||||
android:backgroundTint="#000000"
|
||||
android:text="로그인"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/spinner_account" />
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.QTagger" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
|
||||
Reference in New Issue
Block a user