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

Commit 151a49b3 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

SetupWizard: Add ability to skip the setup wizard

parent 262694ee
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
package org.lineageos.setupwizard;

import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
@@ -26,12 +28,17 @@ import android.widget.TextView;
import com.google.android.setupcompat.template.FooterButtonStyleUtils;
import com.google.android.setupcompat.util.SystemBarHelper;

import org.lineageos.setupwizard.util.SetupWizardUtils;

public class WelcomeActivity extends BaseSetupWizardActivity {

    public static final String TAG = WelcomeActivity.class.getSimpleName();

    private View mRootView;

    private int mVolumeUpCount = 0;
    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -57,6 +64,30 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
    public void onBackPressed() {
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            mVolumeUpCount++;
            if (mVolumeUpCount == 1) {
                 // Schedule a runnable to reset the count after 1 second
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mVolumeUpCount = 0;
                    }
                }, 1000); // 1 second delay
            }
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && mVolumeUpCount == 2) {
            // If the volume down key is pressed and the volume up count is 2
            // Finish the setup wizard and enable the status bar
            SetupWizardUtils.finishSetupWizard(getApplicationContext());
            SetupWizardUtils.enableStatusBar(getApplicationContext());
            finish();
        }

        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.welcome_activity;