mirror of
https://github.com/TrianguloY/UrlChecker.git
synced 2024-09-19 20:02:16 +02:00
show debug data only when requested
This commit is contained in:
parent
85231c5a58
commit
95a264f3ef
@ -3,6 +3,7 @@ package com.trianguloy.urlchecker.modules.list;
|
|||||||
import static java.util.Objects.requireNonNullElse;
|
import static java.util.Objects.requireNonNullElse;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.trianguloy.urlchecker.R;
|
import com.trianguloy.urlchecker.R;
|
||||||
@ -22,7 +23,6 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* This modules marks the insertion point of new modules
|
* This modules marks the insertion point of new modules
|
||||||
* If enabled, shows a textview with debug info.
|
* If enabled, shows a textview with debug info.
|
||||||
* Currently shows the original intent (as uri)
|
|
||||||
* Allows also to enable/disable ctabs toasts
|
* Allows also to enable/disable ctabs toasts
|
||||||
*/
|
*/
|
||||||
public class DebugModule extends AModuleData {
|
public class DebugModule extends AModuleData {
|
||||||
@ -57,11 +57,9 @@ public class DebugModule extends AModuleData {
|
|||||||
class DebugDialog extends AModuleDialog {
|
class DebugDialog extends AModuleDialog {
|
||||||
|
|
||||||
public static final String SEPARATOR = "";
|
public static final String SEPARATOR = "";
|
||||||
private TextView textView;
|
private Button showData;
|
||||||
|
private TextView data;
|
||||||
// cached
|
private UrlData urlData;
|
||||||
private String intentUri;
|
|
||||||
private String referrer;
|
|
||||||
|
|
||||||
public DebugDialog(MainDialog dialog) {
|
public DebugDialog(MainDialog dialog) {
|
||||||
super(dialog);
|
super(dialog);
|
||||||
@ -74,29 +72,24 @@ class DebugDialog extends AModuleDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize(View views) {
|
public void onInitialize(View views) {
|
||||||
textView = views.findViewById(R.id.data);
|
showData = views.findViewById(R.id.showData);
|
||||||
|
data = views.findViewById(R.id.data);
|
||||||
|
|
||||||
// expand when touched (not only clicked, to avoid a double-click-required bug and because it feels better)
|
showData.setOnClickListener(v -> showData());
|
||||||
textView.setOnTouchListener((v, event) -> {
|
|
||||||
if (textView.getMaxHeight() != Integer.MAX_VALUE) textView.setMaxHeight(Integer.MAX_VALUE);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
// cached values
|
|
||||||
intentUri = getActivity().getIntent().toUri(0);
|
|
||||||
referrer = requireNonNullElse(AndroidUtils.getReferrer(getActivity()), "null");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void showData() {
|
||||||
public void onDisplayUrl(UrlData urlData) {
|
showData.setVisibility(View.GONE);
|
||||||
// collapse module to show exactly 5 lines and a half (to indicate there is more data)
|
data.setVisibility(View.VISIBLE);
|
||||||
var fontMetrics = textView.getPaint().getFontMetrics();
|
|
||||||
textView.setMaxHeight(Math.round((fontMetrics.bottom - fontMetrics.top) * 5.5f));
|
|
||||||
|
|
||||||
// data to display
|
// data to display
|
||||||
textView.setText(String.join("\n", List.of(
|
data.setText(String.join("\n", List.of(
|
||||||
"Intent:",
|
"Intent:",
|
||||||
intentUri,
|
getActivity().getIntent().toUri(0),
|
||||||
|
|
||||||
|
SEPARATOR,
|
||||||
|
|
||||||
|
"queryIntentActivityOptions:",
|
||||||
|
IntentApp.getOtherPackages(UrlUtils.getViewIntent(urlData.url, null), getActivity()).toString(),
|
||||||
|
|
||||||
SEPARATOR,
|
SEPARATOR,
|
||||||
|
|
||||||
@ -111,14 +104,20 @@ class DebugDialog extends AModuleDialog {
|
|||||||
SEPARATOR,
|
SEPARATOR,
|
||||||
|
|
||||||
"Referrer:",
|
"Referrer:",
|
||||||
referrer,
|
requireNonNullElse(AndroidUtils.getReferrer(getActivity()), "null")
|
||||||
|
|
||||||
SEPARATOR,
|
|
||||||
|
|
||||||
"queryIntentActivityOptions:",
|
|
||||||
IntentApp.getOtherPackages(UrlUtils.getViewIntent(urlData.url, null), getActivity()).toString()
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrepareUrl(UrlData urlData) {
|
||||||
|
data.setVisibility(View.GONE);
|
||||||
|
showData.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisplayUrl(UrlData urlData) {
|
||||||
|
this.urlData = urlData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DebugConfig extends AModuleConfig {
|
class DebugConfig extends AModuleConfig {
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/data"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textIsSelectable="true"
|
android:orientation="vertical">
|
||||||
android:textSize="11sp">
|
|
||||||
|
|
||||||
</TextView>
|
<Button
|
||||||
|
android:id="@+id/showData"
|
||||||
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/mD_show" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/data"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
@ -206,6 +206,7 @@ Hay algunos enlaces cuyo único propósito es redirigirte a otro enlace. Si el e
|
|||||||
\n
|
\n
|
||||||
\nPuede mantener pulsado para seleccionar el texto.</string>
|
\nPuede mantener pulsado para seleccionar el texto.</string>
|
||||||
<string name="mD_ctabs">Mostrar mensajes de debug del servicio custom tabs</string>
|
<string name="mD_ctabs">Mostrar mensajes de debug del servicio custom tabs</string>
|
||||||
|
<string name="mD_show">Mostrar datos de debug</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="mHist_name">Historial</string>
|
<string name="mHist_name">Historial</string>
|
||||||
<string name="mHist_desc">Cuando la URL cambia, tanto manualmente como por otros módulos, éste te permite ver y revertir los cambios.</string>
|
<string name="mHist_desc">Cuando la URL cambia, tanto manualmente como por otros módulos, éste te permite ver y revertir los cambios.</string>
|
||||||
|
@ -255,6 +255,7 @@ If you enable this it will display some internal debug data (like original inten
|
|||||||
|
|
||||||
You can hold to select text."</string>
|
You can hold to select text."</string>
|
||||||
<string name="mD_ctabs">Show debug messages from the custom tabs service</string>
|
<string name="mD_ctabs">Show debug messages from the custom tabs service</string>
|
||||||
|
<string name="mD_show">Show debug data</string>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<string name="mHist_name">History</string>
|
<string name="mHist_name">History</string>
|
||||||
<string name="mHist_desc">When the URL is edited, either manually or by other modules, this one allows you to view and revert changes.</string>
|
<string name="mHist_desc">When the URL is edited, either manually or by other modules, this one allows you to view and revert changes.</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user