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

Commit 1f646c6f authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽 Committed by Mohammed Althaf T
Browse files

94 - UI Improvement

issue: https://gitlab.e.foundation/e/os/backlog/-/issues/94

Improve the basic camera UI
parent 9c114693
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ android {

    defaultConfig {
        applicationId "foundation.e.blisslauncher"
        minSdkVersion 15
        minSdkVersion 21
        targetSdkVersion 34
        //compileSdkVersion 31 // needed to support appcompat:1.4.0 (which we need for emoji policy support, and not yet ready to target SDK 30)

@@ -51,6 +51,7 @@ android {
}

dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    compileOnly files("../e-ui-sdk.jar")

    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+5 −5
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@
        <activity
            android:name="TakePhoto"
            android:label="@string/take_photo"
            android:icon="@drawable/ic_launcher_take_photo"
            android:icon="@mipmap/ic_launcher"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:taskAffinity=""
            android:excludeFromRecents="true"
@@ -117,7 +117,7 @@
        </receiver> 
        <!-- should not change the android:name, including moving to a subpackage - see http://android-developers.blogspot.co.uk/2011/06/things-that-cannot-change.html -->
        <receiver
            android:icon="@drawable/ic_launcher_take_photo"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/take_photo"
            android:name="MyWidgetProviderTakePhoto"
            android:exported="true">
@@ -131,7 +131,7 @@
        <!-- should not change the android:name, including moving to a subpackage - see http://android-developers.blogspot.co.uk/2011/06/things-that-cannot-change.html -->
        <service
            android:name="net.sourceforge.opencamera.MyTileService"
            android:icon="@lineageos.platform:drawable/ic_camera_photo"
            android:icon="@drawable/ic_switch_camera"
            android:label="@string/camera"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            android:exported="true">
@@ -142,7 +142,7 @@
        <!-- should not change the android:name, including moving to a subpackage - see http://android-developers.blogspot.co.uk/2011/06/things-that-cannot-change.html -->
        <service
            android:name="net.sourceforge.opencamera.MyTileServiceVideo"
            android:icon="@drawable/ic_videocam_white_48dp"
            android:icon="@drawable/ic_switch_video"
            android:label="@string/record_video"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            android:exported="true">
@@ -153,7 +153,7 @@
        <!-- should not change the android:name, including moving to a subpackage - see http://android-developers.blogspot.co.uk/2011/06/things-that-cannot-change.html -->
        <service
            android:name="net.sourceforge.opencamera.MyTileServiceFrontCamera"
            android:icon="@drawable/ic_face_white_48dp"
            android:icon="@drawable/ic_face"
            android:label="@string/selfie"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            android:exported="true">
+38 −42
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -30,14 +29,12 @@ import java.util.concurrent.Future;
import android.Manifest;
import android.app.Fragment;
import android.content.pm.PackageInfo;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.drawable.GradientDrawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@@ -84,8 +81,6 @@ import android.text.InputFilter;
import android.text.InputType;
import android.text.Spanned;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
@@ -491,6 +486,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
        zoomControls.setVisibility(View.GONE);
        View zoomSeekbar = findViewById(R.id.zoom_seekbar);
        zoomSeekbar.setVisibility(View.INVISIBLE);
        View zoomSeekbarIcon = findViewById(R.id.zoom_seekbar_icon);
        zoomSeekbarIcon.setVisibility(View.INVISIBLE);

        // initialise state of on-screen icons
        mainUI.updateOnScreenIcons();
@@ -637,7 +634,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                        launchOnlineHelp();
                    }
                });
                alertDialog.show();
                showAlertDialog(alertDialog, "first time load dialog dismissed");
            }

            setFirstTimeFlag();
@@ -695,7 +692,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                                startActivity(browserIntent);
                            }
                        });*/
                        alertDialog.show();
                        showAlertDialog(alertDialog, "whats new dialog dismissed");
                    }
                }
                // We set the latest_version whether or not the dialog is shown - if we showed the first time dialog, we don't
@@ -2121,13 +2118,16 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
            }
        });
        alertDialog.setNegativeButton(android.R.string.cancel, null);
        showAlertDialog(alertDialog, "custom stamp text dialog dismissed");
    }

    private void showAlertDialog(AlertDialog.Builder alertDialog, final String logMessageOnDismiss) {
        final AlertDialog alert = alertDialog.create();
        alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface arg0) {
                if (MyDebug.LOG)
                    Log.d(TAG, "custom stamp text dialog dismissed");
                    Log.d(TAG, logMessageOnDismiss);
                setWindowFlagsForCamera();
                showPreview(true);
            }
@@ -4282,7 +4282,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
	    /*if( MyDebug.LOG )
			Log.d(TAG, "padding: " + bottom);*/
        galleryButton.setImageBitmap(null);
        galleryButton.setImageResource(lineageos.platform.R.drawable.ic_album);
        galleryButton.setImageResource(R.drawable.ic_album);
        galleryButton.setBorderWidth(0);
        // workaround for setImageResource also resetting padding, Android bug
        galleryButton.setPadding(left, top, right, bottom);
        gallery_bitmap = null;
@@ -4305,6 +4306,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
        }
        CircleImageView galleryButton = this.findViewById(R.id.gallery);
        galleryButton.setImageBitmap(thumbnail);
        galleryButton.setBorderWidth(6);
        gallery_bitmap = thumbnail;
    }

