mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 18:55:31 +08:00
Add a shake animation on a terminal bell
This commit is contained in:
@@ -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,7 +408,10 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
@Override
|
||||
public void onBell(TerminalSession session) {
|
||||
if (mIsVisible) {
|
||||
if (!mIsVisible) return;
|
||||
|
||||
mTerminalView.startAnimation(mOnBellAnimation);
|
||||
|
||||
switch (mSettings.mBellBehaviour) {
|
||||
case TermuxPreferences.BELL_BEEP:
|
||||
mBellSoundPool.play(mBellSoundId, 1.f, 1.f, 1, 0, 1.f);
|
||||
@@ -416,7 +425,6 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorsChanged(TerminalSession changedSession) {
|
||||
|
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>
|
Reference in New Issue
Block a user