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

Commit 8775f442 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '1775-master-cameraux' into 'master'

Update camera ux for murena two

See merge request !79
parents e23c4860 a14ca3f5
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -74,3 +74,4 @@ update-default-branch:
    UPSTREAM_DEFAULT_BRANCH: master
    UPSTREAM_URL: https://git.code.sf.net/p/opencamera/code
    TEMP_LATEST_TAG_BRANCH: latest_upstream_tag_branch
  allow_failure: true
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
            android:name="net.sourceforge.opencamera.MainActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:theme="@style/AppTheme"
            android:launchMode="singleInstance"
            android:clearTaskOnLaunch="true"
            android:exported="true"
            >
+4 −0
Original line number Diff line number Diff line
@@ -38,4 +38,8 @@ public class DeviceSettings {
        final boolean isOne = Build.DEVICE.equals("one") || Build.DEVICE.equals("X2");
        return isMurena && isOne;
    }

    public static boolean isMurenaTwo() {
        return Build.DEVICE.toLowerCase(Locale.US).contains("two");
    }
}
+28 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -185,6 +186,11 @@ public class MainActivity extends AppCompatActivity {
    public static volatile boolean test_preview_want_no_limits; // test flag, if set to true then instead use test_preview_want_no_limits_value; needs to be static, as it needs to be set before activity is created to take effect
    public static volatile boolean test_preview_want_no_limits_value;

    private boolean murenaTwoHwKill = false;

    private Handler handler;
    private Runnable retryRunnable = null;

    // whether this is a multi-camera device (note, this isn't simply having more than 1 camera, but also having more than one with the same facing)
    // note that in most cases, code should check the MultiCamButtonPreferenceKey preference as well as the is_multi_cam flag,
    // this can be done via isMultiCamEnabled().
@@ -358,6 +364,8 @@ public class MainActivity extends AppCompatActivity {
        magneticSensor = new MagneticSensor(this);
        //speechControl = new SpeechControl(this);

        handler = new Handler();

        // determine whether we support Camera2 API
        // must be done before setDeviceDefaults()
        initCamera2Support();
@@ -1594,6 +1602,26 @@ public class MainActivity extends AppCompatActivity {
        else {
            mainUI.onKeyUp(keyCode, event);
        }

        if (!camera_in_background && keyCode == 131 && DeviceSettings.isMurenaTwo()) {
            String cameraState = Utils.getProperty("persist.sys.hwswitch.state", null);
            if (cameraState == null) return super.onKeyUp(keyCode, event);

            if (retryRunnable != null) {
                handler.removeCallbacks(retryRunnable);
            }

            murenaTwoHwKill = Objects.equals(cameraState, "1");
            retryRunnable = () -> {
                if (!murenaTwoHwKill) {
                    preview.retryOpenCamera();
                } else {
                    restartOpenCamera();
                }
            };
            handler.postDelayed(retryRunnable, murenaTwoHwKill ? 200 : 5000);
        }

        return super.onKeyUp(keyCode, event);
    }

+1 −0
Original line number Diff line number Diff line
@@ -2633,6 +2633,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {

    @Override
    public void onCameraError() {
        if (DeviceSettings.isMurenaTwo()) return;
        main_activity.getPreview().showToast(null, R.string.camera_error);
    }

Loading