use of net.sourceforge.opencamera.Preview.Preview in project OpenCamera by ageback.
the class DrawPreview method drawUI.
/**
* This includes drawing of the UI that requires the canvas to be rotated according to the preview's
* current UI rotation.
*/
private void drawUI(Canvas canvas, long time_ms) {
Preview preview = main_activity.getPreview();
CameraController camera_controller = preview.getCameraController();
int ui_rotation = preview.getUIRotation();
boolean ui_placement_right = main_activity.getMainUI().getUIPlacementRight();
boolean has_level_angle = preview.hasLevelAngle();
double level_angle = preview.getLevelAngle();
boolean has_geo_direction = preview.hasGeoDirection();
double geo_direction = preview.getGeoDirection();
canvas.save();
canvas.rotate(ui_rotation, canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f);
if (camera_controller != null && !preview.isPreviewPaused()) {
/*canvas.drawText("PREVIEW", canvas.getWidth() / 2,
canvas.getHeight() / 2, p);*/
// convert dps to pixels
int text_y = (int) (20 * scale + 0.5f);
// fine tuning to adjust placement of text with respect to the GUI, depending on orientation
int text_base_y = 0;
if (ui_rotation == (ui_placement_right ? 0 : 180)) {
text_base_y = canvas.getHeight() - (int) (0.5 * text_y);
} else if (ui_rotation == (ui_placement_right ? 180 : 0)) {
// leave room for GUI icons
text_base_y = canvas.getHeight() - (int) (2.5 * text_y);
} else if (ui_rotation == 90 || ui_rotation == 270) {
// text_base_y = canvas.getHeight() + (int)(0.5*text_y);
/*ImageButton view = (ImageButton)main_activity.findViewById(R.id.take_photo);
// align with "top" of the take_photo button, but remember to take the rotation into account!
view.getLocationOnScreen(gui_location);
int view_left = gui_location[0];
preview.getView().getLocationOnScreen(gui_location);
int this_left = gui_location[0];
// diff_x is the difference from the centre of the canvas to the position we want
int diff_x = view_left - ( this_left + canvas.getWidth()/2 );
*/
/*if( MyDebug.LOG ) {
Log.d(TAG, "view left: " + view_left);
Log.d(TAG, "this left: " + this_left);
Log.d(TAG, "canvas is " + canvas.getWidth() + " x " + canvas.getHeight());
}*/
// diff_x is the difference from the centre of the canvas to the position we want
// assumes canvas is centered
// avoids calling getLocationOnScreen for performance
// convert dps to pixels
int diff_x = preview.getView().getRootView().getRight() / 2 - (int) (100 * scale + 0.5f);
int max_x = canvas.getWidth();
if (ui_rotation == 90) {
// so we don't interfere with the top bar info (datetime, free memory, ISO)
max_x -= (int) (2.5 * text_y);
}
/*if( MyDebug.LOG ) {
Log.d(TAG, "root view right: " + preview.getView().getRootView().getRight());
Log.d(TAG, "diff_x: " + diff_x);
Log.d(TAG, "canvas.getWidth()/2 + diff_x: " + (canvas.getWidth()/2+diff_x));
Log.d(TAG, "max_x: " + max_x);
}*/
if (canvas.getWidth() / 2 + diff_x > max_x) {
// in case goes off the size of the canvas, for "black bar" cases (when preview aspect ratio != screen aspect ratio)
diff_x = max_x - canvas.getWidth() / 2;
}
text_base_y = canvas.getHeight() / 2 + diff_x - (int) (0.5 * text_y);
}
boolean draw_angle = has_level_angle && show_angle_pref;
boolean draw_geo_direction = has_geo_direction && show_geo_direction_pref;
if (draw_angle) {
int color = Color.WHITE;
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
int pixels_offset_x;
if (draw_geo_direction) {
// convert dps to pixels
pixels_offset_x = -(int) (35 * scale + 0.5f);
p.setTextAlign(Paint.Align.LEFT);
} else {
// p.setTextAlign(Paint.Align.CENTER);
// slightly better for performance to use Align.LEFT, due to avoid measureText() call in drawTextWithBackground()
// convert dps to pixels
pixels_offset_x = -(int) ((level_angle < 0 ? 16 : 14) * scale + 0.5f);
p.setTextAlign(Paint.Align.LEFT);
}
if (Math.abs(level_angle) <= close_level_angle) {
color = angle_highlight_color_pref;
p.setUnderlineText(true);
}
if (angle_string == null || time_ms > this.last_angle_string_time + 500) {
// update cached string
/*if( MyDebug.LOG )
Log.d(TAG, "update angle_string: " + angle_string);*/
last_angle_string_time = time_ms;
String number_string = formatLevelAngle(level_angle);
// String number_string = "" + level_angle;
angle_string = number_string + (char) 0x00B0;
cached_angle = level_angle;
// String angle_string = "" + level_angle;
}
// applicationInterface.drawTextWithBackground(canvas, p, angle_string, color, Color.BLACK, canvas.getWidth() / 2 + pixels_offset_x, text_base_y, MyApplicationInterface.Alignment.ALIGNMENT_BOTTOM, ybounds_text, true);
if (text_bounds_angle_single == null) {
if (MyDebug.LOG)
Log.d(TAG, "compute text_bounds_angle_single");
text_bounds_angle_single = new Rect();
String bounds_angle_string = "-9.0" + (char) 0x00B0;
p.getTextBounds(bounds_angle_string, 0, bounds_angle_string.length(), text_bounds_angle_single);
}
if (text_bounds_angle_double == null) {
if (MyDebug.LOG)
Log.d(TAG, "compute text_bounds_angle_double");
text_bounds_angle_double = new Rect();
String bounds_angle_string = "-45.0" + (char) 0x00B0;
p.getTextBounds(bounds_angle_string, 0, bounds_angle_string.length(), text_bounds_angle_double);
}
applicationInterface.drawTextWithBackground(canvas, p, angle_string, color, Color.BLACK, canvas.getWidth() / 2 + pixels_offset_x, text_base_y, MyApplicationInterface.Alignment.ALIGNMENT_BOTTOM, null, true, Math.abs(cached_angle) < 10.0 ? text_bounds_angle_single : text_bounds_angle_double);
p.setUnderlineText(false);
}
if (draw_geo_direction) {
int color = Color.WHITE;
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
int pixels_offset_x;
if (draw_angle) {
// convert dps to pixels
pixels_offset_x = (int) (10 * scale + 0.5f);
p.setTextAlign(Paint.Align.LEFT);
} else {
// p.setTextAlign(Paint.Align.CENTER);
// slightly better for performance to use Align.LEFT, due to avoid measureText() call in drawTextWithBackground()
// convert dps to pixels
pixels_offset_x = -(int) (14 * scale + 0.5f);
p.setTextAlign(Paint.Align.LEFT);
}
float geo_angle = (float) Math.toDegrees(geo_direction);
if (geo_angle < 0.0f) {
geo_angle += 360.0f;
}
String string = "" + Math.round(geo_angle) + (char) 0x00B0;
applicationInterface.drawTextWithBackground(canvas, p, string, color, Color.BLACK, canvas.getWidth() / 2 + pixels_offset_x, text_base_y, MyApplicationInterface.Alignment.ALIGNMENT_BOTTOM, ybounds_text, true);
}
if (preview.isOnTimer()) {
long remaining_time = (preview.getTimerEndTime() - time_ms + 999) / 1000;
if (MyDebug.LOG)
Log.d(TAG, "remaining_time: " + remaining_time);
if (remaining_time > 0) {
// convert dps to pixels
p.setTextSize(42 * scale + 0.5f);
p.setTextAlign(Paint.Align.CENTER);
String time_s;
if (remaining_time < 60) {
// simpler to just show seconds when less than a minute
time_s = "" + remaining_time;
} else {
time_s = getTimeStringFromSeconds(remaining_time);
}
// Red 500
applicationInterface.drawTextWithBackground(canvas, p, time_s, Color.rgb(244, 67, 54), Color.BLACK, canvas.getWidth() / 2, canvas.getHeight() / 2);
}
} else if (preview.isVideoRecording()) {
long video_time = preview.getVideoTime();
String time_s = getTimeStringFromSeconds(video_time / 1000);
/*if( MyDebug.LOG )
Log.d(TAG, "video_time: " + video_time + " " + time_s);*/
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
p.setTextAlign(Paint.Align.CENTER);
// avoid overwriting the zoom, and also allow a bit extra space
int pixels_offset_y = 3 * text_y;
// Red 500
int color = Color.rgb(244, 67, 54);
if (main_activity.isScreenLocked()) {
// writing in reverse order, bottom to top
applicationInterface.drawTextWithBackground(canvas, p, getContext().getResources().getString(R.string.screen_lock_message_2), color, Color.BLACK, canvas.getWidth() / 2, text_base_y - pixels_offset_y);
pixels_offset_y += text_y;
applicationInterface.drawTextWithBackground(canvas, p, getContext().getResources().getString(R.string.screen_lock_message_1), color, Color.BLACK, canvas.getWidth() / 2, text_base_y - pixels_offset_y);
pixels_offset_y += text_y;
}
if (!preview.isVideoRecordingPaused() || ((int) (time_ms / 500)) % 2 == 0) {
// if video is paused, then flash the video time
applicationInterface.drawTextWithBackground(canvas, p, time_s, color, Color.BLACK, canvas.getWidth() / 2, text_base_y - pixels_offset_y);
}
} else if (taking_picture && capture_started) {
if (camera_controller.isManualISO()) {
// only show "capturing" text with time for manual exposure time >= 0.5s
long exposure_time = camera_controller.getExposureTime();
if (exposure_time >= 500000000L) {
if (((int) (time_ms / 500)) % 2 == 0) {
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
p.setTextAlign(Paint.Align.CENTER);
// avoid overwriting the zoom, and also allow a bit extra space
int pixels_offset_y = 3 * text_y;
// Red 500
int color = Color.rgb(244, 67, 54);
applicationInterface.drawTextWithBackground(canvas, p, getContext().getResources().getString(R.string.capturing), color, Color.BLACK, canvas.getWidth() / 2, text_base_y - pixels_offset_y);
}
}
}
} else if (image_queue_full) {
if (((int) (time_ms / 500)) % 2 == 0) {
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
p.setTextAlign(Paint.Align.CENTER);
// avoid overwriting the zoom, and also allow a bit extra space
int pixels_offset_y = 3 * text_y;
applicationInterface.drawTextWithBackground(canvas, p, getContext().getResources().getString(R.string.processing), Color.LTGRAY, Color.BLACK, canvas.getWidth() / 2, text_base_y - pixels_offset_y);
}
}
if (preview.supportsZoom() && show_zoom_pref) {
float zoom_ratio = preview.getZoomRatio();
// only show when actually zoomed in
if (zoom_ratio > 1.0f + 1.0e-5f) {
// Convert the dps to pixels, based on density scale
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
p.setTextAlign(Paint.Align.CENTER);
applicationInterface.drawTextWithBackground(canvas, p, getContext().getResources().getString(R.string.zoom) + ": " + zoom_ratio + "x", Color.WHITE, Color.BLACK, canvas.getWidth() / 2, text_base_y - text_y, MyApplicationInterface.Alignment.ALIGNMENT_BOTTOM, ybounds_text, true);
}
}
} else if (camera_controller == null) {
/*if( MyDebug.LOG ) {
Log.d(TAG, "no camera!");
Log.d(TAG, "width " + canvas.getWidth() + " height " + canvas.getHeight());
}*/
p.setColor(Color.WHITE);
// convert dps to pixels
p.setTextSize(14 * scale + 0.5f);
p.setTextAlign(Paint.Align.CENTER);
// convert dps to pixels
int pixels_offset = (int) (20 * scale + 0.5f);
if (preview.hasPermissions()) {
if (preview.openCameraFailed()) {
canvas.drawText(getContext().getResources().getString(R.string.failed_to_open_camera_1), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f, p);
canvas.drawText(getContext().getResources().getString(R.string.failed_to_open_camera_2), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f + pixels_offset, p);
canvas.drawText(getContext().getResources().getString(R.string.failed_to_open_camera_3), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f + 2 * pixels_offset, p);
}
} else {
canvas.drawText(getContext().getResources().getString(R.string.no_permission), canvas.getWidth() / 2.0f, canvas.getHeight() / 2.0f, p);
}
// canvas.drawRect(0.0f, 0.0f, 100.0f, 100.0f, p);
// canvas.drawRGB(255, 0, 0);
// canvas.drawRect(0.0f, 0.0f, canvas.getWidth(), canvas.getHeight(), p);
}
// convert dps to pixels
final int top_y = (int) (5 * scale + 0.5f);
// convert dps to pixels
int battery_x = (int) (5 * scale + 0.5f);
int battery_y = top_y + (int) (5 * scale + 0.5f);
// convert dps to pixels
int battery_width = (int) (5 * scale + 0.5f);
int battery_height = 4 * battery_width;
if (ui_rotation == 90 || ui_rotation == 270) {
int diff = canvas.getWidth() - canvas.getHeight();
battery_x += diff / 2;
battery_y -= diff / 2;
}
if (ui_rotation == 90) {
battery_y = canvas.getHeight() - battery_y - battery_height;
}
if (ui_rotation == 180) {
battery_x = canvas.getWidth() - battery_x - battery_width;
}
if (show_battery_pref) {
if (!this.has_battery_frac || time_ms > this.last_battery_time + 60000) {
// only check periodically - unclear if checking is costly in any way
// note that it's fine to call registerReceiver repeatedly - we pass a null receiver, so this is fine as a "one shot" use
Intent batteryStatus = main_activity.registerReceiver(null, battery_ifilter);
int battery_level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int battery_scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
has_battery_frac = true;
battery_frac = battery_level / (float) battery_scale;
last_battery_time = time_ms;
if (MyDebug.LOG)
Log.d(TAG, "Battery status is " + battery_level + " / " + battery_scale + " : " + battery_frac);
}
// battery_frac = 0.2999f; // test
boolean draw_battery = true;
if (battery_frac <= 0.05f) {
// flash icon at this low level
draw_battery = (((time_ms / 1000)) % 2) == 0;
}
if (draw_battery) {
// Green 500 or Red 500
p.setColor(battery_frac > 0.15f ? Color.rgb(37, 155, 36) : Color.rgb(244, 67, 54));
p.setStyle(Paint.Style.FILL);
canvas.drawRect(battery_x, battery_y + (1.0f - battery_frac) * (battery_height - 2), battery_x + battery_width, battery_y + battery_height, p);
if (battery_frac < 1.0f) {
p.setColor(Color.BLACK);
p.setAlpha(64);
canvas.drawRect(battery_x, battery_y, battery_x + battery_width, battery_y + (1.0f - battery_frac) * (battery_height - 2), p);
}
}
}
onDrawInfoLines(canvas, top_y, time_ms);
canvas.restore();
}
use of net.sourceforge.opencamera.Preview.Preview in project OpenCamera by ageback.
the class DrawPreview method doThumbnailAnimation.
private void doThumbnailAnimation(Canvas canvas, long time_ms) {
Preview preview = main_activity.getPreview();
CameraController camera_controller = preview.getCameraController();
// note, no need to check preferences here, as we do that when setting thumbnail_anim
if (camera_controller != null && this.thumbnail_anim && last_thumbnail != null) {
int ui_rotation = preview.getUIRotation();
long time = time_ms - this.thumbnail_anim_start_ms;
final long duration = 500;
if (time > duration) {
if (MyDebug.LOG)
Log.d(TAG, "thumbnail_anim finished");
this.thumbnail_anim = false;
} else {
thumbnail_anim_src_rect.left = 0;
thumbnail_anim_src_rect.top = 0;
thumbnail_anim_src_rect.right = last_thumbnail.getWidth();
thumbnail_anim_src_rect.bottom = last_thumbnail.getHeight();
View galleryButton = main_activity.findViewById(R.id.gallery);
float alpha = ((float) time) / (float) duration;
int st_x = canvas.getWidth() / 2;
int st_y = canvas.getHeight() / 2;
int nd_x = galleryButton.getLeft() + galleryButton.getWidth() / 2;
int nd_y = galleryButton.getTop() + galleryButton.getHeight() / 2;
int thumbnail_x = (int) ((1.0f - alpha) * st_x + alpha * nd_x);
int thumbnail_y = (int) ((1.0f - alpha) * st_y + alpha * nd_y);
float st_w = canvas.getWidth();
float st_h = canvas.getHeight();
float nd_w = galleryButton.getWidth();
float nd_h = galleryButton.getHeight();
// int thumbnail_w = (int)( (1.0f-alpha)*st_w + alpha*nd_w );
// int thumbnail_h = (int)( (1.0f-alpha)*st_h + alpha*nd_h );
float correction_w = st_w / nd_w - 1.0f;
float correction_h = st_h / nd_h - 1.0f;
int thumbnail_w = (int) (st_w / (1.0f + alpha * correction_w));
int thumbnail_h = (int) (st_h / (1.0f + alpha * correction_h));
thumbnail_anim_dst_rect.left = thumbnail_x - thumbnail_w / 2;
thumbnail_anim_dst_rect.top = thumbnail_y - thumbnail_h / 2;
thumbnail_anim_dst_rect.right = thumbnail_x + thumbnail_w / 2;
thumbnail_anim_dst_rect.bottom = thumbnail_y + thumbnail_h / 2;
// canvas.drawBitmap(this.thumbnail, thumbnail_anim_src_rect, thumbnail_anim_dst_rect, p);
thumbnail_anim_matrix.setRectToRect(thumbnail_anim_src_rect, thumbnail_anim_dst_rect, Matrix.ScaleToFit.FILL);
// thumbnail_anim_matrix.reset();
if (ui_rotation == 90 || ui_rotation == 270) {
float ratio = ((float) last_thumbnail.getWidth()) / (float) last_thumbnail.getHeight();
thumbnail_anim_matrix.preScale(ratio, 1.0f / ratio, last_thumbnail.getWidth() / 2.0f, last_thumbnail.getHeight() / 2.0f);
}
thumbnail_anim_matrix.preRotate(ui_rotation, last_thumbnail.getWidth() / 2.0f, last_thumbnail.getHeight() / 2.0f);
canvas.drawBitmap(last_thumbnail, thumbnail_anim_matrix, p);
}
}
}
use of net.sourceforge.opencamera.Preview.Preview 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);
}
}
use of net.sourceforge.opencamera.Preview.Preview in project OpenCamera by ageback.
the class MyApplicationInterface method shareLastImage.
void shareLastImage() {
if (MyDebug.LOG)
Log.d(TAG, "shareLastImage");
Preview preview = main_activity.getPreview();
if (preview.isPreviewPaused()) {
LastImage share_image = null;
for (int i = 0; i < last_images.size() && share_image == null; i++) {
LastImage last_image = last_images.get(i);
if (last_image.share) {
share_image = last_image;
}
}
boolean done = true;
if (share_image != null) {
Uri last_image_uri = share_image.uri;
if (MyDebug.LOG)
Log.d(TAG, "Share: " + last_image_uri);
if (last_image_uri == null) {
// could happen with Android 7+ with non-SAF if the image hasn't been scanned yet,
// so we don't know the uri yet
Log.e(TAG, "can't share last image as don't yet have uri");
done = false;
} else {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, last_image_uri);
main_activity.startActivity(Intent.createChooser(intent, "Photo"));
}
}
if (done) {
clearLastImages();
preview.startCameraPreview();
}
}
}
Aggregations