From 2e94d589bfdf4d933374d04cb4d57baac768e377 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Sun, 21 Apr 2019 15:34:07 +0530 Subject: [PATCH 01/11] Call cameraview destroy() instead of close() on Fragment onDestroy() - destroy() releases the camera resource unlike close() which just stops the preview Signed-off-by: Arka Prava Basu --- src/main/java/org/havenapp/main/ui/CameraViewHolder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/havenapp/main/ui/CameraViewHolder.java b/src/main/java/org/havenapp/main/ui/CameraViewHolder.java index 0fb396c8..93e09f88 100644 --- a/src/main/java/org/havenapp/main/ui/CameraViewHolder.java +++ b/src/main/java/org/havenapp/main/ui/CameraViewHolder.java @@ -416,7 +416,9 @@ public void destroy () this.context.unbindService(mConnection); mConnection = null; } - stopCamera(); + if (cameraView != null) { + cameraView.destroy(); + } } public int getCorrectCameraOrientation(Facing facing, int orientation) { From 9f54d450ba0f6ccf818bb7c54abf026fe7946da5 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Mon, 22 Apr 2019 02:16:36 +0530 Subject: [PATCH 02/11] Set LifecyclerOwner to the CameraView - setting LifecycleOwner will remove boilerplate around open(), close() and destroy() - a possible fix for #376 ? Signed-off-by: Arka Prava Basu --- .../java/org/havenapp/main/ui/CameraFragment.java | 12 ++++++------ .../java/org/havenapp/main/ui/CameraViewHolder.java | 12 ------------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/havenapp/main/ui/CameraFragment.java b/src/main/java/org/havenapp/main/ui/CameraFragment.java index ed82c8aa..2edaef24 100644 --- a/src/main/java/org/havenapp/main/ui/CameraFragment.java +++ b/src/main/java/org/havenapp/main/ui/CameraFragment.java @@ -83,12 +83,11 @@ public void updateCamera () } } - public void stopCamera () - { - if (cameraViewHolder != null) { - cameraViewHolder.stopCamera(); - } - } + /** + * Not required. + */ + @Deprecated + public void stopCamera () { } public void initCamera () { @@ -101,6 +100,7 @@ public void initCamera () CameraView cameraView = getActivity().findViewById(R.id.camera_view); cameraView.setAudio(Audio.OFF); + cameraView.setLifecycleOwner(this); if (cameraViewHolder == null) { cameraViewHolder = new CameraViewHolder(getActivity(), cameraView); diff --git a/src/main/java/org/havenapp/main/ui/CameraViewHolder.java b/src/main/java/org/havenapp/main/ui/CameraViewHolder.java index 93e09f88..7da0f5eb 100644 --- a/src/main/java/org/havenapp/main/ui/CameraViewHolder.java +++ b/src/main/java/org/havenapp/main/ui/CameraViewHolder.java @@ -229,7 +229,6 @@ public List select(@NonNull List source) { return result; } }); - cameraView.open(); cameraView.addFrameProcessor(new FrameProcessor() { @Override @@ -402,23 +401,12 @@ private synchronized boolean recordVideo() { } - public synchronized void stopCamera () - { - if (cameraView != null) { - cameraView.close(); - } - } - - public void destroy () { if (mConnection != null) { this.context.unbindService(mConnection); mConnection = null; } - if (cameraView != null) { - cameraView.destroy(); - } } public int getCorrectCameraOrientation(Facing facing, int orientation) { From 9ef9908a6663c013bbf9b3f91bdc4dc41530e8e6 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Fri, 26 Apr 2019 05:14:03 +0530 Subject: [PATCH 03/11] Set listener to null while canceling task - holding this reference may lead to Context leak Signed-off-by: Arka Prava Basu --- .../main/sensors/MicrophoneMonitor.java | 2 +- .../main/sensors/media/MicSamplerTask.java | 18 ++++++++++++------ .../main/ui/MicrophoneConfigureActivity.java | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/havenapp/main/sensors/MicrophoneMonitor.java b/src/main/java/org/havenapp/main/sensors/MicrophoneMonitor.java index 925bf823..2ea3e0db 100644 --- a/src/main/java/org/havenapp/main/sensors/MicrophoneMonitor.java +++ b/src/main/java/org/havenapp/main/sensors/MicrophoneMonitor.java @@ -102,7 +102,7 @@ public void stop (Context context) { context.unbindService(mConnection); if (microphone != null) - microphone.cancel(true); + microphone.cancelTask(); } diff --git a/src/main/java/org/havenapp/main/sensors/media/MicSamplerTask.java b/src/main/java/org/havenapp/main/sensors/media/MicSamplerTask.java index 934a4d86..275c1bb4 100644 --- a/src/main/java/org/havenapp/main/sensors/media/MicSamplerTask.java +++ b/src/main/java/org/havenapp/main/sensors/media/MicSamplerTask.java @@ -15,8 +15,11 @@ import java.io.IOException; +import javax.annotation.Nullable; + public class MicSamplerTask extends AsyncTask { + @Nullable private MicListener listener = null; private AudioCodec volumeMeter = new AudioCodec(); private boolean sampling = true; @@ -30,10 +33,6 @@ public interface MicListener { public void setMicListener(MicListener listener) { this.listener = listener; } - - protected Void onPreExecute(Void...params) { - return null; - } @Override protected Void doInBackground(Void... params) { @@ -106,6 +105,13 @@ public void pause() { @Override protected void onProgressUpdate(Object... progress) { short[] data = (short[]) progress[0]; - listener.onSignalReceived(data); - } + if (listener != null) { + listener.onSignalReceived(data); + } + } + + public void cancelTask() { + cancel(true); + listener = null; + } } diff --git a/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java b/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java index 0ac4d231..70118ef5 100644 --- a/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java +++ b/src/main/java/org/havenapp/main/ui/MicrophoneConfigureActivity.java @@ -192,7 +192,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in protected void onDestroy() { super.onDestroy(); if (microphone != null) - microphone.cancel(true); + microphone.cancelTask(); } From aac0f96ce0eab107b6f8d7dcde3a12f88e89a397 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Fri, 26 Apr 2019 06:55:26 +0530 Subject: [PATCH 04/11] Add LeakCanary dependency Signed-off-by: Arka Prava Basu --- build.gradle | 6 ++++++ src/main/java/org/havenapp/main/HavenApp.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/build.gradle b/build.gradle index fc16d5ff..95b6ae1c 100644 --- a/build.gradle +++ b/build.gradle @@ -188,4 +188,10 @@ dependencies { // new camera view: https://github.com/natario1/CameraView implementation 'com.otaliastudios:cameraview:2.0.0-beta04' + + // leak canary + debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3' + releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' + // Optional, if you use support library fragments: + debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3' } diff --git a/src/main/java/org/havenapp/main/HavenApp.java b/src/main/java/org/havenapp/main/HavenApp.java index ab61507e..9847f211 100644 --- a/src/main/java/org/havenapp/main/HavenApp.java +++ b/src/main/java/org/havenapp/main/HavenApp.java @@ -23,6 +23,7 @@ import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.imagepipeline.core.ImagePipelineConfig; import com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig; +import com.squareup.leakcanary.LeakCanary; import org.havenapp.main.database.HavenEventDB; import org.havenapp.main.service.HavenJobCreator; @@ -51,6 +52,12 @@ public class HavenApp extends MultiDexApplication { @Override public void onCreate() { super.onCreate(); + if (LeakCanary.isInAnalyzerProcess(this)) { + // This process is dedicated to LeakCanary for heap analysis. + // You should not init your app in this process. + return; + } + LeakCanary.install(this); mPrefs = new PreferenceManager(this); From 99eded98c963cc3c33be12ff8ab8e00b16ff2fb3 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Fri, 26 Apr 2019 07:16:13 +0530 Subject: [PATCH 05/11] Keep application context in Signal Sender - keeping Context (Activity/Fragment) in a singleton will cause memory leaks Keep the global application object associated with it instead - fix #399 Signed-off-by: Arka Prava Basu --- src/main/java/org/havenapp/main/service/SignalSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/havenapp/main/service/SignalSender.java b/src/main/java/org/havenapp/main/service/SignalSender.java index 60944391..24560b1b 100644 --- a/src/main/java/org/havenapp/main/service/SignalSender.java +++ b/src/main/java/org/havenapp/main/service/SignalSender.java @@ -40,7 +40,7 @@ public class SignalSender { private SignalSender(Context context, String username) { - mContext = context; + mContext = context.getApplicationContext(); mUsername = username; mAlertCount = 0; preferences = new PreferenceManager(mContext); From 0a99b025b9fc0cb62f4a5f1c7dbfaa3f1e550939 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Sat, 27 Apr 2019 00:32:01 +0530 Subject: [PATCH 06/11] Remove redundant methods Signed-off-by: Arka Prava Basu --- .../org/havenapp/main/MonitorActivity.java | 24 ++++--------------- .../main/ui/CameraConfigureActivity.java | 11 ++++----- .../org/havenapp/main/ui/CameraFragment.java | 19 +++------------ 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/havenapp/main/MonitorActivity.java b/src/main/java/org/havenapp/main/MonitorActivity.java index e82134f4..3576e78a 100644 --- a/src/main/java/org/havenapp/main/MonitorActivity.java +++ b/src/main/java/org/havenapp/main/MonitorActivity.java @@ -17,7 +17,6 @@ package org.havenapp.main; import android.Manifest; -import android.animation.ValueAnimator; import android.app.PictureInPictureParams; import android.content.BroadcastReceiver; import android.content.Context; @@ -25,7 +24,6 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.os.CountDownTimer; @@ -40,7 +38,11 @@ import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.TextView; -import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; @@ -55,11 +57,6 @@ import java.io.FileOutputStream; import java.io.IOException; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; - import static org.havenapp.main.Utils.getTimerText; public class MonitorActivity extends AppCompatActivity implements TimePickerDialog.OnTimeSetListener { @@ -233,8 +230,6 @@ private void initSetupLayout() { } private void configCamera() { - - mFragmentCamera.stopCamera(); startActivityForResult(new Intent(this, CameraConfigureActivity.class),REQUEST_CAMERA); } @@ -317,15 +312,6 @@ else if (requestCode == REQUEST_CAMERA) } } - @Override - protected void onDestroy() { - if (!mIsMonitoring) - { - mFragmentCamera.stopCamera(); - } - super.onDestroy(); - } - private void initTimer() { txtTimer.setTextColor(getResources().getColor(R.color.colorAccent)); cTimer = new CountDownTimer((preferences.getTimerDelay()) * 1000, 1000) { diff --git a/src/main/java/org/havenapp/main/ui/CameraConfigureActivity.java b/src/main/java/org/havenapp/main/ui/CameraConfigureActivity.java index 1a2c2c78..f1f6d9b5 100644 --- a/src/main/java/org/havenapp/main/ui/CameraConfigureActivity.java +++ b/src/main/java/org/havenapp/main/ui/CameraConfigureActivity.java @@ -26,17 +26,16 @@ import android.view.MenuItem; import android.view.View; import android.widget.TextView; -import android.widget.Toast; - -import org.havenapp.main.PreferenceManager; -import org.havenapp.main.R; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import me.angrybyte.numberpicker.listener.OnValueChangeListener; + +import org.havenapp.main.PreferenceManager; +import org.havenapp.main.R; + import me.angrybyte.numberpicker.view.ActualNumberPicker; @@ -111,7 +110,6 @@ else if (camera.equals(PreferenceManager.BACK)) public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - mFragment.stopCamera(); finish(); break; } @@ -124,7 +122,6 @@ public boolean onOptionsItemSelected(MenuItem item) { */ @Override public void onBackPressed() { - mFragment.stopCamera(); finish(); } diff --git a/src/main/java/org/havenapp/main/ui/CameraFragment.java b/src/main/java/org/havenapp/main/ui/CameraFragment.java index 2edaef24..4d9b8fa8 100644 --- a/src/main/java/org/havenapp/main/ui/CameraFragment.java +++ b/src/main/java/org/havenapp/main/ui/CameraFragment.java @@ -8,20 +8,16 @@ */ package org.havenapp.main.ui; -import android.content.BroadcastReceiver; -import android.content.Context; import android.content.Intent; -import android.content.IntentFilter; -import android.graphics.Bitmap; import android.hardware.SensorEvent; import android.os.Bundle; -import android.os.Handler; -import android.os.Message; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; -import android.widget.TextView; + +import androidx.fragment.app.Fragment; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.otaliastudios.cameraview.Audio; import com.otaliastudios.cameraview.CameraView; @@ -30,9 +26,6 @@ import org.havenapp.main.R; import org.havenapp.main.model.EventTrigger; -import androidx.fragment.app.Fragment; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; - public final class CameraFragment extends Fragment { private CameraViewHolder cameraViewHolder; @@ -83,12 +76,6 @@ public void updateCamera () } } - /** - * Not required. - */ - @Deprecated - public void stopCamera () { } - public void initCamera () { From ba89c2d38cb30b4aa93ac3c17b7360152cd3d30f Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Sun, 5 May 2019 23:56:28 +0530 Subject: [PATCH 07/11] Update dependencies - Among others this updates materialdatetimepicker to 4.2.0 which fixes a memory leak Signed-off-by: Arka Prava Basu --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 95b6ae1c..91c35f72 100644 --- a/build.gradle +++ b/build.gradle @@ -141,11 +141,11 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.preference:preference:1.1.0-alpha03' + implementation 'androidx.preference:preference:1.1.0-alpha04' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.annotation:annotation:1.0.1' + implementation 'androidx.annotation:annotation:1.0.2' implementation 'com.google.android.material:material:1.0.0' - implementation 'com.wdullaer:materialdatetimepicker:4.1.1' + implementation 'com.wdullaer:materialdatetimepicker:4.2.0' implementation 'com.github.guardianproject:signal-cli-android:v0.6.0-android-beta-1' implementation 'net.the4thdimension:audio-wife:1.0.3' implementation 'com.github.AppIntro:AppIntro:v5.1.0' From e8e972b11a5f0871bb1f213eb3da200e03c16a0f Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Tue, 14 May 2019 22:58:01 +0530 Subject: [PATCH 08/11] Remove Leak Canary dependency - keep this app dependency free; can be added in debug builds whenever another investigation is required Signed-off-by: Arka Prava Basu --- build.gradle | 6 ------ src/main/java/org/havenapp/main/HavenApp.java | 7 ------- 2 files changed, 13 deletions(-) diff --git a/build.gradle b/build.gradle index 91c35f72..65a29ea5 100644 --- a/build.gradle +++ b/build.gradle @@ -188,10 +188,4 @@ dependencies { // new camera view: https://github.com/natario1/CameraView implementation 'com.otaliastudios:cameraview:2.0.0-beta04' - - // leak canary - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3' - releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' - // Optional, if you use support library fragments: - debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3' } diff --git a/src/main/java/org/havenapp/main/HavenApp.java b/src/main/java/org/havenapp/main/HavenApp.java index 9847f211..ab61507e 100644 --- a/src/main/java/org/havenapp/main/HavenApp.java +++ b/src/main/java/org/havenapp/main/HavenApp.java @@ -23,7 +23,6 @@ import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.imagepipeline.core.ImagePipelineConfig; import com.facebook.imagepipeline.decoder.SimpleProgressiveJpegConfig; -import com.squareup.leakcanary.LeakCanary; import org.havenapp.main.database.HavenEventDB; import org.havenapp.main.service.HavenJobCreator; @@ -52,12 +51,6 @@ public class HavenApp extends MultiDexApplication { @Override public void onCreate() { super.onCreate(); - if (LeakCanary.isInAnalyzerProcess(this)) { - // This process is dedicated to LeakCanary for heap analysis. - // You should not init your app in this process. - return; - } - LeakCanary.install(this); mPrefs = new PreferenceManager(this); From 25581c4ccc1b0e9c472b4493b5524d039b461b38 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Fri, 17 Apr 2020 01:28:49 +0530 Subject: [PATCH 09/11] Update dependencies Signed-off-by: Arka Prava Basu --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index e3a60d5e..ce2b0960 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.72' repositories { google() jcenter() @@ -145,10 +145,10 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0" - implementation 'androidx.preference:preference:1.1.0' + implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.annotation:annotation:1.1.0' - implementation 'com.google.android.material:material:1.2.0-alpha03' + implementation 'com.google.android.material:material:1.2.0-alpha06' implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.wdullaer:materialdatetimepicker:4.2.3' implementation 'com.github.guardianproject:signal-cli-android:v0.6.0-android-beta-1' From 8716256966a934e9c7466f3db7f4473b7aa8a471 Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Sat, 18 Apr 2020 01:45:47 +0530 Subject: [PATCH 10/11] Add leak canary in debug builds Signed-off-by: Arka Prava Basu --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ce2b0960..5aee7a05 100644 --- a/build.gradle +++ b/build.gradle @@ -193,5 +193,5 @@ dependencies { // new camera view: https://github.com/natario1/CameraView implementation 'com.otaliastudios:cameraview:2.4.0' - + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2' } From b891062b234ff46beed8bff9e9e1a59338c99a9e Mon Sep 17 00:00:00 2001 From: Arka Prava Basu Date: Sat, 18 Apr 2020 18:55:36 +0530 Subject: [PATCH 11/11] Use HavenCameraView instead of CameraView - aims to solve https://github.com/guardianproject/haven/pull/395#issuecomment-497101853 - According to https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver [DefaultLifecycleObserver] should *always* be preferred over [androidx.lifecycle.LifecycleObserver] if we use Java 8. [CameraView] library targets Java 7 hence this implementation aims to ignore [androidx.lifecycle.OnLifecycleEvent] annotated methods in the super class and replace them with the callbacks implemeted in this sub class Signed-off-by: Arka Prava Basu --- build.gradle | 1 + .../main/ui/widget/HavenCameraView.kt | 51 +++++++++++++++++++ src/main/res/layout/camera_fragment.xml | 3 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/havenapp/main/ui/widget/HavenCameraView.kt diff --git a/build.gradle b/build.gradle index 5aee7a05..af3d3170 100644 --- a/build.gradle +++ b/build.gradle @@ -178,6 +178,7 @@ dependencies { kapt "android.arch.persistence.room:compiler:2.1.0" implementation "android.arch.lifecycle:runtime:2.1.0" implementation "android.arch.lifecycle:extensions:2.1.0" + implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0" testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test:runner:1.2.0' diff --git a/src/main/java/org/havenapp/main/ui/widget/HavenCameraView.kt b/src/main/java/org/havenapp/main/ui/widget/HavenCameraView.kt new file mode 100644 index 00000000..71a137d0 --- /dev/null +++ b/src/main/java/org/havenapp/main/ui/widget/HavenCameraView.kt @@ -0,0 +1,51 @@ +package org.havenapp.main.ui.widget + +import android.content.Context +import android.util.AttributeSet +import androidx.annotation.NonNull +import androidx.annotation.Nullable +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner +import com.otaliastudios.cameraview.CameraView + +/** + * A subclass of [CameraView] which implements [DefaultLifecycleObserver] + * + * According to https://developer.android.com/reference/androidx/lifecycle/DefaultLifecycleObserver + * [DefaultLifecycleObserver] should *always* be preferred over [androidx.lifecycle.LifecycleObserver] + * if we use Java 8. [CameraView] library targets Java 7 hence this implementation aims to ignore + * [androidx.lifecycle.OnLifecycleEvent] annotated methods in the super class and replace them with + * the callbacks implemeted in this sub class + */ +class HavenCameraView : CameraView, DefaultLifecycleObserver { + constructor(context: Context) : super(context) + + constructor(@NonNull context: Context, @Nullable attrs: AttributeSet) : super(context, attrs) + + override fun onCreate(owner: LifecycleOwner) { + super.onCreate(owner) + } + + override fun onResume(owner: LifecycleOwner) { + super.onResume(owner) + open() + } + + override fun onPause(owner: LifecycleOwner) { + close() + super.onPause(owner) + } + + override fun onStart(owner: LifecycleOwner) { + super.onStart(owner) + } + + override fun onStop(owner: LifecycleOwner) { + super.onStop(owner) + } + + override fun onDestroy(owner: LifecycleOwner) { + destroy() + super.onDestroy(owner) + } +} diff --git a/src/main/res/layout/camera_fragment.xml b/src/main/res/layout/camera_fragment.xml index ae9a742c..97a952c9 100644 --- a/src/main/res/layout/camera_fragment.xml +++ b/src/main/res/layout/camera_fragment.xml @@ -6,8 +6,7 @@ android:foreground="@color/translucentOverlay25"> -