diff options
| author | 2019-10-23 10:58:49 +0200 | |
|---|---|---|
| committer | 2019-10-24 09:15:11 +0200 | |
| commit | b45c80fffadaffc1f39f4c1b13391043fdd47ace (patch) | |
| tree | b9022eeb390f664d273cf44f0a911876878016ed | |
| parent | 8e554f88855b8027e1ef7be0c958c18949094ca1 (diff) | |
Change view/window visibility when indicator is shown/hidden. Change the window title
Change-Id: Ic783ee71753fb719577667bf9cc05cbf35cb3872
Test: (1) manual - run any app that records audio;
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/tv/AudioRecordingDisclosureBar.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/AudioRecordingDisclosureBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/AudioRecordingDisclosureBar.java index d6d0a3603c25..9b685f0ad0f6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/AudioRecordingDisclosureBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/AudioRecordingDisclosureBar.java @@ -30,6 +30,7 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.widget.ImageView; @@ -45,7 +46,10 @@ class AudioRecordingDisclosureBar { private static final String TAG = "AudioRecordingDisclosureBar"; private static final boolean DEBUG = false; - private static final String LAYOUT_PARAMS_TITLE = "AudioRecordingDisclosureBar"; + // This title is used to test the microphone disclosure indicator in + // CtsSystemUiHostTestCases:TvMicrophoneCaptureIndicatorTest + private static final String LAYOUT_PARAMS_TITLE = "MicrophoneCaptureIndicator"; + private static final int ANIM_DURATION_MS = 150; private final Context mContext; @@ -70,6 +74,7 @@ class AudioRecordingDisclosureBar { } private void createView() { + //TODO(b/142228704): this is to be re-implemented once proper design is completed mView = View.inflate(mContext, R.layout.tv_status_bar_audio_recording, null); mAppsInfoContainer = mView.findViewById(R.id.container); @@ -88,7 +93,7 @@ class AudioRecordingDisclosureBar { Context.WINDOW_SERVICE); windowManager.addView(mView, layoutParams); - // Set invisible first util it gains its actual size and we are able to hide it by moving + // Set invisible first until it gains its actual size and we are able to hide it by moving // off the screen mView.setVisibility(View.INVISIBLE); mView.getViewTreeObserver().addOnGlobalLayoutListener( @@ -98,16 +103,18 @@ class AudioRecordingDisclosureBar { // Now that we get the height, we can move the bar off ("below") the screen final int height = mView.getHeight(); mView.setTranslationY(height); - // ... and make it visible - mView.setVisibility(View.VISIBLE); // Remove the observer mView.getViewTreeObserver() .removeOnGlobalLayoutListener(this); + // Now, that the view has been measured, and the translation was set to + // move it off the screen, we change the visibility to GONE + mView.setVisibility(View.GONE); } }); } private void showAudioRecordingDisclosureBar() { + mView.setVisibility(View.VISIBLE); mView.animate() .translationY(0f) .setDuration(ANIM_DURATION_MS) @@ -138,9 +145,10 @@ class AudioRecordingDisclosureBar { } private void hideAudioRecordingDisclosureBar() { - mView.animate() - .translationY(mView.getHeight()) + final ViewPropertyAnimator animator = mView.animate(); + animator.translationY(mView.getHeight()) .setDuration(ANIM_DURATION_MS) + .withEndAction(() -> mView.setVisibility(View.GONE)) .start(); } @@ -156,7 +164,7 @@ class AudioRecordingDisclosureBar { public void onOpActiveChanged(String op, int uid, String packageName, boolean active) { if (DEBUG) { Log.d(TAG, - "OP_RECORD_AUDIO active change, active" + active + ", app=" + packageName); + "OP_RECORD_AUDIO active change, active=" + active + ", app=" + packageName); } if (mExemptApps.contains(packageName)) { |