2017-09-21 10:03:05 -07:00
|
|
|
package org.thoughtcrime.securesms.preferences.widgets;
|
2017-04-21 22:50:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2020-08-19 10:06:26 +10:00
|
|
|
import androidx.preference.Preference;
|
|
|
|
import androidx.preference.PreferenceViewHolder;
|
2017-04-21 22:50:49 -07:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
2017-04-21 22:50:49 -07:00
|
|
|
|
2017-12-01 12:55:24 -08:00
|
|
|
public class SignalPreference extends Preference {
|
2017-04-21 22:50:49 -07:00
|
|
|
|
|
|
|
private TextView rightSummary;
|
|
|
|
private CharSequence summary;
|
|
|
|
|
2017-12-01 12:55:24 -08:00
|
|
|
public SignalPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
2017-04-21 22:50:49 -07:00
|
|
|
super(context, attrs, defStyleAttr, defStyleRes);
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
2017-12-01 12:55:24 -08:00
|
|
|
public SignalPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
2017-04-21 22:50:49 -07:00
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
2017-12-01 12:55:24 -08:00
|
|
|
public SignalPreference(Context context, AttributeSet attrs) {
|
2017-04-21 22:50:49 -07:00
|
|
|
super(context, attrs);
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
2017-12-01 12:55:24 -08:00
|
|
|
public SignalPreference(Context context) {
|
2017-04-21 22:50:49 -07:00
|
|
|
super(context);
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initialize() {
|
|
|
|
setWidgetLayoutResource(R.layout.preference_right_summary_widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-09-20 18:10:44 -07:00
|
|
|
public void onBindViewHolder(PreferenceViewHolder view) {
|
|
|
|
super.onBindViewHolder(view);
|
2017-04-21 22:50:49 -07:00
|
|
|
|
|
|
|
this.rightSummary = (TextView)view.findViewById(R.id.right_summary);
|
2017-12-01 12:55:24 -08:00
|
|
|
setSummary(this.summary);
|
2017-04-21 22:50:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setSummary(CharSequence summary) {
|
|
|
|
super.setSummary(null);
|
|
|
|
|
2017-12-01 12:55:24 -08:00
|
|
|
this.summary = summary;
|
|
|
|
|
|
|
|
if (this.rightSummary != null) {
|
|
|
|
this.rightSummary.setText(summary);
|
2017-04-21 22:50:49 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|