@@ -5500,36 +5502,39 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                Log.d(TAG, "set up zoom");
            if( MyDebug.LOG )
                Log.d(TAG, "has_zoom? " + preview.supportsZoom());
            ZoomControls zoomControls = findViewById(R.id.zoom);
            View zoomControlHolder = findViewById(R.id.zoom);
            SeekBar zoomSeekBar = findViewById(R.id.zoom_seekbar);
            View zoomSeekbarIcon = findViewById(R.id.zoom_seekbar_icon);

            if( preview.supportsZoom() ) {
                if( sharedPreferences.getBoolean(PreferenceKeys.ShowZoomControlsPreferenceKey, false) ) {
                    zoomControls.setIsZoomInEnabled(true);
                    zoomControls.setIsZoomOutEnabled(true);
                    zoomControls.setZoomSpeed(20);
                    if( !mainUI.inImmersiveMode() ) {
                        View zoomInButton = findViewById(R.id.button_zoom_in);
                        View zoomOutButton = findViewById(R.id.button_zoom_out);

                    zoomControls.setOnZoomInClickListener(new View.OnClickListener(){
                        zoomInButton.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                zoomIn();
                            }
                        });
                    zoomControls.setOnZoomOutClickListener(new View.OnClickListener(){

                        zoomOutButton.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                zoomOut();
                            }
                        });
                    if( !mainUI.inImmersiveMode() ) {
                        zoomControls.setVisibility(View.VISIBLE);
                        zoomControlHolder.setVisibility(View.VISIBLE);
                    }
                }
                else {
                    zoomControls.setVisibility(View.GONE);
                    zoomControlHolder.setVisibility(View.GONE);
                }

                zoomSeekBar.setOnSeekBarChangeListener(null); // clear an existing listener - don't want to call the listener when setting up the progress bar to match the existing state
                zoomSeekBar.setMax(preview.getMaxZoom());
                zoomSeekBar.setProgress(preview.getMaxZoom()-preview.getCameraController().getZoom());
                zoomSeekBar.setProgress(preview.getCameraController().getZoom());
                zoomSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
                    @Override
                    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@@ -5539,7 +5544,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                        // indirectly set zoom via this method, from setting the zoom slider
                        // if hasSmoothZoom()==true, then the preview already handled zooming to the current value
                        if( !preview.hasSmoothZoom() )
                            preview.zoomTo(preview.getMaxZoom() - progress, false);
                            preview.zoomTo(progress, false);
                    }

                    @Override
@@ -5554,15 +5559,18 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                if( sharedPreferences.getBoolean(PreferenceKeys.ShowZoomSliderControlsPreferenceKey, false) ) {
                    if( !mainUI.inImmersiveMode() ) {
                        zoomSeekBar.setVisibility(View.VISIBLE);
                        zoomSeekbarIcon.setVisibility(View.VISIBLE);
                    }
                }
                else {
                    zoomSeekBar.setVisibility(View.INVISIBLE); // should be INVISIBLE not GONE, as the focus_seekbar is aligned to be left to this; in future we might want this similarly for exposure panel
                    zoomSeekbarIcon.setVisibility(View.INVISIBLE);
                }
            }
            else {
                zoomControls.setVisibility(View.GONE);
                zoomControlHolder.setVisibility(View.GONE);
                zoomSeekBar.setVisibility(View.INVISIBLE); // should be INVISIBLE not GONE, as the focus_seekbar is aligned to be left to this; in future we might want this similarly for the exposure panel
                zoomSeekbarIcon.setVisibility(View.INVISIBLE);
            }
            if( MyDebug.LOG )
                Log.d(TAG, "cameraSetup: time after setting up zoom: " + (System.currentTimeMillis() - debug_time));
@@ -5684,18 +5692,6 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                    public void onStopTrackingTouch(SeekBar seekBar) {
                    }
                });

                ZoomControls seek_bar_zoom = findViewById(R.id.exposure_seekbar_zoom);
                seek_bar_zoom.setOnZoomInClickListener(new View.OnClickListener(){
                    public void onClick(View v){
                        changeExposure(1);
                    }
                });
                seek_bar_zoom.setOnZoomOutClickListener(new View.OnClickListener(){
                    public void onClick(View v){
                        changeExposure(-1);
                    }
                });
            }
        }
        if( MyDebug.LOG )
+1 −1
Original line number Diff line number Diff line
@@ -2351,7 +2351,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        }

        ImageButton view = main_activity.findViewById(R.id.take_photo);
        view.setImageTintList(ColorStateList.valueOf(main_activity.getResources().getColor(lineageos.platform.R.color.color_default_red1)));
        view.setImageResource(R.drawable.ic_camera_video_recording);
        final VideoMethod video_method = this.createOutputVideoMethod();
        boolean dategeo_subtitles = getVideoSubtitlePref(video_method).equals("preference_video_subtitle_yes");
        if( dategeo_subtitles && video_method != ApplicationInterface.VideoMethod.URI ) {
+8 −0
Original line number Diff line number Diff line
@@ -41,9 +41,12 @@ import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -753,6 +756,11 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared
        alertDialog.setView(scrollView);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.custom_preference_list, container, false);
    }

    /** Programmatically set up dependencies for preference types (e.g., ListPreference) that don't
     *  support this in xml (such as SwitchPreference and CheckBoxPreference), or where this depends
     *  on the device (e.g., Android version).
Loading