Skip to content

Commit 2a3e338

Browse files
committed
Use Google Java Style, reformat
1 parent 67736a4 commit 2a3e338

File tree

343 files changed

+31475
-31051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+31475
-31051
lines changed

android/src/androidTest/java/com/yubico/yubikit/android/ExampleInstrumentedTest.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@
1616

1717
package com.yubico.yubikit.android;
1818

19-
import android.content.Context;
19+
import static org.junit.Assert.assertEquals;
2020

21-
import androidx.test.platform.app.InstrumentationRegistry;
21+
import android.content.Context;
2222
import androidx.test.ext.junit.runners.AndroidJUnit4;
23-
23+
import androidx.test.platform.app.InstrumentationRegistry;
2424
import org.junit.Test;
2525
import org.junit.runner.RunWith;
2626

27-
import static org.junit.Assert.assertEquals;
28-
2927
/**
3028
* Instrumented test, which will execute on an Android device.
3129
*
3230
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
3331
*/
3432
@RunWith(AndroidJUnit4.class)
3533
public class ExampleInstrumentedTest {
36-
@Test
37-
public void useAppContext() {
38-
// Context of the app under test.
39-
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
40-
assertEquals("com.yubico.yubikit.android.test", appContext.getPackageName());
41-
}
42-
}
34+
@Test
35+
public void useAppContext() {
36+
// Context of the app under test.
37+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
38+
assertEquals("com.yubico.yubikit.android.test", appContext.getPackageName());
39+
}
40+
}

android/src/main/java/com/yubico/yubikit/android/YubiKitManager.java

+80-78
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import android.app.Activity;
2020
import android.content.Context;
21-
2221
import com.yubico.yubikit.android.transport.nfc.NfcConfiguration;
2322
import com.yubico.yubikit.android.transport.nfc.NfcNotAvailable;
2423
import com.yubico.yubikit.android.transport.nfc.NfcYubiKeyDevice;
@@ -27,96 +26,99 @@
2726
import com.yubico.yubikit.android.transport.usb.UsbYubiKeyDevice;
2827
import com.yubico.yubikit.android.transport.usb.UsbYubiKeyManager;
2928
import com.yubico.yubikit.core.util.Callback;
30-
3129
import javax.annotation.Nullable;
3230

