Skip to content

Commit

Permalink
--Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
neri4488 committed Aug 17, 2018
1 parent 3e0f672 commit 0697e7f
Show file tree
Hide file tree
Showing 43 changed files with 1,332 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
29 changes: 29 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.hamsoftug.numerickeyboard;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.hamsoftug.numerickeyboard", appContext.getPackageName());
}
}
13 changes: 13 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hamsoftug.numerickeyboard">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"/>

</manifest>
191 changes: 191 additions & 0 deletions app/src/main/java/com/hamsoftug/numerickeyboard/Nk_board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
package com.hamsoftug.numerickeyboard;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


/**
* A simple {@link Fragment} subclass.
*/
public class Nk_board extends Fragment {

private static final int DELAY = 500;

private TextView pass1;
private TextView pass2;
private TextView pass3;
private TextView pass4;

private int length = 0;

public interface OnKeyBoard {
void onPasscodeEntered(String pass);
void onOnDeletePressed();
void onKeyPressed(int value);
}

private OnKeyBoard listener;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.fragment_nk_board, container, false);

pass1 = rootView.findViewById(R.id.passcode1);
pass2 = rootView.findViewById(R.id.passcode2);
pass3 = rootView.findViewById(R.id.passcode3);
pass4 = rootView.findViewById(R.id.passcode4);

rootView.findViewById(R.id.one_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("1");
}
});
rootView.findViewById(R.id.two_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("2");
}
});
rootView.findViewById(R.id.three_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("3");
}
});
rootView.findViewById(R.id.four_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("4");
}
});
rootView.findViewById(R.id.five_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("5");
}
});
rootView.findViewById(R.id.six_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("6");
}
});
rootView.findViewById(R.id.seven_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("7");
}
});
rootView.findViewById(R.id.eight_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("8");
}
});
rootView.findViewById(R.id.nine_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("9");
}
});
rootView.findViewById(R.id.zero_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add("0");
}
});
rootView.findViewById(R.id.delete_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (length) {
case 1:
pass1.setText(null);
length--;
break;
case 2:
pass2.setText(null);
length--;
break;
case 3:
pass3.setText(null);
length--;
break;
case 4:
pass4.setText(null);
length--;
}
listener.onOnDeletePressed();
}
});

return rootView;
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
listener = (OnKeyBoard) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement "
+ OnKeyBoard.class);
}
}

@Override
public void onAttach(Context context) {
super.onAttach(context);

try {
listener = (OnKeyBoard) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString() + " must implement "
+ OnKeyBoard.class);
}

}

private void add(String num) {
listener.onKeyPressed(Integer.parseInt(num));
switch (length + 1) {
case 1:
pass1.setText(num);
length++;
break;
case 2:
pass2.setText(num);
length++;
break;
case 3:
pass3.setText(num);
length++;
break;
case 4:
pass4.setText(num);
length++;

new Handler().postDelayed(new Runnable() {
public void run() {
listener.onPasscodeEntered(pass1.getText().toString() + pass2.getText()
+ pass3.getText() + pass4.getText());
pass1.setText(null);
pass2.setText(null);
pass3.setText(null);
pass4.setText(null);
length = 0;
}
}, DELAY);
}
}

}
Loading

0 comments on commit 0697e7f

Please sign in to comment.