Search in sources :

Example 1 with SharedPreferencesContainer

use of javax.microedition.util.param.SharedPreferencesContainer in project J2ME-Loader by nikita36078.

the class ConfigActivity method onCreate.

@SuppressLint({ "StringFormatMatches", "StringFormatInvalid" })
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_config);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ContextHolder.setCurrentActivity(this);
    pathToMidletDir = getIntent().getDataString();
    String appName = pathToMidletDir.substring(pathToMidletDir.lastIndexOf('/') + 1);
    keylayoutFile = new File(DATA_DIR + appName, "VirtualKeyboardLayout");
    dataDir = new File(DATA_DIR + appName);
    params = new SharedPreferencesContainer(appName, Context.MODE_PRIVATE, this);
    System.setProperty("microedition.sensor.version", "1");
    System.setProperty("microedition.platform", "Nokia 6233");
    System.setProperty("microedition.configuration", "CDLC1.1");
    System.setProperty("microedition.profiles", "MIDP2.0");
    System.setProperty("microedition.m3g.version", "1.1");
    System.setProperty("microedition.media.version", "1.0");
    System.setProperty("supports.mixing", "true");
    System.setProperty("supports.audio.capture", "false");
    System.setProperty("supports.video.capture", "false");
    System.setProperty("supports.recording", "false");
    System.setProperty("microedition.pim.version", "1.0");
    System.setProperty("microedition.io.file.FileConnection.version", "1.0");
    System.setProperty("microedition.locale", Locale.getDefault().getCountry().toLowerCase());
    System.setProperty("microedition.encoding", "ISO-8859-1");
    System.setProperty("user.home", Environment.getExternalStorageDirectory().getPath());
    tfScreenWidth = findViewById(R.id.tfScreenWidth);
    tfScreenHeight = findViewById(R.id.tfScreenHeight);
    tfScreenBack = findViewById(R.id.tfScreenBack);
    cxScaleToFit = findViewById(R.id.cxScaleToFit);
    sbScaleRatio = findViewById(R.id.sbScaleRatio);
    tfScaleRatioValue = findViewById(R.id.tfScaleRatioValue);
    spOrientation = findViewById(R.id.spOrientation);
    cxKeepAspectRatio = findViewById(R.id.cxKeepAspectRatio);
    cxFilter = findViewById(R.id.cxFilter);
    cxImmediate = findViewById(R.id.cxImmediate);
    cxHwAcceleration = findViewById(R.id.cxHwAcceleration);
    tfFontSizeSmall = findViewById(R.id.tfFontSizeSmall);
    tfFontSizeMedium = findViewById(R.id.tfFontSizeMedium);
    tfFontSizeLarge = findViewById(R.id.tfFontSizeLarge);
    cxFontSizeInSP = findViewById(R.id.cxFontSizeInSP);
    tfSystemProperties = findViewById(R.id.tfSystemProperties);
    cxShowKeyboard = findViewById(R.id.cxIsShowKeyboard);
    cxVKFeedback = findViewById(R.id.cxVKFeedback);
    cxTouchInput = findViewById(R.id.cxTouchInput);
    sbVKAlpha = findViewById(R.id.sbVKAlpha);
    tfVKHideDelay = findViewById(R.id.tfVKHideDelay);
    tfVKFore = findViewById(R.id.tfVKFore);
    tfVKBack = findViewById(R.id.tfVKBack);
    tfVKSelFore = findViewById(R.id.tfVKSelFore);
    tfVKSelBack = findViewById(R.id.tfVKSelBack);
    tfVKOutline = findViewById(R.id.tfVKOutline);
    screenWidths = new ArrayList<>();
    screenHeights = new ArrayList<>();
    screenAdapter = new ArrayList<>();
    fillScreenSizePresets(ContextHolder.getDisplayWidth(), ContextHolder.getDisplayHeight());
    fontSmall = new ArrayList<>();
    fontMedium = new ArrayList<>();
    fontLarge = new ArrayList<>();
    fontAdapter = new ArrayList<>();
    addFontSizePreset("128 x 128", 9, 13, 15);
    addFontSizePreset("128 x 160", 13, 15, 20);
    addFontSizePreset("176 x 220", 15, 18, 22);
    addFontSizePreset("240 x 320", 18, 22, 26);
    findViewById(R.id.cmdScreenSizePresets).setOnClickListener(this);
    findViewById(R.id.cmdSwapSizes).setOnClickListener(this);
    findViewById(R.id.cmdFontSizePresets).setOnClickListener(this);
    findViewById(R.id.cmdScreenBack).setOnClickListener(this);
    findViewById(R.id.cmdVKBack).setOnClickListener(this);
    findViewById(R.id.cmdVKFore).setOnClickListener(this);
    findViewById(R.id.cmdVKSelBack).setOnClickListener(this);
    findViewById(R.id.cmdVKSelFore).setOnClickListener(this);
    findViewById(R.id.cmdVKOutline).setOnClickListener(this);
    sbScaleRatio.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
            tfScaleRatioValue.setText(String.valueOf(progress));
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });
    tfScaleRatioValue.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            Integer enteredProgress = Integer.valueOf(s.toString());
            sbScaleRatio.setProgress(enteredProgress);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    loadParams(params);
    applyConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        cxHwAcceleration.setVisibility(View.VISIBLE);
    }
    cxVKFeedback.setEnabled(cxShowKeyboard.isChecked());
    cxShowKeyboard.setOnClickListener(v -> {
        if (!((CheckBox) v).isChecked()) {
            cxVKFeedback.setEnabled(false);
        } else {
            cxVKFeedback.setEnabled(true);
        }
    });
    File appSettings = new File(getFilesDir().getParent() + File.separator + "shared_prefs", appName + ".xml");
    if (appSettings.exists() && !getIntent().getBooleanExtra(SHOW_SETTINGS_KEY, false)) {
        startMIDlet();
    }
}
Also used : SeekBar(android.widget.SeekBar) SharedPreferencesContainer(javax.microedition.util.param.SharedPreferencesContainer) SuppressLint(android.annotation.SuppressLint) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) File(java.io.File) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 SeekBar (android.widget.SeekBar)1 File (java.io.File)1 SharedPreferencesContainer (javax.microedition.util.param.SharedPreferencesContainer)1