palaima / debugdrawer Goto Github PK
View Code? Open in Web Editor NEWAndroid Debug Drawer for faster development
License: Apache License 2.0
Android Debug Drawer for faster development
License: Apache License 2.0
Warning: io.palaima.debugdrawer.scalpel.ScalpelModule: can't find referenced class com.jakewharton.scalpel.ScalpelFrameLayout
Hi,
android:windowTranslucentStatus
is not working when debug drawer attached to activity.
What is the reason for this? How to solve this?
In debugdrawer/src/main/res/layout/debug_drawer.xml change the id of your DrawerLayout to something other than the default "drawer_layout" because if the application already has a navigation drawer with that same id it will create a lot of problems. Use something like "debug_drawer_layout" instead :)
On some devices, I am getting SecurityException while switching ON/OFF WiFi connection:
java.lang.RuntimeException:Error receiving broadcast Intent{act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010bqHint=4VirtualScreenParam=Params{mDisplayId=-1,null,mFlags=0x00000000)}(has extras)}in io.palaima.debugdrawer.commons.NetworkController$NetworkReceiver@775e4b8
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1003)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by:java.lang.SecurityException:WifiService:Neither user 10619nor current process has android.permission.CHANGE_WIFI_STATE.
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at android.net.wifi.IWifiManager$Stub$Proxy.setWifiEnabled(IWifiManager.java:1665)
at android.net.wifi.WifiManager.setWifiEnabled(WifiManager.java:2065)
at io.palaima.debugdrawer.commons.NetworkController.setWifiEnabled(NetworkController.java:94)
at io.palaima.debugdrawer.commons.NetworkModule$1.onCheckedChanged(NetworkModule.java:60)
at android.widget.CompoundButton.setChecked(CompoundButton.java:165)
at android.widget.Switch.setChecked(Switch.java:1138)
at io.palaima.debugdrawer.commons.NetworkModule$4.onChanged(NetworkModule.java:124)
at io.palaima.debugdrawer.commons.NetworkController$1.post(NetworkController.java:182)
at io.palaima.debugdrawer.commons.NetworkController$NetworkReceiver.onReceive(NetworkController.java:219)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:993)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I see few such crashes:
17 java.lang.NullPointerException: Attempt to get length of null array
18 at io.palaima.debugdrawer.timber.data.LumberYard.cleanUp(LumberYard.java:140)
I think this code:
public void cleanUp() {
File dir = getLogDir();
if (dir != null) {
File[] files = dir.listFiles();
for (File file : files) {
if (file.getName().endsWith(LOG_FILE_END)) {
file.delete();
}
}
}
}
should be changed to:
public void cleanUp() {
File dir = getLogDir();
if (dir != null) {
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().endsWith(LOG_FILE_END)) {
file.delete();
}
}
}
}
}
compile 'io.palaima.debugdrawer:debugdrawer-base:0.7.0'
compile 'io.palaima.debugdrawer:debugdrawer-commons:0.7.0'
compile 'io.palaima.debugdrawer:debugdrawer-view:0.7.0'
compile 'io.palaima.debugdrawer:debugdrawer-timber:0.7.0'
compile 'io.palaima.debugdrawer:debugdrawer-actions:0.7.0'
compile 'io.palaima.debugdrawer:debugdrawer-picasso:0.7.0'
If an activity that does not own the drawer gets destroyed, DebugDrawerLifecycleCallbacks
onActivityDestroyed(Activity activity)
de-registers the lifecycle hooks for the drawer and its modules
This manifests in the drawer modules not having their onStart/onStop/onPause/onResume/onOpened/onClosed
handler methods being called any longer, even though the drawer is still accessible
All other DebugDrawerLifecycleCallbacks
methods check first if the activity that invoked the lifecycle is the owner of the drawer before delegating, this needs to happen here too
Hi there,
When I upgraded studio to latest 3.4.x and gradle to 5.x.x . it keeps throwing compilation error . Any workaround for this ?
Getting:
Fatal Exception: android.util.AndroidRuntimeException
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
on SettingsModule#onClick:125
.
I'm using version 0.7.0. Also this is not reproduceable on every device. Happens on some Samsung and Sony devices. In any case the library should not crash.
On Android 5.1.1 (Nexus 5)
Using io.palaima.debugdrawer:debugdrawer:0.1.1
The StatusBar color is disabled
Here's my code :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
stock();
if (BuildConfig.DEBUG) {
mDebugDrawer = new DebugDrawer.Builder(this).modules(
new DeviceModule(this),
new BuildModule(this),
new NetworkModule(this),
new SettingsModule(this)
).build();
}
}
@Override
protected void onStart() {
super.onStart();
if (mDebugDrawer != null) {
mDebugDrawer.onStart();
}
}
@Override
protected void onStop() {
super.onStop();
if (mDebugDrawer != null) {
mDebugDrawer.onStop();
}
}
The issue seems to be in the my stock() function where i'm setting an android.support.v7.widget.Toolbar
. If i remove the toolbar everything is fixed.
Thanks,
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at io.palaima.debugdrawer.timber.data.LumberYard.cleanUp(LumberYard.java:140)
Hello! Thank you guys for your work!
Could you please tell me - are you planning to update the okhttp dependency to version 4.0? Right now it creates some problems, such as NoSuchMethodError
in case of using 4.0 version.
I noticed this in the TODO section, and it sounds very useful for QA. As far as you're aware, has anyone started work on this? If not I might see if I can have a crack at it
Cheers
I got this exception:
Caused by: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10170 nor current process has android.permission.BLUETOOTH.
at android.os.Parcel.readException(Parcel.java:1629)
at android.os.Parcel.readException(Parcel.java:1582)
at android.bluetooth.IBluetooth$Stub$Proxy.getState(IBluetooth.java:878)
at android.bluetooth.BluetoothAdapter.getState(BluetoothAdapter.java:870)
at io.palaima.debugdrawer.commons.NetworkController$NetworkReceiver.onReceive(NetworkController.java:217)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:915)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5885)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:819)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:709)
It's due to a call to bluetoothInfo.getState()
when no bluetooth permission is set in NetworkController
at this line.
It's similar to #43.
I added the dependency but it doesn't compile when the app's target sdk is set to 22. I tried with target sdk set to 23 and it works.
Hey are you still maintaining the repository? If you'd like I could take care of it as a second maintainer.
Hi @palaima! I've started to implement the debug drawer in a few apps at my company, but needed some changes. I've sent a couple of PRs and have more things prepared. But I see there hasn't been any activity here for a few months.
Right now I have my own fork of the library, and I was wondering if it's worth sending PRs here or better officially diverge my fork and publish it as an independent library. I would also be ok becoming a maintainer of your repository, if you wish.
Could you please give us an update on your status with regard to the project?
Thanks!
How can I set the initial state for a SwitchAction before it was inflated? Only writing down a needed value for a needed key to SharedPrefs? Is it possible to do it dynamically?
Hi,
Thanks for making this lib! I cloned and changed api to 11 and there were no errors. If there are no reasons for api 15, would you lower it to 11?
Edit: Looks like Switch requires api 14. Use compat library?
If three drawer is open, and the third drawer is destroyed, the previous two DebugDrawerLifecycleCallbacks
will also be removed.
I think the code in onActivityDestroyed
method also need check If the Destroyed Activity is current activity or not.
When we drag it from right to left we are able to see debug drawer.In the same way when we drag it from left to right we are getting some overlay , how to control it?
I want to hide DebugDrawer at runtime - it means no UI of DebugDrawer, user cannot swipe from right to left to show it. Is it possible?
Just tell me to add that one line of code into my build.gradle, its not gonna hurt the experience much.
Hi! First of all thank you for your library 😉
Do you plan to add support for glide 4?
Thanks!
I'm trying to import your library, but the attribute "rippleColor" generate a conflict with some other libraries I have in my project.
import io.palaima.debugdrawer.actions.SpinnerAction
Cant create release builds
Mobile network toggle doesn't work on my device. I was checking the code and it's commented that it works only for api 16 and below. So, would it be better to not show it for api 17 and plus in the first place? Small issue but could save people using this library some time scratching their head. :) Please let me know if I could contribute.
How can I add a title to a spinner? I got multiple spinners and I want to tell them apart
If you're making some module that needs to update frequently in runtime, it makes sense to run updates if and only if DebugDrawer
is visible (e.g. between onOpened()
and onClosed()
) and Activity
is running (e.g. between onResume()
and onPause()
).
If we're rotating the screen, DrawerLayout
itself maintains its visibility, but it can be new DrawerLayout per se, so we'll get into situation when DrawerLayout
is open, as well as DebugDrawer
, but onOpened()
method for this instance was never called.
There's somewhere a leak in LocationModule. I tracked it down this far with MAT.
If you need more information let me know. I'm using 0.7.0
and setting it up like this:
debugDrawer = new DebugDrawer.Builder(baseActivity).modules(
new LocationModule(application),
// some more ...
).build();`
I'm also calling the lifecycle methods onStart
, onResume
, onPause
and onDestroy
I'd like to disable being able to open/close the debug drawer using swipe gestures, i.e. changing the lock mode of the underlying DrawerLayout
to LOCK_MODE_LOCKED_CLOSED
. Please consider exposing setDrawerLockMode()
in DebugDrawer
.
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
This exception is gonna be thrown if I pass an Application context in the SettingsModule
. To avoid this problem, FLAG_ACTIVITY_NEW_TASK
flag should be set for each intent in here.
Debug drawer works perfectly fine on some screens and on some screen it does not work(does not slide out).
I have BaseActivity and all my activities extend from the BaseActivity. I've added the following lines in onCreate
if (BuildConfig.DEBUG) {
mDebugDrawer = new DebugDrawer.Builder(this).modules(
new ScalpelModule(this),
new LogModule(),
new DeviceModule(this),
new BuildModule(this)
).build();
}
On some Activities it works fine and some it does not. Is there anything missing?
Thank you for the library.
java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.ScrollView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/slider_layout. Make sure other views do not use the same id.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3947)
at android.app.ActivityThread.access$900(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.ScrollView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/slider_layout. Make sure other views do not use the same id.
at android.view.View.onRestoreInstanceState(View.java:13764)
at android.view.View.dispatchRestoreInstanceState(View.java:13740)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2887)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2893)
at android.view.View.restoreHierarchyState(View.java:13718)
at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2009)
at android.app.Activity.onRestoreInstanceState(Activity.java:1023)
at android.app.Activity.performRestoreInstanceState(Activity.java:978)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1162)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3947)
at android.app.ActivityThread.access$900(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
it needs something like append in https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/MultiDrawerActivity.java
Because is really annoying that you need to setup the content view first and add DebugDrawer
in the proper way may we can implement the same thing with ViewOverlay
without at all the need of setContentView
method?
So this great library was not maintained for almost two years. So I decided to fork it and continue to maintain it here: lenguyenthanh/DebugDrawer.
I have done:
I published it to https://jitpack.io/#lenguyenthanh/debugdrawer
so anyone can use that. Here is an example:
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-base:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-view:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-okhttp3:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-scalpel:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-picasso:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-timber:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-fps:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-actions:0.9.0"
debugImplementation "com.github.lenguyenthanh.debugdrawer:debugdrawer-commons:0.9.0"
Welcome to any PR or issues in my repository.
I'd like to programmatically (de)activate the debug drawer, for example by turning a switch "debug mode" in settings.
A solution may be to add 2 methods in DebugDrawer
: enable()
and disable()
, to respond to dynamic changes.
Moreover, the DebugDrawer.Builder::build()
could receive a boolean parameter to enable or not the drawer while building it (true
by default to be compatible with current behavior).
In version 0.8.0, timber module, clicking Show logs, clicking share, causes strict mode exception:
04-08 14:49:15.571 6476 6476 E StrictMode: null
04-08 14:49:15.571 6476 6476 E StrictMode: java.lang.Throwable: file:// Uri exposed through ClipData.Item.getUri()
04-08 14:49:15.571 6476 6476 E StrictMode: at android.os.StrictMode.onFileUriExposed(StrictMode.java:1757)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.net.Uri.checkFileUriExposed(Uri.java:2346)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.content.ClipData.prepareToLeaveProcess(ClipData.java:825)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.content.Intent.prepareToLeaveProcess(Intent.java:8036)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1506)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.app.Activity.startActivityForResult(Activity.java:3917)
04-08 14:49:15.571 6476 6476 E StrictMode: at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.app.Activity.startActivityForResult(Activity.java:3877)
04-08 14:49:15.571 6476 6476 E StrictMode: at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.app.Activity.startActivity(Activity.java:4200)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.app.Activity.startActivity(Activity.java:4168)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.content.ContextWrapper.startActivity(ContextWrapper.java:331)
04-08 14:49:15.571 6476 6476 E StrictMode: at io.palaima.debugdrawer.timber.util.Intents.maybeStartActivity(Intents.java:17)
04-08 14:49:15.571 6476 6476 E StrictMode: at io.palaima.debugdrawer.timber.ui.LogDialog$5.onSave(LogDialog.java:92)
04-08 14:49:15.571 6476 6476 E StrictMode: at io.palaima.debugdrawer.timber.data.LumberYard.save(LumberYard.java:118)
04-08 14:49:15.571 6476 6476 E StrictMode: at io.palaima.debugdrawer.timber.ui.LogDialog.share(LogDialog.java:86)
04-08 14:49:15.571 6476 6476 E StrictMode: at io.palaima.debugdrawer.timber.ui.LogDialog.access$000(LogDialog.java:21)
04-08 14:49:15.571 6476 6476 E StrictMode: at io.palaima.debugdrawer.timber.ui.LogDialog$2.onClick(LogDialog.java:47)
04-08 14:49:15.571 6476 6476 E StrictMode: at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.os.Handler.dispatchMessage(Handler.java:102)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.os.Looper.loop(Looper.java:148)
04-08 14:49:15.571 6476 6476 E StrictMode: at android.app.ActivityThread.main(ActivityThread.java:5417)
04-08 14:49:15.571 6476 6476 E StrictMode: at java.lang.reflect.Method.invoke(Native Method)
04-08 14:49:15.571 6476 6476 E StrictMode: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-08 14:49:15.571 6476 6476 E StrictMode: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Basically file sharing is not allowed since Android N
https://commonsware.com/blog/2016/03/14/psa-file-scheme-ban-n-developer-preview.html
Debug drawer works perfectly fine on some screens and on some screen it does not work(does not slide out).
I have BaseActivity and all my activities extend from the BaseActivity. I've added the following lines in onCreate
if (BuildConfig.DEBUG) {
mDebugDrawer = new DebugDrawer.Builder(this).modules(
new ScalpelModule(this),
new LogModule(),
new DeviceModule(this),
new BuildModule(this)
).build();
}
On some Activities it works fine and some it does not. Is there anything missing?
Thank you for the library.
I've just started implementing LeakCanary in our application and I've found that this library leaks the Context.
How can I save the state of the switch after app killed and opened again.
DebugDrawer is very great project.I think it can help android developer to improve app. Can I add my own log module to DebugDrawer.
A QC (Quality checker) type module might be pretty useful.
Also, it would make sense to have the option to persist all Switch, Checkbox and Spinner changes to the shared_prefs so that it is consistent across all activities (SharedPreference persistence can be switched on/off globally depending on the developer's use-case).
Starting from Android 24, you cannot use file:// schemas to share content to other apps.
https://commonsware.com/blog/2016/03/14/psa-file-scheme-ban-n-developer-preview.html
The library should use a FileProvider to share the logs with other apps. Keep in mind that an app can have one single FileProvider so the TimberModule needs to get the app's file provider authority and use that to create the URI.
Let me know if you're interested in a PR.
<application
tools:replace="android:label,android:allowBackup"
android:name=".Application"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
and
Error:Execution failed for task ':app:processDevDebugManifest'.
> Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:23:9-36 is also present at [io.palaima.debugdrawer:debugdrawer:0.7.0] AndroidManifest.xml:11:18-44 value=(true). Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:20:5-65:19 to override.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.