Commit 22bfc0a7 authored by Roumen Petrov's avatar Roumen Petrov

construct settings only from context

parent 51d5fee0
......@@ -71,10 +71,8 @@ protected void onCreate(Bundle savedInstanceState) {
return;
}
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
mSettings = new TermSettings(getResources(), pref);
path_settings = new PathSettings(getResources(), pref);
mSettings = new TermSettings(this);
path_settings = new PathSettings(this);
PathCollector path_collector = new PathCollector(this, path_settings);
path_collector.setOnPathsReceivedListener(() -> {
path_collected = true;
......
......@@ -215,12 +215,11 @@ public void onCreate(Bundle icicle) {
if (icicle == null)
onNewIntent(getIntent());
final SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mSettings = new TermSettings(getResources(), mPrefs);
mPrefs.registerOnSharedPreferenceChangeListener(this);
mSettings = new TermSettings(this);
path_settings = new PathSettings(this);
mActionBarMode = mSettings.actionBarMode();
path_settings = new PathSettings(getResources(), mPrefs);
path_collected = false;
PathCollector path_collector = new PathCollector(this, path_settings);
path_collector.setOnPathsReceivedListener(() -> {
......@@ -228,6 +227,9 @@ public void onCreate(Bundle icicle) {
populateSessions();
});
PreferenceManager.getDefaultSharedPreferences(this)
.registerOnSharedPreferenceChangeListener(this);
TSIntent = new Intent(this, TermService.class);
startService(TSIntent);
......
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (C) 2018 Roumen Petrov. All rights reserved.
* Copyright (C) 2018-2019 Roumen Petrov. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -17,6 +17,7 @@
package jackpal.androidterm.compat;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.text.TextUtils;
......@@ -25,6 +26,8 @@
import java.io.File;
import androidx.preference.PreferenceManager;
/* NOTE: refactored path settings from TermSettings.java
* TODO: pending removal as functionality does not support multiple entries.
......@@ -42,9 +45,9 @@ private PathSettings(Resources res) {
path_verify = res.getBoolean(R.bool.pref_verify_path_default);
}
public PathSettings(Resources res, SharedPreferences prefs) {
this(res);
extractPreferences(prefs);
public PathSettings(Context context) {
this(context.getResources());
extractPreferences(PreferenceManager.getDefaultSharedPreferences(context));
}
public void extractPreferences(SharedPreferences prefs) {
......
......@@ -131,12 +131,8 @@
private static final int BACK_KEY_MAX = 4;
public TermSettings(Context context) {
this(context.getResources(), PreferenceManager.getDefaultSharedPreferences(context));
}
public TermSettings(Resources res, SharedPreferences prefs) {
readDefaultPrefs(res);
readPrefs(prefs);
readDefaultPrefs(context.getResources());
readPrefs(PreferenceManager.getDefaultSharedPreferences(context));
}
private void readDefaultPrefs(Resources res) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment