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

Commit 1ef790d3 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Port our theme changes

parent 0de67f50
Loading
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -93,7 +93,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"
@@ -130,7 +130,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">
@@ -144,7 +144,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="@drawable/ic_photo_camera_white_48dp"
            android:icon="@drawable/ic_switch_camera"
            android:label="@string/camera"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            android:exported="true">
@@ -155,7 +155,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">
@@ -166,7 +166,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">
+51 −45
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ import net.sourceforge.opencamera.preview.Preview;
import net.sourceforge.opencamera.preview.VideoProfile;
import net.sourceforge.opencamera.qr.QrImageAnalyzer;
import net.sourceforge.opencamera.remotecontrol.BluetoothRemoteControl;
import net.sourceforge.opencamera.ui.CircleImageView;
import net.sourceforge.opencamera.ui.DrawPreview;
import net.sourceforge.opencamera.ui.FolderChooserDialog;
import net.sourceforge.opencamera.ui.MainUI;
@@ -26,7 +27,7 @@ import java.io.InputStream;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -166,7 +167,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
    private boolean camera_in_background; // whether the camera is covered by a fragment/dialog (such as settings or folder picker)
    private GestureDetector gestureDetector;
    private boolean screen_is_locked; // whether screen is "locked" - this is Open Camera's own lock to guard against accidental presses, not the standard Android lock
    private final Map<Integer, Bitmap> preloaded_bitmap_resources = new Hashtable<>();
    private final Map<Integer, Bitmap> preloaded_bitmap_resources = new HashMap<>();
    private ValueAnimator gallery_save_anim;
    private boolean last_continuous_fast_burst; // whether the last photo operation was a continuous_fast_burst
    private Future<?> update_gallery_future;
@@ -603,7 +604,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
        }

        // initialise on-screen button visibility
        View switchCameraButton = findViewById(R.id.switch_camera);
        ImageButton switchCameraButton = findViewById(R.id.switch_camera);
        switchCameraButton.setVisibility(n_cameras > 1 ? View.VISIBLE : View.GONE);
        // switchMultiCameraButton visibility updated below in mainUI.updateOnScreenIcons(), as it also depends on user preference
        View speechRecognizerButton = findViewById(R.id.audio_control);
@@ -612,10 +613,12 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
            Log.d(TAG, "onCreate: time after setting button visibility: " + (System.currentTimeMillis() - debug_time));
        View pauseVideoButton = findViewById(R.id.pause_video);
        pauseVideoButton.setVisibility(View.GONE);
        View takePhotoVideoButton = findViewById(R.id.take_photo_when_video_recording);
        ImageButton takePhotoVideoButton = findViewById(R.id.take_photo_when_video_recording);
        takePhotoVideoButton.setVisibility(View.GONE);
        View cancelPanoramaButton = findViewById(R.id.cancel_panorama);
        cancelPanoramaButton.setVisibility(View.GONE);
        View finishPanoramaButton = findViewById(R.id.finish_panorama);
        finishPanoramaButton.setVisibility(View.GONE);

        // We initialise optional controls to invisible/gone, so they don't show while the camera is opening - the actual visibility is
        // set in cameraSetup().
@@ -629,6 +632,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();
@@ -1684,11 +1689,11 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
    }

    public void zoomIn() {
        zoomByStep(1);
        zoomByStep(-1);
    }

    public void zoomOut() {
        zoomByStep(-1);
        zoomByStep(1);
    }

    public void changeExposure(int change) {
@@ -2243,6 +2248,13 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
        applicationInterface.stopPanorama(true);
    }

    public void clickedFinishPanorama(View view) {
        if (MyDebug.LOG) {
            Log.d(TAG, "clickedFinishPanorama");
        }
        this.takePicture(false);
    }

    public void clickedCycleRaw(View view) {
        if( MyDebug.LOG )
            Log.d(TAG, "clickedCycleRaw");
@@ -4670,7 +4682,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
    private void updateGalleryIconToBlank() {
        if( MyDebug.LOG )
            Log.d(TAG, "updateGalleryIconToBlank");
        ImageButton galleryButton = this.findViewById(R.id.gallery);
        CircleImageView galleryButton = this.findViewById(R.id.gallery);
        int bottom = galleryButton.getPaddingBottom();
        int top = galleryButton.getPaddingTop();
        int right = galleryButton.getPaddingRight();
@@ -4678,7 +4690,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
	    /*if( MyDebug.LOG )
			Log.d(TAG, "padding: " + bottom);*/
        galleryButton.setImageBitmap(null);
        galleryButton.setImageResource(R.drawable.baseline_photo_library_white_48);
        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;
@@ -4698,8 +4711,9 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
                Log.d(TAG, "cancel update_gallery_future");
            update_gallery_future.cancel(true);
        }
        ImageButton galleryButton = this.findViewById(R.id.gallery);
        CircleImageView galleryButton = this.findViewById(R.id.gallery);
        galleryButton.setImageBitmap(thumbnail);
        galleryButton.setBorderWidth(6);
        gallery_bitmap = thumbnail;
    }

