Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widget behavior for several tables #39

Closed
RalfWerner opened this issue Feb 7, 2020 · 11 comments
Closed

widget behavior for several tables #39

RalfWerner opened this issue Feb 7, 2020 · 11 comments

Comments

@RalfWerner
Copy link

RalfWerner commented Feb 7, 2020

Feature description
@xeffyr With mv .shortcuts widget I changed the path, connected again with the symlink:
w=widget; s='~/.shortcuts'; ln -s $w $s and split my entries in 3 paths (termux ~/$w, ubuntu uu/$w and sdcard/proot i/$w). Then I add the entries:
cd uu/$w; echo"s=$s; rm $s; ln -s ~/$w $s">' termux-widget' and
cd ~/$w; echo "s=$s; rm $s; ln -s ~uu/$w $s">' ubuntu-widget' (same for sdcard).
So nothing has changed on the startscreen except for the first (two) action (replaces the symlink with shortcuts that are possible in ubuntu and proot) and now it looks like this:
grafik
I started processes from all tables, which are managed in the Navigator (shot4).

What I expect is to have a changed table on the start screen (shot2/3) by tapping the second action (shot1). However, this is only the case, if no termux-bash is open and after I have tapped reload.
Could this be realized by a specific exit number, such as exit 1 (received the navigator entry) - no switch and reload?

Continued from our dialog about Studio test environment with API/widget with Q10/R11 emulators:

install Termux:API but not run it ... Just added in per-repository mode.

To your @xeffyr last topic mv wd/te*/*/dev* wc/.android would be ok - or better not?

WSL[AS/x]$ ll wd/te*/*/dev* wc/.android/deb* wd wc
lrwxrwxrwx 1 th80wr th80wr   19 Mar 12 09:48 wc -> /mnt/c/Users/th80wr
-rwxrwxrwx 1 th80wr th80wr 2105 Mar 14 12:45 wc/.android/debug.keystore
-rwxrwxrwx 1 th80wr th80wr    0 Mar 14 12:45 wc/.android/debug.keystore.lock
lrwxrwxrwx 1 th80wr th80wr   18 Mar 12 09:04 wd -> /mnt/d/Android/App
-rwxrwxrwx 1 th80wr th80wr 2097 Mar  6 16:10 wd/termux-api/app/dev_keystore.jks
-rwxrwxrwx 1 th80wr th80wr 2097 Mar  6 16:10 wd/termux-app/app/dev_keystore.jks
-rwxrwxrwx 1 th80wr th80wr 2097 Mar  4 17:23 wd/termux-widget/app/dev_keystore.jks
-rwxrwxrwx 1 th80wr th80wr 2097 Mar  6 16:10 wd/termux-x11/app/dev_keystore.jks

Installation of the API plugin in Studio. Shot1: the build actions of the first three parts generate the APK and install it on the current emulation (here Q10). Shot2: the *.apk is created with Build Bundle. Shot3: after drag & drop from PC Explorer, the plugin is also included in the emulation. Shot4: Start screen with the widget table from which dialog API is started and then displayed in Shot5 - here with the emulated phone functions on the right. In Shot6 the process can be seen in the Navigator (if no dialog is active anymore). The sensor analysis runs in the background.
grafik
Unfortunately the API installation is more complex than for the other plugins and there are a few problems that I have reported in paste or only occur in the emulation:

  • Dialogues and navigator (drawer) can not be displayed at the same time. Here I use a while loop, which enables cell phone rotation (termux-dialog interrupt the action, as with drawer). Starting multiple times is also problematic if dialogues are held at the same time. But also possible parallel actions (sensor/selfie) lead to stalled problems!
  • The action selfie creates a ~/tmp.jpg file and ends the widget action with exit 1, which is not done with the camera during emulation (my inexperiance). The image could edited with termux-open tmp.jpg before exit 1.
  • The action speech should have a written&acoustic dialogue with you and the phone/emulator. This is no problem on the real device. It's funny to count up 1-9 in different languages ​​and what the recognition does with it. Unfortunately, the process often does not come to a conclusion (stalled) as can be seen in the process control (Shot1 below) and can only be stopped with pkill termux-api.

