-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathBulletCommentsSettingsFragment.java
More file actions
87 lines (77 loc) · 3.96 KB
/
BulletCommentsSettingsFragment.java
File metadata and controls
87 lines (77 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package org.schabi.newpipe.settings;
import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.preference.SeekBarPreference;
import org.schabi.newpipe.R;
public class BulletCommentsSettingsFragment extends BasePreferenceFragment {
private SharedPreferences.OnSharedPreferenceChangeListener listener;
@Override
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
addPreferencesFromResourceRegistry();
listener = (sharedPreferences, s) -> {
if (s.equals(getString(R.string.top_bottom_bullet_comments_duration_key))) {
final int newSetting = sharedPreferences.getInt(s, 8);
final SeekBarPreference topBottomBulletCommentsDuration = findPreference(s);
if (topBottomBulletCommentsDuration != null) {
topBottomBulletCommentsDuration.setSummary(newSetting + " seconds");
}
} else if (s.equals(getString(R.string.regular_bullet_comments_duration_key))) {
final int newSetting = sharedPreferences.getInt(s, 8);
final SeekBarPreference regularBulletCommentsDuration = findPreference(s);
if (regularBulletCommentsDuration != null) {
regularBulletCommentsDuration.setSummary(newSetting + " seconds");
}
} else if (s.equals(getString(R.string.max_bullet_comments_rows_top_key))
|| s.equals(getString(R.string.max_bullet_comments_rows_bottom_key))
|| s.equals(getString(R.string.max_bullet_comments_rows_regular_key))) {
final int newSetting = sharedPreferences.getInt(s, 15);
final SeekBarPreference rowsPref = findPreference(s);
if (rowsPref != null) {
rowsPref.setSummary(String.valueOf(newSetting));
}
}
};
final SeekBarPreference regularBulletCommentsDuration =
findPreference(getString(R.string.regular_bullet_comments_duration_key));
if (regularBulletCommentsDuration != null) {
regularBulletCommentsDuration.setMin(5);
}
final SeekBarPreference topBottomBulletCommentsDuration =
findPreference(getString(R.string.top_bottom_bullet_comments_duration_key));
if (topBottomBulletCommentsDuration != null) {
topBottomBulletCommentsDuration.setMin(5);
}
final SeekBarPreference topRowsPref =
findPreference(getString(R.string.max_bullet_comments_rows_top_key));
final SeekBarPreference bottomRowsPref =
findPreference(getString(R.string.max_bullet_comments_rows_bottom_key));
final SeekBarPreference regularRowsPref =
findPreference(getString(R.string.max_bullet_comments_rows_regular_key));
final SharedPreferences sharedPreferences =
getPreferenceManager().getSharedPreferences();
if (topRowsPref != null) {
topRowsPref.setSummary(String.valueOf(sharedPreferences.getInt(
getString(R.string.max_bullet_comments_rows_top_key), 15)));
}
if (bottomRowsPref != null) {
bottomRowsPref.setSummary(String.valueOf(sharedPreferences.getInt(
getString(R.string.max_bullet_comments_rows_bottom_key), 15)));
}
if (regularRowsPref != null) {
regularRowsPref.setSummary(String.valueOf(sharedPreferences.getInt(
getString(R.string.max_bullet_comments_rows_regular_key), 15)));
}
}
@Override
public void onResume() {
super.onResume();
getPreferenceManager().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(listener);
}
@Override
public void onPause() {
super.onPause();
getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(listener);
}
}