Issue #297 - Adds custom tabs in settings

This commit is contained in:
stom79 2018-02-09 17:01:13 +01:00
parent 30105fa603
commit 12abe7502e
4 changed files with 31 additions and 2 deletions

View File

@ -302,13 +302,17 @@ public class SettingsFragment extends Fragment {
final CheckBox set_embedded_browser = rootView.findViewById(R.id.set_embedded_browser);
final LinearLayout set_javascript_container = rootView.findViewById(R.id.set_javascript_container);
final CheckBox set_custom_tabs = rootView.findViewById(R.id.set_custom_tabs);
final SwitchCompat set_javascript = rootView.findViewById(R.id.set_javascript);
boolean javascript = sharedpreferences.getBoolean(Helper.SET_JAVASCRIPT, true);
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
boolean custom_tabs = sharedpreferences.getBoolean(Helper.SET_CUSTOM_TABS, true);
if( !embedded_browser){
set_javascript_container.setVisibility(View.GONE);
set_custom_tabs.setVisibility(View.VISIBLE);
}else{
set_javascript_container.setVisibility(View.VISIBLE);
set_custom_tabs.setVisibility(View.GONE);
}
set_embedded_browser.setChecked(embedded_browser);
set_embedded_browser.setOnClickListener(new View.OnClickListener() {
@ -319,8 +323,10 @@ public class SettingsFragment extends Fragment {
editor.apply();
if( !set_embedded_browser.isChecked()){
set_javascript_container.setVisibility(View.GONE);
set_custom_tabs.setVisibility(View.VISIBLE);
}else{
set_javascript_container.setVisibility(View.VISIBLE);
set_custom_tabs.setVisibility(View.GONE);
}
}
});
@ -335,6 +341,16 @@ public class SettingsFragment extends Fragment {
}
});
set_custom_tabs.setChecked(custom_tabs);
set_custom_tabs.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_CUSTOM_TABS, isChecked);
editor.apply();
}
});
final LinearLayout set_cookies_container = rootView.findViewById(R.id.set_cookies_container);
final SwitchCompat set_cookies = rootView.findViewById(R.id.set_cookies);
boolean cookies = sharedpreferences.getBoolean(Helper.SET_COOKIES, false);

View File

@ -230,7 +230,13 @@
android:layout_height="wrap_content" />
<CheckBox
android:visibility="gone"
android:layout_marginTop="10dp"
android:id="@+id/set_custom_tabs"
android:layout_width="wrap_content"
android:text="@string/custom_tabs"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/set_javascript_container"

View File

@ -228,7 +228,13 @@
android:layout_height="wrap_content" />
<CheckBox
android:visibility="gone"
android:layout_marginTop="10dp"
android:id="@+id/set_custom_tabs"
android:layout_width="wrap_content"
android:text="@string/custom_tabs"
android:layout_height="wrap_content" />
<LinearLayout

View File

@ -325,6 +325,7 @@
<string name="settings_hour_init">Start time</string>
<string name="settings_hour_end">End time</string>
<string name="embedded_browser">Use the built-in browser</string>
<string name="custom_tabs">Custom tabs</string>
<string name="use_javascript">Enable Javascript</string>
<string name="use_cookies">Allow third-party cookies</string>
<string name="settings_ui_layout">Layout for timelines: </string>