- Saved searches
- Use saved searches to filter your results more quickly
- License
- pwittchen/touch
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Java, Touchscreen and Swing
- Are you a Developer working with PDF files?
- Do you need to solve any of these problems?
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Android library, which allows to monitor raw touch events on the screen of the device with RxJava
License
pwittchen/touch
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Android library, which allows to monitor raw touch events on the screen of the device with RxJava
Current Branch | Branch | Artifact Id | Maven Central | CI build |
---|---|---|---|---|
☑️ | RxJava2.x | touch-rx2 |
Step 1: Create Touch attribute and Disposable in the Activity :
private Touch touch; private Disposable disposable;
Step 2: Initialize Touch object and subscribe Flowable :
@Override protected void onCreate(Bundle savedInstanceState) < super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); info = (TextView) findViewById(R.id.info); touch = new Touch(); disposable = touch.observe() .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(touchEvent -> info.setText(touchEvent.toString())); >
TouchEvent is a class with the following values:
public enum TouchEvent < public float x() <> public float y() <> public TouchType type() <> >
TouchType is an enum with the following values:
public enum TouchType < UP, DOWN, MOVE >
Step 3: override dispatchTouchEvent(MotionEvent event) :
@Override public boolean dispatchTouchEvent(MotionEvent event) < touch.dispatchTouchEvent(event); return super.dispatchTouchEvent(event); >
Step 4: dispose previously created Disposable when it’s no longer needed:
@Override protected void onPause() < super.onPause(); if (disposable != null && !disposable.isDisposed()) < disposable.dispose(); > >
Exemplary application is located in app directory of this repository.
replace x.y.z with the latest version of the library
You can depend on the library through Maven:
dependency> groupId>com.github.pwittchengroupId> artifactId>touch-rx2artifactId> version>x.y.zversion> dependency>
dependencies < compile 'com.github.pwittchen:touch-rx2:x.y.z' >
To execute unit tests run:
Code style used in the project is called SquareAndroid from Java Code Styles repository by Square available at: https://github.com/square/java-code-styles.
Static code analysis runs Checkstyle, PMD and Lint. It can be executed with command:
Reports from analysis are generated in library/build/reports/ directory.
To release the library, bump its version and call the following command:
./gradlew uploadArchives closeAndReleaseRepository
Copyright 2020 Piotr Wittchen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
About
Android library, which allows to monitor raw touch events on the screen of the device with RxJava
Java, Touchscreen and Swing
My personal laptop has recently had to be retired. A combination of age, damage to the outer case and over heating problems has made it difficult to use for anything beyond web browsing without it over heating and shutting down. The case is battered to the point of a new chip coming loose every few weeks. The laptop was getting old so it was about time to replace it.
My new laptop has a touchscreen. So I decided to take it to work with me and look into the possibilities of touchscreen with our library and Swing in general. Now I know Swing is on its way out but that doesn’t mean we shouldn’t squeeze as much out of it as possible before then.
So looking at the way the touchscreen works it appears as if the touchscreen is actually just a fancy mouse, when you include multi-touch support it is a very fancy mouse. Now I believe that multi-touch may be a bit out of the reach of Swing. I could be wrong here, a quick search has shown that it might be possible but for now it is beyond my knowledge.
So, single-touch touchscreen functionality is basically a mouse. When using the touchscreen, Swing treats the events of the touch screen as various mouse events. A tap is treated as a mouse pressed action, double tap as a mouse clicked. It is easy enough to guess what the different input methods for the touchscreen translate to.
This is only a very basic review of using touchscreen monitors with Swing. In future posts I will be describing in more detail how to achieve different effects such as using flick to scroll pages based on speed and direction of the flick, gestures and patterns to perform given tasks and anything else I can find of interest.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Do you need to solve any of these problems?
Kieran France Kieran France is a programmer for IDRSolutions in charge of there internal test suite. In his spare time he enjoys tinkering with gadgets and code.