The following Shot1 shows the processes during dialog API action (stalled: 18005,19202) and Shot2 the script (extract from sd/ip/bashrc). Shot3 is the first try (strings only) widget via Studio adjust
grafik
You added feature request to this repo. Would this be a suitable case (I use Studio or signed all *.apk with my private keystroke) to use it?

@RalfWerner
Copy link
Author

RalfWerner commented Sep 23, 2021

With the widget version 0.13 .shortcuts is no longer allowed as a symlink. Also symlinks in this path are now prohibited. The idea of this issue ​​managing a widget table with a data object, which has not been a problem so far, is so no longer possible in this way.
As a reasoning writes @agnostic-apollo

It's not a bug, it's intentional behaviour. The canonical path of all scripts must be under ~/.shortcuts, I'll make it more clear in README. You can create hidden directories under it like ~/.shortcuts/.ubuntu and replace the contents of ~/.shortcuts (except the hidden directories) with that of a specific hidden directory dynamically. That should work.

Since there was no problem so far, the justification does not light up to me. Also why symlinks on paths are treated differently than paths themselves is very unusual for bash. Now you has cemented this behavior and you does not seem to dissuade your idea.
So canonical path means symlinks forbidden!
Maybe I'm not the only one like the simple switch between widget tables and others also complain the loss and would like to behave normal bash. So I'm waiting for further issues before I do:

For object widgets, a more complicated procedure is to choose and I have to rewrite widget on all my devices.
I had hoped with this issue to get a simple procedure analogous to exit 1 for confirm (e.g., exit 2) for the refresh.

Instead, the refresh toast has been extend by an <id>. If tap manually on Reload Buttom*) and put <id> from toast in mind, that must be edited manually in the documented am ... action inside the widget action script. So refresh without manual refresh buttom, can only be done by manual refresh. I checked that on two devices and got two different <id>.
Could you also describe a way that determines the <id> by this script? Please answer here!

*) PID above is kown in Termux. How get the behavior of the following script without open Termux, is that possible?

s=.shortcuts t=$s/termux u=$s/ubuntu;if [ -e $t ];then mv $t $u; else mv $u $t;fi
am broadcast -n com.termux.widget/.TermuxWidgetProvider -a com.termux.widget.ACTION_REFRESH_WIDGET --ei appWidgetId 6

$u script above toggle between $u (init) and $t and refresh. On my SM-OS with PiP this is possible because the start screen is preserved. But the action change every time the currently edited shell. This is also undesired - how to avoid this behavior?.

@agnostic-apollo
Copy link
Member

So canonical path means symlinks forbidden!

It's forbidden for termux-tasker too for almost a year now.

Could you also describe a way that determines the by this script?

The id is not decided by termux-widget but by the launcher (maybe android) and will be different for each widget created on each device. There is no way to get it from a script, unless you use root access to get it from the launcher db, but you probably won't be able to know which entry is for which widget if multiple widgets exist. Maybe in future termux can store the ids internally when it receives them and refresh all widgets at once. That can be looked into in future, I haven't looked much into how widgets work.

@RalfWerner
Copy link
Author

RalfWerner commented Sep 23, 2021

It's forbidden for termux-tasker too for almost a year now.

Ok! Thanks for responding termux-tasker I've checked only rough but Tasker is not Widget and "canonical" not needet. Above I've extend the two lines example with some more questions - any Idea to that?

Doing the same on my Gigaset and close all Termux session, the toggle works with meantime toopface ofTermux (Middle of Shot) and changed Table. The env-ls-ps shortcut is here in Table and two times as icon (before/after update of Widget app):
grafik
The second is new created and the first (old and unusable) where created with previous symlinks (same path names).
So all these icon-shortcuts must recreate with 0.13 version?

@RalfWerner
Copy link
Author

RalfWerner commented Sep 23, 2021

The am ... function behind reload.Style in Termux is also executable via script (termux-reload-settings). Could a comparable process be inserted in the widget app to avoid the <id> problem and reduce "canonical" to $s/task?
If so, I would like to have passed the name of the table as above as a parameter.

I just realized, that you are faster then I could describe - so I continue my checks :)
Did I overlook something that makes the manual <id> process superfluous? A widget source analysis shows: last 34, this morning 32 and less before. In the changed 4,6 sources I have not found anything like that.

@agnostic-apollo
Copy link
Member

