mirror of
https://github.com/TrianguloY/UrlChecker.git
synced 2024-09-19 20:02:16 +02:00
individually toggle module titles & round background
This commit is contained in:
parent
229978d0e1
commit
beb08da7a4
@ -34,7 +34,6 @@ public class ModulesActivity extends Activity {
|
||||
private LinearLayout list;
|
||||
private final Map<AModuleConfig, Switch> switches = new HashMap<>();
|
||||
private GenericPref.LstStr order;
|
||||
private GenericPref.Bool showDecorations;
|
||||
|
||||
// ------------------- listeners -------------------
|
||||
|
||||
@ -49,9 +48,6 @@ public class ModulesActivity extends Activity {
|
||||
|
||||
list = findViewById(R.id.list);
|
||||
order = ModuleManager.ORDER_PREF(this);
|
||||
showDecorations = ModuleManager.DECORATIONS_PREF(this);
|
||||
|
||||
initConfig();
|
||||
|
||||
// initialize modules
|
||||
for (AModuleData module : ModuleManager.getModules(true, this)) {
|
||||
@ -74,10 +70,6 @@ public class ModulesActivity extends Activity {
|
||||
|
||||
// ------------------- actions -------------------
|
||||
|
||||
private void initConfig() {
|
||||
showDecorations.attachToCheckBox(findViewById(R.id.showDecorations));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes and adds a module to the list
|
||||
*/
|
||||
@ -113,6 +105,9 @@ public class ModulesActivity extends Activity {
|
||||
title.setText(getString(R.string.dd, getString(module.getName())));
|
||||
AndroidUtils.setAsClickable(title);
|
||||
|
||||
// configure generic settings
|
||||
ModuleManager.getDecorationsPrefOfModule(module, this).attachToCheckBox(parent.findViewById(R.id.decorations));
|
||||
|
||||
// configuration of the module
|
||||
var child = Inflater.inflate(config.getLayoutId(), parent.findViewById(R.id.box), this);
|
||||
config.onInitialize(child);
|
||||
|
@ -117,7 +117,6 @@ public class MainDialog extends Activity {
|
||||
// ------------------- initialize -------------------
|
||||
|
||||
private LinearLayout ll_mods;
|
||||
private boolean showDecorations;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -132,7 +131,6 @@ public class MainDialog extends Activity {
|
||||
ll_mods = findViewById(R.id.middle_modules);
|
||||
|
||||
// initialize
|
||||
showDecorations = ModuleManager.DECORATIONS_PREF(this).get();
|
||||
initializeModules();
|
||||
|
||||
// load url
|
||||
@ -179,7 +177,7 @@ public class MainDialog extends Activity {
|
||||
|
||||
ViewGroup parent;
|
||||
// set module block
|
||||
if (showDecorations) {
|
||||
if (ModuleManager.getDecorationsPrefOfModule(moduleData, this).get()) {
|
||||
// init decorations
|
||||
View block = Inflater.inflate(R.layout.dialog_module, ll_mods, this);
|
||||
final TextView title = block.findViewById(R.id.title);
|
||||
|
@ -64,23 +64,25 @@ public class ModuleManager {
|
||||
|
||||
// ------------------- enabled/disabled -------------------
|
||||
|
||||
private static final String PREF_SUFFIX = "_en";
|
||||
private static final String ENABLED_PREF_SUFFIX = "_en";
|
||||
|
||||
/**
|
||||
* Returns a preference to indicate if a specific module is enabled or not
|
||||
*/
|
||||
public static GenericPref.Bool getEnabledPrefOfModule(AModuleData module, Context cntx) {
|
||||
return new GenericPref.Bool(module.getId() + PREF_SUFFIX, module.isEnabledByDefault(), cntx);
|
||||
return new GenericPref.Bool(module.getId() + ENABLED_PREF_SUFFIX, module.isEnabledByDefault(), cntx);
|
||||
}
|
||||
|
||||
|
||||
// ------------------- decorations -------------------
|
||||
|
||||
private static final String DECORATIONS_PREF_SUFFIX = "_decorate";
|
||||
|
||||
/**
|
||||
* Returns a preference to indicate if decorations are shown or not
|
||||
* Returns a preference to indicate if decorations are shown or not for a specific module
|
||||
*/
|
||||
public static GenericPref.Bool DECORATIONS_PREF(Context cntx) {
|
||||
return new GenericPref.Bool("showDecorations", false, cntx);
|
||||
public static GenericPref.Bool getDecorationsPrefOfModule(AModuleData module, Context cntx) {
|
||||
return new GenericPref.Bool(module.getId() + DECORATIONS_PREF_SUFFIX, false, cntx);
|
||||
}
|
||||
|
||||
/* ------------------- getter ------------------- */
|
||||
|
8
app/src/main/res/drawable/round_border.xml
Normal file
8
app/src/main/res/drawable/round_border.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/transparent" />
|
||||
<stroke
|
||||
android:width="4px"
|
||||
android:color="@color/grey" />
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
@ -20,20 +20,7 @@
|
||||
android:paddingRight="@dimen/smallPadding"
|
||||
android:paddingBottom="@dimen/padding"
|
||||
android:text="@string/txt_conf" />
|
||||
<include layout="@layout/separator" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/showDecorations"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/padding"
|
||||
android:layout_marginLeft="@dimen/padding"
|
||||
android:layout_marginTop="@dimen/smallPadding"
|
||||
android:layout_marginEnd="@dimen/padding"
|
||||
android:layout_marginRight="@dimen/padding"
|
||||
android:layout_marginBottom="@dimen/smallPadding"
|
||||
android:paddingRight="@dimen/padding"
|
||||
android:text="@string/chk_decorations" />
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
@ -44,7 +31,6 @@
|
||||
android:layout_marginRight="@dimen/padding"
|
||||
android:onClick="resetOrder"
|
||||
android:text="@string/reset_order" />
|
||||
<include layout="@layout/separator" />
|
||||
<LinearLayout
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@ -16,18 +16,18 @@
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/edit"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/json_edit"
|
||||
style="?android:attr/buttonBarButtonStyle" />
|
||||
android:text="@string/json_edit" />
|
||||
<Button
|
||||
android:id="@+id/rebuild"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/mHosts_build"
|
||||
style="?android:attr/buttonBarButtonStyle" />
|
||||
android:text="@string/mHosts_build" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -2,7 +2,10 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="@drawable/round_border"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
@ -10,8 +13,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:paddingBottom="5dp">
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
@ -74,17 +76,27 @@
|
||||
android:id="@+id/details"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingRight="25dp">
|
||||
<FrameLayout
|
||||
android:id="@+id/box"
|
||||
android:orientation="vertical">
|
||||
<CheckBox
|
||||
android:id="@+id/decorations"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true">
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginLeft="25dp"
|
||||
android:paddingRight="25dp"
|
||||
android:text="@string/chk_decorations" />
|
||||
<include
|
||||
layout="@layout/separator"
|
||||
android:layout_height="wrap_content" />
|
||||
<FrameLayout
|
||||
android:id="@+id/box"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingRight="25dp">
|
||||
|
||||
</FrameLayout>
|
||||
<include layout="@layout/separator" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -6,5 +6,5 @@
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:background="#808080"
|
||||
android:background="@color/grey"
|
||||
android:orientation="vertical" />
|
@ -28,7 +28,7 @@ Traducciones: %s."</string>
|
||||
<string name="txt_conf">Lista de módulos: puedes habilitarlos o deshabilitarlos, ver su descripción y configurarlos.</string>
|
||||
<string name="toast_cantEnable">No se puede habilitar el módulo. ¿Está configurado?</string>
|
||||
<string name="reset_order">Reiniciar orden</string>
|
||||
<string name="chk_decorations">Mostrar el título de los módulos</string>
|
||||
<string name="chk_decorations">Mostrar el título del módulo</string>
|
||||
|
||||
|
||||
<!-- settings -->
|
||||
|
@ -4,5 +4,5 @@
|
||||
<color name="good">#804CAF50</color>
|
||||
<color name="warning">#80FF9800</color>
|
||||
<color name="bad">#80E91E63</color>
|
||||
<color name="transparent">#00000000</color>
|
||||
<color name="transparent">#00000000</color><color name="grey">#808080</color>
|
||||
</resources>
|
@ -28,7 +28,7 @@ Translations: %s."</string>
|
||||
<string name="txt_conf">List of modules: You can enable or disable them, also check its description and configuration.</string>
|
||||
<string name="toast_cantEnable">"Can't enable the module, missing configuration?"</string>
|
||||
<string name="reset_order">Reset Order</string>
|
||||
<string name="chk_decorations">Show modules titles</string>
|
||||
<string name="chk_decorations">Show module title</string>
|
||||
|
||||
<!-- settings -->
|
||||
<string name="txt_openLinks">Open links on this app: Over the years Android has changed the way to configure it, and differs between versions. Find below all available settings for your device, if links are not being opened on this app try them all.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user