Skip to content

Commit

Permalink
Merge pull request #72 from aashishksahu/64-bug-in-app-camera-not-wor…
Browse files Browse the repository at this point in the history
…king

64 bug in app camera not working
  • Loading branch information
aashishksahu authored Jul 4, 2024
2 parents 5e89251 + a989a0e commit e707d90
Show file tree
Hide file tree
Showing 50 changed files with 1,425 additions and 987 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {

minSdk 29
targetSdk 34
versionCode 32
versionName "2.0.1"
versionCode 33
versionName "2.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 32,
"versionName": "2.0.1",
"versionCode": 33,
"versionName": "2.0.2",
"outputFile": "app-release.apk"
}
],
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
android:theme="@style/Theme.SafeSpace"
tools:replace="android:allowBackup"
tools:targetApi="31">
<activity
android:name=".LogActivity"
android:exported="false"
android:theme="@style/Theme.SafeSpace" />
<activity
android:name=".experimental.settings.SettingsActivity"
android:exported="false"
Expand Down Expand Up @@ -60,10 +64,6 @@
android:name=".document.PDFView"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="false" />
<activity
android:name=".main.MainActivity"
android:configChanges="keyboardHidden|screenSize"
android:exported="false" />

<provider
android:name="androidx.core.content.FileProvider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import org.privacymatters.safespace.lib.Reload
import org.privacymatters.safespace.depracated.lib.Reload

class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ class AuthActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_auth)

// Experimental - Remove before release
// val intent = Intent(applicationContext, MainnActivity::class.java)
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
// startActivity(intent)
// finish()


authTouch = findViewById(R.id.fingerprint)
pinField = findViewById(R.id.editTextPassword)
Expand Down
92 changes: 92 additions & 0 deletions app/src/main/java/org/privacymatters/safespace/LogActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package org.privacymatters.safespace

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import org.privacymatters.safespace.experimental.main.ui.SafeSpaceTheme
import org.privacymatters.safespace.utils.Utils
import java.io.BufferedReader
import java.io.File
import java.io.FileNotFoundException
import java.io.FileReader
import java.io.IOException


