Fix the fix

This commit is contained in:
Privacy_Dragon 2023-01-19 20:13:24 +01:00
parent 4cfbee2524
commit 5c8b038a99
No known key found for this signature in database
13 changed files with 45 additions and 53 deletions

View File

@ -1,28 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_5_API_26.avd" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<targetSelectedWithDropDown> <targetSelectedWithDropDown>
<Target> <Target>
<type value="QUICK_BOOT_TARGET" /> <type value="QUICK_BOOT_TARGET" />
<deviceKey> <deviceKey>
<Key> <Key>
<type value="VIRTUAL_DEVICE_PATH" /> <type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.android/avd/Pixel_5_API_26.avd" /> <value value="$USER_HOME$/.android/avd/Pixel_2_API_24.avd" />
</Key> </Key>
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-01-18T19:46:02.696157Z" /> <timeTargetWasSelectedWithDropDown value="2023-01-19T17:01:06.009496Z" />
</component> </component>
</project> </project>

2
.idea/gradle.xml generated
View File

@ -7,13 +7,13 @@
<option name="testRunner" value="GRADLE" /> <option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="11" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" /> <option value="$PROJECT_DIR$/app" />
</set> </set>
</option> </option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings> </GradleProjectSettings>
</option> </option>
</component> </component>

2
.idea/misc.xml generated
View File

@ -11,7 +11,7 @@
</map> </map>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -8,9 +8,9 @@ android {
defaultConfig { defaultConfig {
applicationId "nl.privacydragon.bookwyrm" applicationId "nl.privacydragon.bookwyrm"
minSdk 23 minSdk 23
targetSdk 31 targetSdk 33
versionCode 10 versionCode 11
versionName "1.3.3" versionName "1.3.4"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
} }
@ -25,6 +25,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
namespace 'nl.privacydragon.bookwyrm'
} }
dependencies { dependencies {

Binary file not shown.

Binary file not shown.

View File

@ -11,8 +11,8 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 10, "versionCode": 11,
"versionName": "1.3.3", "versionName": "1.3.4",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }
], ],

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:tools="http://schemas.android.com/tools"
package="nl.privacydragon.bookwyrm">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />

View File

@ -256,7 +256,6 @@ public class HandlerActivity extends AppCompatActivity {
intentIntegrator.setPrompt("SCAN"); intentIntegrator.setPrompt("SCAN");
intentIntegrator.setBarcodeImageEnabled(false); intentIntegrator.setBarcodeImageEnabled(false);
intentIntegrator.initiateScan(); intentIntegrator.initiateScan();
//return "blup"; //return "blup";
//return "bla"; //return "bla";
} }
@ -269,8 +268,14 @@ public class HandlerActivity extends AppCompatActivity {
Toast.makeText(this, "cancelled", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "cancelled", Toast.LENGTH_SHORT).show();
} else { } else {
Log.d("MainActivity", "Scanned"); Log.d("MainActivity", "Scanned");
myWebView.loadUrl("Javascript:(function() {document.getElementById('tour-search').value = " + Result.getContents() + ";" + "document.getElementById('search_input').value = " + Result.getContents() + ";" + myWebView.loadUrl("Javascript:(function() {" +
"document.getElementsByTagName('form')[0].submit(); ;})()"); "try {" +
"document.getElementById('tour-search').value = " + Result.getContents() + ";" +
"} catch {" +
"document.getElementById('search_input').value = " + Result.getContents() + ";" +
"}" +
"document.getElementsByTagName('form')[0].submit();" +
";})()");
LoadIndicator.setVisibility(View.VISIBLE); LoadIndicator.setVisibility(View.VISIBLE);
} }

View File

