Skip to content

Commit

Permalink
remove unused camera event listening, which may have been causing a c…
Browse files Browse the repository at this point in the history
…rash
  • Loading branch information
n8fr8 committed Jan 22, 2024
1 parent 18586ac commit dac9878
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import org.witness.proofmode.camera.analyzer.LuminosityAnalyzer
import org.witness.proofmode.camera.c2pa.C2paUtils
import org.witness.proofmode.camera.databinding.FragmentCameraBinding
import org.witness.proofmode.camera.enums.CameraTimer
import org.witness.proofmode.camera.fragments.CameraFragment.CameraConstants.NEW_MEDIA_EVENT
import org.witness.proofmode.camera.utils.*
import java.io.File
import java.io.FileNotFoundException
Expand Down Expand Up @@ -677,7 +676,7 @@ class CameraFragment : BaseFragment<FragmentCameraBinding>(R.layout.fragment_cam
override fun onError(exception: ImageCaptureException) {
// This function is called if there is an errors during capture process
val msg = "Photo capture failed: ${exception.message}"
Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show()
// Toast.makeText(requireContext(), msg, Toast.LENGTH_SHORT).show()
Log.e(TAG, msg)
exception.printStackTrace()
}
Expand Down Expand Up @@ -730,9 +729,6 @@ class CameraFragment : BaseFragment<FragmentCameraBinding>(R.layout.fragment_cam
private const val RATIO_16_9_VALUE = 16.0 / 9.0 // aspect ratio 16x9
}

object CameraConstants {
const val NEW_MEDIA_EVENT = "org.witness.proofmode.NEW_MEDIA"
}

fun sendLocalCameraEvent(newMediaFile: Uri) {

Expand All @@ -743,7 +739,7 @@ class CameraFragment : BaseFragment<FragmentCameraBinding>(R.layout.fragment_cam

MediaStore.Images.Media.insertImage(
context?.contentResolver,
f.getAbsolutePath(), f.getName(), null
f.absolutePath, f.name, null
)
context?.sendBroadcast(
Intent(
Expand All @@ -755,9 +751,6 @@ class CameraFragment : BaseFragment<FragmentCameraBinding>(R.layout.fragment_cam
}
}

// var intent = Intent(NEW_MEDIA_EVENT)
// intent.data = newMediaFile
// activity?.applicationContext?.let { LocalBroadcastManager.getInstance(it).sendBroadcast(intent) }

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class ProofMode {
private static CameraEventReceiver mReceiver;

private static boolean mInit = false;
public final static String NEW_MEDIA_EVENT = "org.witness.proofmode.NEW_MEDIA";

public synchronized static void initBackgroundService (Context context)
{
Expand All @@ -110,7 +111,9 @@ public synchronized static void initBackgroundService (Context context)

if (mReceiver == null) {
mReceiver = new CameraEventReceiver();
addCameraEventListeners(context, mReceiver);
//internal camera event
LocalBroadcastManager.getInstance(context).
registerReceiver(mReceiver, new IntentFilter("org.witness.proofmode.NEW_MEDIA"));
}

startLocationListener(context);
Expand All @@ -126,21 +129,6 @@ private static void startLocationListener (Context context) {
mLocationTracker.updateLocation();
}

private static void addCameraEventListeners (Context context, CameraEventReceiver receiver) {

//external potential camera events
context.registerReceiver(receiver, new IntentFilter("com.android.camera.NEW_PICTURE"));
context.registerReceiver(receiver, new IntentFilter("android.hardware.action.NEW_PICTURE"));
context.registerReceiver(receiver, new IntentFilter("com.android.camera.NEW_VIDEO"));
context.registerReceiver(receiver, new IntentFilter("org.witness.proofmode.NEW_MEDIA"));

//internal camera event
LocalBroadcastManager.getInstance(context).
registerReceiver(receiver, new IntentFilter("org.witness.proofmode.NEW_MEDIA"));


}

public static void stopBackgroundService (Context context)
{

Expand Down

0 comments on commit dac9878

Please sign in to comment.