Android
Android copied to clipboard
This pull request enables new group widgets
This is just a draft because after a group widget is created, the group doesn't open up. Instead just the last window of the app opens. The group id is well transfered with the intent to the MainActivity, but then I don't really know how to do ^^ I'm sure it's a not a very difficult fix, but for the moment I'm stuck. This would fix this feature request: #397
In MainActivity there is a note like this:
// Restore settings from Shared Preference
You probably need to edit that to be like: if this is opened from the group widget, use that group. Otherwise, restore from shared preference
Ah ok I understand. But I don't really know how to write the "if this is opened from the group widget" logic... I'm new to android development :)
It works now on my device! Feel free to make a review or propose some changes. As I'm new to android development, don't hesitate to make suggestions/corrections/bug reports !
I noticed a bug: when changing a group name after a widget has been created for this group, the widget doesn't work anymore. At least like for the cards, the widget should continue to work even if there the widget doesn't update the icon and the text. EDIT: this also happens for deleted groups. The same functions as the card shortcuts need to be implemented.
I just added the following: an error message now appears if the group name has changed or has been deleted. That's the best thing I could do for this case :) I don't see other errors, so for me this PR is fully functional :)
Please don't edit the MainActivity to also list groups, it complicates the code a lot and makes it hard to maintain.
You code is honestly overly complex and given how simple selecting a group is, you could use Android's built-in android.R.layout.simple_list_item_2 for choosing a group, then you don't even need to create or edit any layout. Something like this: https://stackoverflow.com/a/18529511
Please don't edit the MainActivity to also list groups, it complicates the code a lot and makes it hard to maintain.
Well I didn't modify MainActivity to also list groups... at least I don't think so. I just implemented a way to check if a certain group has been passed by the intent, and to open this group up. But indeed I can simplify this part as some parts are written twice!
You code is honestly overly complex and given how simple selecting a group is, you could use Android's built-in
android.R.layout.simple_list_item_2for choosing a group, then you don't even need to create or edit any layout. Something like this: https://stackoverflow.com/a/18529511
Oh I'm sorry if it is too complicated :/ I just went the "simple" route and took already created parts in the code. I kind of reused the ManageGroups Layout, that looked good to me, but I can change the layout to the one you proposed.
So to resume the changes I need to make: refactor/simplify the "detect intent group" test in MainActivity and use the standart layout instead of the one I created?
I simplified MainActivity.
For the group selection code complexity,
You code is honestly overly complex and given how simple selecting a group is, you could use Android's built-in
android.R.layout.simple_list_item_2for choosing a group, then you don't even need to create or edit any layout. Something like this: https://stackoverflow.com/a/18529511
I don't really know if I should change something. It looks pretty good right now in my opinion and is pretty consistent with the group management view. I just replaced the 4 buttons (up, down, edit and delete) with a select button. If you really want me to change the code, that would be feasible. But using the suggested ArrayAdapter seems not to be a drop-in replacement, because for the moment all is coded for a RecyclerView...
The main problem is that the group management view actually looks pretty bad, so basing it on that doesn't really sound like much of an improvement. But I will accept it I guess. I also didn't mean to change it to an ArrayAdapter, I may just make that change myself later.
Ah I didn't know that you consider the group management to look bad. I don't think it looks that bad, but I understand that you might have some ideas for improvements :) Anyway I'm sorry if my implementation isn't the best and I will look at the changes you requested.
Apart from the icon for the group shortcut and the updateShortcut discussions, I have implemented all requested changes as far as I could. But while testing, I noticed a bug: when opening a group widget, then tapping on the home button, then open a card widget and then open a group widget again, the view stays at the card and the group doesn't open :/ EDIT: After further testing, I noticed that this bug is not really related to my implementation of group widgets. It also happens when doing card widget > group widget > card widget or other combinations also with the app icon itself...
But while testing, I noticed a bug: when opening a group widget, then tapping on the home button, then open a card widget and then open a group widget again, the view stays at the card and the group doesn't open :/ EDIT: After further testing, I noticed that this bug is not really related to my implementation of group widgets. It also happens when doing card widget > group widget > card widget or other combinations also with the app icon itself...
@TheLastProject Should I open a separate issue for that? Can this group widget branch be merged even if there is this bug or should we fix the bug before to avoid user confusion?
But while testing, I noticed a bug: when opening a group widget, then tapping on the home button, then open a card widget and then open a group widget again, the view stays at the card and the group doesn't open :/ EDIT: After further testing, I noticed that this bug is not really related to my implementation of group widgets. It also happens when doing card widget > group widget > card widget or other combinations also with the app icon itself...
@TheLastProject Should I open a separate issue for that? Can this group widget branch be merged even if there is this bug or should we fix the bug before to avoid user confusion?
I'm not sure how that bug isn't inside of this PR? If you can reproduce something on the master branch please create a new GitHub issue.
I'm not sure how that bug isn't inside of this PR? If you can reproduce something on the master branch please create a new GitHub issue.
I cannot reproduce it with the last stable release. It's a specific issue related to group widget, card widget and the app launch icon. Something is working great and it may also include the implementation of the card widget (the widget in general). I will try to look at this issue. What needs to be done: When we click on a shortcut, it should open it whatever has been opened before
I just pushed a fix for the interference of the card and group widgets...but I don't understand why it doesn't build anymore. It works on my machine :(
I just pushed a fix for the interference of the card and group widgets...but I don't understand why it doesn't build anymore. It works on my machine :(
Hmm, I think GitHub tries to applies your changes on top of master, which has a lot of DB-related changes (see #680). If you pull the master branch into your branch you will see the same build errors now.
Hmm, I think GitHub tries to applies your changes on top of master, which has a lot of DB-related changes (see #680). If you pull the master branch into your branch you will see the same build errors now.
Ah I didn't know this behavior, weird as I didn't merge the latest master branch in this PR. So should I import the current master in my branch and see where I should fix it?
Hmm, I think GitHub tries to applies your changes on top of master, which has a lot of DB-related changes (see #680). If you pull the master branch into your branch you will see the same build errors now.
Ah I didn't know this behavior, weird as I didn't merge the latest master branch in this PR. So should I import the current master in my branch and see where I should fix it?
Yup exactly!
Basically, all the database stuff changed so your db.function(value) like things should become DBHelper.function(db, value). It's a fairly easy change once you figure it out :)
Well I am testing out the latest changes, but with the merge of the new DB changes, I'm not able to create any shortcut anymore. The app crashes before even entering the selector. Is that maybe due to 2 errors in DBHelper? (in Android Studio 2 errors are detected): line 111 and line 266.
The tokenize=unicode61 stuff is not an error, it's just Android Studio not understanding that valid syntax.
If you get a crash, well, what is the crash exactly? It should print a stacktrace while running the app through Android Studio.
If you get a crash, well, what is the crash exactly? It should print a stacktrace while running the app through Android Studio.
I'm running it on my own device, for some reason didn't manage to start the emulators, or they were too slow.
I'm running it on my own device, for some reason didn't manage to start the emulators, or they were too slow.
That shouldn't matter, as long as you use adb you will still just see the stack trace in Android Studio when the app crashes no matter if it's running on your device or in an emulator.
The only time you won't see the crash log in Android Studio is if you don't run the app through Android Studio but instead build it and manually install the .apk. While I really wouldn't recommend going that route as it is extremely slow and tedious in comparison, Scoop can help you in that case.
Here is the crash I get:
E/AndroidRuntime: FATAL EXCEPTION: main Process: me.hackerchick.catima.debug, PID: 13120 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{me.hackerchick.catima.debug/protect.card_locker.CardShortcutConfigure}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2335) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544) at android.app.ActivityThread.access$900(ActivityThread.java:163) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5608) 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:1397) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1192) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:274) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223) at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187) at protect.card_locker.CardShortcutConfigure.<init>(CardShortcutConfigure.java:21) at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.Class.newInstance(Class.java:1656) at android.app.Instrumentation.newActivity(Instrumentation.java:1071) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2544) at android.app.ActivityThread.access$900(ActivityThread.java:163) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5608) 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:1397) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1192)
It seems to be something related to the database...
android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187) at protect.card_locker.CardShortcutConfigure.<init>(CardShortcutConfigure.java:21)
That's the important part, so CardShortcutConfigure.java, line 21. It doesn't look like you changed anything there so maybe you found a crash that's in the master branch? What did you do to reproduce it? I can't reproduce the crash you mentioned on the master branch. I haven't tried your branch yet for this, it's been a busy week sorry.
android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187) at protect.card_locker.CardShortcutConfigure.<init>(CardShortcutConfigure.java:21)That's the important part, so CardShortcutConfigure.java, line 21. It doesn't look like you changed anything there so maybe you found a crash that's in the master branch? What did you do to reproduce it? I can't reproduce the crash you mentioned on the master branch. I haven't tried your branch yet for this, it's been a busy week sorry.
No worries, you can take your time :) I don't think I changed anything in this place compared to master. Will try the master branch on the same device and maybe open an issue if I encounter the problem again. To reproduce the issue on my branch: just try to create a shortcut.
It's the same in the main branch, just created an issue.
I'm sorry that this takes so much time for me to fix. Currently I don't have much time, but I plan to resume the work on this PR soon:copyright: :laughing: But I anyone has an idea of how to help for the update/delete shortcut functionnality it would be great. I tried several things but it was not working :/ Thanks!
No worries. I could maybe do the update/delete part myself if you can't run an emulator with a less broken Android version but no promises because time and stuff
Well it looks like I need to update a lot of my code with the new UI... Is there a "rapid" and "clean" way to update to the new UI?
Looking at the "Resolve conflicts" button on GitHub, the conflicts are really small, should be easy to resolve in the web UI.
But you can also use the command line, look at the text "Use the web editor or the to resolve conflicts." GitHub shows on this PR
Yes I now I could use this, but the group widget selector was based on the old UI and has therefor not been adapted to the new UI...