From 70c38645c19688865ea885598236c1edad952ddc Mon Sep 17 00:00:00 2001 From: GTripathee Date: Fri, 23 Jan 2026 11:02:27 +0100 Subject: [PATCH 01/10] refact: Resolve conficlt in expview the --- app/src/main/java/de/rwth_aachen/phyphox/ExpView.java | 11 ++++++----- .../de/rwth_aachen/phyphox/InteractiveGraphView.java | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/rwth_aachen/phyphox/ExpView.java b/app/src/main/java/de/rwth_aachen/phyphox/ExpView.java index 8afa6c326..f6f6c6314 100644 --- a/app/src/main/java/de/rwth_aachen/phyphox/ExpView.java +++ b/app/src/main/java/de/rwth_aachen/phyphox/ExpView.java @@ -23,6 +23,7 @@ import android.text.TextPaint; import android.text.method.DigitsKeyListener; import android.text.style.MetricAffectingSpan; +import android.transition.Visibility; import android.util.Log; import android.util.TypedValue; import android.view.ContextThemeWrapper; @@ -574,10 +575,10 @@ protected String createViewHTML(){ @Override //We just have to send calculated value and the unit to the textView protected void onMayReadFromBuffers(PhyphoxExperiment experiment) { + super.onMayReadFromBuffers(experiment); if (!needsUpdate) return; needsUpdate = false; - super.onMayReadFromBuffers(experiment); double x = experiment.getBuffer(inputs.get(0)).value; if (tv != null) { String vStr = ""; @@ -1398,10 +1399,10 @@ else if (!inputs.get(i).isEmpty) @Override protected void onMayReadFromBuffers(PhyphoxExperiment experiment) { + super.onMayReadFromBuffers(experiment); if (!needsUpdate) return; needsUpdate = false; - super.onMayReadFromBuffers(experiment); if(dynamicBuffer == null){ return; @@ -1912,10 +1913,10 @@ protected String createViewHTML(){ @Override protected void onMayReadFromBuffers(PhyphoxExperiment experiment) { + super.onMayReadFromBuffers(experiment); if (!needsUpdate) return; needsUpdate = false; - super.onMayReadFromBuffers(experiment); for (int i = 0; i < inputs.size(); i+=2) { if (inputs.size() > i+1) { DataBuffer x = experiment.getBuffer(inputs.get(i+1)); @@ -3347,10 +3348,10 @@ protected double getValue() { @Override protected void onMayReadFromBuffers(PhyphoxExperiment experiment) { + super.onMayReadFromBuffers(experiment); if (!needsUpdate || triggered || autoCompleteTextView == null) return; needsUpdate = false; - super.onMayReadFromBuffers(experiment); double x = experiment.getBuffer(inputs.get(0)).value; int index= -1; @@ -3694,10 +3695,10 @@ protected boolean onMayWriteToBuffers(PhyphoxExperiment experiment) { @Override protected void onMayReadFromBuffers(PhyphoxExperiment experiment) { + super.onMayReadFromBuffers(experiment); if (!needsUpdate || triggered) return; needsUpdate = false; - super.onMayReadFromBuffers(experiment); if (inputs.size() == 0) return; double value = experiment.getBuffer(inputs.get(0)).value; diff --git a/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java b/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java index d1b976f80..a56017437 100644 --- a/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java +++ b/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java @@ -867,7 +867,7 @@ public void spectroscopyUnCalibrated(SpectroscopyCalibrationManager manager) { @Override public void spectroscopyCalibrationDidStart(SpectroscopyCalibrationManager manager) { spectroscopyStatusLabel.setText(getResources().getString(R.string.spectroscopy_tap_first_point)); - spectroscopyStatusLabel.setVisibility(VISIBLE); + spectroscopyStatusLabel.setVisibility(GONE); clearCalibrationMarkers(); markerOverlayView.update(null, null); graphView.resetPicks(); From dfc0e85d52bb642263d31d454ea6e982b6d87955 Mon Sep 17 00:00:00 2001 From: GTripathee Date: Fri, 23 Jan 2026 11:09:59 +0100 Subject: [PATCH 02/10] refact: Remove the calibration status label from graph to make graph more clean, instead we can show the status from the infos and values view element, and control it with visibility attribute. --- .../phyphox/InteractiveGraphView.java | 19 ------------------- .../SpectroscopyCalibrationManager.java | 14 -------------- 2 files changed, 33 deletions(-) diff --git a/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java b/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java index a56017437..74d4c2e1a 100644 --- a/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java +++ b/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java @@ -100,7 +100,6 @@ public void set(float viewX, float viewY, float dataX, float dataY, float dataZ) TextView popupWindowText = null; MarkerOverlayView markerOverlayView; private SpectroscopyCalibrationManager spectroscopyCalibrationManager; - private TextView spectroscopyStatusLabel; private List calibrationMarkerViews = new ArrayList<>(); private boolean needsCalibrationMarkerUpdate = false; @@ -829,10 +828,6 @@ public void setCalibrationMode(SpectroscopyCalibrationManager.CalibrationMode ca return; } - spectroscopyStatusLabel = createStatusLabel(context); - spectroscopyStatusLabel.setText(getResources().getString(R.string.calibration_invalid)); - graphFrame.addView(spectroscopyStatusLabel); - if(spectroscopyCalibrationManager == null){ spectroscopyCalibrationManager = new SpectroscopyCalibrationManager(context, parent); spectroscopyCalibrationManager.setDelegate(this); @@ -858,16 +853,12 @@ public void setInterceptBuffer(DataBuffer interceptBuffer){ @Override public void spectroscopyUnCalibrated(SpectroscopyCalibrationManager manager) { - spectroscopyStatusLabel.setText(""); - spectroscopyStatusLabel.setVisibility(GONE); clearCalibrationMarkers(); markerOverlayView.update(null, null); } @Override public void spectroscopyCalibrationDidStart(SpectroscopyCalibrationManager manager) { - spectroscopyStatusLabel.setText(getResources().getString(R.string.spectroscopy_tap_first_point)); - spectroscopyStatusLabel.setVisibility(GONE); clearCalibrationMarkers(); markerOverlayView.update(null, null); graphView.resetPicks(); @@ -881,11 +872,9 @@ public void spectroscopyCalibrationDidUpdatePoints(SpectroscopyCalibrationManage switch (state) { case FIRST_POINT_SELECTED: - spectroscopyStatusLabel.setText(getResources().getString(R.string.spectroscopy_tap_second_point)); showCalibrationPointMarkers(points); break; case SECOND_POINT_SELECTED: - spectroscopyStatusLabel.setText(getResources().getString(R.string.spectroscopy_calculating)); showCalibrationPointMarkers(points); break; default: @@ -896,11 +885,6 @@ public void spectroscopyCalibrationDidUpdatePoints(SpectroscopyCalibrationManage @Override public void spectroscopyCalibrationDidComplete(SpectroscopyCalibrationManager manager, double slope, double intercept) { - String calibrationInfo = manager.getCalibrationInfo(); - if (calibrationInfo != null) { - spectroscopyStatusLabel.setText(calibrationInfo); - } - markerOverlayView.update(null, null); updateCalibrationParametersBuffer(slope,intercept); @@ -912,7 +896,6 @@ public void spectroscopyCalibrationDidComplete(SpectroscopyCalibrationManager ma @Override public void spectroscopyCalibrationDidReset(SpectroscopyCalibrationManager manager) { - spectroscopyStatusLabel.setText(getResources().getString(R.string.spectroscopy_tap_first_point)); clearCalibrationMarkers(); markerOverlayView.update(null, null); graphView.resetPicks(); @@ -934,8 +917,6 @@ public void spectroscopyCalibrationShouldPresentDialog(SpectroscopyCalibrationMa @Override public void spectroscopyDidFailWithError(SpectroscopyCalibrationManager manager, String error) { - spectroscopyStatusLabel.setText(getResources().getString(R.string.spectroscopy_calibration_failed)); - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(getResources().getString(R.string.error)) .setMessage(error) diff --git a/app/src/main/java/de/rwth_aachen/phyphox/SpectroscopyCalibrationManager.java b/app/src/main/java/de/rwth_aachen/phyphox/SpectroscopyCalibrationManager.java index 7a6acc44c..f94ed968c 100644 --- a/app/src/main/java/de/rwth_aachen/phyphox/SpectroscopyCalibrationManager.java +++ b/app/src/main/java/de/rwth_aachen/phyphox/SpectroscopyCalibrationManager.java @@ -254,20 +254,6 @@ public void resetCalibration() { } } - public String getCalibrationInfo() { - if (calibrationParameters == null) { - return null; - } - - DecimalFormat formatter = new DecimalFormat("#.####"); - formatter.setMinimumFractionDigits(2); - - String slopeStr = formatter.format(calibrationParameters.slope); - String interceptStr = formatter.format(calibrationParameters.intercept); - - return "Calibrated: a- " + slopeStr + ", b- " + interceptStr; - } - // Helper method for getting localized strings private String getString(String key) { int resId = context.getResources().getIdentifier(key, "string", context.getPackageName()); From 46ee1b0b3ce0856c4739c1778cf9a73995caa935 Mon Sep 17 00:00:00 2001 From: GTripathee Date: Mon, 26 Jan 2026 12:37:26 +0100 Subject: [PATCH 03/10] fix: when calibration mode is undefined, the flag must disable some feature. --- app/src/main/assets/remote | 2 +- .../de/rwth_aachen/phyphox/InteractiveGraphView.java | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/src/main/assets/remote b/app/src/main/assets/remote index 028f5655c..947bcd449 160000 --- a/app/src/main/assets/remote +++ b/app/src/main/assets/remote @@ -1 +1 @@ -Subproject commit 028f5655ce698fa41eece4c8f09354fd179293c0 +Subproject commit 947bcd449aa0eeaebcec50e58fa220f3fdfe07bf diff --git a/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java b/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java index 74d4c2e1a..0c1c4dd22 100644 --- a/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java +++ b/app/src/main/java/de/rwth_aachen/phyphox/InteractiveGraphView.java @@ -155,14 +155,6 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) { return true; case R.id.graph_tools_calibrate: removePopUpAndMarkerOverlayView(); - Log.d("Interactive", "calibrationMode"+calibrationMode); - Log.d("Interactive", "calibrationMarkerViews"+calibrationMarkerViews.size()); - if(calibrationMarkerViews.size() > 0){ - Log.d("Interactive", "calibrationMarkerViews"+calibrationMarkerViews.get(0).getVisibility()); - } - - Log.d("Interactive", "enableCalibrationMode"+enableCalibrationMode); - Log.d("Interactive", "marker"+marker.length); graphView.setTouchMode(GraphView.TouchMode.calibrate); if(!graphView.isSpectroscopyCalibrated) spectroscopyCalibrationManager.resetCalibration(); return true; @@ -825,6 +817,7 @@ public void setCalibrationMode(SpectroscopyCalibrationManager.CalibrationMode ca this.calibrationMode = calibrationMode; this.enableCalibrationMode = true; } else { + this.enableCalibrationMode = false; return; } From ebb84f6fe41bd6610694d6145ddf88168f58aca2 Mon Sep 17 00:00:00 2001 From: GTripathee Date: Tue, 27 Jan 2026 12:57:13 +0100 Subject: [PATCH 04/10] make the spectum orientation setting selection more clear from icons and the make the selection more descriptive by showing dialogs and toggles. --- .../phyphox/camera/ui/CameraPreviewScreen.kt | 98 ++++++++++++++++++- .../res/color/toggle_selector_background.xml | 5 + .../res/drawable/arrow_gradient_bottom.xml | 13 +++ .../main/res/drawable/arrow_gradient_left.xml | 13 +++ .../res/drawable/arrow_gradient_right.xml | 23 +++++ .../main/res/drawable/arrow_gradient_top.xml | 13 +++ .../res/layout/dialog_analysis_settings.xml | 97 ++++++++++++++++++ app/src/main/res/layout/fragment_camera.xml | 17 +++- app/src/main/res/values/strings.xml | 12 ++- 9 files changed, 284 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/color/toggle_selector_background.xml create mode 100644 app/src/main/res/drawable/arrow_gradient_bottom.xml create mode 100644 app/src/main/res/drawable/arrow_gradient_left.xml create mode 100644 app/src/main/res/drawable/arrow_gradient_right.xml create mode 100644 app/src/main/res/drawable/arrow_gradient_top.xml create mode 100644 app/src/main/res/layout/dialog_analysis_settings.xml diff --git a/app/src/main/java/de/rwth_aachen/phyphox/camera/ui/CameraPreviewScreen.kt b/app/src/main/java/de/rwth_aachen/phyphox/camera/ui/CameraPreviewScreen.kt index 1a2c17d3a..3c4aebb4c 100644 --- a/app/src/main/java/de/rwth_aachen/phyphox/camera/ui/CameraPreviewScreen.kt +++ b/app/src/main/java/de/rwth_aachen/phyphox/camera/ui/CameraPreviewScreen.kt @@ -11,6 +11,7 @@ import android.graphics.PorterDuff import android.graphics.RectF import android.os.Build import android.util.Log +import android.view.LayoutInflater import android.view.MotionEvent import android.view.Surface import android.view.TextureView @@ -20,9 +21,9 @@ import android.view.WindowManager import android.view.animation.AlphaAnimation import android.widget.AdapterView import android.widget.ArrayAdapter +import android.widget.Button import android.widget.FrameLayout import android.widget.ImageView -import android.widget.LinearLayout import android.widget.Spinner import android.widget.TextView import androidx.annotation.RequiresApi @@ -31,14 +32,12 @@ import androidx.appcompat.widget.LinearLayoutCompat import androidx.camera.core.CameraSelector.LENS_FACING_BACK import androidx.camera.core.CameraSelector.LENS_FACING_FRONT import androidx.core.content.ContextCompat -import androidx.core.view.get import androidx.core.view.isVisible import androidx.lifecycle.findViewTreeLifecycleOwner import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import androidx.transition.Visibility import com.google.android.material.button.MaterialButton import com.google.android.material.slider.Slider import com.google.common.util.concurrent.ListenableFuture @@ -68,6 +67,8 @@ import java.math.RoundingMode import java.text.DecimalFormat import kotlin.math.ln import kotlin.math.pow +import androidx.appcompat.app.AlertDialog +import com.google.android.material.button.MaterialButtonToggleGroup @RequiresApi(Build.VERSION_CODES.LOLLIPOP) @@ -95,6 +96,8 @@ class CameraPreviewScreen( private val buttonMinimize: ImageView = root.findViewById(R.id.imageMinimize) private val spinnerSpectrumOrientation: Spinner = root.findViewById(R.id.btnSelectSpectroscopyOrientation) + private val btnAnalysisSetting: MaterialButton = root.findViewById(R.id.imgAnalysisSetting) + private val txtAnalysisOrientation: TextView = root.findViewById(R.id.textSpec) private val lnrSpectrumOrientation: LinearLayoutCompat = root.findViewById(R.id.lnrSpectroscopyAnalysisControl) private val zoomSlider: Slider = root.findViewById(R.id.zoomSlider) @@ -159,6 +162,9 @@ class CameraPreviewScreen( var resizableState = ResizableViewModuleState.Normal + var isHorizontal = true + var isRedToBlue = false + init { initializeAndSetupCameraDimension() @@ -229,12 +235,76 @@ class CameraPreviewScreen( } if(cameraInput.isFeatureSpectroscopy()){ - Log.d("CameraPreviewScreen","isFeatSpec") + lnrSpectrumOrientation.visibility = View.VISIBLE + btnAnalysisSetting.setOnClickListener { openAnalysisConfigurationDialog() } createSpinnerForSpectrumOrientation() spinnerSpectrumOrientation.onItemSelectedListener = this } } + private fun openAnalysisConfigurationDialog() { + + val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_analysis_settings, null) + val btnBR: Button = dialogView.findViewById(R.id.btnBR) + val btnRB: Button = dialogView.findViewById(R.id.btnRB) + val axisToggle: MaterialButtonToggleGroup = dialogView.findViewById(R.id.axisToggle) + val directionToggle: MaterialButtonToggleGroup = dialogView.findViewById(R.id.directionToggle) + + fun updateLabels() { + if (isHorizontal) { + btnBR.text = context.resources.getString(R.string.spectrum_left_to_right) + btnRB.text = context.resources.getString(R.string.spectrum_right_to_left) + } else { + btnBR.text = context.resources.getString(R.string.spectrum_bottom_to_top) + btnRB.text = context.resources.getString(R.string.spectrum_top_to_bottom) + } + } + + fun applyChanges() { + val orientation = getSelectedSpectrumOrientation(isHorizontal, isRedToBlue) + cameraInput.changeSpectrumAnalysisOrientation(orientation) + + val iconRes = when (orientation) { + SpectrumOrientation.HORIZONTAL_RED_RIGHT -> R.drawable.arrow_gradient_right + SpectrumOrientation.VERTICAL_RED_UP -> R.drawable.arrow_gradient_bottom + SpectrumOrientation.HORIZONTAL_BLUE_RIGHT -> R.drawable.arrow_gradient_left + SpectrumOrientation.VERTICAL_BLUE_UP -> R.drawable.arrow_gradient_top + else -> R.drawable.arrow_gradient_right + } + btnAnalysisSetting.apply { + setIconResource(iconRes) + iconTint = null + } + } + + updateLabels() + + axisToggle.check(if (isHorizontal) R.id.btnHorizontal else R.id.btnVertical) + directionToggle.check(if (isRedToBlue) R.id.btnRB else R.id.btnBR) + + axisToggle.addOnButtonCheckedListener { _, checkedId, isChecked -> + if (isChecked) { + isHorizontal = (checkedId == R.id.btnHorizontal) + updateLabels() + applyChanges() + } + + } + + directionToggle.addOnButtonCheckedListener { _, checkedId, isChecked -> + if (isChecked) { + isRedToBlue = (checkedId == R.id.btnRB) + applyChanges() + } + } + + AlertDialog.Builder(context) + .setView(dialogView) + .setPositiveButton(context.resources.getString(R.string.ok)) { dialog, _ -> dialog.dismiss() } + .create() + .show() + } + fun setInteractive(interactive: Boolean) { if (interactive) { buttonMinimize.visibility = View.VISIBLE @@ -850,7 +920,6 @@ class CameraPreviewScreen( } fun createSpinnerForSpectrumOrientation(){ - lnrSpectrumOrientation.visibility = View.VISIBLE ArrayAdapter.createFromResource( context, R.array.spectroscopy_orientation_array, @@ -879,6 +948,25 @@ class CameraPreviewScreen( // Another interface callback. } + fun getSelectedSpectrumOrientation(isHorizontal: Boolean, isRedToBlue: Boolean) : SpectrumOrientation { + val orientation: SpectrumOrientation = if(isHorizontal){ + if(isRedToBlue){ + SpectrumOrientation.HORIZONTAL_BLUE_RIGHT + } else{ + SpectrumOrientation.HORIZONTAL_RED_RIGHT + } + + } else { + if(isRedToBlue){ + SpectrumOrientation.VERTICAL_RED_UP + } else{ + SpectrumOrientation.VERTICAL_BLUE_UP + } + } + return orientation; + + } + } diff --git a/app/src/main/res/color/toggle_selector_background.xml b/app/src/main/res/color/toggle_selector_background.xml new file mode 100644 index 000000000..6da491c36 --- /dev/null +++ b/app/src/main/res/color/toggle_selector_background.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/arrow_gradient_bottom.xml b/app/src/main/res/drawable/arrow_gradient_bottom.xml new file mode 100644 index 000000000..b912ca70b --- /dev/null +++ b/app/src/main/res/drawable/arrow_gradient_bottom.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/arrow_gradient_left.xml b/app/src/main/res/drawable/arrow_gradient_left.xml new file mode 100644 index 000000000..36aeedf84 --- /dev/null +++ b/app/src/main/res/drawable/arrow_gradient_left.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/arrow_gradient_right.xml b/app/src/main/res/drawable/arrow_gradient_right.xml new file mode 100644 index 000000000..b9cc956d1 --- /dev/null +++ b/app/src/main/res/drawable/arrow_gradient_right.xml @@ -0,0 +1,23 @@ + + + + + + + + + diff --git a/app/src/main/res/drawable/arrow_gradient_top.xml b/app/src/main/res/drawable/arrow_gradient_top.xml new file mode 100644 index 000000000..99fbeceba --- /dev/null +++ b/app/src/main/res/drawable/arrow_gradient_top.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/app/src/main/res/layout/dialog_analysis_settings.xml b/app/src/main/res/layout/dialog_analysis_settings.xml new file mode 100644 index 000000000..67053d63a --- /dev/null +++ b/app/src/main/res/layout/dialog_analysis_settings.xml @@ -0,0 +1,97 @@ + + + + + + + + + + +