зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1460874 - Part 2: Rename instance variables to better match GeckoView code style. r=geckoview-reviewers,snorp
Differential Revision: https://phabricator.services.mozilla.com/D17744 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f83531d710
Коммит
b0ce764ff2
|
@ -30,14 +30,14 @@ class GeckoFontScaleListener
|
||||||
|
|
||||||
// We're referencing the *application* context, so this is in fact okay.
|
// We're referencing the *application* context, so this is in fact okay.
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private static final GeckoFontScaleListener listenerInstance = new GeckoFontScaleListener();
|
private static final GeckoFontScaleListener sInstance = new GeckoFontScaleListener();
|
||||||
|
|
||||||
private Context applicationContext;
|
private Context mApplicationContext;
|
||||||
private boolean initialized;
|
private boolean mInitialized;
|
||||||
private boolean running;
|
private boolean mRunning;
|
||||||
|
|
||||||
public static GeckoFontScaleListener getInstance() {
|
public static GeckoFontScaleListener getInstance() {
|
||||||
return listenerInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GeckoFontScaleListener() {
|
private GeckoFontScaleListener() {
|
||||||
|
@ -45,53 +45,53 @@ class GeckoFontScaleListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initialize(final Context context) {
|
public synchronized void initialize(final Context context) {
|
||||||
if (initialized) {
|
if (mInitialized) {
|
||||||
Log.w(LOGTAG, "Already initialized!");
|
Log.w(LOGTAG, "Already initialized!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
applicationContext = context.getApplicationContext();
|
mApplicationContext = context.getApplicationContext();
|
||||||
SharedPreferences prefs = GeckoSharedPrefs.forApp(applicationContext);
|
SharedPreferences prefs = GeckoSharedPrefs.forApp(mApplicationContext);
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
onPrefChange(prefs);
|
onPrefChange(prefs);
|
||||||
initialized = true;
|
mInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void shutdown() {
|
public synchronized void shutdown() {
|
||||||
if (!initialized) {
|
if (!mInitialized) {
|
||||||
Log.w(LOGTAG, "Already shut down!");
|
Log.w(LOGTAG, "Already shut down!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoSharedPrefs.forApp(applicationContext).unregisterOnSharedPreferenceChangeListener(this);
|
GeckoSharedPrefs.forApp(mApplicationContext).unregisterOnSharedPreferenceChangeListener(this);
|
||||||
stop();
|
stop();
|
||||||
applicationContext = null;
|
mApplicationContext = null;
|
||||||
initialized = false;
|
mInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void start() {
|
private synchronized void start() {
|
||||||
if (running) {
|
if (mRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentResolver contentResolver = applicationContext.getContentResolver();
|
ContentResolver contentResolver = mApplicationContext.getContentResolver();
|
||||||
Uri fontSizeSetting = Settings.System.getUriFor(Settings.System.FONT_SCALE);
|
Uri fontSizeSetting = Settings.System.getUriFor(Settings.System.FONT_SCALE);
|
||||||
contentResolver.registerContentObserver(fontSizeSetting, false, this);
|
contentResolver.registerContentObserver(fontSizeSetting, false, this);
|
||||||
onSystemFontScaleChange(contentResolver, false);
|
onSystemFontScaleChange(contentResolver, false);
|
||||||
|
|
||||||
running = true;
|
mRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void stop() {
|
private synchronized void stop() {
|
||||||
if (!running) {
|
if (!mRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentResolver contentResolver = applicationContext.getContentResolver();
|
ContentResolver contentResolver = mApplicationContext.getContentResolver();
|
||||||
contentResolver.unregisterContentObserver(this);
|
contentResolver.unregisterContentObserver(this);
|
||||||
onSystemFontScaleChange(contentResolver, /*stopping*/ true);
|
onSystemFontScaleChange(contentResolver, /*stopping*/ true);
|
||||||
|
|
||||||
running = false;
|
mRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSystemFontScaleChange(final ContentResolver contentResolver, boolean stopping) {
|
private void onSystemFontScaleChange(final ContentResolver contentResolver, boolean stopping) {
|
||||||
|
@ -122,7 +122,7 @@ class GeckoFontScaleListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
onSystemFontScaleChange(applicationContext.getContentResolver(), false);
|
onSystemFontScaleChange(mApplicationContext.getContentResolver(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread // According to the docs.
|
@UiThread // According to the docs.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче