0
0
mirror of https://git.code.sf.net/p/opencamera/code.git synced 2024-09-19 19:42:29 +02:00

New option to show on-screen icon for focus peaking.

This commit is contained in:
Mark Harman 2024-03-10 21:03:50 +00:00
parent ae61c064d9
commit 4101ca0339
15 changed files with 111 additions and 3 deletions

View File

@ -692,7 +692,7 @@ image should be drawn with.</p>
<p><b>Zebra stripes foreground/background colour</b> - If "Show zebra stripes" is enabled, these options allow you to
choose the colours of the stripes.</p>
<p><b>Focus peaking</b> - Allows displaying on-screen highlights to indicate edges (contours) that are in-focus
<p><a name="focus_peaking"><b>Focus peaking</b></a> - Allows displaying on-screen highlights to indicate edges (contours) that are in-focus
(only available if Camera2 API is used). This is particularly useful in conjunction with manual focus mode, to help show
which regions of the image are in focus. Note that enabling focus peaking may use more battery.</p>
@ -752,6 +752,9 @@ to only have the preview showing.</li>
<p><b>Show flash icon</b> - Whether to display an on-screen icon for cycling through flash modes. If this is enabled, then
flash modes won't show on the popup menu. Also note that it is not possible to enable the torch with this method.</p>
<p><b>Show focus peaking icon</b> - Whether to display an on-screen icon for enabling or disabling focus peaking. See
<a href="#focus_peaking">Settings/Camera preview/"Focus peaking"</a> above for more details.</p>
<p><b>Show auto-level icon</b> - Whether to display an on-screen icon for enabling or disabling auto-level. See
<a href="#face_detection">Settings/"Face detection"</a> above for more details.</p>

View File

