for research purposes I am developing a native Android app (with Java), which allows geriatric patients after an ambulatory rehab to record a nutrition diary.
Due to the high age of the target group it has to be taken into account that the users have a tremor in their hands.
My approach to avoid "unintended" inputs: Is there some kind of global setting that defines a "minimum time" between two touch inputs? If this time is underrun, the app only executes the first input and ignores further inputs within this timeframe.
Of course I am open for other approaches and ideas. Maybe Android itself provides input assistance for people with tremor? So far I could not find anything that helps me with this topic.
To give you an idea of the situation: The user clicks a button. This causes the UI to change and a new button to appear in the exact same place where the user clicked. This button should not be directly "clickable". But of course, buttons at other locations should not react directly either.
Remember when the last Button
was clicked, then compare that time to the time the next Button
was clicked:
final long noClickWithinThisAmountOfMS = 2000; //2000ms = 2 seconds
long oldTime = 0;
long newTime = 0;
Button buttonOne = (Button) view.findViewById(R.id.button_one);
Button buttonTwo = (Button) view.findViewById(R.id.button_two);
buttonOne.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
newTime = System.currentTimeMillis();
if((newTime - oldTime) > noClickWithinThisAmountOfMS) {
//Don't ignore the click
oldTime = newTime;
//TODO: Add actual "onClick" code here
} //else: Ignore the click
}
});
buttonTwo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
newTime = System.currentTimeMillis();
if((newTime - oldTime) > noClickWithinThisAmountOfMS) {
oldTime = newTime;
//TODO: Add actual "onClick" code here
}
}
});
Do this for every Button
that has to be affected.
You can even create "clusters" of buttons this way by using multiple oldTime
and newTime
if e.g. ButtonOne and ButtonTwo are next to each other but should act independently of ButtonThree and ButtonFour.