Skip to content

Commit

Permalink
Little code cleanup done. Ready for next release
Browse files Browse the repository at this point in the history
  • Loading branch information
krishanudey committed Jan 18, 2017
1 parent 0287efb commit ec26158
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 50 deletions.
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.goodiebag.pinview.example"
minSdkVersion 21
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,5 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.activity_main);
pinview1 = (Pinview) findViewById(R.id.pinview1);
pinview2 = (Pinview) findViewById(R.id.pinview2);
pinview3 = (Pinview) findViewById(R.id.pinview3);
pinview4 = (Pinview) findViewById(R.id.pinview4);
b = (Button) findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// int random = ThreadLocalRandom.current().nextInt(50, 60);
// random*=getResources().getDisplayMetrics().density;
// Log.d("random", "" + random);
// pinview1.setPinWidth(random);
// pinview2.setPinWidth(random);
// pinview3.setPinWidth(random);
// pinview4.setPinWidth(random);

pinview1.setPinBackgroundRes(R.drawable.sample_background);
pinview1.setInputType(Pinview.InputType.TEXT);
pinview2.setPassword(!pinview2.isPassword());
pinview3.setPassword(!pinview3.isPassword());
pinview4.setPassword(!pinview4.isPassword());
}
});
}
}
31 changes: 18 additions & 13 deletions example/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<Button
android:id="@+id/btn"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="set"/>

android:text="Number"/>
<com.goodiebag.pinview.Pinview
android:id="@+id/pinview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CCC"
app:cursorVisible="false"
app:hint="0"
app:inputType="number"
Expand All @@ -31,12 +28,14 @@
app:pinLength="4"
app:pinWidth="40dp" />


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text"/>
<com.goodiebag.pinview.Pinview
android:id="@+id/pinview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CCC"
app:cursorVisible="false"
app:hint="0"
app:inputType="text"
Expand All @@ -46,29 +45,35 @@
app:pinLength="4"
app:pinWidth="40dp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number-Password"/>
<com.goodiebag.pinview.Pinview
android:id="@+id/pinview3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CCC"
app:cursorVisible="false"
app:hint="0"
app:inputType="text"
app:password="false"
app:inputType="number"
app:password="true"
app:pinBackground="@drawable/example_drawable"
app:pinHeight="40dp"
app:pinLength="4"
app:pinWidth="40dp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text-Password"/>
<com.goodiebag.pinview.Pinview
android:id="@+id/pinview4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CCC"
app:cursorVisible="false"
app:hint="0"
app:inputType="number"
app:password="false"
app:inputType="text"
app:password="true"
app:pinBackground="@drawable/example_drawable"
app:pinHeight="40dp"
app:pinLength="4"
Expand Down
19 changes: 7 additions & 12 deletions pinview/src/main/java/com/goodiebag/pinview/Pinview.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ public Pinview(Context context, AttributeSet attrs) {
public Pinview(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setGravity(Gravity.CENTER);
//init fields and attributes
init(context, attrs, defStyleAttr);
//style and draw it
//styleEditText();
}

private void init(Context context, AttributeSet attrs, int defStyleAttr) {
Expand Down Expand Up @@ -131,7 +128,6 @@ private void createEditTexts() {
private void initAttributes(Context context, AttributeSet attrs, int defStyleAttr) {
if (attrs != null) {
final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.Pinview, defStyleAttr, 0);
//array.
mPinBackground = array.getResourceId(R.styleable.Pinview_pinBackground, mPinBackground);
mPinLength = array.getInt(R.styleable.Pinview_pinLength, mPinLength);
mPinHeight = (int) array.getDimension(R.styleable.Pinview_pinHeight, mPinHeight);
Expand Down Expand Up @@ -182,18 +178,17 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
default:
it = TYPE_CLASS_TEXT;
}
if (mPassword) {
if (inputType == InputType.NUMBER) {
it = TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD;
} else if (inputType == InputType.TEXT) {
it = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD;
}
}
// if (mPassword) {
// if (inputType == InputType.NUMBER) {
// it = TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD;
// } else if (inputType == InputType.TEXT) {
// it = TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD;
// }
// }
styleEditText.setInputType(it);
styleEditText.addTextChangedListener(this);
styleEditText.setOnFocusChangeListener(this);
styleEditText.setOnKeyListener(this);
//this.addView(styleEditText);
}

public String getValue() {
Expand Down

0 comments on commit ec26158

Please sign in to comment.