Skip to content

Commit

Permalink
Changes to Enable 3A features
Browse files Browse the repository at this point in the history
  • Loading branch information
tdivy20 committed Feb 20, 2025
1 parent 6e2735d commit 040ff76
Show file tree
Hide file tree
Showing 35 changed files with 169 additions and 42 deletions.
2 changes: 1 addition & 1 deletion camera/MultiCameraApplication/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package {
}

android_app {
name: "MultiCameraApp",
name: "AdvancedMultiCameraApp",

static_libs: [
"androidx.legacy_legacy-support-v13",
Expand Down
2 changes: 1 addition & 1 deletion camera/MultiCameraApplication/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.intel.multicamera">
package="com.intel.AdvancedMultiCamera">

<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="33"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.content.Context;
import android.util.AttributeSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.app.Activity;
import android.app.Dialog;
Expand Down Expand Up @@ -149,6 +149,36 @@ private void ClickListeners(ImageButton PictureButton, ImageButton RecordButton,
CameraSplit(CameraSplit);
}

private void applyAdvancedSettingsToPreview() {
SharedPreferences sharedPreferences = mActivity.getPreferences(Context.MODE_PRIVATE);
boolean autoFocusEnabled = sharedPreferences.getBoolean("pref_auto_focus", true);
boolean autoExposureEnabled = sharedPreferences.getBoolean("pref_auto_exposure", true);
boolean autoWhiteBalanceEnabled = sharedPreferences.getBoolean("pref_auto_white_balance", true);
if (autoFocusEnabled) {
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
Log.d(TAG, "Auto Focus enabled");
}
else {
captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
Log.d(TAG, "Auto Focus disabled");
}
if (autoExposureEnabled) {
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
Log.d(TAG, "Auto Exposure enabled");
}
else {
captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
Log.d(TAG, "Auto Exposure disabled");
}
if (autoWhiteBalanceEnabled) {
captureRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
Log.d(TAG, "Auto White Balance enabled");
}
else {
captureRequestBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_OFF);
Log.d(TAG, "Auto White Balance disabled");
}
}

private void TakePicureOnClicked(ImageButton PictureButton) {
takePictureButton = PictureButton;
Expand Down Expand Up @@ -483,6 +513,7 @@ public void createCameraPreview() {
mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);

captureRequestBuilder.addTarget(surface);
applyAdvancedSettingsToPreview();

mCameraDevice.createCaptureSession(
outputSurfaces, new CameraCaptureSession.StateCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.app.AlertDialog;
import android.app.Dialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
Expand Down Expand Up @@ -53,7 +53,7 @@
import java.util.concurrent.TimeUnit;
import java.util.Objects;

import static com.intel.multicamera.MultiViewActivity.updateStorageSpace;
import static com.intel.AdvancedMultiCamera.MultiViewActivity.updateStorageSpace;

public class FullScreenActivity extends AppCompatActivity {
private static final String TAG = "FullScreenActivity";
Expand Down Expand Up @@ -93,7 +93,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

setContentView(R.layout.activity_full_screen);

Log.i("TAG", "fullscreen is called.");
mIsRecordingVideo = false;
mCameraInst = MultiCamera.getInstance();
mCameraSwitch = findViewById(R.id.camera_switch);
Expand Down Expand Up @@ -207,6 +207,7 @@ public void onClick(View v) {
bundle.putString("pref_resolution", "pref_resolution");
bundle.putString("video_list", "video_list");
bundle.putString("capture_list", "capture_list");
bundle.putString("advanced_list", "advanced_list");

Fragment = new SettingsPrefUtil();
Fragment.setArguments(bundle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.content.Context;
import android.provider.MediaStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.content.ContentValues;
import android.graphics.Camera;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.Manifest;
import android.app.Dialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.Manifest;
import android.app.AlertDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.app.Activity;
import android.app.Dialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.app.Activity;
import android.content.Intent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.content.Context;
import android.content.SharedPreferences;
Expand All @@ -33,6 +33,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.SwitchCompat;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragment;
Expand All @@ -42,6 +43,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import android.app.AlertDialog;

public class SettingsPrefUtil
extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
Expand Down Expand Up @@ -177,6 +179,47 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

setPreferencesFromResource(root_preferences, rootKey);
mCamcorderProfileNames = getResources().getStringArray(R.array.camcorder_profile_names);

Preference advancedSettingsPreference = findPreference("advanced_settings");

if (advancedSettingsPreference != null) {
advancedSettingsPreference.setOnPreferenceClickListener(preference -> {
showAdvancedSettingsDialog();
return true;
});
}
}
private void showAdvancedSettingsDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
LayoutInflater inflater = LayoutInflater.from(getContext());
View dialogView = inflater.inflate(R.layout.dialog_advanced_settings, null);
SwitchCompat switchAutoFocus = dialogView.findViewById(R.id.switch_auto_focus);
SwitchCompat switchAutoExposure = dialogView.findViewById(R.id.switch_auto_exposure);
SwitchCompat switchAutoWhiteBalance = dialogView.findViewById(R.id.switch_auto_white_balance);

SharedPreferences sharedPreferences = getActivity().getPreferences(Context.MODE_PRIVATE);

switchAutoFocus.setChecked(sharedPreferences.getBoolean("pref_auto_focus", false));
switchAutoExposure.setChecked(sharedPreferences.getBoolean("pref_auto_exposure", false));
switchAutoWhiteBalance.setChecked(sharedPreferences.getBoolean("pref_auto_white_balance", false));

builder.setView(dialogView)
.setTitle("Advanced Settings")
.setPositiveButton("OK", (dialog, which) -> {
SharedPreferences.Editor editor = sharedPreferences.edit();

editor.putBoolean("pref_auto_focus", switchAutoFocus.isChecked());
editor.putBoolean("pref_auto_exposure", switchAutoExposure.isChecked());
editor.putBoolean("pref_auto_white_balance", switchAutoWhiteBalance.isChecked());

editor.apply();

Log.d(TAG, "Auto Focus: " + switchAutoFocus.isChecked());
Log.d(TAG, "Auto Exposure: " + switchAutoExposure.isChecked());
Log.d(TAG, "Auto White Balance: " + switchAutoWhiteBalance.isChecked());
})
.setNegativeButton("Cancel", null)
.show();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.Manifest;
import android.app.Dialog;
Expand Down Expand Up @@ -51,7 +51,7 @@
import java.util.Objects;

import static android.hardware.usb.UsbManager.ACTION_USB_DEVICE_ATTACHED;
import static com.intel.multicamera.MultiViewActivity.updateStorageSpace;
import static com.intel.AdvancedMultiCamera.MultiViewActivity.updateStorageSpace;

public class SingleCameraActivity extends AppCompatActivity {
private static final String TAG = "SingleCameraActivity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.graphics.SurfaceTexture;
import android.opengl.GLES20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.app.Activity;
import android.app.AlertDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.annotation.SuppressLint;
import android.app.Activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package com.intel.multicamera;
package com.intel.AdvancedMultiCamera;

import android.app.Activity;
import android.content.ContentValues;
Expand Down Expand Up @@ -58,7 +58,7 @@
import java.util.Arrays;
import java.util.List;

import static com.intel.multicamera.SettingsPrefUtil.SIZE_HD;
import static com.intel.AdvancedMultiCamera.SettingsPrefUtil.SIZE_HD;

public class VideoRecord implements MediaRecorder.OnErrorListener, MediaRecorder.OnInfoListener{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.intel.multicamera.FullScreenActivity">
tools:context="com.intel.AdvancedMultiCamera.FullScreenActivity">

<FrameLayout android:id="@+id/control1"
android:layout_width="match_parent"
Expand All @@ -16,13 +16,13 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.intel.multicamera.AutoFitTextureView
<com.intel.AdvancedMultiCamera.AutoFitTextureView
android:id="@+id/textureview"
android:layout_width="match_parent"
android:layout_height="match_parent" />


<com.intel.multicamera.RoundedThumbnailView
<com.intel.AdvancedMultiCamera.RoundedThumbnailView
android:id="@+id/rounded_thumbnail_view"
android:layout_width="146dp"
android:layout_height="198dp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:layout_height="match_parent">


<com.intel.multicamera.AutoFitTextureView
<com.intel.AdvancedMultiCamera.AutoFitTextureView
android:id="@+id/textureview0"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.intel.multicamera.PhotoPreviewActivity">
tools:context="com.intel.AdvancedMultiCamera.PhotoPreviewActivity">

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 040ff76

Please sign in to comment.