From 6b05d58018c2806459c121e507c005639b74aee9 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 18 Jul 2011 13:09:59 -0700 Subject: Fix 5044158: Initial pass: add music transport controls to LockScreen Refactored all lockscreen notifications to go through new KeyguardStatusViewManager. This is required to intercept messages originally intended for separate TextViews that are now shown in a single view when showing the transport control view. Refactor EmergencyCallButton to be handled by common code in KeyguardStatusViewManager. First pass at LockScreenWidgetCallback for LockScreen "widgets" to send events back to LockScreen. First pass at LockScreenWidgetInterface, which will be required of Views that want to be rendered on LockScreen. Added place-holder TransportControlView until the real one is ready and integrated it into GridLayouts. Ensured emergencyCallButton is in all views, even if not shown since some devices may lock the user out if certain criteria isn't met (missing SIM, etc). Refactored layouts and removed keyguard_screen_status*.xml since layouts are all over the map and no longer make good use of a shared layout for this. Minor tweak to MultiWaveView to fix layout issues when placed in GridLayout where the measurement was being calculated improperly. Moved EmergencyCallButton to bottom of view where we can. Removed unused Alpha keyboards from tablet password unlock layouts. Removed unused views (status2, emergencyCallText screenLocked) from layouts and made common views have common names. Fixed bug with MultiWave layout in landscape where array was shown in wrong orientation. Separated clock colors for phones/tablets since they're now different. Converted remaining phone layouts to use GridLayout. Start routing audiomanager events to lockscreen views. Move emergency call button handling to KeyguardStatusViewManager. Change-Id: I480b0346cfe19aad316fea0c0aaabf8862693636 --- .../internal/widget/TransportControlView.java | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 core/java/com/android/internal/widget/TransportControlView.java (limited to 'core/java/com/android/internal/widget/TransportControlView.java') diff --git a/core/java/com/android/internal/widget/TransportControlView.java b/core/java/com/android/internal/widget/TransportControlView.java new file mode 100644 index 0000000..3961de3 --- /dev/null +++ b/core/java/com/android/internal/widget/TransportControlView.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.widget; + +import com.android.internal.R; + +import android.content.Context; +import android.media.AudioManager; +import android.os.Handler; +import android.os.Message; +import android.util.AttributeSet; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.LinearLayout; + +/** + * A special widget for displaying audio playback ("transport controls") in LockScreen. + * + */ +public class TransportControlView extends LinearLayout implements LockScreenWidgetInterface, + OnClickListener { + private static final String TAG = "TransportControlView"; + static final int sViewIds[] = { R.id.control_prev, R.id.control_pauseplay, R.id.control_next }; + protected static final int AUDIO_FOCUS_CHANGED = 100; + private LockScreenWidgetCallback mCallback; + + private Handler mHandler = new Handler() { + public void handleMessage(Message msg) { + switch (msg.what){ + case AUDIO_FOCUS_CHANGED: + handleAudioFocusChange(msg.arg1); + } + } + }; + + AudioManager.OnAudioFocusChangeListener mAudioFocusChangeListener = + new AudioManager.OnAudioFocusChangeListener() { + public void onAudioFocusChange(final int focusChange) { + mHandler.obtainMessage(AUDIO_FOCUS_CHANGED, focusChange, 0).sendToTarget(); + } + }; + + public TransportControlView(Context context) { + this(context, null); + } + + public TransportControlView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + protected void handleAudioFocusChange(int focusChange) { + // TODO + } + + public void setCallback(LockScreenWidgetCallback callback) { + mCallback = callback; + } + + @Override + public void onFinishInflate() { + for (int i = 0; i < sViewIds.length; i++) { + View view = findViewById(sViewIds[i]); + if (view != null) { + view.setOnClickListener(this); + } + } + } + + public void onClick(View v) { + switch (v.getId()) { + case R.id.control_prev: + // TODO + break; + + case R.id.control_pauseplay: + // TODO + break; + + case R.id.control_next: + // TODO + break; + } + // Have any button click extend lockscreen's timeout. + if (mCallback != null) { + mCallback.userActivity(this); + } + } + +} -- cgit v1.1