Skip to content

Commit

Permalink
Added: homescreen widgets, f-droid metadata, lockscreen activities.
Browse files Browse the repository at this point in the history
  • Loading branch information
tareksander committed Nov 6, 2021
1 parent 7618c45 commit 5d902f0
Show file tree
Hide file tree
Showing 56 changed files with 995 additions and 973 deletions.
10 changes: 9 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 42 additions & 7 deletions Protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

If you don't want to implement a custom library for using the protocol, you can skip to the [protocol methods](#methods)<!-- @IGNORE PREVIOUS: anchor -->

### WARNING: The protocol is not yet stable and could change anytime
### WARNING: The protocol is not yet stable and could change anytime, and parts are not implemented yet.


## Connection
Expand Down Expand Up @@ -47,8 +47,11 @@ These methods control Android [Activities](https://developer.android.com/referen
- Parameters:
- tid: the task in which the Activity should be started. If not specified, a new Task is created and the id is returned after the Activity id.
- flags: Flags to set when launching the Activity via the Intent.
- dialog: boolean value. If true, the Activity will be launched as a dialog.
- pip: boolean. Whether or not to start the Activity in [Picture-in-Picture mode](https://developer.android.com/guide/topics/ui/picture-in-picture). Default is false. This should only be used to create Activities in a new Task.
- One of:
- dialog: boolean value. If true, the Activity will be launched as a dialog.
- pip: boolean. Whether or not to start the Activity in [Picture-in-Picture mode](https://developer.android.com/guide/topics/ui/picture-in-picture). Default is false. This should only be used to create Activities in a new Task.
- lockscreen: displays this Activity on the lockscreen.
- overlay: uses a system overlay window to display above everything else.
- finishActivity: Closes an Activity.
- Parameters:
- aid: The id of the Activity to close.
Expand All @@ -69,13 +72,18 @@ These methods control Android [Activities](https://developer.android.com/referen
- setTaskDescription: Sets the Icon of the Task, the label and set the primary color to the one specified with setTheme. The background color of the icon will be the current primary color.
- Parameters:
- aid: The id of an Activity in the Task you want to set the icon.
- img: The image data in PNG or JPEG format.
- img: The image data in PNG or JPEG format. May also be the literal string "default". to reset to the default Termux icon.
- label: The new Task label.
- setPiPParams: Sets the PiP parameters for the Activity. PiP parameters are only available on Android 8+, on earlier versions this is a noop.
- Parameters:
- aid: The id of an Activity in the Task you want to set the icon.
- num: Numerator of the desired aspect ration.
- den: Denominator of the desired aspect ration.
- setInputMode: Determines what happens when the virtual keyboard is shown.
- Parameters:
- aid: The id of the Activity.
- mode: one of: "resize": resizes the Activity, "pan": pans the Activity.



Layout and View control:
Expand All @@ -84,6 +92,7 @@ These methods create and Manipulate [Views](https://developer.android.com/refere
- The following Views and Layouts are supported:
- [LinearLayout](https://developer.android.com/guide/topics/ui/layout/linear)
- [RelativeLayout](https://developer.android.com/guide/topics/ui/layout/relative)
- [FrameLayout](https://developer.android.com/reference/android/widget/FrameLayout)
- [TextView](https://developer.android.com/reference/android/widget/TextView)
- [EditText](https://developer.android.com/reference/android/widget/EditText)
- [Button](https://developer.android.com/reference/android/widget/Button)
Expand Down Expand Up @@ -202,13 +211,39 @@ Event control:
- aid: The id of the Activity the View is in.
- send: Whether to send the event ot not, a boolean.

Widgets:
App widget support only a subset of Views. See [remote views](https://developer.android.com/reference/android/widget/RemoteViews#public-constructors).
- bindWidget: Binds a widget to this connection, so you can perform actions on it. Returns 0 on success, another number on failure.
- Parameters:
- wid: The widget id.
- blitWidget: updates the widget with the views you created and configured in it.
- Parameters:
- wid: The widget id.
- clearWidget: clears the widget representation. This is needed because you can't remove views in a widget, you then have to build it again.
- Parameters:
- wid: The widget id.
- createListView: Creates a ListView where content can be placed dynamically

The following methods can also take the parameter wid instead of aid to operate on widgets:
- createLinearLayout: can only be used as the root layout
- createImageView: the image has to be specified in this method and cannot be changed afterwards.
- createButton: The text has to be specified here and cannot be changed afterwards.
- createTextView: The text has to be specified here and cannot be changed afterwards.
- createGridLayout: Works as a collection like ListView
- createProgressBar







## Events

Once you have opened an Activity and placed all Views and configured it, like mit GUI applications you have to wait for user input.
Events arrive on the event socket.
Events that are enabled by default:
- click for Buttons
- click for Buttons, Checkboxes
-

Event types:
Expand Down Expand Up @@ -236,8 +271,8 @@ Event types:
- value: whether or not the Activity is finishing
- stop
- value: whether or not the Activity is finishing
- destroy
- value: whether or not the Activity is finishing
- destroy:
- value: whether or not the Activity is finishing. Only for destroy this is guaranteed to be accurate. The previous events may not report that. So if you want to save state when the Activity is destroyed, request that state when it is stopped instead.
- Custom events:
- recitem: The plugin needs an item for a RecyclerView
- value:
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ With these fundamentals you can go ahead and use this plugin. If you need more

## Language Bindings

### Python




### C/C++
- [Python](https://github.com/tareksander/termux-gui-python-bindings)
- [C/C++](https://github.com/tareksander/termux-gui-c-bindings)



33 changes: 26 additions & 7 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,53 @@
[ ] system overlay window support
[ ] Action Bar with elements
[ ] App widgets
[ ] when the user places a widget, generate a ID and put it in the clipboard. The Widget can then be manipulated with the ID.
[ ] only 1 depth layouts, because the IDs can't be changed
[ ] or have 10 different layout files for each view type with 10 different ids, that allows a bit of nesting
[ ] 5 for Layouts, 10 for textview and button, 5 for progress bar
[ ] But the main dynamic content should be made with collections: https://developer.android.com/guide/topics/appwidgets/collections
[ ] support for using layouts in widgets (if parent != null, use R.id.remoteview as parent)
[ ] Notifications with custom Layout
[ ] method to get the screen resolution, to change layout if needed
[ ] on screen orientation change event
[ ] support for divider between elements in LinearLayouts an RecyclerViews
[ ] Gesture events
[ ] Multitouch
[ ] setting visibility to hidden or gone
[ ] Lockscreen activities: https://stackoverflow.com/questions/60732308/android-displaying-view-over-the-lockscreen-like-google-maps
[ ] demo program: Write notes in an EditText, they get placed in a file.

[ ] method to check dark mode and other configuration variables
[ ] register dynamic broadcast receivers for things like language chance, airplane mode and other useful events and relay them to the program
- ACTION_AIRPLANE_MODE_CHANGED
- ACTION_BATTERY_LOW
- ACTION_BATTERY_OKAY
- ACTION_DEVICE_STORAGE_LOW
- ACTION_DEVICE_STORAGE_OK
- ACTION_LOCALE_CHANGED
- ACTION_BATTERY_CHANGED
- ACTION_SCREEN_OFF
- ACTION_SCREEN_ON
- ACTION_TIMEZONE_CHANGED
[ ] settings explicit size for views
[ ] settings ImageView size in px, so it can be exactly the size of the bitmap buffer
[ ] or query the current size of the ImageView to use a new buffer
[ ] Toasts


[ ] finish f-droid metadata
[ ] finish Python bindings when the plugin is available on f-droid and upload them to pypi

Implement Views:
[ ] RelativeLayout
[ ] Button
[x] FrameLayout
[x] Button
[x] ImageView
[x] Space
[ ] NestedScrollView
[x] NestedScrollView
[ ] RecyclerView
[ ] use the paging library to get good performance. When a new page is needed, send an event to the program.
Then the program has to send back a list of json layouts to populate the view.
To update existing items, the program can send a page unrequested.
[ ] RadioButton
[ ] RadioGroup
[ ] Checkbox
[x] Checkbox
[ ] ToggleButton
[ ] ImageButton
[ ] Spinner
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}

dependencies {
Expand All @@ -52,5 +55,6 @@ dependencies {
implementation 'com.github.flipkart-incubator.proteus:recyclerview-v7:5.0.1'
implementation 'com.github.flipkart-incubator.proteus:support-v4:5.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.4.0'

}
Binary file removed app/icon.png
Binary file not shown.
42 changes: 37 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.termux.gui"
android:sharedUserId="com.termux">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:name=".App"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TermuxGUI"
android:name=".App">
android:theme="@style/Theme.TermuxGUI">
<receiver android:name=".WidgetButtonReceiver"
android:exported="false">
</receiver>
<receiver
android:name=".GUIWidget"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>

<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget" />
</receiver>
<receiver
android:name=".ServiceShutdownReceiver"
android:enabled="true"
android:exported="false" />

<activity
android:name=".GUIWidgetConfigurationActivity"
android:excludeFromRecents="true"
android:exported="false"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
<activity
android:name=".GUIActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="false"
android:supportsPictureInPicture="true" />
<activity
android:name=".GUIActivityLockscreen"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="false"
android:showOnLockScreen="true"
android:showWhenLocked="true"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"/>
tools:targetApi="o_mr1" />
<activity
android:name=".GUIActivityDialog"
android:excludeFromRecents="true"
android:exported="false"
android:theme="@style/TermuxAlertDialogStyle"
android:excludeFromRecents="true"/>
android:theme="@style/TermuxAlertDialogStyle" />

<service
android:name=".GUIService"
Expand Down
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5d902f0

Please sign in to comment.