0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 11:52:14 +02:00

enable/disable ctabs toast from the debug configuration module

updated gitignore
This commit is contained in:
TrianguloY 2021-01-16 11:24:31 +01:00
parent 4f0c87706d
commit b2090c2f66
6 changed files with 102 additions and 12 deletions

28
.gitignore vendored
View File

@ -1,6 +1,8 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab
mapping.txt
output.json
@ -14,6 +16,8 @@ output.json
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
@ -34,15 +38,17 @@ proguard/
# Android Studio captures folder
captures/
# Intellij
# IntelliJ
*.iml
.idea/
# Keystore files
*.jks
*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
google-services.json
@ -51,3 +57,23 @@ google-services.json
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# Android Profiling
*.hprof

View File

@ -1,6 +1,8 @@
package com.trianguloy.urlchecker.modules.list;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.trianguloy.urlchecker.R;
@ -9,11 +11,13 @@ import com.trianguloy.urlchecker.dialogs.MainDialog;
import com.trianguloy.urlchecker.modules.AModuleConfig;
import com.trianguloy.urlchecker.modules.AModuleData;
import com.trianguloy.urlchecker.modules.AModuleDialog;
import com.trianguloy.urlchecker.modules.DescriptionConfig;
import com.trianguloy.urlchecker.services.CustomTabs;
import com.trianguloy.urlchecker.utilities.GenericPref;
/**
* A textview with debug info.
* Currently shows the original intent (as uri)
* Allows also to enable/disable ctabs toasts
*/
public class DebugModule extends AModuleData {
@Override
@ -38,7 +42,7 @@ public class DebugModule extends AModuleData {
@Override
public AModuleConfig getConfig(ConfigActivity cntx) {
return new DescriptionConfig(R.string.dbg_desc);
return new DebugConfig(cntx);
}
}
@ -64,4 +68,36 @@ class DebugDialog extends AModuleDialog {
getActivity().getIntent().toUri(0)
);
}
}
class DebugConfig extends AModuleConfig {
GenericPref.Bool show_toasts = CustomTabs.SHOWTOAST_PREF();
public DebugConfig(ConfigActivity activity) {
super(activity);
show_toasts.init(activity);
}
@Override
public boolean canBeEnabled() {
return true;
}
@Override
public int getLayoutId() {
return R.layout.config_debug;
}
@Override
public void onInitialize(View views) {
CheckBox chk_ctabs = views.findViewById(R.id.chk_ctabs);
chk_ctabs.setChecked(show_toasts.get());
chk_ctabs.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
show_toasts.set(isChecked);
}
});
}
}

View File

@ -6,7 +6,7 @@ import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
import com.trianguloy.urlchecker.BuildConfig;
import com.trianguloy.urlchecker.utilities.GenericPref;
/**
* Empty service for fake custom tabs.
@ -15,28 +15,31 @@ import com.trianguloy.urlchecker.BuildConfig;
*/
public class CustomTabs extends Service {
public static GenericPref.Bool SHOWTOAST_PREF() {
return new GenericPref.Bool("ctabs_toast", false);
}
@Override
public void onCreate() {
super.onCreate();
log("onCreate", true);
log("onCreate");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
log("onStartCommand\n" + intent.toUri(0), true);
log("onStartCommand\n" + intent.toUri(0));
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
log("onDestroy", true);
log("onDestroy");
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent) {
log("onBind\n" + intent.toUri(0), false); // a toast here, for some reason, isn't shown and later it crashes
log("onBind\n" + intent.toUri(0)); // a toast here, for some reason, isn't shown and later it crashes
return null;
// return new IBinder() {
// @Override
@ -96,9 +99,11 @@ public class CustomTabs extends Service {
private static final String TAG = "CUSTOMTABS";
private void log(String message, boolean toast) {
private void log(String message) {
Log.d(TAG, message);
if (BuildConfig.DEBUG && toast) {
GenericPref.Bool showToast = SHOWTOAST_PREF();
showToast.init(this);
if (showToast.get()) {
Toast.makeText(this, TAG + ": " + message, Toast.LENGTH_LONG).show();
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dbg_desc" />
<CheckBox
android:id="@+id/chk_ctabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dbg_ctabs" />
</LinearLayout>

View File

@ -1,2 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:textSize="10sp" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:textSize="10sp" />

View File

@ -64,6 +64,7 @@
<string name="mVT_jsonError">Can\'t connect to VirusTotal. Make sure the api key is valid or try again later.</string>
<string name="dbg_name">Debug module</string>
<string name="dbg_desc">Displays debug data, intended for developers.</string>
<string name="dbg_desc">Displays the received intent as uri, intended for developers.</string>
<string name="dbg_ctabs">Show debug messages from the custom tabs service</string>
</resources>