prepare settings

This commit is contained in:
tom79 2019-09-13 17:37:59 +02:00
parent 01996465b8
commit ad5d00b4d8
4 changed files with 106 additions and 2 deletions

View File

@ -776,7 +776,63 @@ public class ContentSettingsFragment extends Fragment implements ScreenShotable
@Override
public void afterTextChanged(Editable s) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.SET_INVIDIOUS_HOST, s.toString().trim());
if( s.toString().trim().length() > 0) {
editor.putString(Helper.SET_INVIDIOUS_HOST, s.toString().toLowerCase().trim());
}else{
editor.putString(Helper.SET_INVIDIOUS_HOST, null);
}
editor.apply();
}
});
TextView set_nitter_host = rootView.findViewById(R.id.set_nitter_host);
boolean nitter = sharedpreferences.getBoolean(Helper.SET_NITTER, false);
final CheckBox set_nitter = rootView.findViewById(R.id.set_nitter);
set_nitter.setChecked(nitter);
set_nitter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_NITTER, set_nitter.isChecked());
editor.apply();
if (set_nitter.isChecked()) {
set_nitter_host.setVisibility(View.VISIBLE);
} else {
set_nitter_host.setVisibility(View.GONE);
}
}
});
if (nitter) {
set_nitter_host.setVisibility(View.VISIBLE);
} else {
set_nitter_host.setVisibility(View.GONE);
}
String nitterHost = sharedpreferences.getString(Helper.SET_NITTER_HOST, null);
if (nitterHost != null) {
set_nitter_host.setText(nitterHost);
}
set_nitter_host.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
SharedPreferences.Editor editor = sharedpreferences.edit();
if( s.toString().trim().length() > 0) {
editor.putString(Helper.SET_NITTER_HOST, s.toString().toLowerCase().trim());
}else{
editor.putString(Helper.SET_NITTER_HOST, null);
}
editor.apply();
}
});

View File

@ -437,6 +437,8 @@ public class Helper {
public static final String SET_INVIDIOUS = "set_invidious";
public static final String SET_INVIDIOUS_HOST = "set_invidious_host";
public static final String SET_NITTER = "set_nitter";
public static final String SET_NITTER_HOST = "set_nitter_host";
public static final String DEFAULT_INVIDIOUS_HOST = "invidio.us";
public static final String SET_NOTIF_VALIDATION = "set_share_validation";
public static final String SET_NOTIF_VALIDATION_FAV = "set_share_validation_fav";

View File

@ -188,7 +188,6 @@
android:text="@string/set_invidious"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/mastodonC2"
android:text="@string/set_invidious_indication"
@ -200,10 +199,52 @@
<EditText
android:hint="@string/set_invidious_host"
android:id="@+id/set_invidious_host"
android:inputType="textWebEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_checkbox_margin"
android:layout_marginBottom="@dimen/settings_checkbox_margin"
android:orientation="horizontal">
<CheckBox
android:id="@+id/set_nitter"
android:layout_width="wrap_content"
android:textSize="16sp"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/set_nitter_text"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textSize="16sp"
android:text="@string/set_nitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:textColor="@color/mastodonC2"
android:text="@string/set_nitter_indication"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<EditText
android:hint="@string/set_nitter_host"
android:id="@+id/set_nitter_host"
android:inputType="textWebEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -1206,6 +1206,11 @@
<string name="set_invidious">Replace Youtube with Invidio.us</string>
<string name="set_invidious_indication">Invidious is an alternative front-end to YouTube</string>
<string name="set_invidious_host">Enter your custom host or leave blank for using invidio.us</string>
<string name="set_nitter">Replace Twitter with Nitter</string>
<string name="set_nitter_indication">Nitter is open source alternative Twitter front-end focused on privacy.</string>
<string name="set_nitter_host">Enter your custom host or leave blank for using nitter.net</string>
<string name="set_hide_status_bar">Hide Fedilab notification bar</string>
<string name="set_hide_status_bar_indication">For hiding the remaining notification in the status bar, click on the eye icon button then uncheck: \"Display in status bar\"</string>
<string name="set_live_type_title">Enable delayed notifications</string>