Zoom level option color should be grayed when disabled #556

This commit is contained in:
prajurock 2019-02-22 17:52:34 +05:30 committed by Isaac Hutt
parent cfe6258618
commit 367e0d642b

View File

@ -19,6 +19,7 @@ package org.kiwix.kiwixmobile.settings;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
@ -26,6 +27,9 @@ import android.widget.SeekBar;
import android.widget.TextView;
import org.kiwix.kiwixmobile.R;
import static org.kiwix.kiwixmobile.utils.Constants.PREF_NIGHTMODE;
import static org.kiwix.kiwixmobile.utils.Constants.PREF_ZOOM_ENABLED;
public class SliderPreference extends DialogPreference {
protected final static int SEEKBAR_MAX = 500;
@ -159,4 +163,29 @@ public class SliderPreference extends DialogPreference {
}
super.onDialogClosed(positiveResult);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
setGrayState(view);
}
private void setGrayState(View view) {
boolean enabled = getPreferenceManager().getSharedPreferences().getBoolean(PREF_ZOOM_ENABLED, false);
boolean Nightmode = getPreferenceManager().getSharedPreferences().getBoolean(PREF_NIGHTMODE, false);
TextView titleView = view.findViewById(android.R.id.title);
TextView summaryTV = view.findViewById(android.R.id.summary);
if (!enabled) {
titleView.setTextColor(Color.GRAY);
summaryTV.setTextColor(Color.GRAY);
} else {
if (Nightmode) {
titleView.setTextColor(Color.WHITE);
summaryTV.setTextColor(Color.WHITE);
} else {
titleView.setTextColor(Color.BLACK);
summaryTV.setTextColor(Color.BLACK);
}
}
}
}