|
@@ -1,6 +1,9 @@
|
|
|
package com.sikey.skphone.activity;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
+import android.text.SpannableString;
|
|
|
+import android.text.Spanned;
|
|
|
+import android.text.style.AbsoluteSizeSpan;
|
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.ImageButton;
|
|
@@ -11,7 +14,7 @@ import com.sikey.skphone.R;
|
|
|
public class BaseInputActivity extends BaseActionActivity {
|
|
|
public String mInput = "";
|
|
|
private TextView mTextView = null;
|
|
|
- private int mInputMax = 32;
|
|
|
+ private final int INPUT_MAX = 32;
|
|
|
|
|
|
protected void onSureClick(String value) {};
|
|
|
|
|
@@ -25,7 +28,6 @@ public class BaseInputActivity extends BaseActionActivity {
|
|
|
|
|
|
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);
|
|
@@ -39,6 +41,7 @@ public class BaseInputActivity extends BaseActionActivity {
|
|
|
ImageButton buttonOK = findViewById(R.id.buttonOK);
|
|
|
ImageButton buttonBack = findViewById(R.id.buttonBack);
|
|
|
|
|
|
+ //短按
|
|
|
button1.setOnClickListener(mOnClickListener);
|
|
|
button2.setOnClickListener(mOnClickListener);
|
|
|
button3.setOnClickListener(mOnClickListener);
|
|
@@ -51,6 +54,24 @@ public class BaseInputActivity extends BaseActionActivity {
|
|
|
button0.setOnClickListener(mOnClickListener);
|
|
|
buttonOK.setOnClickListener(mOnClickListener);
|
|
|
buttonBack.setOnClickListener(mOnClickListener);
|
|
|
+
|
|
|
+ //长按
|
|
|
+ button7.setOnLongClickListener(mOnLongClickListener);
|
|
|
+ button9.setOnLongClickListener(mOnLongClickListener);
|
|
|
+ button0.setOnLongClickListener(mOnLongClickListener);
|
|
|
+ initButton(button7);
|
|
|
+ initButton(button9);
|
|
|
+ initButton(button0);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initButton(Button button) {
|
|
|
+ String text = button.getText().toString();
|
|
|
+ SpannableString spannableString = new SpannableString(text);
|
|
|
+ spannableString.setSpan(new AbsoluteSizeSpan(30), 0, 1,
|
|
|
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
+ spannableString.setSpan(new AbsoluteSizeSpan(20), 2, text.length(),
|
|
|
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
+ button.setText(spannableString);
|
|
|
}
|
|
|
|
|
|
View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
|
@@ -64,7 +85,7 @@ public class BaseInputActivity extends BaseActionActivity {
|
|
|
onSureClick(mInput);
|
|
|
}
|
|
|
} else {
|
|
|
- if (mInput.length() >= mInputMax)
|
|
|
+ if (mInput.length() >= INPUT_MAX)
|
|
|
return;
|
|
|
mInput += tag;
|
|
|
showInputCode();
|
|
@@ -72,6 +93,24 @@ public class BaseInputActivity extends BaseActionActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ View.OnLongClickListener mOnLongClickListener = new View.OnLongClickListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onLongClick(View v) {
|
|
|
+ if (mInput.length() >= INPUT_MAX)
|
|
|
+ return true;
|
|
|
+ int tag = Integer.parseInt((String) v.getTag());
|
|
|
+ if (tag == 7) {
|
|
|
+ mInput += "#";
|
|
|
+ } else if (tag == 9) {
|
|
|
+ mInput += "*";
|
|
|
+ } else if (tag == 0) {
|
|
|
+ mInput += "+";
|
|
|
+ }
|
|
|
+ showInputCode();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
private void showInputCode() {
|
|
|
mTextView.setText(mInput);
|
|
|
}
|