2015-05-17 12:13:34 +00:00
|
|
|
package org.thoughtcrime.securesms.components;
|
|
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Build;
|
2017-09-21 01:10:44 +00:00
|
|
|
import android.support.v7.preference.CheckBoxPreference;
|
2018-02-26 17:58:18 +00:00
|
|
|
import android.support.v7.preference.Preference;
|
2015-05-17 12:13:34 +00:00
|
|
|
import android.util.AttributeSet;
|
2018-02-26 17:58:18 +00:00
|
|
|
import android.view.View;
|
2015-05-17 12:13:34 +00:00
|
|
|
|
2019-07-24 02:30:23 +00:00
|
|
|
import network.loki.messenger.R;
|
2015-05-17 12:13:34 +00:00
|
|
|
|
|
|
|
public class SwitchPreferenceCompat extends CheckBoxPreference {
|
|
|
|
|
2018-02-26 17:58:18 +00:00
|
|
|
private Preference.OnPreferenceClickListener listener;
|
|
|
|
|
2015-05-17 12:13:34 +00:00
|
|
|
public SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
setLayoutRes();
|
|
|
|
}
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
|
|
public SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
|
|
super(context, attrs, defStyleAttr, defStyleRes);
|
|
|
|
setLayoutRes();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SwitchPreferenceCompat(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
setLayoutRes();
|
|
|
|
}
|
|
|
|
|
|
|
|
public SwitchPreferenceCompat(Context context) {
|
|
|
|
super(context);
|
|
|
|
setLayoutRes();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setLayoutRes() {
|
|
|
|
setWidgetLayoutResource(R.layout.switch_compat_preference);
|
|
|
|
}
|
2018-02-26 17:58:18 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setOnPreferenceClickListener(Preference.OnPreferenceClickListener listener) {
|
|
|
|
this.listener = listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onClick() {
|
|
|
|
if (listener == null || !listener.onPreferenceClick(this)) {
|
|
|
|
super.onClick();
|
|
|
|
}
|
|
|
|
}
|
2015-05-17 12:13:34 +00:00
|
|
|
}
|