@ -64,6 +64,7 @@ FIXED Clicking on gallery icon when using Storage Access Framework would open
ADDED Camera vendor extensions show percentage progress on supported Android 14 devices.
ADDED Long press on switch camera icons now bring up a menu to jump to any camera (for devices
that expose multiple cameras).
ADDED New option for on-screen icon to enable or disable focus peaking.
ADDED Support for themed/monochrome application icon.
UPDATED Smoother zoom for Camera2 API.
UPDATED Improvements for loading thumbnails for gallery icon (including fixing orientation for

View File

@ -264,6 +264,7 @@ Also see <i>"Can I use the Open Camera source code in my app?"</i> under the <a
ic_timelapse_white_48dp.png, ic_timer_white_48dp.png,
ic_touch_app_white_48dp.png, ic_videocam_white_48dp.png,
ic_stat_notify_take_photo.png (modified from ic_photo_camera_white_48dp),
key_visualizer_red.xml (modified from key_visualizer), key_visualizer.xml,
popup*.png (modified from ic_more_vert_white, baseline_highlight_white, baseline_remove_red_eye_white, baseline_flash_auto_white,
baseline_flash_off_white, ic_action_flash_on),
settings.png (from ic_action_settings), share.png (from ic_action_share),

View File

@ -2127,6 +2127,25 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
preview.showToast(stamp_toast, value ? R.string.stamp_enabled : R.string.stamp_disabled, true);
}
public void clickedFocusPeaking(View view) {
clickedFocusPeaking();
}
public void clickedFocusPeaking() {
if( MyDebug.LOG )
Log.d(TAG, "clickedFocusPeaking");
boolean value = applicationInterface.getFocusPeakingPref();
value = !value;
final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(PreferenceKeys.FocusPeakingPreferenceKey, value ? "preference_focus_peaking_on" : "preference_focus_peaking_off");
editor.apply();
mainUI.updateFocusPeakingIcon();
applicationInterface.getDrawPreview().updateSettings(); // needed to update focus peaking
}
public void clickedAutoLevel(View view) {
clickedAutoLevel();
}
@ -3318,6 +3337,11 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
changed = changed || (button.getVisibility() != View.GONE);
button.setVisibility(View.GONE);
}
if( !mainUI.showFocusPeakingIcon() ) {
View button = findViewById(R.id.focus_peaking);
changed = changed || (button.getVisibility() != View.GONE);
button.setVisibility(View.GONE);
}
if( !mainUI.showAutoLevelIcon() ) {
View button = findViewById(R.id.auto_level);
changed = changed || (button.getVisibility() != View.GONE);

View File

@ -1247,6 +1247,11 @@ public class MyApplicationInterface extends BasicApplicationInterface {
return sharedPreferences.getString(PreferenceKeys.RecordAudioSourcePreferenceKey, "audio_src_camcorder");
}
public boolean getFocusPeakingPref() {
String focus_peaking_pref = sharedPreferences.getString(PreferenceKeys.FocusPeakingPreferenceKey, "preference_focus_peaking_off");
return !focus_peaking_pref.equals("preference_focus_peaking_off") && main_activity.supportsPreviewBitmaps();
}
public boolean getAutoStabilisePref() {
boolean auto_stabilise = sharedPreferences.getBoolean(PreferenceKeys.AutoStabilisePreferenceKey, false);
return auto_stabilise && main_activity.supportsAutoStabilise();

View File

@ -232,6 +232,8 @@ public class PreferenceKeys {
public static final String ShowCycleFlashPreferenceKey = "preference_show_cycle_flash";
public static final String ShowFocusPeakingPreferenceKey = "preference_show_focus_peaking";
public static final String ShowAutoLevelPreferenceKey = "preference_show_auto_level";
public static final String ShowStampPreferenceKey = "preference_show_stamp";

View File

@ -34,6 +34,10 @@ public class PreferenceSubGUI extends PreferenceSubScreen {
if( MyDebug.LOG )
Log.d(TAG, "supports_flash: " + supports_flash);
final boolean supports_preview_bitmaps = bundle.getBoolean("supports_preview_bitmaps");
if( MyDebug.LOG )
Log.d(TAG, "supports_preview_bitmaps: " + supports_preview_bitmaps);
final boolean supports_auto_stabilise = bundle.getBoolean("supports_auto_stabilise");
if( MyDebug.LOG )
Log.d(TAG, "supports_auto_stabilise: " + supports_auto_stabilise);
@ -80,6 +84,13 @@ public class PreferenceSubGUI extends PreferenceSubScreen {
pg.removePreference(pref);
}
if( !supports_preview_bitmaps ) {
Preference pref = findPreference("preference_show_focus_peaking");
//PreferenceGroup pg = (PreferenceGroup)this.findPreference("preference_screen_gui");
PreferenceGroup pg = (PreferenceGroup)this.findPreference("preferences_root");
pg.removePreference(pref);
}
if( !supports_auto_stabilise ) {
Preference pref = findPreference("preference_show_auto_level");
//PreferenceGroup pg = (PreferenceGroup)this.findPreference("preference_screen_gui");

View File

@ -788,8 +788,7 @@ public class DrawPreview {
String zebra_stripes_color_background_value = sharedPreferences.getString(PreferenceKeys.ZebraStripesBackgroundColorPreferenceKey, "#ffffffff");
zebra_stripes_color_background = Color.parseColor(zebra_stripes_color_background_value);
String focus_peaking_pref = sharedPreferences.getString(PreferenceKeys.FocusPeakingPreferenceKey, "preference_focus_peaking_off");
want_focus_peaking = !focus_peaking_pref.equals("preference_focus_peaking_off") && main_activity.supportsPreviewBitmaps();
want_focus_peaking = applicationInterface.getFocusPeakingPref();
String focus_peaking_color = sharedPreferences.getString(PreferenceKeys.FocusPeakingColorPreferenceKey, "#ffffff");
focus_peaking_color_pref = Color.parseColor(focus_peaking_color);

View File

@ -453,6 +453,7 @@ public class MainUI {
buttons_permanent.add(main_activity.findViewById(R.id.store_location));
buttons_permanent.add(main_activity.findViewById(R.id.text_stamp));
buttons_permanent.add(main_activity.findViewById(R.id.stamp));
buttons_permanent.add(main_activity.findViewById(R.id.focus_peaking));
buttons_permanent.add(main_activity.findViewById(R.id.auto_level));
buttons_permanent.add(main_activity.findViewById(R.id.cycle_flash));
buttons_permanent.add(main_activity.findViewById(R.id.face_detection));
@ -1278,6 +1279,13 @@ public class MainUI {
return sharedPreferences.getBoolean(PreferenceKeys.ShowStampPreferenceKey, false);
}
public boolean showFocusPeakingIcon() {
if( !main_activity.supportsPreviewBitmaps() )
return false;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity);
return sharedPreferences.getBoolean(PreferenceKeys.ShowFocusPeakingPreferenceKey, false);
}
public boolean showAutoLevelIcon() {
if( !main_activity.supportsAutoStabilise() )
return false;
@ -1328,6 +1336,7 @@ public class MainUI {
View storeLocationButton = main_activity.findViewById(R.id.store_location);
View textStampButton = main_activity.findViewById(R.id.text_stamp);
View stampButton = main_activity.findViewById(R.id.stamp);
View focusPeakingButton = main_activity.findViewById(R.id.focus_peaking);
View autoLevelButton = main_activity.findViewById(R.id.auto_level);
View cycleFlashButton = main_activity.findViewById(R.id.cycle_flash);
View faceDetectionButton = main_activity.findViewById(R.id.face_detection);
@ -1358,6 +1367,8 @@ public class MainUI {
textStampButton.setVisibility(visibility);
if( showStampIcon() )
stampButton.setVisibility(visibility);
if( showFocusPeakingIcon() )
focusPeakingButton.setVisibility(visibility);
if( showAutoLevelIcon() )
autoLevelButton.setVisibility(visibility);
if( showCycleFlashIcon() )
@ -1452,6 +1463,7 @@ public class MainUI {
View storeLocationButton = main_activity.findViewById(R.id.store_location);
View textStampButton = main_activity.findViewById(R.id.text_stamp);
View stampButton = main_activity.findViewById(R.id.stamp);
View focusPeakingButton = main_activity.findViewById(R.id.focus_peaking);
View autoLevelButton = main_activity.findViewById(R.id.auto_level);
View cycleFlashButton = main_activity.findViewById(R.id.cycle_flash);
View faceDetectionButton = main_activity.findViewById(R.id.face_detection);
@ -1476,6 +1488,8 @@ public class MainUI {
textStampButton.setVisibility(visibility);
if( showStampIcon() )
stampButton.setVisibility(visibility);
if( showFocusPeakingIcon() )
focusPeakingButton.setVisibility(visibility);
if( showAutoLevelIcon() )
autoLevelButton.setVisibility(visibility);
if( showCycleFlashIcon() )
@ -1558,6 +1572,13 @@ public class MainUI {
view.setContentDescription( main_activity.getResources().getString(enabled ? R.string.stamp_disable : R.string.stamp_enable) );
}
public void updateFocusPeakingIcon() {
ImageButton view = main_activity.findViewById(R.id.focus_peaking);
boolean enabled = main_activity.getApplicationInterface().getFocusPeakingPref();
view.setImageResource(enabled ? R.drawable.key_visualizer_red : R.drawable.key_visualizer);
view.setContentDescription( main_activity.getResources().getString(enabled ? R.string.focus_peaking_disable : R.string.focus_peaking_enable) );
}
public void updateAutoLevelIcon() {
ImageButton view = main_activity.findViewById(R.id.auto_level);
boolean enabled = main_activity.getApplicationInterface().getAutoStabilisePref();
@ -1619,6 +1640,7 @@ public class MainUI {
this.updateStoreLocationIcon();
this.updateTextStampIcon();
this.updateStampIcon();
this.updateFocusPeakingIcon();
this.updateAutoLevelIcon();
this.updateCycleFlashIcon();
this.updateFaceDetectionIcon();

View File

@ -0,0 +1,5 @@
<vector android:height="48dp" android:tint="#ffffff"
android:viewportHeight="960" android:viewportWidth="960"
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M120,840L120,760L240,760L240,840L120,840ZM120,680L120,600L440,600L440,680L120,680ZM120,520L120,440L840,440L840,520L120,520ZM120,360L120,280L440,280L440,360L120,360ZM120,200L120,120L240,120L240,200L120,200ZM320,840L320,760L440,760L440,840L320,840ZM320,200L320,120L440,120L440,200L320,200ZM520,840L520,760L640,760L640,840L520,840ZM520,680L520,600L840,600L840,680L520,680ZM520,360L520,280L840,280L840,360L520,360ZM520,200L520,120L640,120L640,200L520,200ZM720,840L720,760L840,760L840,840L720,840ZM720,200L720,120L840,120L840,200L720,200Z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="48dp" android:tint="#ff0000"
android:viewportHeight="960" android:viewportWidth="960"
android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#ffffff" android:pathData="M120,840L120,760L240,760L240,840L120,840ZM120,680L120,600L440,600L440,680L120,680ZM120,520L120,440L840,440L840,520L120,520ZM120,360L120,280L440,280L440,360L120,360ZM120,200L120,120L240,120L240,200L120,200ZM320,840L320,760L440,760L440,840L320,840ZM320,200L320,120L440,120L440,200L320,200ZM520,840L520,760L640,760L640,840L520,840ZM520,680L520,600L840,600L840,680L520,680ZM520,360L520,280L840,280L840,360L520,360ZM520,200L520,120L640,120L640,200L520,200ZM720,840L720,760L840,760L840,840L720,840ZM720,200L720,120L840,120L840,200L720,200Z"/>
</vector>

View File

@ -345,6 +345,21 @@
android:visibility="gone"
/>
<ImageButton
android:id="@+id/focus_peaking"
android:layout_width="@dimen/onscreen_button_size"
android:layout_height="@dimen/onscreen_button_size"
android:padding="10dp"
android:scaleType="fitCenter"
android:contentDescription="@string/focus_peaking_enable"
app:srcCompat="@drawable/key_visualizer"
android:background="@color/icons_background"
android:backgroundTint="@color/icons_background_tint"
android:backgroundTintMode="src_in"
android:onClick="clickedFocusPeaking"
android:visibility="gone"
/>
<ImageButton
android:id="@+id/auto_level"
android:layout_width="@dimen/onscreen_button_size"

View File

@ -947,6 +947,7 @@
<item>@string/preference_focus_peaking_off</item>
<item>@string/preference_focus_peaking_on</item>
</string-array>
<!-- need to keep in sync with clickedFocusPeaking() -->
<string-array name="preference_focus_peaking_values">
<item>preference_focus_peaking_off</item>
<item>preference_focus_peaking_on</item>

View File

@ -1020,6 +1020,11 @@
<string name="choose_camera">Choose camera:</string>
<string name="preference_show_focus_peaking">Show focus peaking icon</string>
<string name="preference_show_focus_peaking_summary">Whether to show an on-screen icon for enabling or disabling focus peaking. When focus peaking is enabled, highlights will be shown on in-focus edges (contours). See Settings/Camera preview/"Focus peaking".</string>
<string name="focus_peaking_enable">Enable focus peaking</string> <!-- for "ContentDescription" (used for accessibility, e.g., Google Talkback) -->
<string name="focus_peaking_disable">Disable focus peaking</string> <!-- for "ContentDescription" (used for accessibility, e.g., Google Talkback) -->
<!-- The following strings should not be translated (and shouldn't be included in language-specific strings.xml), in case they need updating -->
<string name="preference_privacy_policy" translatable="false">Privacy policy</string>

View File

@ -39,6 +39,15 @@
android:defaultValue="false"
/>
<!-- if we move this to another PreferenceGroup, we should update code to remove this Preference -->
<CheckBoxPreference
android:key="preference_show_focus_peaking"
android:title="@string/preference_show_focus_peaking"
android:summary="@string/preference_show_focus_peaking_summary"
android:icon="@drawable/key_visualizer"
android:defaultValue="false"
/>
<!-- if we move this to another PreferenceGroup, we should update code to remove this Preference -->
<CheckBoxPreference
android:key="preference_show_auto_level"