导航菜单

页面标题

页面副标题

EFFICIENT POS v1.5.7 - SettingsActivity.java 源代码

正在查看: EFFICIENT POS v1.5.7 应用的 SettingsActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package dev.gtr.pos.activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SwitchCompat;
import dev.gtr.pos.R;

public class SettingsActivity extends AppCompatActivity implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
    SharedPreferences.Editor editor;
    ImageView imageViewBack;
    String isBrowserChecked;
    String isCheckedMultiScan;
    String isCheckedPayment;
    String isCheckedPrint;
    String isCheckedScan;
    int progress = 0;
    SeekBar seekBar;
    String seekScanSpeed;
    SharedPreferences sharedPreferences;
    SwitchCompat switchCompatBrowser;
    SwitchCompat switchCompatMultiScan;
    SwitchCompat switchCompatPayment;
    SwitchCompat switchCompatPrint;
    SwitchCompat switchCompatScan;
    TextView textViewTitle;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_settings);
        this.textViewTitle = (TextView) findViewById(R.id.textView_title);
        this.imageViewBack = (ImageView) findViewById(R.id.imageView_back);
        this.switchCompatScan = findViewById(R.id.sw_continuous_scan);
        this.switchCompatBrowser = findViewById(R.id.switchCompat);
        this.switchCompatPayment = findViewById(R.id.sw_auto_payment);
        this.switchCompatPrint = findViewById(R.id.sw_continuous_print);
        this.switchCompatMultiScan = findViewById(R.id.sw_multi_scan);
        this.seekBar = (SeekBar) findViewById(R.id.seekbar_scale);
        this.imageViewBack.setOnClickListener(this);
        this.textViewTitle.setText("Settings");
        this.switchCompatScan.setOnCheckedChangeListener(this);
        this.switchCompatPrint.setOnCheckedChangeListener(this);
        this.switchCompatPayment.setOnCheckedChangeListener(this);
        this.switchCompatMultiScan.setOnCheckedChangeListener(this);
        this.switchCompatBrowser.setOnCheckedChangeListener(this);
        init();
    }

    private void init() {
        SharedPreferences sharedPreferences = getSharedPreferences("LOGIN", 0);
        this.sharedPreferences = sharedPreferences;
        this.editor = sharedPreferences.edit();
        this.isCheckedScan = this.sharedPreferences.getString("SCAN", "0");
        this.isCheckedPrint = this.sharedPreferences.getString("PRINT", "0");
        this.isCheckedPayment = this.sharedPreferences.getString("PAYMENT", "0");
        this.isCheckedMultiScan = this.sharedPreferences.getString("MULTISCAN", "0");
        this.isBrowserChecked = this.sharedPreferences.getString("IN_BROWSER", "0");
        this.seekScanSpeed = this.sharedPreferences.getString("SEEKSCAN", "0");
        if (this.isCheckedScan.equals("1")) {
            this.switchCompatScan.setChecked(true);
        }
        if (this.isCheckedPayment.equals("1")) {
            this.switchCompatPayment.setChecked(true);
        }
        if (this.isBrowserChecked.equals("1")) {
            this.switchCompatBrowser.setChecked(true);
        }
        if (this.isCheckedPrint.equals("1")) {
            this.switchCompatBrowser.setChecked(true);
        }
        if (this.isCheckedMultiScan.equals("1")) {
            this.switchCompatMultiScan.setChecked(true);
        }
        if (!this.seekScanSpeed.equals("0")) {
            this.seekBar.setProgress(Integer.parseInt(this.seekScanSpeed));
        } else {
            this.editor.putString("SEEKSCAN", "5");
            this.editor.apply();
            this.seekScanSpeed = "5";
            this.seekBar.setProgress(Integer.parseInt("5"));
        }
        this.seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                SettingsActivity.this.editor.putString("SEEKSCAN", "" + seekBar.getProgress());
                SettingsActivity.this.editor.apply();
            }
        });
    }

    @Override
    public void onClick(View view) {
        if (view == this.imageViewBack) {
            finish();
        }
    }

    @Override
    public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
        if (compoundButton == this.switchCompatScan) {
            if (z) {
                this.editor.putString("SCAN", "1");
                this.editor.putString("MULTISCAN", "0");
                this.switchCompatMultiScan.setChecked(false);
            } else {
                this.editor.putString("SCAN", "0");
            }
            this.editor.apply();
        }
        if (compoundButton == this.switchCompatPayment) {
            if (z) {
                this.editor.putString("PAYMENT", "1");
            } else {
                this.editor.putString("PAYMENT", "0");
            }
            this.editor.apply();
        }
        if (compoundButton == this.switchCompatPrint) {
            if (z) {
                this.editor.putString("PRINT", "1");
            } else {
                this.editor.putString("PRINT", "0");
            }
            this.editor.apply();
        }
        if (compoundButton == this.switchCompatMultiScan) {
            if (z) {
                this.editor.putString("MULTISCAN", "1");
                this.editor.putString("SCAN", "0");
                this.switchCompatScan.setChecked(false);
            } else {
                this.editor.putString("MULTISCAN", "0");
            }
            this.editor.apply();
        }
        if (compoundButton == this.switchCompatBrowser) {
            if (z) {
                this.editor.putString("IN_BROWSER", "1");
            } else {
                this.editor.putString("IN_BROWSER", "0");
            }
            this.editor.apply();
        }
    }
}