diff --git a/.idea/gradle.xml b/.idea/gradle.xml index f241d8a..0e3823e 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -4,7 +4,7 @@ diff --git a/.idea/libraries/Gradle__androidx_activity_activity_1_2_4_aar.xml b/.idea/libraries/Gradle__androidx_activity_activity_1_2_4_aar.xml index ba71638..485c449 100644 --- a/.idea/libraries/Gradle__androidx_activity_activity_1_2_4_aar.xml +++ b/.idea/libraries/Gradle__androidx_activity_activity_1_2_4_aar.xml @@ -1,13 +1,12 @@ - + + - - - + diff --git a/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_1_0_aar.xml index fe840dd..2bbd97e 100644 --- a/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_1_0_aar.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_4_0_aar.xml b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_4_0_aar.xml index aff7092..c7ffd13 100644 --- a/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_4_0_aar.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/.idea/libraries/Gradle__androidx_core_core_ktx_1_7_0_aar.xml b/.idea/libraries/Gradle__androidx_core_core_ktx_1_7_0_aar.xml index 5abebd6..6d67ad9 100644 --- a/.idea/libraries/Gradle__androidx_core_core_ktx_1_7_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_core_core_ktx_1_7_0_aar.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml index 3a25157..2ce7f6b 100644 --- a/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml +++ b/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml @@ -1,10 +1,9 @@ + - - - + diff --git a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml index 68872b2..380e571 100644 --- a/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml index 2c236a3..06b15f0 100644 --- a/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_core_1_4_0_aar.xml @@ -1,10 +1,9 @@ + - - - + diff --git a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml index 320952e..ff05e6b 100644 --- a/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_3_aar.xml @@ -1,10 +1,9 @@ + - - - + diff --git a/.idea/libraries/Gradle__androidx_test_services_storage_1_4_0_aar.xml b/.idea/libraries/Gradle__androidx_test_services_storage_1_4_0_aar.xml index b7a43e8..dcedcc5 100644 --- a/.idea/libraries/Gradle__androidx_test_services_storage_1_4_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_test_services_storage_1_4_0_aar.xml @@ -1,10 +1,9 @@ + - - - + diff --git a/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml b/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml index f027b26..1c3ed84 100644 --- a/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml +++ b/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml @@ -1,12 +1,12 @@ - + - - - + + + diff --git a/.idea/libraries/Gradle__com_karumi_dexter_5_0_0_aar.xml b/.idea/libraries/Gradle__com_karumi_dexter_5_0_0_aar.xml index 3bb383e..82cf732 100644 --- a/.idea/libraries/Gradle__com_karumi_dexter_5_0_0_aar.xml +++ b/.idea/libraries/Gradle__com_karumi_dexter_5_0_0_aar.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/.idea/libraries/Gradle__junit_junit_4_12.xml b/.idea/libraries/Gradle__junit_junit_4_12.xml index f7d27c4..6c078d6 100644 --- a/.idea/libraries/Gradle__junit_junit_4_12.xml +++ b/.idea/libraries/Gradle__junit_junit_4_12.xml @@ -1,8 +1,5 @@ - - - diff --git a/.idea/libraries/Gradle__junit_junit_4_13_2.xml b/.idea/libraries/Gradle__junit_junit_4_13_2.xml index 198592d..c2cb45d 100644 --- a/.idea/libraries/Gradle__junit_junit_4_13_2.xml +++ b/.idea/libraries/Gradle__junit_junit_4_13_2.xml @@ -1,8 +1,5 @@ - - - diff --git a/.idea/misc.xml b/.idea/misc.xml index d7b993d..6199cc2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,13 +1,5 @@ - - - diff --git a/.idea/modules.xml b/.idea/modules.xml index 5d81d38..5b746e4 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,9 +4,6 @@ - - - \ No newline at end of file diff --git a/.idea/modules/Crypto.iml b/.idea/modules/Crypto.iml index 29bf448..bc65fa8 100644 --- a/.idea/modules/Crypto.iml +++ b/.idea/modules/Crypto.iml @@ -3,6 +3,7 @@ + diff --git a/.idea/modules/app/Crypto.app.androidTest.iml b/.idea/modules/app/Crypto.app.androidTest.iml deleted file mode 100644 index 259817f..0000000 --- a/.idea/modules/app/Crypto.app.androidTest.iml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/app/Crypto.app.iml b/.idea/modules/app/Crypto.app.iml index da9c79e..b79d199 100644 --- a/.idea/modules/app/Crypto.app.iml +++ b/.idea/modules/app/Crypto.app.iml @@ -55,10 +55,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/app/Crypto.app.main.iml b/.idea/modules/app/Crypto.app.main.iml deleted file mode 100644 index aa3be1b..0000000 --- a/.idea/modules/app/Crypto.app.main.iml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/app/Crypto.app.unitTest.iml b/.idea/modules/app/Crypto.app.unitTest.iml deleted file mode 100644 index 80e502e..0000000 --- a/.idea/modules/app/Crypto.app.unitTest.iml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3480008 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# crypto \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index dacbae8..7dca4f3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,16 +1,16 @@ plugins { id 'com.android.application' id 'kotlin-android' - id 'com.google.gms.google-services' } android { - compileSdk 30 + compileSdkVersion 32 + buildToolsVersion "32.0.0" defaultConfig { - applicationId "com.febrian.qrbarcodescanner" - minSdk 21 - targetSdk 30 + applicationId "com.example.crypto" + minSdkVersion 21 + targetSdkVersion 32 versionCode 1 versionName "1.0" @@ -23,11 +23,6 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } - - buildFeatures{ - viewBinding true - } - compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -39,16 +34,15 @@ android { dependencies { - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'androidx.core:core-ktx:1.7.0' + implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' - implementation 'com.google.firebase:firebase-ml-vision:24.0.1' + implementation 'androidx.security:security-crypto:1.1.0-alpha02' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - implementation 'me.dm7.barcodescanner:zxing:1.9.8' - implementation 'com.squareup.retrofit2:retrofit:2.3.0' - implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + implementation 'com.karumi:dexter:5.0.0' } \ No newline at end of file diff --git a/app/google-services.json b/app/google-services.json deleted file mode 100644 index e835186..0000000 --- a/app/google-services.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "project_info": { - "project_number": "887834380688", - "project_id": "textreaderandroid", - "storage_bucket": "textreaderandroid.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:887834380688:android:e1b6144472c748888dcb15", - "android_client_info": { - "package_name": "com.febrian.qrbarcodescanner" - } - }, - "oauth_client": [ - { - "client_id": "887834380688-aign70ghmmp2otls3rjc24hkrjfnmrl3.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyAGc5eXg4igTb4YoaiAasx7Yq_T_tnnlAw" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "887834380688-aign70ghmmp2otls3rjc24hkrjfnmrl3.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/app/src/androidTest/java/com/febrian/qrbarcodescanner/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/crypto/ExampleInstrumentedTest.kt similarity index 83% rename from app/src/androidTest/java/com/febrian/qrbarcodescanner/ExampleInstrumentedTest.kt rename to app/src/androidTest/java/com/example/crypto/ExampleInstrumentedTest.kt index 877d4a8..7e031e1 100644 --- a/app/src/androidTest/java/com/febrian/qrbarcodescanner/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/example/crypto/ExampleInstrumentedTest.kt @@ -1,4 +1,4 @@ -package com.febrian.qrbarcodescanner +package com.example.crypto import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 @@ -19,6 +19,6 @@ class ExampleInstrumentedTest { fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.febrian.qrbarcodescanner", appContext.packageName) + assertEquals("com.example.crypto", appContext.packageName) } } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d68b837..5332869 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,26 +1,33 @@ + package="com.example.crypto"> - - + + - + android:theme="@style/Theme.Crypto"> + + + + + + + - + android:name=".AboutUs" + android:parentActivityName=".SelectPath"> + + + diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..d8d348a Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/example/crypto/AboutUs.kt b/app/src/main/java/com/example/crypto/AboutUs.kt new file mode 100644 index 0000000..e3f864a --- /dev/null +++ b/app/src/main/java/com/example/crypto/AboutUs.kt @@ -0,0 +1,26 @@ +package com.example.crypto + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import com.google.android.material.button.MaterialButton + +class AboutUs : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContentView(R.layout.activity_about_us) + +// val btnBack = findViewById(R.id.btnback) +// +// // go back +// +// btnBack.setOnClickListener { +// var Intent = Intent(this, SelectPath::class.java) +// startActivity(Intent) +// } + + + } +} + diff --git a/app/src/main/java/com/example/crypto/ContactUs.kt b/app/src/main/java/com/example/crypto/ContactUs.kt new file mode 100644 index 0000000..4407f85 --- /dev/null +++ b/app/src/main/java/com/example/crypto/ContactUs.kt @@ -0,0 +1,33 @@ +package com.example.crypto + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.TextView +import android.widget.Toast +import com.google.android.material.button.MaterialButton + +class ContactUs : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_contact_us) + + val firstName = findViewById(R.id.firstName) + val lastName = findViewById(R.id.lastName) + val email = findViewById(R.id.email) + val message = findViewById(R.id.message) + + + val btnSubmit = findViewById(R.id.btnSubmit) + + btnSubmit.setOnClickListener { + if (firstName.text.toString().isEmpty() || lastName.text.toString() + .isEmpty() || email.text.toString().isEmpty() || message.text.toString().isEmpty() + ) { + Toast.makeText(this, "Please fill all the fields!", Toast.LENGTH_SHORT).show() + } else { + Toast.makeText(this, "Your message received!", Toast.LENGTH_SHORT).show() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/DecryptText.java b/app/src/main/java/com/example/crypto/DecryptText.java new file mode 100644 index 0000000..15226ab --- /dev/null +++ b/app/src/main/java/com/example/crypto/DecryptText.java @@ -0,0 +1,91 @@ +package com.example.crypto; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.os.Bundle; +import android.util.Base64; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.google.android.material.button.MaterialButton; + +import java.security.MessageDigest; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +public class DecryptText extends AppCompatActivity { + + EditText inputPassword, inputText; + TextView outputText; + Button decryptBtn, copyBtn; + String outputString; + String AES = "AES"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_decrypt_text); + + inputText = (EditText) findViewById(R.id.txtPlain); + inputPassword = (EditText) findViewById(R.id.txtKey); + outputText = (TextView) findViewById(R.id.txtOuptput); + + decryptBtn = (MaterialButton) findViewById(R.id.btnDecrypt); + copyBtn = (MaterialButton) findViewById(R.id.btnCopy); + + decryptBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + try { + outputString = decrypt(inputText.getText().toString(), inputPassword.getText().toString()); + } catch (Exception e) { + Toast.makeText(DecryptText.this, "Wrong Key!", Toast.LENGTH_SHORT).show(); + e.printStackTrace(); + } + outputText.setText(outputString); + } + }); + + copyBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("EncryptedText", outputText.getText().toString()); + clipboard.setPrimaryClip(clip); + + Toast.makeText(DecryptText.this, "Copied to clipboard", Toast.LENGTH_SHORT).show(); + + } + }); + + + } + + private String decrypt(String Data, String password) throws Exception { + SecretKeySpec key = generateKey(password); + Cipher c = Cipher.getInstance(AES); + c.init(Cipher.DECRYPT_MODE, key); + byte[] decodedValue = Base64.decode(Data, Base64.DEFAULT); + byte[] decValue = c.doFinal(decodedValue); + String decryptedValue = new String(decValue); + return decryptedValue; + + } + + private SecretKeySpec generateKey(String password) throws Exception { + final MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] bytes = password.getBytes("UTF-8"); + digest.update(bytes, 0, bytes.length); + byte[] key = digest.digest(); + SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); + return secretKeySpec; + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/EncryptFiles2.java b/app/src/main/java/com/example/crypto/EncryptFiles2.java new file mode 100644 index 0000000..25e2fde --- /dev/null +++ b/app/src/main/java/com/example/crypto/EncryptFiles2.java @@ -0,0 +1,240 @@ +package com.example.crypto; + +import androidx.activity.result.ActivityResult; +import androidx.activity.result.ActivityResultCallback; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContract; +import androidx.activity.result.contract.ActivityResultContracts; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; +import androidx.security.crypto.EncryptedFile; +import androidx.security.crypto.MasterKeys; + +import android.Manifest; +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; +import android.provider.OpenableColumns; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.Toast; + +import com.example.crypto.Utils.Encrypter; +import com.google.android.material.button.MaterialButton; +import com.karumi.dexter.Dexter; +import com.karumi.dexter.MultiplePermissionsReport; +import com.karumi.dexter.PermissionToken; +import com.karumi.dexter.listener.PermissionRequest; +import com.karumi.dexter.listener.multi.MultiplePermissionsListener; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.List; + +import javax.crypto.NoSuchPaddingException; + +public class EncryptFiles2 extends AppCompatActivity { + + private static final String FILE_NAME_ENC = "download"; + private static final String FILE_NAME_DEC = "download.png"; + Button btn_enc, btn_dec, btn_browse; + ImageView imageView; + EditText filePath; + File myDir; + File newFile; + + String my_key = "mDxGC8Q4EDDGdcOV"; + String my_spec_key = "clq0LefoQvApP5M2"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_encrypt_files2); + + + btn_dec = (MaterialButton) findViewById(R.id.btn_decrypt); + btn_enc = (MaterialButton) findViewById(R.id.btn_encrypt); + btn_browse = (MaterialButton) findViewById(R.id.btnbrowse); + filePath = (EditText) findViewById(R.id.txtFilePath); + + myDir = new File(Environment.getExternalStorageDirectory().toString() + "/saved_images"); + + + Dexter.withActivity(this) + .withPermissions(new String[]{ + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE + }) + .withListener(new MultiplePermissionsListener() { + @Override + public void onPermissionsChecked(MultiplePermissionsReport multiplePermissionsReport) { + btn_dec.setEnabled(true); + btn_enc.setEnabled(true); + } + + @Override + public void onPermissionRationaleShouldBeShown(List list, PermissionToken permissionToken) { + Toast.makeText(EncryptFiles2.this, "You must enable permission", Toast.LENGTH_SHORT).show(); + + } + }).check(); + + btn_dec.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + File outputFileDec = new File(myDir, FILE_NAME_DEC); + File encFile = new File(myDir, FILE_NAME_ENC); + try { + Encrypter.decryptToFile(my_key, my_spec_key, new FileInputStream(encFile), new FileOutputStream(outputFileDec)); + + imageView.setImageURI(Uri.fromFile(outputFileDec)); + + // delete file after decrypt + + outputFileDec.delete(); + Toast.makeText(EncryptFiles2.this, "Decrypted!", Toast.LENGTH_SHORT).show(); + + } catch (IOException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { + e.printStackTrace(); + } catch (InvalidAlgorithmParameterException e) { + e.printStackTrace(); + } catch (NoSuchPaddingException e) { + e.printStackTrace(); + } + } + }); + + btn_enc.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + + Context context = EncryptFiles2.this; + + + EncryptedFile encryptedFile = null; + try { + encryptedFile = new EncryptedFile.Builder( + newFile, + context, + my_spec_key, + EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB + ).build(); +// Toast.makeText(EncryptFiles2.this, newFile.getPath() , Toast.LENGTH_SHORT).show(); + System.out.println(newFile.getPath()); + +// Toast.makeText(EncryptFiles2.this, encryptedFile.toString() , Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + e.printStackTrace(); + } + + // write to the encrypted file + try { + FileOutputStream encryptedOutputStream = encryptedFile.openFileOutput(); + Toast.makeText(EncryptFiles2.this, "two", Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + e.printStackTrace(); + } + + // read the encrypted file + try { + FileInputStream encryptedInputStream = encryptedFile.openFileInput(); + Toast.makeText(EncryptFiles2.this, "three", Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + }); + } + + // file picker + + ActivityResultLauncher activityResultLauncher = registerForActivityResult( + new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + if (result.getResultCode() == Activity.RESULT_OK) { + Intent data = result.getData(); + Uri uri = data.getData(); + newFile = new File(uri.getPath()); +// Toast.makeText(this, filePath, Toast.LENGTH_LONG).show(); + Toast.makeText(EncryptFiles2.this, newFile.getPath(), Toast.LENGTH_LONG).show(); + filePath.setText(getFileName(uri, getApplicationContext())); + } + } + } + ); + + public void openFileDialog(View view) { + Intent data = new Intent(Intent.ACTION_OPEN_DOCUMENT); + data.setType("*/*"); + data = Intent.createChooser(data, "Choose a file"); + activityResultLauncher.launch(data); + + } + + String getFileName(Uri uri, Context context) { + String res = null; + if(uri.getScheme().equals("content")){ + Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); + try { + if(cursor != null && cursor.moveToFirst()) { + res = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + + } + } finally { + cursor.close(); + } + if (res == null) { + res = uri.getPath(); + int cutt = res.lastIndexOf('/'); + if(cutt != -1) { + res = res.substring(cutt +1); + } + } + } + + return res; + } + + +// private String getRealPathFromURI(Uri contentURI) { +// String result; +// Cursor cursor = getContentResolver().query(contentURI, null, null, null, null); +// if (cursor == null) { // Source is Dropbox or other similar local file path +// result = contentURI.getPath(); +// } else { +// cursor.moveToFirst(); +// int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); +// result = cursor.getString(idx); +// cursor.close(); +// } +// return result; +// } + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/EncryptText.java b/app/src/main/java/com/example/crypto/EncryptText.java new file mode 100644 index 0000000..f0241d4 --- /dev/null +++ b/app/src/main/java/com/example/crypto/EncryptText.java @@ -0,0 +1,100 @@ +package com.example.crypto; + +import androidx.appcompat.app.AppCompatActivity; + +import android.content.ClipData; +import android.content.ClipboardManager; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Base64; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.google.android.material.button.MaterialButton; + +import java.security.MessageDigest; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + + +public class EncryptText extends AppCompatActivity { + + EditText inputPassword, inputText; + TextView outputText; + Button encryptBtn, copyBtn; + String outputString; + String AES = "AES"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_encrypt_text); + inputPassword = (EditText) findViewById(R.id.txtKey); + inputText = (EditText) findViewById(R.id.txtPlain); + outputText = (TextView) findViewById(R.id.txtOuptput); + + encryptBtn = (MaterialButton) findViewById(R.id.btnEncrypt); + copyBtn = (MaterialButton) findViewById(R.id.btnCopy); + + encryptBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + try { + outputString = encrypt(inputText.getText().toString(), inputPassword.getText().toString()); + outputText.setText(outputString); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + + copyBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText("EncryptedText", outputText.getText().toString()); + clipboard.setPrimaryClip(clip); + + Toast.makeText(EncryptText.this, "Copied to clipboard", Toast.LENGTH_SHORT).show(); + + } + }); + + } + + private String decrypt(String outputString, String password) throws Exception{ + SecretKeySpec key = generateKey(password); + Cipher c = Cipher.getInstance(AES); + c.init(Cipher.DECRYPT_MODE, key); + byte[] decodedValue = Base64.decode(outputString, Base64.DEFAULT); + byte[] decValue = c.doFinal(decodedValue); + String decryptedValue = new String(decValue); + return decryptedValue; + + } + + private String encrypt(String Data, String password) throws Exception { + SecretKeySpec key = generateKey(password); + Cipher c = Cipher.getInstance(AES); + c.init(Cipher.ENCRYPT_MODE, key); + byte[] encVal = c.doFinal(Data.getBytes()); + String encryptedValue = Base64.encodeToString(encVal, Base64.DEFAULT); + return encryptedValue; + } + + private SecretKeySpec generateKey(String password) throws Exception { + final MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] bytes = password.getBytes("UTF-8"); + digest.update(bytes, 0, bytes.length); + byte[] key = digest.digest(); + SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); + return secretKeySpec; + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/MainActivity.kt b/app/src/main/java/com/example/crypto/MainActivity.kt new file mode 100644 index 0000000..716b0b7 --- /dev/null +++ b/app/src/main/java/com/example/crypto/MainActivity.kt @@ -0,0 +1,55 @@ +package com.example.crypto + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.TextView +import android.widget.Toast +import com.google.android.material.button.MaterialButton + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val username = findViewById(R.id.username); + val password = findViewById(R.id.password); + + val btnLogin = findViewById(R.id.btnlogin); + val btnSignUP = findViewById(R.id.btnsignup) + + // admin and admin + + btnLogin.setOnClickListener { + + + if (username.text.toString().isEmpty() || password.text.toString().isEmpty()) { + Toast.makeText(this, "Please fill all the fields!", Toast.LENGTH_SHORT).show() + } else { + if (username.text.toString().equals("admin") && password.text.toString() + .equals("admin") + ) { + // correct + Toast.makeText(this, "Login Successfull", Toast.LENGTH_SHORT).show() + var Intent = Intent(this, SelectPath::class.java) + startActivity(Intent) + } else { + // incorrect + Toast.makeText(this, "Login Failed!", Toast.LENGTH_SHORT).show() + + } + } + + + } + + // go to signup screen + + btnSignUP.setOnClickListener { + var Intent = Intent(this, SignUp::class.java) + startActivity(Intent) + } + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/SelectAlgorithm.kt b/app/src/main/java/com/example/crypto/SelectAlgorithm.kt new file mode 100644 index 0000000..23238a6 --- /dev/null +++ b/app/src/main/java/com/example/crypto/SelectAlgorithm.kt @@ -0,0 +1,164 @@ +package com.example.crypto + +import android.content.Intent +import android.os.Bundle +import android.view.View +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.google.android.material.button.MaterialButton +import com.google.android.material.button.MaterialButtonToggleGroup + +class SelectAlgorithm : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_select_algorithm) + + val toggleButtonGroup = findViewById(R.id.toggleButtonGroup) + val intentValue = intent.getStringExtra("type") + + + toggleButtonGroup.addOnButtonCheckedListener { toggleButtonGroup, checkedId, isChecked -> + if (isChecked) { + when (checkedId) { + R.id.btntext -> { + showToast("Text selected") + selectTextAlgorithm() + } + R.id.btnfile -> { + showToast("File selected.") + selectFileAlgorithm() + + } + } + } else { + if (toggleButtonGroup.checkedButtonId == View.NO_ID) { + showToast("Nothing Selected") + } + } + } + + + } + + // toggle button 'text' + + private fun selectTextAlgorithm() { + val btnBlowfish = findViewById(R.id.btnblowfish) + val btnAES = findViewById(R.id.btnaes) + val btnDES = findViewById(R.id.btndes) + + + // Blowfish + + btnBlowfish.setOnClickListener { + Toast.makeText(this, "Blowfish algorithm selected", Toast.LENGTH_SHORT).show() + val type = intent.getStringExtra("type") + if (type.equals("encrypt")) { + var Intent = Intent(this, EncryptText::class.java) + Intent.putExtra("type", "Blowfish") + startActivity(Intent) + } + if (type.equals("decrypt")) { + var Intent = Intent(this, DecryptText::class.java) + Intent.putExtra("type", "Blowfish") + startActivity(Intent) + } + + + } + + // AES + + btnAES.setOnClickListener { + Toast.makeText(this, "AES algorithm selected", Toast.LENGTH_SHORT).show() + val type = intent.getStringExtra("type") + if (type.equals("encrypt")) { + var Intent = Intent(this, EncryptText::class.java) + Intent.putExtra("type", "AES") + startActivity(Intent) + } + if (type.equals("decrypt")) { + var Intent = Intent(this, DecryptText::class.java) + Intent.putExtra("type", "AES") + startActivity(Intent) + } + } + + // DES + + btnDES.setOnClickListener { + Toast.makeText(this, "DES algorithm selected", Toast.LENGTH_SHORT).show() + val type = intent.getStringExtra("type") + if (type.equals("encrypt")) { + var Intent = Intent(this, EncryptText::class.java) + Intent.putExtra("type", "DES") + + startActivity(Intent) + } + if (type.equals("decrypt")) { + var Intent = Intent(this, DecryptText::class.java) + Intent.putExtra("type", "DES") + startActivity(Intent) + } + } + } + + // toggle button 'file' + + private fun selectFileAlgorithm() { + val btnBlowfish = findViewById(R.id.btnblowfish) + val btnAES = findViewById(R.id.btnaes) + val btnDES = findViewById(R.id.btndes) + + // Blowfish + + btnBlowfish.setOnClickListener { + Toast.makeText(this, "Blowfish algorithm selected", Toast.LENGTH_SHORT).show() + val type = intent.getStringExtra("type") + if (type.equals("encrypt")) { + var Intent = Intent(this, EncryptFiles2::class.java) + startActivity(Intent) + } + if (type.equals("decrypt")) { + var Intent = Intent(this, EncryptFiles2::class.java) + startActivity(Intent) + } + } + + // AES + + btnAES.setOnClickListener { + Toast.makeText(this, "AES algorithm selected", Toast.LENGTH_SHORT).show() + val type = intent.getStringExtra("type") + if (type.equals("encrypt")) { + var Intent = Intent(this, EncryptFiles2::class.java) + startActivity(Intent) + } + if (type.equals("decrypt")) { + var Intent = Intent(this, EncryptFiles2::class.java) + startActivity(Intent) + } + } + + // DES + + btnDES.setOnClickListener { + Toast.makeText(this, "DES algorithm selected", Toast.LENGTH_SHORT).show() + val type = intent.getStringExtra("type") + if (type.equals("encrypt")) { + var Intent = Intent(this, EncryptFiles2::class.java) + startActivity(Intent) + } + if (type.equals("decrypt")) { + var Intent = Intent(this, EncryptFiles2::class.java) + startActivity(Intent) + } + } + } + + private fun showToast(str: String) { + Toast.makeText(this, str, Toast.LENGTH_SHORT).show() + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/SelectPath.kt b/app/src/main/java/com/example/crypto/SelectPath.kt new file mode 100644 index 0000000..6c7d77b --- /dev/null +++ b/app/src/main/java/com/example/crypto/SelectPath.kt @@ -0,0 +1,61 @@ +package com.example.crypto + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.ImageButton +import android.widget.Toast +import com.google.android.material.button.MaterialButton + +class SelectPath : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_select_path) + + val btnEncryption = findViewById(R.id.btnencryption) + val btnDecryption = findViewById(R.id.btndecryption) + val btnLogout = findViewById(R.id.btnLogout) + val btnAboutUs = findViewById(R.id.btnabout) + val btnContact = findViewById(R.id.imageButton) + + // go to encryption + + btnEncryption.setOnClickListener { + var intent = Intent(this, SelectAlgorithm::class.java) + val type = String() + intent.putExtra("type","encrypt") + startActivity(intent) + } + + // go to decryption + + btnDecryption.setOnClickListener { + var intent = Intent(this, SelectAlgorithm::class.java) + val type = String() + intent.putExtra("type", "decrypt") + startActivity(intent) + } + // logout + + btnLogout.setOnClickListener { + var Intent = Intent(this, MainActivity::class.java) + startActivity(Intent) + } + + // about us + + btnAboutUs.setOnClickListener { + var Intent = Intent(this, AboutUs::class.java) + startActivity(Intent) + } + + // contact us + btnContact.setOnClickListener { + var Intent = Intent(this, ContactUs::class.java) + startActivity(Intent) + } + + + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/SignUp.kt b/app/src/main/java/com/example/crypto/SignUp.kt new file mode 100644 index 0000000..0795a31 --- /dev/null +++ b/app/src/main/java/com/example/crypto/SignUp.kt @@ -0,0 +1,32 @@ +package com.example.crypto + +import android.content.Intent +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import android.widget.TextView +import android.widget.Toast +import com.google.android.material.button.MaterialButton + +class SignUp : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_sign_up) + + val username = findViewById(R.id.username) + val password = findViewById(R.id.password) + val email = findViewById(R.id.email) + + val btnSignup = findViewById(R.id.btnSignUpIn) + + btnSignup.setOnClickListener { + if (username.text.toString().isEmpty() || password.text.toString() + .isEmpty() || email.text.toString().isEmpty() + ) { + Toast.makeText(this, "Please fill all the fields!", Toast.LENGTH_SHORT).show() + } else { + var Intent = Intent(this, SelectPath::class.java) + startActivity(Intent) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/crypto/Utils/Encrypter.java b/app/src/main/java/com/example/crypto/Utils/Encrypter.java new file mode 100644 index 0000000..f17336a --- /dev/null +++ b/app/src/main/java/com/example/crypto/Utils/Encrypter.java @@ -0,0 +1,67 @@ +package com.example.crypto.Utils; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.Cipher; +import javax.crypto.CipherOutputStream; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +public class Encrypter { + private final static int READ_WRITE_BLOCK_BUFFER = 1024; + private final static String ALGO_IMAGE_ENCRYPTOR = "AES/CBC/PKCS5Padding"; + private final static String ALGO_SECRET_KEY = "AES"; + + public static void encryptToFile(String keyStr, String spceStr, InputStream in, OutputStream out) + throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, + InvalidKeyException, IOException { + try{ + IvParameterSpec iv = new IvParameterSpec(spceStr.getBytes("UTF-8")); + + SecretKeySpec keySpec = new SecretKeySpec(keyStr.getBytes("UTF-8"),ALGO_SECRET_KEY); + + Cipher c = Cipher.getInstance(ALGO_IMAGE_ENCRYPTOR); + c.init(Cipher.ENCRYPT_MODE, keySpec, iv); + out = new CipherOutputStream(out, c); + int count = 0; + byte[] buffer = new byte[READ_WRITE_BLOCK_BUFFER]; + while ((count = in.read(buffer)) > 0) + out.write(buffer, 0, count); + + + } + finally { + out.close(); + } + } + + public static void decryptToFile(String keyStr, String spceStr, InputStream in, OutputStream out) + throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, + InvalidKeyException, IOException { + try{ + IvParameterSpec iv = new IvParameterSpec(spceStr.getBytes("UTF-8")); + + SecretKeySpec keySpec = new SecretKeySpec(keyStr.getBytes("UTF-8"),ALGO_SECRET_KEY); + + Cipher c = Cipher.getInstance(ALGO_IMAGE_ENCRYPTOR); + c.init(Cipher.DECRYPT_MODE, keySpec, iv); + out = new CipherOutputStream(out, c); + int count = 0; + byte[] buffer = new byte[READ_WRITE_BLOCK_BUFFER]; + while ((count = in.read(buffer)) > 0) + out.write(buffer, 0, count); + + + } + finally { + out.close(); + } + } + +} diff --git a/app/src/main/java/com/febrian/qrbarcodescanner/ApiInterface.kt b/app/src/main/java/com/febrian/qrbarcodescanner/ApiInterface.kt deleted file mode 100644 index b1507c9..0000000 --- a/app/src/main/java/com/febrian/qrbarcodescanner/ApiInterface.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.febrian.qrbarcodescanner - -import retrofit2.Call -import retrofit2.http.GET -import retrofit2.http.Path - -interface ApiInterface { - @GET("products/{productId}") - fun getData( - @Path("productId") number: Long - ): Call -} \ No newline at end of file diff --git a/app/src/main/java/com/febrian/qrbarcodescanner/MainActivity.kt b/app/src/main/java/com/febrian/qrbarcodescanner/MainActivity.kt deleted file mode 100644 index a2ba865..0000000 --- a/app/src/main/java/com/febrian/qrbarcodescanner/MainActivity.kt +++ /dev/null @@ -1,102 +0,0 @@ -package com.febrian.qrbarcodescanner - -import android.content.Intent -import android.net.Uri -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import android.speech.tts.TextToSpeech -import android.view.View -import android.widget.Toast -import com.febrian.qrbarcodescanner.databinding.ActivityMainBinding -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import java.util.* -import kotlin.properties.Delegates - -const val BASE_URL = "https://androidbarcodereader.herokuapp.com/api/" - -class MainActivity : AppCompatActivity() { - - companion object { - const val RESULT = "RESULT" - } - - private lateinit var binding: ActivityMainBinding - var myVariable by Delegates.notNull() - - lateinit var tts: TextToSpeech - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) - setContentView(binding.root) - - binding.btnTextScan.setOnClickListener{ - var Intent = Intent(this, TextDetect::class.java) - startActivity(Intent) - } - - binding.btnScan.setOnClickListener { - val intent = Intent(applicationContext, ScanActivity::class.java) - startActivity(intent) - } - - val result = intent.getStringExtra(RESULT) - - if (result != null) { - if (result.contains("https://") || result.contains("http://")) { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(result)) - startActivity(intent) - } else { - binding.result.text = result.toString() -// Toast.makeText(this, result, Toast.LENGTH_SHORT).show() - myVariable = result.toLong() - - } - } - - if (result != null) { - getMyData() - } - - } - - - private fun getMyData() { - val retrofitBuilder = Retrofit.Builder() - .addConverterFactory(GsonConverterFactory.create()) - .baseUrl(BASE_URL) - .build() - .create(ApiInterface::class.java) - - val retrofitData = retrofitBuilder.getData(myVariable) - - retrofitData.enqueue(object : Callback { - override fun onResponse(call: Call, response: Response) { - if(response.isSuccessful) { - val productName = response.body()?.name.toString() - binding.name.text = productName.toString() - - tts = TextToSpeech(applicationContext, TextToSpeech.OnInitListener { - if(it == TextToSpeech.SUCCESS) { - tts.language = Locale.US - tts.setSpeechRate(1.0f) - tts.speak(productName.toString(), TextToSpeech.QUEUE_ADD, null) - } - }) - } - } - - override fun onFailure(call: Call, t: Throwable) { - - } - }) - - } - - - -} \ No newline at end of file diff --git a/app/src/main/java/com/febrian/qrbarcodescanner/QrData.kt b/app/src/main/java/com/febrian/qrbarcodescanner/QrData.kt deleted file mode 100644 index 08ca1aa..0000000 --- a/app/src/main/java/com/febrian/qrbarcodescanner/QrData.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.febrian.qrbarcodescanner - -class QrData : ArrayList() \ No newline at end of file diff --git a/app/src/main/java/com/febrian/qrbarcodescanner/QrDataItem.kt b/app/src/main/java/com/febrian/qrbarcodescanner/QrDataItem.kt deleted file mode 100644 index ac4d058..0000000 --- a/app/src/main/java/com/febrian/qrbarcodescanner/QrDataItem.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.febrian.qrbarcodescanner - -data class QrDataItem( - val __v: Int, - val _id: String, - val createdAt: String, - val description: String, - val name: String, - val productId: Long, - val updatedAt: String -) \ No newline at end of file diff --git a/app/src/main/java/com/febrian/qrbarcodescanner/ScanActivity.kt b/app/src/main/java/com/febrian/qrbarcodescanner/ScanActivity.kt deleted file mode 100644 index 38b3349..0000000 --- a/app/src/main/java/com/febrian/qrbarcodescanner/ScanActivity.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.febrian.qrbarcodescanner - -import android.content.Intent -import android.content.pm.PackageManager -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import android.widget.Toast -import androidx.core.app.ActivityCompat -import androidx.core.content.ContextCompat -import com.febrian.qrbarcodescanner.MainActivity.Companion.RESULT -import com.google.zxing.Result -import me.dm7.barcodescanner.zxing.ZXingScannerView - -class ScanActivity : AppCompatActivity(), ZXingScannerView.ResultHandler { - - var scannerView: ZXingScannerView? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - scannerView = ZXingScannerView(this) - setContentView(scannerView) - - setPermission() - } - - override fun handleResult(p0: Result?) { - val intent = Intent(applicationContext, MainActivity::class.java) - intent.putExtra(RESULT, p0.toString()) - startActivity(intent) - } - - override fun onResume() { - super.onResume() - - scannerView?.setResultHandler(this) - scannerView?.startCamera() - } - - override fun onStop() { - super.onStop() - scannerView?.stopCamera() - onBackPressed() - } - - private fun setPermission() { - val permission = ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) - - if (permission != PackageManager.PERMISSION_GRANTED) { - makeRequest() - } - } - - private fun makeRequest() { - ActivityCompat.requestPermissions( - this, arrayOf(android.Manifest.permission.CAMERA), - 1 - ) - } - - override fun onRequestPermissionsResult( - requestCode: Int, - permissions: Array, - grantResults: IntArray - ) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults) - - when (requestCode) { - 1 -> { - if (grantResults.isEmpty() || grantResults[0] != PackageManager.PERMISSION_GRANTED) { - Toast.makeText( - applicationContext, - "You need camera permission", - Toast.LENGTH_SHORT - ).show() - } - } - } - - } -} \ No newline at end of file diff --git a/app/src/main/java/com/febrian/qrbarcodescanner/TextDetect.java b/app/src/main/java/com/febrian/qrbarcodescanner/TextDetect.java deleted file mode 100644 index 7818630..0000000 --- a/app/src/main/java/com/febrian/qrbarcodescanner/TextDetect.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.febrian.qrbarcodescanner; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; -import androidx.appcompat.app.AppCompatActivity; - -import android.Manifest; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.graphics.Bitmap; -import android.os.Build; -import android.os.Bundle; -import android.provider.MediaStore; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.ml.vision.FirebaseVision; -import com.google.firebase.ml.vision.common.FirebaseVisionImage; -import com.google.firebase.ml.vision.text.FirebaseVisionText; -import com.google.firebase.ml.vision.text.FirebaseVisionTextRecognizer; - -public class TextDetect extends AppCompatActivity { - - ImageView imageView; - TextView textView; - - @RequiresApi(api = Build.VERSION_CODES.M) - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_text_detect); - //find imageview - imageView = findViewById(R.id.imageId); - //find textview - textView = findViewById(R.id.textId); - //check app level permission is granted for Camera - if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){ - //grant the permission - requestPermissions(new String[]{Manifest.permission.CAMERA}, 101); - } - } - - public void doProcess(View view) { - //open the camera => create an Intent object - Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - startActivityForResult(intent, 101); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { - super.onActivityResult(requestCode, resultCode, data); - Bundle bundle = data.getExtras(); - //from bundle, extract the image - Bitmap bitmap = (Bitmap) bundle.get("data"); - //set image in imageview - imageView.setImageBitmap(bitmap); - //process the image - //1. create a FirebaseVisionImage object from a Bitmap object - FirebaseVisionImage firebaseVisionImage = FirebaseVisionImage.fromBitmap(bitmap); - //2. Get an instance of FirebaseVision - FirebaseVision firebaseVision = FirebaseVision.getInstance(); - //3. Create an instance of FirebaseVisionTextRecognizer - FirebaseVisionTextRecognizer firebaseVisionTextRecognizer = firebaseVision.getOnDeviceTextRecognizer(); - //4. Create a task to process the image - Task task = firebaseVisionTextRecognizer.processImage(firebaseVisionImage); - //5. if task is success - task.addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(FirebaseVisionText firebaseVisionText) { - String s = firebaseVisionText.getText(); - textView.setText(s); - } - }); - //6. if task is failure - task.addOnFailureListener(new OnFailureListener() { - @Override - public void onFailure(@NonNull Exception e) { - Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); - } - }); - } -} \ No newline at end of file diff --git a/app/src/main/res/drawable-hdpi/download.png b/app/src/main/res/drawable-hdpi/download.png new file mode 100644 index 0000000..c85284d Binary files /dev/null and b/app/src/main/res/drawable-hdpi/download.png differ diff --git a/app/src/main/res/drawable-mdpi/download.png b/app/src/main/res/drawable-mdpi/download.png new file mode 100644 index 0000000..8432933 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/download.png differ diff --git a/app/src/main/res/drawable-xhdpi/download.png b/app/src/main/res/drawable-xhdpi/download.png new file mode 100644 index 0000000..9bf660a Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/download.png differ diff --git a/app/src/main/res/drawable-xxhdpi/download.png b/app/src/main/res/drawable-xxhdpi/download.png new file mode 100644 index 0000000..bbcf602 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/download.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/download.png b/app/src/main/res/drawable-xxxhdpi/download.png new file mode 100644 index 0000000..bf76431 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/download.png differ diff --git a/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml new file mode 100644 index 0000000..fa122e1 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_arrow_back_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_contact_support_24.xml b/app/src/main/res/drawable/ic_baseline_contact_support_24.xml new file mode 100644 index 0000000..38d1eb1 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_contact_support_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_content_copy_24.xml b/app/src/main/res/drawable/ic_baseline_content_copy_24.xml new file mode 100644 index 0000000..0fb13c2 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_content_copy_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_email_24.xml b/app/src/main/res/drawable/ic_baseline_email_24.xml new file mode 100644 index 0000000..80111c8 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_email_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_lock_24.xml b/app/src/main/res/drawable/ic_baseline_lock_24.xml new file mode 100644 index 0000000..6c6b260 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_lock_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_person_24.xml b/app/src/main/res/drawable/ic_baseline_person_24.xml new file mode 100644 index 0000000..bd8dc80 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_person_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/logo.png b/app/src/main/res/drawable/logo.png new file mode 100644 index 0000000..dc78078 Binary files /dev/null and b/app/src/main/res/drawable/logo.png differ diff --git a/app/src/main/res/drawable/wallpaper.jpg b/app/src/main/res/drawable/wallpaper.jpg new file mode 100644 index 0000000..c14ca62 Binary files /dev/null and b/app/src/main/res/drawable/wallpaper.jpg differ diff --git a/app/src/main/res/layout/activity_about_us.xml b/app/src/main/res/layout/activity_about_us.xml new file mode 100644 index 0000000..bcfd045 --- /dev/null +++ b/app/src/main/res/layout/activity_about_us.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_contact_us.xml b/app/src/main/res/layout/activity_contact_us.xml new file mode 100644 index 0000000..df86efc --- /dev/null +++ b/app/src/main/res/layout/activity_contact_us.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_decrypt_text.xml b/app/src/main/res/layout/activity_decrypt_text.xml new file mode 100644 index 0000000..53dab50 --- /dev/null +++ b/app/src/main/res/layout/activity_decrypt_text.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_encrypt_files2.xml b/app/src/main/res/layout/activity_encrypt_files2.xml new file mode 100644 index 0000000..d8a18d8 --- /dev/null +++ b/app/src/main/res/layout/activity_encrypt_files2.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_encrypt_text.xml b/app/src/main/res/layout/activity_encrypt_text.xml new file mode 100644 index 0000000..b44abbc --- /dev/null +++ b/app/src/main/res/layout/activity_encrypt_text.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 0223404..238096d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,52 +1,93 @@ - -