mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-12-03 23:51:08 +01:00
Add a shake animation on a terminal bell
This commit is contained in:
parent
a0fa51eb92
commit
883be37b98
2 changed files with 27 additions and 12 deletions
|
|
@ -49,6 +49,8 @@ import android.view.View.OnClickListener;
|
|||
import android.view.View.OnLongClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
|
@ -139,6 +141,8 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION).build()).build();
|
||||
int mBellSoundId;
|
||||
|
||||
Animation mOnBellAnimation;
|
||||
|
||||
private final BroadcastReceiver mBroadcastReceiever = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
|
@ -209,6 +213,8 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
mOnBellAnimation = AnimationUtils.loadAnimation(this, R.anim.on_bell);
|
||||
|
||||
mSettings = new TermuxPreferences(this);
|
||||
|
||||
setContentView(R.layout.drawer_layout);
|
||||
|
|
@ -402,20 +408,22 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
|||
|
||||
@Override
|
||||
public void onBell(TerminalSession session) {
|
||||
if (mIsVisible) {
|
||||
switch (mSettings.mBellBehaviour) {
|
||||
case TermuxPreferences.BELL_BEEP:
|
||||
mBellSoundPool.play(mBellSoundId, 1.f, 1.f, 1, 0, 1.f);
|
||||
break;
|
||||
case TermuxPreferences.BELL_VIBRATE:
|
||||
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(50);
|
||||
break;
|
||||
case TermuxPreferences.BELL_IGNORE:
|
||||
// Ignore the bell character.
|
||||
break;
|
||||
}
|
||||
if (!mIsVisible) return;
|
||||
|
||||
mTerminalView.startAnimation(mOnBellAnimation);
|
||||
|
||||
switch (mSettings.mBellBehaviour) {
|
||||
case TermuxPreferences.BELL_BEEP:
|
||||
mBellSoundPool.play(mBellSoundId, 1.f, 1.f, 1, 0, 1.f);
|
||||
break;
|
||||
case TermuxPreferences.BELL_VIBRATE:
|
||||
((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(50);
|
||||
break;
|
||||
case TermuxPreferences.BELL_IGNORE:
|
||||
// Ignore the bell character.
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
7
app/src/main/res/anim/on_bell.xml
Normal file
7
app/src/main/res/anim/on_bell.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:duration="30"
|
||||
android:fromXDelta="-1%"
|
||||
android:repeatCount="1"
|
||||
android:repeatMode="reverse"
|
||||
android:toXDelta="1%"/>
|
||||
</set>
|
||||
Loading…
Add table
Add a link
Reference in a new issue