Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Added additional label to settings for current counter HOTP
Browse files Browse the repository at this point in the history
  • Loading branch information
julianschmuckli committed Aug 9, 2018
1 parent 5034687 commit 09a0992
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation "com.google.guava:guava:16+"
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'
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/coderbunker/kioskapp/KioskActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ protected void onCreate(Bundle savedInstanceState) {
webView = findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
public void onPageFinished(final WebView view, String url) {
super.onPageFinished(view, url);
TimerTask lock = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(context, "Kioskmode locked", Toast.LENGTH_SHORT).show();
}
});
locked = true;
}
};
Expand Down Expand Up @@ -136,7 +141,6 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
});

numbers = new ArrayList<Button>();

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class SettingsActivity extends Activity {
private Context context = this;
private EditText editURL;
private ImageView imgQRCode, imgQRCodeHOTP;
private TextView lblCurrentHOTPCycle;
private Button btnSave;

private SharedPreferences prefs;
Expand All @@ -51,7 +52,7 @@ protected void onCreate(Bundle savedInstanceState) {
imgQRCodeHOTP = findViewById(R.id.imgQRCodeHOTP);
editURL = findViewById(R.id.editText_URL);
btnSave = findViewById(R.id.btnSave);

lblCurrentHOTPCycle = findViewById(R.id.current_hotp_cycle);

btnSave.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -75,6 +76,8 @@ public void onClick(View v) {

editURL.setText(url);

lblCurrentHOTPCycle.setText("Current counter cycle: " + hotp_counter);

if (otp == null) {

byte key_1 = (byte) Math.floor(Math.random() * 10);
Expand All @@ -95,7 +98,7 @@ public void onClick(View v) {
}

otp_uri = "otpauth://totp/Time%20based?secret=" + otp + "&issuer=Kiosk%20Coderbunker";
hotp_uri = "otpauth://hotp/Hash%20based?secret=" + otp + "&issuer=Kiosk%20Coderbunker&counter=" + hotp_counter + "&algorithm=SHA1";
hotp_uri = "otpauth://hotp/Hash%20based?secret=" + otp + "&issuer=Kiosk%20Coderbunker&counter=" + (hotp_counter - 1) + "&algorithm=SHA1";

generateQRCodeTOTP(otp_uri);
generateQRCodeHOTP(hotp_uri);
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher_background" />

<TextView
android:id="@+id/placeholder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textAlignment="center" />

</LinearLayout>

<LinearLayout
Expand All @@ -72,6 +80,15 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/ic_launcher_background" />

<TextView
android:id="@+id/current_hotp_cycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Current cycle: ---"
android:textAlignment="center" />

</LinearLayout>

</LinearLayout>
Expand Down

0 comments on commit 09a0992

Please sign in to comment.