Add a shake animation on a terminal bell

This commit is contained in:
Fredrik Fornwall
2016-11-19 15:41:24 +01:00
parent a0fa51eb92
commit 883be37b98
2 changed files with 27 additions and 12 deletions

View File

@@ -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) {

View 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>