Pārlūkot izejas kodu

添加拨号盘

liuzhenxing1118 5 mēneši atpakaļ
vecāks
revīzija
541aadcbbb

+ 0 - 19
.idea/gradle.xml

@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="GradleMigrationSettings" migrationVersion="1" />
-  <component name="GradleSettings">
-    <option name="linkedExternalProjectsSettings">
-      <GradleProjectSettings>
-        <option name="testRunner" value="GRADLE" />
-        <option name="distributionType" value="DEFAULT_WRAPPED" />
-        <option name="externalProjectPath" value="$PROJECT_DIR$" />
-        <option name="modules">
-          <set>
-            <option value="$PROJECT_DIR$" />
-            <option value="$PROJECT_DIR$/app" />
-          </set>
-        </option>
-      </GradleProjectSettings>
-    </option>
-  </component>
-</project>

+ 7 - 0
app/src/main/AndroidManifest.xml

@@ -32,6 +32,13 @@
             </intent-filter>
         </activity>
 
+        <activity
+            android:name=".activity.DialActivity"
+            android:exported="true"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:launchMode="singleInstance">
+        </activity>
+
     </application>
 
 

+ 91 - 0
app/src/main/java/com/sikey/skcontact/activity/BaseInputActivity.java

@@ -0,0 +1,91 @@
+package com.sikey.xpcontact.activity;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.TextView;
+
+import com.sikey.skcontact.R;
+import com.sikey.skcontact.activity.BaseActivity;
+
+public class BaseInputActivity extends BaseActivity {
+    public String mInput = "";
+    private TextView mTextView = null;
+
+    protected void onSureClick() {};
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_input_code);
+        initView();
+    }
+
+    private void initView() {
+        mTextView = findViewById(R.id.text);
+
+        Button button1 = findViewById(R.id.button1);
+        Button button2 = findViewById(R.id.button2);
+        Button button3 = findViewById(R.id.button3);
+        Button button4 = findViewById(R.id.button4);
+        Button button5 = findViewById(R.id.button5);
+        Button button6 = findViewById(R.id.button6);
+        Button button7 = findViewById(R.id.button7);
+        Button button8 = findViewById(R.id.button8);
+        Button button9 = findViewById(R.id.button9);
+        Button button0 = findViewById(R.id.button0);
+        ImageButton buttonOK = findViewById(R.id.buttonOK);
+        ImageButton buttonBack = findViewById(R.id.buttonBack);
+
+        button1.setOnClickListener(mOnClickListener);
+        button2.setOnClickListener(mOnClickListener);
+        button3.setOnClickListener(mOnClickListener);
+        button4.setOnClickListener(mOnClickListener);
+        button5.setOnClickListener(mOnClickListener);
+        button6.setOnClickListener(mOnClickListener);
+        button7.setOnClickListener(mOnClickListener);
+        button8.setOnClickListener(mOnClickListener);
+        button9.setOnClickListener(mOnClickListener);
+        button0.setOnClickListener(mOnClickListener);
+        buttonOK.setOnClickListener(mOnClickListener);
+        buttonBack.setOnClickListener(mOnClickListener);
+    }
+
+    View.OnClickListener mOnClickListener = new View.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+            int tag = Integer.parseInt((String) v.getTag());
+            if (tag == 100) {
+                actionBack();
+            } else if (tag == 101) {
+                if (mInput.length() > 0) {
+                    onSureClick();
+                }
+            } else {
+                if (mInput.length() >= 4)
+                    return;
+                mInput += tag;
+                showInputCode();
+            }
+        }
+    };
+
+    private void showInputCode() {
+        mTextView.setText(mInput);
+    }
+
+    private void actionBack() {
+        if (mInput.length() <= 0)
+            return;
+        mInput = mInput.substring(0, mInput.length() - 1);
+        showInputCode();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mInput = "";
+        showInputCode();
+    }
+}

+ 12 - 0
app/src/main/java/com/sikey/skcontact/activity/DialActivity.java

@@ -0,0 +1,12 @@
+package com.sikey.skcontact.activity;
+
+import com.sikey.xpcontact.activity.BaseInputActivity;
+
+public class DialActivity extends BaseInputActivity {
+
+    @Override
+    protected void onSureClick() {
+        super.onSureClick();
+
+    }
+}

+ 187 - 0
app/src/main/res/layout/activity_input_code.xml

@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:background="@color/black"
+    android:layout_marginStart="5dp"
+    android:layout_marginEnd="5dp"
+    >
+
+    <TextView
+        android:id="@+id/text"
+        android:layout_width="match_parent"
+        android:layout_height="32dp"
+        android:layout_marginTop="10dp"
+        android:gravity="center"
+        android:textFontWeight="500"
+        android:textColor="@color/white"
+        android:textSize="17sp"
+        />
+
+    <LinearLayout
+        android:id="@+id/mLine1Layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="5dp"
+        android:orientation="horizontal"
+        android:layout_weight="1"
+        >
+        <Button
+            android:id="@+id/button1"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="1"
+            android:tag="1" />
+        <Button
+            android:id="@+id/button2"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="3dp"
+            android:layout_marginEnd="3dp"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="2"
+            android:tag="2" />
+        <Button
+            android:id="@+id/button3"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="3"
+            android:tag="3" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/mLine2Layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="3dp"
+        android:orientation="horizontal"
+        android:layout_weight="1"
+        >
+        <Button
+            android:id="@+id/button4"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="4"
+            android:tag="4" />
+        <Button
+            android:id="@+id/button5"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="3dp"
+            android:layout_marginEnd="3dp"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="5"
+            android:tag="5" />
+        <Button
+            android:id="@+id/button6"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="6"
+            android:tag="6" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/mLine3Layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="3dp"
+        android:orientation="horizontal"
+        android:layout_weight="1"
+        >
+        <Button
+            android:id="@+id/button7"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="7"
+            android:tag="7" />
+        <Button
+            android:id="@+id/button8"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="3dp"
+            android:layout_marginEnd="3dp"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="8"
+            android:tag="8" />
+        <Button
+            android:id="@+id/button9"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="9"
+            android:tag="9" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/mLine4Layout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="3dp"
+        android:orientation="horizontal"
+        android:layout_weight="1"
+        android:layout_marginBottom="10dp"
+        >
+        <ImageButton
+            android:id="@+id/buttonOK"
+            android:layout_width="50dp"
+            android:layout_height="match_parent"
+            android:background="@drawable/bg_gray"
+            android:src="@drawable/input_sure"
+            android:layout_weight="1"
+            android:tag="101" />
+        <Button
+            android:id="@+id/button0"
+            android:layout_width="50dp"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="3dp"
+            android:layout_marginEnd="3dp"
+            android:background="@drawable/bg_gray"
+            android:layout_weight="1"
+            android:textSize="15sp"
+            android:textColor="@color/white"
+            android:text="0"
+            android:tag="0" />
+        <ImageButton
+            android:id="@+id/buttonBack"
+            android:layout_width="50dp"
+            android:layout_height="match_parent"
+            android:background="@drawable/bg_gray"
+            android:src="@drawable/input_delete"
+            android:layout_weight="1"
+            android:tag="100" />
+    </LinearLayout>
+
+</LinearLayout>