Loading app/src/main/java/net/sourceforge/opencamera/DeviceSettings.java 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 E FOUNDATION * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package net.sourceforge.opencamera; import android.os.Build; import java.util.Locale; public class DeviceSettings { /** Returns whether the the device uses fake flash in Camera API2. * Some older device have issues in low light. */ public static boolean deviceUsingFakeFlash() { final boolean is_xiaomi = Build.MANUFACTURER.toLowerCase(Locale.US).contains("xiaomi"); final boolean is_fairphone = Build.MANUFACTURER.toLowerCase(Locale.US).contains("fairphone"); final boolean is_GS290 = Build.DEVICE != null && Build.DEVICE.equals("GS290"); return is_fairphone || is_xiaomi || is_GS290; } } app/src/main/java/net/sourceforge/opencamera/MainActivity.java +8 −1 Original line number Diff line number Diff line Loading @@ -863,7 +863,7 @@ public class MainActivity extends AppCompatActivity { void setDeviceDefaults() { if( MyDebug.LOG ) Log.d(TAG, "setDeviceDefaults"); //SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); //boolean is_samsung = Build.MANUFACTURER.toLowerCase(Locale.US).contains("samsung"); //boolean is_oneplus = Build.MANUFACTURER.toLowerCase(Locale.US).contains("oneplus"); //boolean is_nexus = Build.MODEL.toLowerCase(Locale.US).contains("nexus"); Loading @@ -878,6 +878,13 @@ public class MainActivity extends AppCompatActivity { //Log.d(TAG, "is_pixel_phone? " + is_pixel_phone); //Log.d(TAG, "is_pixel_xl_phone? " + is_pixel_xl_phone); }*/ if ( DeviceSettings.deviceUsingFakeFlash() ) { if( MyDebug.LOG ) Log.d(TAG, "set fake flash for camera2"); final SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(PreferenceKeys.Camera2FakeFlashPreferenceKey, true); editor.apply(); } /*if( is_samsung || is_oneplus ) { // The problems we used to have on Samsung Galaxy devices are now fixed, by setting // TEMPLATE_PREVIEW for the precaptureBuilder in CameraController2. This also fixes the Loading app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java +12 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,18 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared pg.removePreference(pref); } if ( DeviceSettings.deviceUsingFakeFlash() ) { if( MyDebug.LOG ) Log.d(TAG, "set fake flash for camera2"); Preference pref = findPreference(PreferenceKeys.Camera2FakeFlashPreferenceKey); pref.setDefaultValue(true); pref.setEnabled(false); final SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(PreferenceKeys.Camera2FakeFlashPreferenceKey, true); editor.apply(); } if( Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 ) { // BluetoothLeService requires Android 4.3+ Preference pref = findPreference("preference_screen_remote_control"); Loading Loading
app/src/main/java/net/sourceforge/opencamera/DeviceSettings.java 0 → 100644 +34 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 E FOUNDATION * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package net.sourceforge.opencamera; import android.os.Build; import java.util.Locale; public class DeviceSettings { /** Returns whether the the device uses fake flash in Camera API2. * Some older device have issues in low light. */ public static boolean deviceUsingFakeFlash() { final boolean is_xiaomi = Build.MANUFACTURER.toLowerCase(Locale.US).contains("xiaomi"); final boolean is_fairphone = Build.MANUFACTURER.toLowerCase(Locale.US).contains("fairphone"); final boolean is_GS290 = Build.DEVICE != null && Build.DEVICE.equals("GS290"); return is_fairphone || is_xiaomi || is_GS290; } }
app/src/main/java/net/sourceforge/opencamera/MainActivity.java +8 −1 Original line number Diff line number Diff line Loading @@ -863,7 +863,7 @@ public class MainActivity extends AppCompatActivity { void setDeviceDefaults() { if( MyDebug.LOG ) Log.d(TAG, "setDeviceDefaults"); //SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); //boolean is_samsung = Build.MANUFACTURER.toLowerCase(Locale.US).contains("samsung"); //boolean is_oneplus = Build.MANUFACTURER.toLowerCase(Locale.US).contains("oneplus"); //boolean is_nexus = Build.MODEL.toLowerCase(Locale.US).contains("nexus"); Loading @@ -878,6 +878,13 @@ public class MainActivity extends AppCompatActivity { //Log.d(TAG, "is_pixel_phone? " + is_pixel_phone); //Log.d(TAG, "is_pixel_xl_phone? " + is_pixel_xl_phone); }*/ if ( DeviceSettings.deviceUsingFakeFlash() ) { if( MyDebug.LOG ) Log.d(TAG, "set fake flash for camera2"); final SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(PreferenceKeys.Camera2FakeFlashPreferenceKey, true); editor.apply(); } /*if( is_samsung || is_oneplus ) { // The problems we used to have on Samsung Galaxy devices are now fixed, by setting // TEMPLATE_PREVIEW for the precaptureBuilder in CameraController2. This also fixes the Loading
app/src/main/java/net/sourceforge/opencamera/MyPreferenceFragment.java +12 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,18 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared pg.removePreference(pref); } if ( DeviceSettings.deviceUsingFakeFlash() ) { if( MyDebug.LOG ) Log.d(TAG, "set fake flash for camera2"); Preference pref = findPreference(PreferenceKeys.Camera2FakeFlashPreferenceKey); pref.setDefaultValue(true); pref.setEnabled(false); final SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(PreferenceKeys.Camera2FakeFlashPreferenceKey, true); editor.apply(); } if( Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 ) { // BluetoothLeService requires Android 4.3+ Preference pref = findPreference("preference_screen_remote_control"); Loading