Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44db8e21 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Camera: Use alternative flash default on xiaomi, fairphone and gigaset

- Fixes e/backlog#5818

Change-Id: Id2c1f9f5cc647017fc0469ff3009cb0f9acbe6ca
parent 629148c5
Loading
Loading
Loading
Loading
+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;
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -887,6 +887,14 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
            //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");
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
            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
+12 −0
Original line number Diff line number Diff line
@@ -229,6 +229,18 @@ public class PreferenceSubPhoto extends PreferenceSubScreen {
            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( !supports_expo_bracketing || max_expo_bracketing_n_images <= 3 ) {
            Preference pref = findPreference("preference_expo_bracketing_n_images");
            //PreferenceGroup pg = (PreferenceGroup) this.findPreference("preference_screen_photo_settings");