Update OTP parser defaults, Fix some bugs
This commit is contained in:
parent
00d460be14
commit
76e12e8f6f
@ -338,9 +338,11 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
// OTPDatabase.unloadDatabase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ import androidx.camera.core.SurfaceOrientedMeteringPointFactory;
|
||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.cringe_studios.cringe_authenticator.BaseActivity;
|
||||
import com.cringe_studios.cringe_authenticator.R;
|
||||
import com.cringe_studios.cringe_authenticator.databinding.ActivityQrScannerBinding;
|
||||
import com.cringe_studios.cringe_authenticator.model.OTPData;
|
||||
@ -42,7 +43,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class QRScannerActivity extends AppCompatActivity {
|
||||
public class QRScannerActivity extends BaseActivity {
|
||||
|
||||
public static final int RESULT_ERROR = -2;
|
||||
|
||||
@ -63,7 +64,7 @@ public class QRScannerActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(new String[] {Manifest.permission.CAMERA}, 1234);
|
||||
requestPermissions(new String[] {Manifest.permission.CAMERA}, 1234); // TODO: handle denied
|
||||
}
|
||||
|
||||
binding = ActivityQrScannerBinding.inflate(getLayoutInflater());
|
||||
|
@ -71,10 +71,6 @@ public class OTPDatabase {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(ctx instanceof BaseActivity)) {
|
||||
throw new RuntimeException("NOT BASEACTIVITY");
|
||||
}
|
||||
|
||||
if(!SettingsUtil.isDatabaseEncrypted(ctx)) {
|
||||
try {
|
||||
loadDatabase(ctx, null);
|
||||
@ -85,17 +81,6 @@ public class OTPDatabase {
|
||||
return;
|
||||
}
|
||||
|
||||
/*DialogUtil.showInputPasswordDialog(ctx, password -> {
|
||||
try {
|
||||
SecretKey key = Crypto.generateKey(SettingsUtil.getCryptoParameters(ctx), password);
|
||||
loadDatabase(ctx, key);
|
||||
if (success != null) success.run();
|
||||
}catch(CryptoException e) {
|
||||
DialogUtil.showErrorDialog(ctx, "Failed to load database: Invalid password or database corrupted", failure);
|
||||
} catch (OTPDatabaseException e) {
|
||||
DialogUtil.showErrorDialog(ctx, "Failed to load database: " + e, failure);
|
||||
}
|
||||
}, failure);*/
|
||||
((BaseActivity) ctx).promptUnlock(success, failure);
|
||||
}
|
||||
|
||||
|
@ -172,10 +172,9 @@ public class OTPParser {
|
||||
}
|
||||
|
||||
try {
|
||||
// 0 or null for defaults (handled by Cringe-Authenticator-Library)
|
||||
OTPAlgorithm fAlgorithm = algorithm == null ? null : OTPAlgorithm.valueOf(algorithm.toUpperCase());
|
||||
int fDigits = digits == null ? 0 : Integer.parseInt(digits);
|
||||
int fPeriod = period == null ? 0 : Integer.parseInt(period);
|
||||
OTPAlgorithm fAlgorithm = algorithm == null ? OTPAlgorithm.SHA1 : OTPAlgorithm.valueOf(algorithm.toUpperCase());
|
||||
int fDigits = digits == null ? 6 : Integer.parseInt(digits);
|
||||
int fPeriod = period == null ? 30 : Integer.parseInt(period);
|
||||
int fCounter = counter == null ? 0 : Integer.parseInt(counter);
|
||||
boolean fChecksum = false;
|
||||
if(checksum != null) {
|
||||
|
@ -2,7 +2,8 @@
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
android:viewportHeight="960"
|
||||
android:tint="?android:attr/textColor">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M80,402v-40q0,-109 105,-175.5T480,120q190,0 295,66.5T880,362v40L80,402ZM142,342h676q-3,-69 -96.5,-115.5T480,180q-148,0 -242.5,46.5T142,342ZM80,578v-60q33,0 57.5,-22t78.5,-22q54,0 71.5,22t58.5,22q41,0 60.5,-22t73.5,-22q54,0 73.5,22t60.5,22q41,0 58.5,-22t71.5,-22q54,0 78.5,22t57.5,22v60q-54,0 -74.5,-22T744,534q-41,0 -58.5,22T614,578q-54,0 -73.5,-22T480,534q-41,0 -60.5,22T346,578q-54,0 -71.5,-22T216,534q-41,0 -61.36,22T80,578ZM140,840q-24,0 -42,-18t-18,-42v-128h800v128q0,24 -18,42t-42,18L140,840ZM140,780h680v-68L140,712v68ZM140,712h680,-680ZM142,342h676,-676Z"/>
|
||||
|
Loading…
Reference in New Issue
Block a user