3331
/**
34-
* Starting point for YubiKey device discovery over both USB and NFC.
35-
* Use this class to listen for YubiKeys and get a {@link com.yubico.yubikit.core.YubiKeyDevice} reference.
32+
* Starting point for YubiKey device discovery over both USB and NFC. Use this class to listen for
33+
* YubiKeys and get a {@link com.yubico.yubikit.core.YubiKeyDevice} reference.
3634
*/
3735
public final class YubiKitManager {
38-
private final UsbYubiKeyManager usbYubiKeyManager;
39-
@Nullable
40-
private final NfcYubiKeyManager nfcYubiKeyManager;
36+
private final UsbYubiKeyManager usbYubiKeyManager;
37+
@Nullable private final NfcYubiKeyManager nfcYubiKeyManager;
4138

42-
@Nullable
43-
private static NfcYubiKeyManager buildNfcDeviceManager(Context context) {
44-
try {
45-
return new NfcYubiKeyManager(context, null);
46-
} catch (NfcNotAvailable e) {
47-
return null;
48-
}
39+
@Nullable private static NfcYubiKeyManager buildNfcDeviceManager(Context context) {
40+
try {
41+
return new NfcYubiKeyManager(context, null);
42+
} catch (NfcNotAvailable e) {
43+
return null;
4944
}
45+
}
5046

51-
/**
52-
* Initialize instance of {@link YubiKitManager}
53-
*
54-
* @param context application context
55-
*/
56-
public YubiKitManager(Context context) {
57-
this(new UsbYubiKeyManager(context.getApplicationContext()), buildNfcDeviceManager(context.getApplicationContext()));
58-
}
47+
/**
48+
* Initialize instance of {@link YubiKitManager}
49+
*
50+
* @param context application context
51+
*/
52+
public YubiKitManager(Context context) {
53+
this(
54+
new UsbYubiKeyManager(context.getApplicationContext()),
55+
buildNfcDeviceManager(context.getApplicationContext()));
56+
}
5957

60-
/**
61-
* Initialize an instance of {@link YubiKitManager}, providing the USB and NFC YubiKey managers to use for device discovery.
62-
*
63-
* @param usbYubiKeyManager UsbYubiKeyManager instance to use for USB communication
64-
* @param nfcYubiKeyManager NfcYubiKeyManager instance to use for NFC communication
65-
*/
66-
public YubiKitManager(UsbYubiKeyManager usbYubiKeyManager, @Nullable NfcYubiKeyManager nfcYubiKeyManager) {
67-
this.usbYubiKeyManager = usbYubiKeyManager;
68-
this.nfcYubiKeyManager = nfcYubiKeyManager;
69-
}
58+
/**
59+
* Initialize an instance of {@link YubiKitManager}, providing the USB and NFC YubiKey managers to
60+
* use for device discovery.
61+
*
62+
* @param usbYubiKeyManager UsbYubiKeyManager instance to use for USB communication
63+
* @param nfcYubiKeyManager NfcYubiKeyManager instance to use for NFC communication
64+
*/
65+
public YubiKitManager(
66+
UsbYubiKeyManager usbYubiKeyManager, @Nullable NfcYubiKeyManager nfcYubiKeyManager) {
67+
this.usbYubiKeyManager = usbYubiKeyManager;
68+
this.nfcYubiKeyManager = nfcYubiKeyManager;
69+
}
7070

71+
/**
72+
* Subscribe on changes that happen via USB and detect if there any Yubikeys got connected
73+
*
74+
* <p>This registers broadcast receivers, to unsubscribe from receiver use {@link
75+
* YubiKitManager#stopUsbDiscovery()}
76+
*
77+
* @param usbConfiguration additional configurations on how USB discovery should be handled
78+
* @param listener listener that is going to be invoked upon successful discovery of key session
79+
* or failure to detect any session (lack of permissions)
80+
*/
81+
public void startUsbDiscovery(
82+
final UsbConfiguration usbConfiguration, Callback<? super UsbYubiKeyDevice> listener) {
83+
usbYubiKeyManager.enable(usbConfiguration, listener);
84+
}
7185

72-
/**
73-
* Subscribe on changes that happen via USB and detect if there any Yubikeys got connected
74-
* <p>
75-
* This registers broadcast receivers, to unsubscribe from receiver use {@link YubiKitManager#stopUsbDiscovery()}
76-
*
77-
* @param usbConfiguration additional configurations on how USB discovery should be handled
78-
* @param listener listener that is going to be invoked upon successful discovery of key session
79-
* or failure to detect any session (lack of permissions)
80-
*/
81-
public void startUsbDiscovery(final UsbConfiguration usbConfiguration, Callback<? super UsbYubiKeyDevice> listener) {
82-
usbYubiKeyManager.enable(usbConfiguration, listener);
86+
/**
87+
* Subscribe on changes that happen via NFC and detect if there any Yubikeys tags got passed
88+
*
89+
* <p>This registers broadcast receivers and blocks Ndef tags to be passed to activity, to
90+
* unsubscribe use {@link YubiKitManager#stopNfcDiscovery(Activity)}
91+
*
92+
* @param nfcConfiguration additional configurations on how NFC discovery should be handled
93+
* @param listener listener that is going to be invoked upon successful discovery of YubiKeys or
94+
* failure to detect any device (setting if off or no nfc adapter on device)
95+
* @param activity active (not finished) activity required for nfc foreground dispatch
96+
* @throws NfcNotAvailable in case if NFC not available on android device
97+
*/
98+
public void startNfcDiscovery(
99+
final NfcConfiguration nfcConfiguration,
100+
Activity activity,
101+
Callback<? super NfcYubiKeyDevice> listener)
102+
throws NfcNotAvailable {
103+
if (nfcYubiKeyManager == null) {
104+
throw new NfcNotAvailable("NFC is not available on this device", false);
83105
}
106+
nfcYubiKeyManager.enable(activity, nfcConfiguration, listener);
107+
}
84108

85-
/**
86-
* Subscribe on changes that happen via NFC and detect if there any Yubikeys tags got passed
87-
* <p>
88-
* This registers broadcast receivers and blocks Ndef tags to be passed to activity,
89-
* to unsubscribe use {@link YubiKitManager#stopNfcDiscovery(Activity)}
90-
*
91-
* @param nfcConfiguration additional configurations on how NFC discovery should be handled
92-
* @param listener listener that is going to be invoked upon successful discovery of YubiKeys
93-
* or failure to detect any device (setting if off or no nfc adapter on device)
94-
* @param activity active (not finished) activity required for nfc foreground dispatch
95-
* @throws NfcNotAvailable in case if NFC not available on android device
96-
*/
97-
public void startNfcDiscovery(final NfcConfiguration nfcConfiguration, Activity activity, Callback<? super NfcYubiKeyDevice> listener)
98-
throws NfcNotAvailable {
99-
if (nfcYubiKeyManager == null) {
100-
throw new NfcNotAvailable("NFC is not available on this device", false);
101-
}
102-
nfcYubiKeyManager.enable(activity, nfcConfiguration, listener);
103-
}
104-
105-
/**
106-
* Unsubscribe from changes that happen via USB
107-
*/
108-
public void stopUsbDiscovery() {
109-
usbYubiKeyManager.disable();
110-
}
109+
/** Unsubscribe from changes that happen via USB */
110+
public void stopUsbDiscovery() {
111+
usbYubiKeyManager.disable();
112+
}
111113

112-
/**
113-
* Unsubscribe from changes that happen via NFC
114-
*
115-
* @param activity active (not finished) activity required for nfc foreground dispatch
116-
*/
117-
public void stopNfcDiscovery(Activity activity) {
118-
if (nfcYubiKeyManager != null) {
119-
nfcYubiKeyManager.disable(activity);
120-
}
114+
/**
115+
* Unsubscribe from changes that happen via NFC
116+
*
117+
* @param activity active (not finished) activity required for nfc foreground dispatch
118+
*/
119+
public void stopNfcDiscovery(Activity activity) {
120+
if (nfcYubiKeyManager != null) {
121+
nfcYubiKeyManager.disable(activity);
121122
}
123+
}
122124
}

android/src/main/java/com/yubico/yubikit/android/internal/Base64CodecImpl.java

+19-20
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@
2020

2121
public class Base64CodecImpl implements com.yubico.yubikit.core.internal.codec.Base64Codec {
2222

23-
@Override
24-
public String toUrlSafeString(byte[] data) {
25-
return Base64.encodeToString(data, Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE);
26-
}
27-
28-
@Override
29-
public String toString(byte[] data) {
30-
return Base64.encodeToString(data, Base64.NO_WRAP | Base64.NO_PADDING);
31-
}
32-
33-
@Override
34-
public byte[] fromUrlSafeString(String data) {
35-
return Base64.decode(data, Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE);
36-
}
37-
38-
@Override
39-
public byte[] fromString(String data) {
40-
return Base64.decode(data, Base64.NO_WRAP | Base64.NO_PADDING);
41-
}
23+
@Override
24+
public String toUrlSafeString(byte[] data) {
25+
return Base64.encodeToString(data, Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE);
26+
}
27+
28+
@Override
29+
public String toString(byte[] data) {
30+
return Base64.encodeToString(data, Base64.NO_WRAP | Base64.NO_PADDING);
31+
}
32+
33+
@Override
34+
public byte[] fromUrlSafeString(String data) {
35+
return Base64.decode(data, Base64.NO_WRAP | Base64.NO_PADDING | Base64.URL_SAFE);
36+
}
37+
38+
@Override
39+
public byte[] fromString(String data) {
40+
return Base64.decode(data, Base64.NO_WRAP | Base64.NO_PADDING);
41+
}
4242
}
43-

android/src/main/java/com/yubico/yubikit/android/internal/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
@PackageNonnullByDefault
1818
package com.yubico.yubikit.android.internal;
1919

20-
import com.yubico.yubikit.core.PackageNonnullByDefault;
20+
import com.yubico.yubikit.core.PackageNonnullByDefault;

android/src/main/java/com/yubico/yubikit/android/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
@PackageNonnullByDefault
1717
package com.yubico.yubikit.android;
1818

19-
import com.yubico.yubikit.core.PackageNonnullByDefault;
19+
import com.yubico.yubikit.core.PackageNonnullByDefault;

0 commit comments

Comments
 (0)