@@ -4872,7 +4886,7 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen

        this.runOnUiThread(new Runnable() {
            public void run() {
                final ImageButton galleryButton = findViewById(R.id.gallery);
                final CircleImageView galleryButton = findViewById(R.id.gallery);
                if( started ) {
                    //galleryButton.setColorFilter(0x80ffffff, PorterDuff.Mode.MULTIPLY);
                    if( gallery_save_anim == null ) {
@@ -5908,36 +5922,38 @@ 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);

                    zoomControls.setOnZoomInClickListener(new View.OnClickListener(){
                    if( !mainUI.inImmersiveMode() ) {
                        View zoomInButton = findViewById(R.id.button_zoom_in);
                        View zoomOutButton = findViewById(R.id.button_zoom_out);
                        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) {
@@ -5947,8 +5963,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);
			updateMultiCameraIcon();
                    }

@@ -5964,20 +5979,23 @@ 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));

            View takePhotoButton = findViewById(R.id.take_photo);
            ImageButton takePhotoButton = findViewById(R.id.take_photo);
            if( sharedPreferences.getBoolean(PreferenceKeys.ShowTakePhotoPreferenceKey, true) ) {
                if( !mainUI.inImmersiveMode() ) {
                    takePhotoButton.setVisibility(View.VISIBLE);
@@ -6094,18 +6112,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 )
+7 −7
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import net.sourceforge.opencamera.preview.ApplicationInterface;
import net.sourceforge.opencamera.preview.BasicApplicationInterface;
import net.sourceforge.opencamera.preview.Preview;
import net.sourceforge.opencamera.preview.VideoProfile;
import net.sourceforge.opencamera.ui.CircleImageView;
import net.sourceforge.opencamera.ui.DrawPreview;

import android.annotation.TargetApi;
@@ -1887,9 +1888,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        panorama_pic_accepted = false;
        panorama_dir_left_to_right = true;

        main_activity.getMainUI().setTakePhotoIcon();
        View cancelPanoramaButton = main_activity.findViewById(R.id.cancel_panorama);
        cancelPanoramaButton.setVisibility(View.VISIBLE);
        main_activity.getMainUI().handlePanoromaModeButtonsVisibility();
        main_activity.getMainUI().closeExposureUI(); // close seekbars if open (popup is already closed when taking a photo)
        // taking the photo will end up calling MainUI.showGUI(), which will hide the other on-screen icons
    }
@@ -1925,9 +1924,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        if( is_cancelled ) {
            imageSaver.flushImageBatch();
        }
        main_activity.getMainUI().setTakePhotoIcon();
        View cancelPanoramaButton = main_activity.findViewById(R.id.cancel_panorama);
        cancelPanoramaButton.setVisibility(View.GONE);
        main_activity.getMainUI().handlePanoromaModeButtonsVisibility();
        main_activity.getMainUI().showGUI(); // refresh UI icons now that we've stopped panorama
    }

@@ -2352,6 +2349,9 @@ public class MyApplicationInterface extends BasicApplicationInterface {
        if( dategeo_subtitles && video_method != ApplicationInterface.VideoMethod.URI ) {
            startVideoSubtitlesTask(video_method);
        }

        ImageButton view = main_activity.findViewById(R.id.take_photo);
        view.setImageResource(R.drawable.ic_camera_video_recording);
    }

    @Override
@@ -2458,7 +2458,7 @@ public class MyApplicationInterface extends BasicApplicationInterface {
                }
            }
            if( thumbnail != null ) {
                ImageButton galleryButton = main_activity.findViewById(R.id.gallery);
                CircleImageView galleryButton = main_activity.findViewById(R.id.gallery);
                int width = thumbnail.getWidth();
                int height = thumbnail.getHeight();
                if( MyDebug.LOG )
+17 −0
Original line number Diff line number Diff line
package net.sourceforge.opencamera;

import android.content.Context;

public class ScaleUtils {

    private ScaleUtils() {
    }

    public static float convertPxToDp(Context context, float px) {
        return px / context.getResources().getDisplayMetrics().density;
    }

    public static float convertDpToPx(Context context, float dp) {
        return dp * context.getResources().getDisplayMetrics().density;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -153,8 +153,8 @@ class QrImageAnalyzer(private val activity: Activity, private val scope: Corouti
                )?.let {
                    DrawableCompat.wrap(it.mutate()).apply {
                        DrawableCompat.setTint(
                            this, activity.getThemeColor(
                                com.google.android.material.R.attr.colorOnBackground
                            this, activity.getColor(
                                R.color.e_icon_color
                            )
                        )
                    }
Loading