class LogActivity : ComponentActivity() {
private val content = StringBuilder()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val logsFolder = File(application.filesDir.canonicalPath + File.separator + "logs")
val logFile = File(logsFolder.canonicalPath + File.separator + "safe_space_log.txt")

try {
val buffer = BufferedReader(FileReader(logFile))
var line: String?

while (buffer.readLine().also { line = it } != null) {
content.append(line)
content.append('\n')
}
buffer.close()
} catch (e: FileNotFoundException) {
content.clear()
content.append(getString(R.string.text_exception_title))

} catch (e: IOException) {
content.clear()
content.append(getString(R.string.text_exception_IO))
}

setContent {
SafeSpaceTheme {
Scaffold(modifier = Modifier.fillMaxSize(),
topBar = {
IconButton(

onClick = {
Utils.clearLogs(application)
}) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.delete_white_36dp),
contentDescription = getString(R.string.context_menu_delete),
tint = MaterialTheme.colorScheme.primary
)
}
}) { innerPadding ->
Text(
text = content.toString(),
modifier = Modifier
.padding(
PaddingValues(
top = innerPadding.calculateTopPadding(),
bottom = innerPadding.calculateBottomPadding(),
start = 5.dp,
end = 5.dp
)
)
.fillMaxSize()
.verticalScroll(rememberScrollState())
.horizontalScroll(rememberScrollState())
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.AspectRatio
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageCapture
import androidx.camera.core.ImageCaptureException
Expand All @@ -31,9 +30,10 @@ import androidx.camera.view.PreviewView
import androidx.core.content.ContextCompat
import androidx.core.util.Consumer
import org.privacymatters.safespace.R
import org.privacymatters.safespace.depracated.lib.Reload
import org.privacymatters.safespace.experimental.main.DataManager
import org.privacymatters.safespace.lib.Reload
import org.privacymatters.safespace.utils.Constants
import org.privacymatters.safespace.utils.Utils
import java.io.File
import java.text.SimpleDateFormat
import java.util.Locale
Expand Down Expand Up @@ -341,7 +341,7 @@ class CameraActivity : AppCompatActivity() {

// Preview
preview = Preview.Builder()
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
// .setTargetAspectRatio(AspectRatio.RATIO_16_9)
.build()
.also {
it.setSurfaceProvider(viewFinder.surfaceProvider)
Expand All @@ -368,7 +368,7 @@ class CameraActivity : AppCompatActivity() {
// image capture
imageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY)
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
// .setTargetAspectRatio(AspectRatio.RATIO_16_9)
.build()

try {
Expand All @@ -383,8 +383,8 @@ class CameraActivity : AppCompatActivity() {
this, cameraSelector, preview, imageCapture, videoCapture
)

} catch (_: Exception) {

} catch (e: Exception) {
Utils.exportToLog(application, "@CameraActivity.startCamera()", e)
}

}, ContextCompat.getMainExecutor(applicationContext))
Expand Down Expand Up @@ -414,7 +414,7 @@ class CameraActivity : AppCompatActivity() {
ContextCompat.getMainExecutor(applicationContext),
object : ImageCapture.OnImageSavedCallback {
override fun onError(exc: ImageCaptureException) {
// exc.printStackTrace()
Utils.exportToLog(application, "@CameraActivity.takePhoto()", exc)
}

override fun onImageSaved(outputFileResults: ImageCapture.OutputFileResults) {
Expand Down Expand Up @@ -465,6 +465,11 @@ class CameraActivity : AppCompatActivity() {
}

if (event.hasError()) {
Utils.exportToLog(
application,
"@CameraActivity.captureVideo()\n${event.error} - ${event.cause}",
null
)
Toast.makeText(
shutterButton.context,
getString(R.string.video_error),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CameraViewModel(application: Application, private val initialTimerText: St
timer = Timer()
viewModelScope.launch(Dispatchers.Main) {

timer?.scheduleAtFixedRate(timerTask {
timer?.schedule(timerTask {
timerCounter += 1u
timerCounterText.postValue(
(timerCounter / 60u).toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.privacymatters.safespace.lib
package org.privacymatters.safespace.depracated.lib

class Reload {
companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
package org.privacymatters.safespace.lib
package org.privacymatters.safespace.depracated.lib

import android.content.SharedPreferences
import android.view.View
import android.widget.RadioGroup
import org.privacymatters.safespace.R
import org.privacymatters.safespace.lib.fileManager.FileItem
import org.privacymatters.safespace.lib.fileManager.Operations
import org.privacymatters.safespace.depracated.lib.fileManager.FileItem
//import org.privacymatters.safespace.depracated.lib.fileManager.Operations
import org.privacymatters.safespace.utils.Constants

class Sortinator(sharedPref: SharedPreferences, ops: Operations) {
class Sortinator(sharedPref: SharedPreferences,
// ops: Operations
) {

private var fileSortBy: String? = null
private var fileSortOrder: String? = null
private var ops: Operations? = null
// private var ops: Operations? = null
private var sortByGroup: RadioGroup? = null
private var sortOrderGroup: RadioGroup? = null
private var sharedPref: SharedPreferences

init {

this.ops = ops
// this.ops = ops
this.sharedPref = sharedPref

fileSortBy = sharedPref.getString(Constants.FILE_SORT_BY, Constants.NAME) // Name, Date or Size
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.privacymatters.safespace.lib.fileManager
package org.privacymatters.safespace.depracated.lib.fileManager

class FileItem(
name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.privacymatters.safespace.lib.fileManager
package org.privacymatters.safespace.depracated.lib.fileManager

class FolderItem(
name: String,
Expand Down
Loading

0 comments on commit e707d90

Please sign in to comment.