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

Commit a104fae0 authored by Michael Webster's avatar Michael Webster
Browse files

Add flashlight button to gesture creation screen

Change-Id: I6302be349e2e14d8ac4180469ecbdb47b1bfa7f1
parent cb9e0691
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -48,6 +48,12 @@
            android:text="@string/gestures_toggle_sound"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:onClick="pickSoundOnly" />
        <Button android:id="@+id/flashlight_pick"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/gestures_flashlight"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:onClick="pickFlashlight" />
    </LinearLayout>
    <android.gesture.GestureOverlayView
        android:id="@+id/gestures_overlay"
+1 −0
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@
    <string name="gestures_error_loading">Problem with gesture file operation.</string>
    <string name="gestures_unlock_only">Unlock phone</string>
    <string name="gestures_toggle_sound">Toggle sound</string>
    <string name="gestures_flashlight">Flashlight</string>
    <string name="pref_lockscreen_disable_unlock_tab">Disable unlock slider</string>
    <string name="pref_lockscreen_disable_unlock_tab_summary">Note: You need to enable trackball, menu key, or gesture unlocking before this option becomes available</string>
    <string name="gestures_explain_create_screen">Pick an action to perform (or select Unlock or Sound) and draw a gesture on the screen.</string>
+14 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ import com.cyanogenmod.cmparts.R;
import android.app.Activity;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.view.MotionEvent;
@@ -28,6 +30,7 @@ import android.graphics.RectF;
import android.widget.Button;
import android.widget.Toast;

import java.util.List;
import java.util.ArrayList;

public class GestureCreateActivity extends Activity {
@@ -52,6 +55,13 @@ public class GestureCreateActivity extends Activity {
        mShortcutButton = (Button) findViewById(R.id.shortcut_picker);
        GestureOverlayView overlay = (GestureOverlayView) findViewById(R.id.gestures_overlay);
        overlay.addOnGestureListener(new GesturesProcessor());
        // Remove flashlight button if Torch app isn't on the phone
        PackageManager pm = this.getBaseContext().getPackageManager();
        List<ResolveInfo> l = pm.queryBroadcastReceivers(new Intent("net.cactii.flash2.TOGGLE_FLASHLIGHT"), 0);
        if (l.isEmpty()) {
            Button flashlight = (Button) findViewById(R.id.flashlight_pick);
            flashlight.setVisibility(View.GONE);
        }
    }

    @Override
@@ -154,6 +164,10 @@ public class GestureCreateActivity extends Activity {
        mUri = "SOUND___SOUND";
    }

    public void pickFlashlight(View v) {
        mShortcutButton.setText(getString(R.string.gestures_flashlight));
        mUri = "FLASHLIGHT___FLASHLIGHT";
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {