use of android.widget.ZoomControls in project OpenCamera by ageback.
the class MainActivity method cameraSetup.
void cameraSetup() {
long debug_time = 0;
if (MyDebug.LOG) {
Log.d(TAG, "cameraSetup");
debug_time = System.currentTimeMillis();
}
if (this.supportsForceVideo4K() && preview.usingCamera2API()) {
if (MyDebug.LOG)
Log.d(TAG, "using Camera2 API, so can disable the force 4K option");
this.disableForceVideo4K();
}
if (this.supportsForceVideo4K() && preview.getVideoQualityHander().getSupportedVideoSizes() != null) {
for (CameraController.Size size : preview.getVideoQualityHander().getSupportedVideoSizes()) {
if (size.width >= 3840 && size.height >= 2160) {
if (MyDebug.LOG)
Log.d(TAG, "camera natively supports 4K, so can disable the force option");
this.disableForceVideo4K();
}
}
}
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after handling Force 4K option: " + (System.currentTimeMillis() - debug_time));
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
{
if (MyDebug.LOG)
Log.d(TAG, "set up zoom");
if (MyDebug.LOG)
Log.d(TAG, "has_zoom? " + preview.supportsZoom());
ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoom);
SeekBar zoomSeekBar = (SeekBar) findViewById(R.id.zoom_seekbar);
if (preview.supportsZoom()) {
if (sharedPreferences.getBoolean(PreferenceKeys.ShowZoomControlsPreferenceKey, false)) {
zoomControls.setIsZoomInEnabled(true);
zoomControls.setIsZoomOutEnabled(true);
zoomControls.setZoomSpeed(20);
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
public void onClick(View v) {
zoomIn();
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
public void onClick(View v) {
zoomOut();
}
});
if (!mainUI.inImmersiveMode()) {
zoomControls.setVisibility(View.VISIBLE);
}
} else {
zoomControls.setVisibility(View.GONE);
}
// clear an existing listener - don't want to call the listener when setting up the progress bar to match the existing state
zoomSeekBar.setOnSeekBarChangeListener(null);
zoomSeekBar.setMax(preview.getMaxZoom());
zoomSeekBar.setProgress(preview.getMaxZoom() - preview.getCameraController().getZoom());
zoomSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (MyDebug.LOG)
Log.d(TAG, "zoom onProgressChanged: " + progress);
// note we zoom even if !fromUser, as various other UI controls (multitouch, volume key zoom, -/+ zoomcontrol)
// indirectly set zoom via this method, from setting the zoom slider
preview.zoomTo(preview.getMaxZoom() - progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
if (sharedPreferences.getBoolean(PreferenceKeys.ShowZoomSliderControlsPreferenceKey, true)) {
if (!mainUI.inImmersiveMode()) {
zoomSeekBar.setVisibility(View.VISIBLE);
}
} else {
// should be INVISIBLE not GONE, as the focus_seekbar is aligned to be left to this
zoomSeekBar.setVisibility(View.INVISIBLE);
}
} else {
zoomControls.setVisibility(View.GONE);
zoomSeekBar.setVisibility(View.GONE);
}
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting up zoom: " + (System.currentTimeMillis() - debug_time));
View takePhotoButton = findViewById(R.id.take_photo);
if (sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true)) {
if (!mainUI.inImmersiveMode()) {
takePhotoButton.setVisibility(View.VISIBLE);
}
} else {
takePhotoButton.setVisibility(View.INVISIBLE);
}
}
{
if (MyDebug.LOG)
Log.d(TAG, "set up manual focus");
SeekBar focusSeekBar = (SeekBar) findViewById(R.id.focus_seekbar);
// clear an existing listener - don't want to call the listener when setting up the progress bar to match the existing state
focusSeekBar.setOnSeekBarChangeListener(null);
setProgressSeekbarScaled(focusSeekBar, 0.0, preview.getMinimumFocusDistance(), preview.getCameraController().getFocusDistance());
focusSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
double frac = progress / (double) manual_n;
double scaling = MainActivity.seekbarScaling(frac);
float focus_distance = (float) (scaling * preview.getMinimumFocusDistance());
preview.setFocusDistance(focus_distance);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
final int visibility = preview.getCurrentFocusValue() != null && this.getPreview().getCurrentFocusValue().equals("focus_mode_manual2") ? View.VISIBLE : View.GONE;
focusSeekBar.setVisibility(visibility);
}
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting up manual focus: " + (System.currentTimeMillis() - debug_time));
{
if (preview.supportsISORange()) {
if (MyDebug.LOG)
Log.d(TAG, "set up iso");
SeekBar iso_seek_bar = ((SeekBar) findViewById(R.id.iso_seekbar));
// clear an existing listener - don't want to call the listener when setting up the progress bar to match the existing state
iso_seek_bar.setOnSeekBarChangeListener(null);
setProgressSeekbarExponential(iso_seek_bar, preview.getMinimumISO(), preview.getMaximumISO(), preview.getCameraController().getISO());
iso_seek_bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (MyDebug.LOG)
Log.d(TAG, "iso seekbar onProgressChanged: " + progress);
double frac = progress / (double) manual_n;
if (MyDebug.LOG)
Log.d(TAG, "exposure_time frac: " + frac);
/*double scaling = MainActivity.seekbarScaling(frac);
if( MyDebug.LOG )
Log.d(TAG, "exposure_time scaling: " + scaling);
int min_iso = preview.getMinimumISO();
int max_iso = preview.getMaximumISO();
int iso = min_iso + (int)(scaling * (max_iso - min_iso));*/
int min_iso = preview.getMinimumISO();
int max_iso = preview.getMaximumISO();
int iso = (int) exponentialScaling(frac, min_iso, max_iso);
preview.setISO(iso);
mainUI.updateSelectedISOButton();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
if (preview.supportsExposureTime()) {
if (MyDebug.LOG)
Log.d(TAG, "set up exposure time");
SeekBar exposure_time_seek_bar = ((SeekBar) findViewById(R.id.exposure_time_seekbar));
// clear an existing listener - don't want to call the listener when setting up the progress bar to match the existing state
exposure_time_seek_bar.setOnSeekBarChangeListener(null);
setProgressSeekbarExponential(exposure_time_seek_bar, preview.getMinimumExposureTime(), preview.getMaximumExposureTime(), preview.getCameraController().getExposureTime());
exposure_time_seek_bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (MyDebug.LOG)
Log.d(TAG, "exposure_time seekbar onProgressChanged: " + progress);
double frac = progress / (double) manual_n;
if (MyDebug.LOG)
Log.d(TAG, "exposure_time frac: " + frac);
// long exposure_time = min_exposure_time + (long)(frac * (max_exposure_time - min_exposure_time));
// double exposure_time_r = min_exposure_time_r + (frac * (max_exposure_time_r - min_exposure_time_r));
// long exposure_time = (long)(1.0 / exposure_time_r);
// we use the formula: [100^(percent/100) - 1]/99.0 rather than a simple linear scaling
/*double scaling = MainActivity.seekbarScaling(frac);
if( MyDebug.LOG )
Log.d(TAG, "exposure_time scaling: " + scaling);
long min_exposure_time = preview.getMinimumExposureTime();
long max_exposure_time = preview.getMaximumExposureTime();
long exposure_time = min_exposure_time + (long)(scaling * (max_exposure_time - min_exposure_time));*/
long min_exposure_time = preview.getMinimumExposureTime();
long max_exposure_time = preview.getMaximumExposureTime();
long exposure_time = exponentialScaling(frac, min_exposure_time, max_exposure_time);
preview.setExposureTime(exposure_time);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
}
setManualWBSeekbar();
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting up iso: " + (System.currentTimeMillis() - debug_time));
{
if (preview.supportsExposures()) {
if (MyDebug.LOG)
Log.d(TAG, "set up exposure compensation");
final int min_exposure = preview.getMinimumExposure();
SeekBar exposure_seek_bar = ((SeekBar) findViewById(R.id.exposure_seekbar));
// clear an existing listener - don't want to call the listener when setting up the progress bar to match the existing state
exposure_seek_bar.setOnSeekBarChangeListener(null);
exposure_seek_bar.setMax(preview.getMaximumExposure() - min_exposure);
exposure_seek_bar.setProgress(preview.getCurrentExposure() - min_exposure);
exposure_seek_bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (MyDebug.LOG)
Log.d(TAG, "exposure seekbar onProgressChanged: " + progress);
preview.setExposure(min_exposure + progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
ZoomControls seek_bar_zoom = (ZoomControls) findViewById(R.id.exposure_seekbar_zoom);
seek_bar_zoom.setOnZoomInClickListener(new View.OnClickListener() {
public void onClick(View v) {
changeExposure(1);
}
});
seek_bar_zoom.setOnZoomOutClickListener(new View.OnClickListener() {
public void onClick(View v) {
changeExposure(-1);
}
});
}
}
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting up exposure: " + (System.currentTimeMillis() - debug_time));
View exposureButton = findViewById(R.id.exposure);
exposureButton.setVisibility(supportsExposureButton() && !mainUI.inImmersiveMode() ? View.VISIBLE : View.GONE);
ImageButton exposureLockButton = (ImageButton) findViewById(R.id.exposure_lock);
exposureLockButton.setVisibility(preview.supportsExposureLock() && !mainUI.inImmersiveMode() ? View.VISIBLE : View.GONE);
if (preview.supportsExposureLock()) {
exposureLockButton.setImageResource(preview.isExposureLocked() ? R.drawable.exposure_locked : R.drawable.exposure_unlocked);
}
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting exposure lock button: " + (System.currentTimeMillis() - debug_time));
// needed so that the icon is set right even if no flash mode is set when starting up camera (e.g., switching to front camera with no flash)
mainUI.setPopupIcon();
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting popup icon: " + (System.currentTimeMillis() - debug_time));
mainUI.setTakePhotoIcon();
mainUI.setSwitchCameraContentDescription();
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: time after setting take photo icon: " + (System.currentTimeMillis() - debug_time));
if (!block_startup_toast) {
this.showPhotoVideoToast(false);
}
block_startup_toast = false;
if (MyDebug.LOG)
Log.d(TAG, "cameraSetup: total time for cameraSetup: " + (System.currentTimeMillis() - debug_time));
}
use of android.widget.ZoomControls in project open-event-android by fossasia.
the class OSMapFragment method populateMap.
private void populateMap() {
if (!mayRequestStorageForOfflineMap())
return;
final MapView mapView = (MapView) rootView.findViewById(R.id.mapview);
final ZoomControls zoomControls = (ZoomControls) rootView.findViewById(R.id.zoomControls);
Resources resources = getContext().getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
zoomControls.setPadding(0, 0, 0, resources.getDimensionPixelSize(resourceId) + 4);
}
mapView.setBuiltInZoomControls(false);
mapView.setMultiTouchControls(true);
event = realmRepo.getEvent();
event.addChangeListener(new RealmChangeListener<RealmModel>() {
@Override
public void onChange(RealmModel realmModel) {
showEvent();
}
});
GeoPoint geoPoint = new GeoPoint(getDestinationLatitude(), getDestinationLongitude());
mapView.getController().setCenter(geoPoint);
mapView.getController().setZoom(17);
mapView.setMaxZoomLevel(20);
mapView.setMinZoomLevel(3);
OverlayItem position = new OverlayItem(getDestinationName(), "Location", geoPoint);
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mapView.getController().zoomIn();
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mapView.getController().zoomOut();
}
});
ArrayList<OverlayItem> items = new ArrayList<>();
items.add(position);
mapView.getOverlays().add(new ItemizedIconOverlay<>(items, new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemSingleTapUp(int index, OverlayItem item) {
return false;
}
@Override
public boolean onItemLongPress(int index, OverlayItem item) {
return false;
}
}, new DefaultResourceProxyImpl(getActivity())));
mapView.invalidate();
}
use of android.widget.ZoomControls in project Zong by Xenoage.
the class ScoreActivity method registerListeners.
private void registerListeners() {
// zoom buttons
final ZoomControls zoomControls = (ZoomControls) findViewById(R.id.score_zoom);
zoomControls.setOnZoomInClickListener(view -> {
if (currentScalingIndex + 1 < scalings.length) {
currentScalingIndex++;
updateScoreView();
// enable/disable buttons
zoomControls.setIsZoomInEnabled(currentScalingIndex + 1 < scalings.length);
zoomControls.setIsZoomOutEnabled(true);
}
});
zoomControls.setOnZoomOutClickListener(view -> {
if (currentScalingIndex > 0) {
currentScalingIndex--;
updateScoreView();
// enable/disable buttons
zoomControls.setIsZoomInEnabled(true);
zoomControls.setIsZoomOutEnabled(currentScalingIndex > 0);
}
});
// play button
final Button playbackButton = (Button) findViewById(R.id.score_playback);
playbackButton.setOnClickListener(view -> {
playback();
playbackButton.setText(playing ? "Stop" : "Play");
});
}
use of android.widget.ZoomControls in project OpenCamera by ageback.
the class MainActivityTest method testZoom.
/* Tests zoom.
*/
public void testZoom() {
Log.d(TAG, "testZoom");
setToDefault();
if (!mPreview.supportsZoom()) {
Log.d(TAG, "zoom not supported");
return;
}
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity);
SharedPreferences.Editor editor = settings.edit();
final ZoomControls zoomControls = (ZoomControls) mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom);
assertTrue(zoomControls.getVisibility() == View.GONE);
final SeekBar zoomSeekBar = (SeekBar) mActivity.findViewById(net.sourceforge.opencamera.R.id.zoom_seekbar);
assertTrue(zoomSeekBar.getVisibility() == View.VISIBLE);
int max_zoom = mPreview.getMaxZoom();
assertTrue(zoomSeekBar.getMax() == max_zoom);
Log.d(TAG, "zoomSeekBar progress = " + zoomSeekBar.getProgress());
Log.d(TAG, "actual zoom = " + mPreview.getCameraController().getZoom());
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
if (mPreview.supportsFocus()) {
assertTrue(!mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() == null);
assertTrue(mPreview.getCameraController().getMeteringAreas() == null);
// touch to auto-focus with focus area
TouchUtils.clickView(MainActivityTest.this, mPreview.getView());
assertTrue(mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() != null);
assertTrue(mPreview.getCameraController().getFocusAreas().size() == 1);
assertTrue(mPreview.getCameraController().getMeteringAreas() != null);
assertTrue(mPreview.getCameraController().getMeteringAreas().size() == 1);
}
int zoom = mPreview.getCameraController().getZoom();
// now test multitouch zoom
mPreview.scaleZoom(2.0f);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() > zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
mPreview.scaleZoom(0.5f);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
// test to max/min
mPreview.scaleZoom(10000.0f);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to max_zoom " + max_zoom);
assertTrue(mPreview.getCameraController().getZoom() == max_zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
mPreview.scaleZoom(1.0f / 10000.0f);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zero");
assertTrue(mPreview.getCameraController().getZoom() == 0);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
// use seekbar to zoom
Log.d(TAG, "zoom to max");
Log.d(TAG, "progress was: " + zoomSeekBar.getProgress());
zoomSeekBar.setProgress(0);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to max_zoom " + max_zoom);
assertTrue(mPreview.getCameraController().getZoom() == max_zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
if (mPreview.supportsFocus()) {
// check that focus areas cleared
assertTrue(!mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() == null);
assertTrue(mPreview.getCameraController().getMeteringAreas() == null);
}
Log.d(TAG, "zoom to min");
Log.d(TAG, "progress was: " + zoomSeekBar.getProgress());
zoomSeekBar.setProgress(zoomSeekBar.getMax());
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
// use volume keys to zoom in/out
editor.putString(PreferenceKeys.VolumeKeysPreferenceKey, "volume_zoom");
editor.apply();
Log.d(TAG, "zoom in with volume keys");
this.getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_UP);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom + 1);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
Log.d(TAG, "zoom out with volume keys");
this.getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_VOLUME_DOWN);
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
// now test with -/+ controls
editor.putBoolean(PreferenceKeys.ShowZoomControlsPreferenceKey, true);
editor.apply();
updateForSettings();
assertTrue(zoomControls.getVisibility() == View.VISIBLE);
Log.d(TAG, "zoom in");
mActivity.zoomIn();
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom + 1);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
if (mPreview.supportsFocus()) {
// check that focus areas cleared
assertTrue(!mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() == null);
assertTrue(mPreview.getCameraController().getMeteringAreas() == null);
// touch to auto-focus with focus area
TouchUtils.clickView(MainActivityTest.this, mPreview.getView());
assertTrue(mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() != null);
assertTrue(mPreview.getCameraController().getFocusAreas().size() == 1);
assertTrue(mPreview.getCameraController().getMeteringAreas() != null);
assertTrue(mPreview.getCameraController().getMeteringAreas().size() == 1);
}
Log.d(TAG, "zoom out");
mActivity.zoomOut();
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
if (mPreview.supportsFocus()) {
// check that focus areas cleared
assertTrue(!mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() == null);
assertTrue(mPreview.getCameraController().getMeteringAreas() == null);
// touch to auto-focus with focus area
TouchUtils.clickView(MainActivityTest.this, mPreview.getView());
assertTrue(mPreview.hasFocusArea());
assertTrue(mPreview.getCameraController().getFocusAreas() != null);
assertTrue(mPreview.getCameraController().getFocusAreas().size() == 1);
assertTrue(mPreview.getCameraController().getMeteringAreas() != null);
assertTrue(mPreview.getCameraController().getMeteringAreas().size() == 1);
}
// now test with slider invisible
editor.putBoolean(PreferenceKeys.ShowZoomSliderControlsPreferenceKey, false);
editor.apply();
updateForSettings();
assertTrue(zoomSeekBar.getVisibility() == View.INVISIBLE);
Log.d(TAG, "zoom in");
mActivity.zoomIn();
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom + 1);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
Log.d(TAG, "zoom out");
mActivity.zoomOut();
this.getInstrumentation().waitForIdleSync();
Log.d(TAG, "compare actual zoom " + mPreview.getCameraController().getZoom() + " to zoom " + zoom);
assertTrue(mPreview.getCameraController().getZoom() == zoom);
assertTrue(max_zoom - zoomSeekBar.getProgress() == mPreview.getCameraController().getZoom());
}
use of android.widget.ZoomControls in project OpenCamera by ageback.
the class MainUI method setupExposureUI.
private void setupExposureUI() {
if (MyDebug.LOG)
Log.d(TAG, "setupExposureUI");
test_ui_buttons.clear();
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity);
final Preview preview = main_activity.getPreview();
View sliders_container = main_activity.findViewById(R.id.sliders_container);
sliders_container.setVisibility(View.VISIBLE);
ViewGroup iso_buttons_container = (ViewGroup) main_activity.findViewById(R.id.iso_buttons);
iso_buttons_container.removeAllViews();
List<String> supported_isos;
if (preview.supportsISORange()) {
if (MyDebug.LOG)
Log.d(TAG, "supports ISO range");
int min_iso = preview.getMinimumISO();
int max_iso = preview.getMaximumISO();
List<String> values = new ArrayList<>();
values.add(CameraController.ISO_DEFAULT);
values.add(manual_iso_value);
// must match where we place the manual button!
iso_button_manual_index = 1;
int[] iso_values = { 50, 100, 200, 400, 800, 1600, 3200, 6400 };
values.add("" + min_iso);
for (int iso_value : iso_values) {
if (iso_value > min_iso && iso_value < max_iso) {
values.add("" + iso_value);
}
}
values.add("" + max_iso);
supported_isos = values;
} else {
supported_isos = preview.getSupportedISOs();
iso_button_manual_index = -1;
}
String current_iso = sharedPreferences.getString(PreferenceKeys.ISOPreferenceKey, CameraController.ISO_DEFAULT);
// if the manual ISO value isn't one of the "preset" values, then instead highlight the manual ISO icon
if (!current_iso.equals(CameraController.ISO_DEFAULT) && supported_isos != null && supported_isos.contains(manual_iso_value) && !supported_isos.contains(current_iso))
current_iso = manual_iso_value;
// n.b., we hardcode the string "ISO" as this isn't a user displayed string, rather it's used to filter out "ISO" included in old Camera API parameters
iso_buttons = PopupView.createButtonOptions(iso_buttons_container, main_activity, 280, test_ui_buttons, supported_isos, -1, -1, "ISO", false, current_iso, "TEST_ISO", new PopupView.ButtonOptionsPopupListener() {
@Override
public void onClick(String option) {
if (MyDebug.LOG)
Log.d(TAG, "clicked iso: " + option);
SharedPreferences.Editor editor = sharedPreferences.edit();
String old_iso = sharedPreferences.getString(PreferenceKeys.ISOPreferenceKey, CameraController.ISO_DEFAULT);
if (MyDebug.LOG)
Log.d(TAG, "old_iso: " + old_iso);
editor.putString(PreferenceKeys.ISOPreferenceKey, option);
String toast_option = option;
if (preview.supportsISORange()) {
if (option.equals(CameraController.ISO_DEFAULT)) {
if (MyDebug.LOG)
Log.d(TAG, "switched from manual to auto iso");
// also reset exposure time when changing from manual to auto from the popup menu:
editor.putLong(PreferenceKeys.ExposureTimePreferenceKey, CameraController.EXPOSURE_TIME_DEFAULT);
editor.apply();
main_activity.updateForSettings("ISO: " + toast_option);
} else if (old_iso.equals(CameraController.ISO_DEFAULT)) {
if (MyDebug.LOG)
Log.d(TAG, "switched from auto to manual iso");
if (option.equals("m")) {
// if we used the generic "manual", then instead try to preserve the current iso if it exists
if (preview.getCameraController() != null && preview.getCameraController().captureResultHasIso()) {
int iso = preview.getCameraController().captureResultIso();
if (MyDebug.LOG)
Log.d(TAG, "apply existing iso of " + iso);
editor.putString(PreferenceKeys.ISOPreferenceKey, "" + iso);
toast_option = "" + iso;
} else {
if (MyDebug.LOG)
Log.d(TAG, "no existing iso available");
// use a default
final int iso = 800;
editor.putString(PreferenceKeys.ISOPreferenceKey, "" + iso);
toast_option = "" + iso;
}
}
// if changing from auto to manual, preserve the current exposure time if it exists
if (preview.getCameraController() != null && preview.getCameraController().captureResultHasExposureTime()) {
long exposure_time = preview.getCameraController().captureResultExposureTime();
if (MyDebug.LOG)
Log.d(TAG, "apply existing exposure time of " + exposure_time);
editor.putLong(PreferenceKeys.ExposureTimePreferenceKey, exposure_time);
} else {
if (MyDebug.LOG)
Log.d(TAG, "no existing exposure time available");
}
editor.apply();
main_activity.updateForSettings("ISO: " + toast_option);
} else {
if (MyDebug.LOG)
Log.d(TAG, "changed manual iso");
if (option.equals("m")) {
// if user selected the generic "manual", then just keep the previous non-ISO option
if (MyDebug.LOG)
Log.d(TAG, "keep existing iso of " + old_iso);
editor.putString(PreferenceKeys.ISOPreferenceKey, "" + old_iso);
}
editor.apply();
int iso = preview.parseManualISOValue(option);
if (iso >= 0) {
// if changing between manual ISOs, no need to call updateForSettings, just change the ISO directly (as with changing the ISO via manual slider)
preview.setISO(iso);
updateSelectedISOButton();
}
}
} else {
editor.apply();
preview.getCameraController().setISO(option);
}
setupExposureUI();
}
});
if (supported_isos != null) {
View iso_container_view = main_activity.findViewById(R.id.iso_container);
iso_container_view.setVisibility(View.VISIBLE);
}
View exposure_seek_bar = main_activity.findViewById(R.id.exposure_container);
View manual_exposure_seek_bar = main_activity.findViewById(R.id.manual_exposure_container);
String iso_value = main_activity.getApplicationInterface().getISOPref();
if (main_activity.getPreview().usingCamera2API() && !iso_value.equals(CameraController.ISO_DEFAULT)) {
exposure_seek_bar.setVisibility(View.GONE);
// with Camera2 API, when using manual ISO we instead show sliders for ISO range and exposure time
if (main_activity.getPreview().supportsISORange()) {
manual_exposure_seek_bar.setVisibility(View.VISIBLE);
SeekBar exposure_time_seek_bar = ((SeekBar) main_activity.findViewById(R.id.exposure_time_seekbar));
if (main_activity.getPreview().supportsExposureTime()) {
exposure_time_seek_bar.setVisibility(View.VISIBLE);
} else {
exposure_time_seek_bar.setVisibility(View.GONE);
}
} else {
manual_exposure_seek_bar.setVisibility(View.GONE);
}
} else {
manual_exposure_seek_bar.setVisibility(View.GONE);
if (main_activity.getPreview().supportsExposures()) {
exposure_seek_bar.setVisibility(View.VISIBLE);
ZoomControls seek_bar_zoom = (ZoomControls) main_activity.findViewById(R.id.exposure_seekbar_zoom);
seek_bar_zoom.setVisibility(View.VISIBLE);
} else {
exposure_seek_bar.setVisibility(View.GONE);
}
}
View manual_white_balance_seek_bar = main_activity.findViewById(R.id.manual_white_balance_container);
if (main_activity.getPreview().supportsWhiteBalanceTemperature()) {
// we also show slider for manual white balance, if in that mode
String white_balance_value = main_activity.getApplicationInterface().getWhiteBalancePref();
if (main_activity.getPreview().usingCamera2API() && white_balance_value.equals("manual")) {
manual_white_balance_seek_bar.setVisibility(View.VISIBLE);
} else {
manual_white_balance_seek_bar.setVisibility(View.GONE);
}
} else {
manual_white_balance_seek_bar.setVisibility(View.GONE);
}
}
Aggregations