@ -44,7 +44,7 @@ public class MainActivity extends AppCompatActivity {
SharedPreferences sharedPref = MainActivity.this.getSharedPreferences(getString(R.string.server), Context.MODE_PRIVATE); SharedPreferences sharedPref = MainActivity.this.getSharedPreferences(getString(R.string.server), Context.MODE_PRIVATE);
String defaultValue = "none"; String defaultValue = "none";
String server = sharedPref.getString(getString(R.string.server), defaultValue); String server = sharedPref.getString(getString(R.string.server), defaultValue);
if (server != "none") { if (!"none".equals(server)) {
startActivity(new Intent(MainActivity.this, nl.privacydragon.bookwyrm.StartActivity.class)); startActivity(new Intent(MainActivity.this, nl.privacydragon.bookwyrm.StartActivity.class));
} }
} }
@ -54,9 +54,10 @@ public class MainActivity extends AppCompatActivity {
String ALLOWED_CHARACTERS ="0123456789qwertyuiopasdfghjklzxcvbnm!@#$%^&*()_+=][{}"; String ALLOWED_CHARACTERS ="0123456789qwertyuiopasdfghjklzxcvbnm!@#$%^&*()_+=][{}";
final Random random=new Random(); final Random random=new Random();
final StringBuilder sb=new StringBuilder(12); final StringBuilder sb=new StringBuilder(12);
for(int i = 0; i< 12; ++i) for(int i = 0; i< 12; ++i) {
sb.append(ALLOWED_CHARACTERS.charAt(random.nextInt(ALLOWED_CHARACTERS.length()))); sb.append(ALLOWED_CHARACTERS.charAt(random.nextInt(ALLOWED_CHARACTERS.length())));
return sb.toString(); }
return sb.toString();
} }
public void LogIn(View view) throws IllegalBlockSizeException, BadPaddingException, KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, UnrecoverableKeyException, NoSuchPaddingException, InvalidKeyException { public void LogIn(View view) throws IllegalBlockSizeException, BadPaddingException, KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, UnrecoverableKeyException, NoSuchPaddingException, InvalidKeyException {
@ -81,7 +82,7 @@ public class MainActivity extends AppCompatActivity {
keyGenerator.init( keyGenerator.init(
new KeyGenParameterSpec.Builder("BookWyrm", new KeyGenParameterSpec.Builder("BookWyrm",
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT) KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_GCM) .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) .setBlockModes(KeyProperties.BLOCK_MODE_GCM).setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.setRandomizedEncryptionRequired(false) .setRandomizedEncryptionRequired(false)
.build()); .build());
keyGenerator.generateKey(); keyGenerator.generateKey();

View File

@ -88,48 +88,35 @@ public class StartActivity extends AppCompatActivity {
//Then, load it. or something. To make sure that it can be used. //Then, load it. or something. To make sure that it can be used.
try { try {
keyStore.load(null); keyStore.load(null);
} catch (CertificateException e) { } catch (CertificateException | IOException | NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace(); e.printStackTrace();
} }
//Next, retrieve the key to be used for the decryption. //Next, retrieve the key to be used for the decryption.
Key DragonLikeKey = null; Key DragonLikeKey = null;
try { try {
DragonLikeKey = keyStore.getKey("BookWyrm", null); DragonLikeKey = keyStore.getKey("BookWyrm", null);
} catch (KeyStoreException e) { } catch (KeyStoreException | NoSuchAlgorithmException | UnrecoverableKeyException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnrecoverableKeyException e) {
e.printStackTrace(); e.printStackTrace();
} }
//Do something with getting the/a cipher or something. //Do something with getting the/a cipher or something.
Cipher c = null; Cipher c = null;
try { try {
c = Cipher.getInstance("AES/GCM/NoPadding"); c = Cipher.getInstance("AES/GCM/NoPadding");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace(); e.printStackTrace();
} }
//And then initiating the cipher, so it can be used. //And then initiating the cipher, so it can be used.
try { try {
assert c != null;
c.init(Cipher.DECRYPT_MODE, DragonLikeKey, new GCMParameterSpec(128, codeMagic.getBytes())); c.init(Cipher.DECRYPT_MODE, DragonLikeKey, new GCMParameterSpec(128, codeMagic.getBytes()));
} catch (InvalidAlgorithmParameterException e) { } catch (InvalidAlgorithmParameterException | InvalidKeyException e) {
e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace(); e.printStackTrace();
} }
//Decrypt the password! //Decrypt the password!
byte[] truePass = null; byte[] truePass = null;
try { try {
truePass = c.doFinal(Base64.decode(pass, Base64.DEFAULT)); truePass = c.doFinal(Base64.decode(pass, Base64.DEFAULT));
} catch (BadPaddingException e) { } catch (BadPaddingException | IllegalBlockSizeException e) {
e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace(); e.printStackTrace();
} }
//Convert the decrypted password back to a string. //Convert the decrypted password back to a string.
@ -177,7 +164,7 @@ public class StartActivity extends AppCompatActivity {
} }
IntentIntegrator intentIntegrator = new IntentIntegrator(StartActivity.this); IntentIntegrator intentIntegrator = new IntentIntegrator(StartActivity.this);
intentIntegrator.setDesiredBarcodeFormats(intentIntegrator.EAN_13); intentIntegrator.setDesiredBarcodeFormats(IntentIntegrator.EAN_13);
intentIntegrator.setBeepEnabled(false); intentIntegrator.setBeepEnabled(false);
intentIntegrator.setCameraId(0); intentIntegrator.setCameraId(0);
intentIntegrator.setPrompt("SCAN ISBN"); intentIntegrator.setPrompt("SCAN ISBN");
@ -196,8 +183,14 @@ public class StartActivity extends AppCompatActivity {
Toast.makeText(this, "cancelled", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "cancelled", Toast.LENGTH_SHORT).show();
} else { } else {
Log.d("MainActivity", "Scanned"); Log.d("MainActivity", "Scanned");
myWebView.loadUrl("Javascript:(function() {document.getElementById('tour-search').value = " + Result.getContents() + ";" + "document.getElementById('search_input').value = " + Result.getContents() + ";" + myWebView.loadUrl("Javascript:(function() {" +
"document.getElementsByTagName('form')[0].submit(); ;})()"); "try {" +
"document.getElementById('tour-search').value = " + Result.getContents() + ";" +
"} catch {" +
"document.getElementById('search_input').value = " + Result.getContents() + ";" +
"}" +
"document.getElementsByTagName('form')[0].submit();" +
";})()");
LoadIndicator.setVisibility(View.VISIBLE); LoadIndicator.setVisibility(View.VISIBLE);
} }

View File

@ -0,0 +1,5 @@
The same as release 1.3.3, but not the one bug is actually fixed for real...
* Fixed a bug with the barcode scanning. Now you can scan barcodes again.
* Dependencies have been updated to newest versions.
* More Bookwyrm instances have been added.

View File

@ -1,6 +1,6 @@
#Mon Feb 14 18:09:26 CET 2022 #Mon Feb 14 18:09:26 CET 2022
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME