Преглед изворни кода

[회원가입][NEW] 회원 가입 구현 비밀번호 랜덤 키보드 및 이벤드 구현 중

Hasemi пре 7 година
родитељ
комит
267e58f297

+ 57 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/fragment/signup/PasswordDialog.java

@@ -3,10 +3,16 @@ package kr.co.zumo.app.lifeplus.view.fragment.signup;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v4.app.DialogFragment;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowManager;
+import android.widget.Button;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 
 import kr.co.zumo.app.R;
 
@@ -20,7 +26,10 @@ import kr.co.zumo.app.R;
  * @history 하세미   [2018-09-13]   [최초 작성]
  * @since 2018-09-13
  */
-public class PasswordDialog extends DialogFragment{
+public class PasswordDialog extends DialogFragment {
+
+  private ArrayList<Integer> numberList;
+  private ArrayList<Button> buttonList;
 
   public PasswordDialog() {
   }
@@ -32,17 +41,61 @@ public class PasswordDialog extends DialogFragment{
     super.onCreate(savedInstanceState);
   }
 
-
   @Nullable
   @Override
   public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
-   getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
+    getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
     View view = inflater.inflate(R.layout.password_dialog, container, false);
+    Button button0 = view.findViewById(R.id.button_0);
+    Button button1 = view.findViewById(R.id.button_1);
+    Button button2 = view.findViewById(R.id.button_2);
+    Button button3 = view.findViewById(R.id.button_3);
+    Button button4 = view.findViewById(R.id.button_4);
+    Button button5 = view.findViewById(R.id.button_5);
+    Button button6 = view.findViewById(R.id.button_6);
+    Button button7 = view.findViewById(R.id.button_7);
+    Button button8 = view.findViewById(R.id.button_8);
+    Button button9 = view.findViewById(R.id.button_9);
+    Button buttonShuffle = view.findViewById(R.id.button_shuffle);
+
+    numberList = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
+    buttonList = new ArrayList<>(Arrays.asList(button0, button1, button2, button3, button4, button5, button6, button7, button8, button9));
+
+    buttonShuffle.setOnClickListener(new View.OnClickListener() {
+      @Override
+      public void onClick(View view) {
+        shuffleKeyboard();
+      }
+    });
+
+    int size = buttonList.size();
+    for (int i = 0; i < size; ++i) {
+      buttonList.get(i).setOnClickListener(new View.OnClickListener() {
+        @Override
+        public void onClick(View view) {
+          Log.e("APP#  PasswordDialog | onClick", "|" + ((Button)view).getText());
+
 
-    return view;
 
+
+        }
+      });
+    }
+
+    shuffleKeyboard();
+
+    return view;
   }
 
 
+  public void shuffleKeyboard() {
+
+    Collections.shuffle(numberList);
+    int size = buttonList.size();
+
+    for (int i = 0; i < size; ++i) {
+      buttonList.get(i).setText(String.valueOf(numberList.get(i)));
+    }
+  }
 
 }

+ 7 - 0
app/src/main/res/drawable/circle_empty.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+       android:shape="oval">
+  <stroke
+    android:width="3dp"
+    android:color="#78d9ff"/>
+</shape>

+ 6 - 0
app/src/main/res/drawable/circle_full.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+       android:shape="oval">
+  <solid
+    android:color="#48b3ff"/>
+</shape>

+ 195 - 14
app/src/main/res/layout/password_dialog.xml

@@ -1,23 +1,204 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout
+<RelativeLayout
   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"
-  android:background="@color/colorAccent"
-  tools:layout_editor_absoluteY="81dp">
+  android:background="@color/colorAccent">
 
+  <LinearLayout
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_alignParentStart="true"
+    android:layout_alignParentTop="true"
+    android:layout_marginTop="30dp"
+    android:orientation="vertical">
+
+    <TextView
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_centerInParent="true"
+      android:text="@string/sign_up_password"
+      android:textAlignment="center"
+      />
+  </LinearLayout>
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="15dp"
+      android:orientation="horizontal"
+      android:layout_alignParentStart="true"
+      android:layout_alignParentTop="true"
+      android:layout_marginTop="80dp"
+      android:weightSum="4"
+      >
+
+      <ImageView
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:src="@drawable/circle_empty"
+        />
+
+      <ImageView
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:src="@drawable/circle_empty"
+        />
+
+      <ImageView
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:src="@drawable/circle_empty"
+        />
+
+      <ImageView
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="1"
+        android:src="@drawable/circle_empty"
+        />
 
-  <TextView
-    android:id="@+id/textView"
-    android:layout_width="wrap_content"
+    </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_marginTop="101dp"
-    android:text="@string/sign_up_input_password"
-    app:layout_constraintEnd_toEndOf="parent"
-    app:layout_constraintStart_toStartOf="parent"
-    app:layout_constraintTop_toTopOf="parent"
-    />
-
-</android.support.constraint.ConstraintLayout>
+    android:layout_alignParentBottom="true"
+    android:orientation="vertical"
+
+    >
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_gravity="bottom"
+      android:orientation="horizontal"
+      android:weightSum="3"
+      >
+
+      <Button
+        android:id="@+id/button_0"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:id="@+id/button_1"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:id="@+id/button_2"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+    </LinearLayout>
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_gravity="bottom"
+      android:orientation="horizontal"
+      android:weightSum="3"
+      >
+
+      <Button
+        android:id="@+id/button_3"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:id="@+id/button_4"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:id="@+id/button_5"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+    </LinearLayout>
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_gravity="bottom"
+      android:orientation="horizontal"
+      android:weightSum="3"
+      >
+
+      <Button
+        android:id="@+id/button_6"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:id="@+id/button_7"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:id="@+id/button_8"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+    </LinearLayout>
+
+    <LinearLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:orientation="horizontal"
+      android:weightSum="3"
+      >
+
+      <Button
+        android:id="@+id/button_shuffle"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:text="@string/sign_up_shuffle"/>
+
+      <Button
+        android:id="@+id/button_9"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        tools:text="1"
+        />
+
+      <Button
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:text="x"
+        />
+    </LinearLayout>
+  </LinearLayout>
+</RelativeLayout>

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -28,4 +28,7 @@
 
   <string name="sign_up_password">Lifeplus에 사용할 간편 암호를 등록해주세요. </string>
   <string name="sign_up_input_password">등록하실 간편암호 4자리를 입력해주세요.</string>
+
+  <string name="sign_up_shuffle">재배열</string>
+
 </resources>