0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 20:02:16 +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 # Built application files
*.apk *.apk
*.aar
*.ap_ *.ap_
*.aab
mapping.txt mapping.txt
output.json output.json
@ -14,6 +16,8 @@ output.json
bin/ bin/
gen/ gen/
out/ 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 files
.gradle/ .gradle/
@ -34,15 +38,17 @@ proguard/
# Android Studio captures folder # Android Studio captures folder
captures/ captures/
# Intellij # IntelliJ
*.iml *.iml
.idea/ .idea/
# Keystore files # Keystore files
*.jks *.jks
*.keystore
# External native build folder generated in Android Studio 2.2 and later # External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild .externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase) # Google Services (e.g. APIs or Firebase)
google-services.json google-services.json
@ -51,3 +57,23 @@ google-services.json
freeline.py freeline.py
freeline/ freeline/
freeline_project_description.json 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; package com.trianguloy.urlchecker.modules.list;
import android.view.View; import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView; import android.widget.TextView;
import com.trianguloy.urlchecker.R; 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.AModuleConfig;
import com.trianguloy.urlchecker.modules.AModuleData; import com.trianguloy.urlchecker.modules.AModuleData;
import com.trianguloy.urlchecker.modules.AModuleDialog; 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. * A textview with debug info.
* Currently shows the original intent (as uri) * Currently shows the original intent (as uri)
* Allows also to enable/disable ctabs toasts
*/ */
public class DebugModule extends AModuleData { public class DebugModule extends AModuleData {
@Override @Override
@ -38,7 +42,7 @@ public class DebugModule extends AModuleData {
@Override @Override
public AModuleConfig getConfig(ConfigActivity cntx) { public AModuleConfig getConfig(ConfigActivity cntx) {
return new DescriptionConfig(R.string.dbg_desc); return new DebugConfig(cntx);
} }
} }
@ -65,3 +69,35 @@ class DebugDialog extends AModuleDialog {
); );
} }
} }
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.util.Log;
import android.widget.Toast; import android.widget.Toast;
import com.trianguloy.urlchecker.BuildConfig; import com.trianguloy.urlchecker.utilities.GenericPref;
/** /**
* Empty service for fake custom tabs. * Empty service for fake custom tabs.
@ -15,28 +15,31 @@ import com.trianguloy.urlchecker.BuildConfig;
*/ */
public class CustomTabs extends Service { public class CustomTabs extends Service {
public static GenericPref.Bool SHOWTOAST_PREF() {
return new GenericPref.Bool("ctabs_toast", false);
}
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
log("onCreate", true); log("onCreate");
} }
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { 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); return super.onStartCommand(intent, flags, startId);
} }
@Override @Override
public void onDestroy() { public void onDestroy() {
log("onDestroy", true); log("onDestroy");
super.onDestroy(); super.onDestroy();
} }
@Override @Override
public IBinder onBind(Intent intent) { 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 null;
// return new IBinder() { // return new IBinder() {
// @Override // @Override
@ -96,9 +99,11 @@ public class CustomTabs extends Service {
private static final String TAG = "CUSTOMTABS"; private static final String TAG = "CUSTOMTABS";
private void log(String message, boolean toast) { private void log(String message) {
Log.d(TAG, 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(); 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"?> <?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="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_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> </resources>