With bcb0ab6, the canonical path can be under ~/.termux. You should be able to do whatever you were doing before by moving directories under ~/.termux. I don't have time to understand it. This change will also be helpful if and when main directory is changed to ~/.termux/widget from ~/.shortcuts, with backward compatibility.

So all these icon-shortcuts must recreate with 0.13 version?

Read the v0.13.0 changelog, its written in bold.

A widget source analysis shows: last 34, this morning 32 and less before. In the changed 4,6 sources I have not found anything like that.

I am not sure why your launcher would change it, but as I said, such problems will be looked into in future with a possible "refresh all" option.

@RalfWerner
Copy link
Author

RalfWerner commented Sep 24, 2021

The canonical path can be under t=~/.termux. You should be able to do whatever you were doing before

Than would be ln -s .termux/widget ~/widget valid, but is'nt! Two reasons: first $t still must be canonical (check impossible) and secondly shortcuts in $t are not taken into account in the widget table. If I remove s=.shortcuts, refresh newly created it, even if $t/widget exists with canonical shortcuts. Dit I somethig wrong?

I am not sure why your launcher would change it ...

Mostly I use selfbuild *.apk, whose source I get with git clone ... locally, after I saved the last version. diff -r ...>1 is then README+your commit as file. That I call here widget sources analysis and has now again 34 sources (find -type f|wc -l), in which 6 sources are changed (grep -c diff 1).
With grep "/.termux" 1 I get the two lines in README and also not more, when I search in all sources. I have made one check with replacement of $s to $t in app/src/main/res/values/strings.xml but without success: Refresh still creates an empty $s and in the widget table is No files in ~/.termux/ though they are there. I made the same again with Termux app: Result 257 sources (2 add and 1 deleted) with 13 changed but nothing new with /.shortcuts except one old line here. Behavior is unchanged.
How/where should the switch from $s to $t be done in sources?

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Sep 26, 2021

If you want scripts in ~/.termux to show, create a symlink for them inside ~/.shortcuts, like for a script file with ln -s ~/.termux/script ~/.shortcuts/script or for a whole directory with ln -s ~/.termux/dir ~/.shortcuts/dir. I am not going to spend time trying to understand whatever you are trying to do and say. You probably want to create multiple widgets, each with its own directory. That can be added in future and is not supported currently. Wait till its implemented.

You are "probably" looking for this https://github.com/termux/termux-widget/blob/v0.13.0/app/src/main/java/com/termux/widget/TermuxWidgetService.java#L20

@RalfWerner
Copy link
Author

RalfWerner commented Sep 26, 2021

That can be added in future and is not supported currently. Wait till its implemented

My problem is That currently (0.13) does not work anymore! At 0.12 (this Issue) I've described How That works but refresh is the topic of this issue. To this, you have a cumbersome workaround (no problem) that open termux each time (unsightly and should affect Startscreen only).

... or for a whole directory with ln -s ~/.termux/dir ~/.shortcuts/dir.

Did you ever check that? Of course it does not work because of Canonical

If you want scripts in ~/.termux to show

You've described this in README (I do not wont it)!

@Grimler91
Copy link
Member

@RalfWerner I also do not understand what the issue is, or what the feature that you are requesting is. Please open a new issue or feature request and fill in the info requested in the bug report template or the feature request template, in a concise manner.

For the best result I think you can leave out all bold text, all italic text, and avoid concatenating screenshots

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Sep 26, 2021

That currently (0.13) does not work anymore!

The only thing that doesn't work is trying to put symlink files that target files outside ~/.shortcuts or ~/.termux.

Did you ever check that?

Yes, I did.

Of course it does not work because of Canonical

It seems you don't understand the meaning of canonical path. The ln -s ~/.termux/dir ~/.shortcuts/dir command will create a symlink file at ~/.shortcuts/dir that points to the directory at /data/data/com.termux/files/home/.termux/dir which is under ~/.termux and is an allowed path. If you were trying to create the symlink like ln -s .termux/widget ... mentioned above without ~/ at the start which is expanded by the shell, then that will create a dangling symlink that doesn't point to anything and is not a valid path. I am not here to fix your shell scripting mistakes.

@RalfWerner
Copy link
Author

Did you ever check that? Yes, I did.

I've also just now checked again with 0.13 and the same effect. What is the difference between our checks?
Ive checked on two real devices and one AVD. with Android 9 and 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants