Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Froyo #7

Open
wants to merge 2 commits into
base: froyo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,17 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
"lock_pattern_tactile_feedback_enabled";

/**
* Whether to use statusbar music control
* @hide
*/
public static final String STATUSBAR_MUSIC_CONTROLS = "statusbar_music_controls";

/**
* Whether to use statusbar music control
* @hide
*/
public static final String STATUSBAR_ALWAYS_MUSIC_CONTROLS = "statusbar_always_music_controls";

/**
* A formatted string of the next alarm that is set, or the empty string
Expand Down Expand Up @@ -2156,6 +2167,12 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
*/
public static final String TRACKBALL_UNLOCK_SCREEN = "trackball_unlock_screen";

/**
* Whether to unlock the screen with the HOLD key. The value is boolean (1 or 0).
* @hide
*/
public static final String HOLD_UNLOCK_SCREEN = "hold_unlock_screen";

/**
* Pulse the Trackball with Screen On. The value is boolean (1 or 0).
* @hide
Expand Down Expand Up @@ -2223,13 +2240,13 @@ public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
public static final String NOTIF_BAR_CUSTOM = "notif_bar_custom";

/**
* Whether to use custom notification bar
* Whether to use lockscreen music controls
* @hide
*/
public static final String LOCKSCREEN_MUSIC_CONTROLS = "lockscreen_music_controls";

/**
* Whether to use custom notification bar
* Whether to always show lockscreen music controls
* @hide
*/
public static final String LOCKSCREEN_ALWAYS_MUSIC_CONTROLS = "lockscreen_always_music_controls";
Expand Down Expand Up @@ -4514,4 +4531,4 @@ public static CharSequence getTitle(Context context, Cursor cursor) {
public static String getGTalkDeviceId(long androidId) {
return "android-" + Long.toHexString(androidId);
}
}
}
70 changes: 61 additions & 9 deletions core/res/res/layout/status_bar_expanded.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
>
<LinearLayout android:id="@+id/exp_power_stat_1"
android:layout_width="0dip"
android:layout_weight="1"
Expand All @@ -48,7 +48,7 @@
android:focusable="true"
android:visibility="gone"
android:background="@drawable/stat_power_bg"
>
>
<ImageView android:id="@+id/exp_power_image_1"
android:layout_width="match_parent"
android:layout_height="0dip"
Expand All @@ -70,7 +70,7 @@
android:focusable="true"
android:visibility="gone"
android:background="@drawable/stat_power_bg"
>
>
<ImageView android:id="@+id/exp_power_image_2"
android:layout_width="match_parent"
android:layout_height="0dip"
Expand All @@ -92,7 +92,7 @@
android:focusable="true"
android:visibility="gone"
android:background="@drawable/stat_power_bg"
>
>
<ImageView android:id="@+id/exp_power_image_3"
android:layout_width="match_parent"
android:layout_height="0dip"
Expand All @@ -113,8 +113,8 @@
android:clickable="true"
android:focusable="true"
android:visibility="gone"
android:background="@drawable/stat_power_bg"
>
android:background="@drawable/stat_power_bg"
>
<ImageView android:id="@+id/exp_power_image_4"
android:layout_width="match_parent"
android:layout_height="0dip"
Expand All @@ -136,7 +136,7 @@
android:focusable="true"
android:visibility="gone"
android:background="@drawable/stat_power_bg"
>
>
<ImageView android:id="@+id/exp_power_image_5"
android:layout_width="match_parent"
android:layout_height="0dip"
Expand All @@ -158,7 +158,7 @@
android:focusable="true"
android:visibility="gone"
android:background="@drawable/stat_power_bg"
>
>
<ImageView android:id="@+id/exp_power_image_6"
android:layout_width="match_parent"
android:layout_height="0dip"
Expand All @@ -179,8 +179,9 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
>
<LinearLayout
android:id="@+id/carrierBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
Expand All @@ -189,6 +190,7 @@
android:layout_gravity="center_vertical"
android:paddingBottom="1dp"
android:orientation="vertical"
android:visibility="gone"
>
<TextView android:id="@+id/plmnLabel"
android:layout_width="wrap_content"
Expand All @@ -207,6 +209,56 @@
android:paddingLeft="4dp"
/>
</LinearLayout>
<!-- Begin Music Control -->
<LinearLayout android:id="@+id/exp_music_control"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="1dp"
android:layout_marginLeft="5dp"
android:paddingBottom="1dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:visibility="gone"
>
<ImageButton
android:id="@+id/music_control_previous"
android:src="@drawable/ic_media_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10px"
android:background="@color/transparent"
/>
<ImageButton
android:id="@+id/music_control_play"
android:src="@drawable/ic_media_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10px"
android:background="@color/transparent"
android:visibility="gone"
/>
<ImageButton
android:id="@+id/music_control_pause"
android:src="@drawable/ic_media_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10px"
android:background="@color/transparent"
android:visibility="gone"
/>
<ImageButton
android:id="@+id/music_control_next"
android:src="@drawable/ic_media_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10px"
android:layout_toRightOf="@+id/music_control_pause"
android:background="@color/transparent"
/>
</LinearLayout>
<!-- End Music Control -->
<!-- "Clear All" button -->
<TextView android:id="@+id/clear_all_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
127 changes: 126 additions & 1 deletion services/java/com/android/server/status/StatusBarService.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.ScrollView;
Expand Down Expand Up @@ -288,6 +289,18 @@ public boolean dispatchKeyEvent(KeyEvent event) {
private HashMap<String,PowerButton> mUsedPowerButtons = new HashMap<String,PowerButton>();
private boolean mHideOnPowerButtonChange = false;

// statusbar music controls
private AudioManager am;
private boolean mIsMusicActive;
private ImageButton mPlayIcon;
private ImageButton mPauseIcon;
private ImageButton mRewindIcon;
private ImageButton mForwardIcon;
private LinearLayout mStatusbarMusicControls;
private LinearLayout mCarrierBox;
private boolean mStatusMusicControls;
private boolean mStatusAlwaysMusic;

/**
* Construct the service, add the status bar view to the window manager
*/
Expand Down Expand Up @@ -348,7 +361,6 @@ private void makeStatusBarView(Context context) {
mIcons = (LinearLayout)sb.findViewById(R.id.icons);
mTickerView = sb.findViewById(R.id.ticker);


mExpandedDialog = new ExpandedDialog(context);
mExpandedView = expanded;
mExpandedContents = expanded.findViewById(R.id.notificationLinearLayout);
Expand All @@ -359,11 +371,19 @@ private void makeStatusBarView(Context context) {
mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button);
mClearButton.setOnClickListener(mClearButtonListener);
mCarrierBox = (LinearLayout)expanded.findViewById(R.id.carrierBox);
mSpnLabel = (TextView)expanded.findViewById(R.id.spnLabel);
mPlmnLabel = (TextView)expanded.findViewById(R.id.plmnLabel);
mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);

// music controls
mPlayIcon = (ImageButton) expanded.findViewById(R.id.music_control_play);
mPauseIcon = (ImageButton) expanded.findViewById(R.id.music_control_pause);
mRewindIcon = (ImageButton) expanded.findViewById(R.id.music_control_previous);
mForwardIcon = (ImageButton) expanded.findViewById(R.id.music_control_next);
mStatusbarMusicControls = (LinearLayout) expanded.findViewById(R.id.exp_music_control);

if (custExpBar) {
mExpandedView.findViewById(R.id.exp_view_lin_layout).
setBackgroundDrawable(expBarHeadDrawable);
Expand Down Expand Up @@ -406,6 +426,7 @@ private void makeStatusBarView(Context context) {
// set the inital view visibility
setAreThereNotifications();
mDateView.setVisibility(View.INVISIBLE);
mCarrierBox.setVisibility(View.VISIBLE);

// before we register for broadcasts
mPlmnLabel.setText(R.string.lockscreen_carrier_default);
Expand Down Expand Up @@ -451,6 +472,13 @@ public void systemReady() {
setVisibility(View.GONE);
}

// music controls
mStatusMusicControls = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.STATUSBAR_MUSIC_CONTROLS, 1) == 1;
mStatusAlwaysMusic = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.STATUSBAR_ALWAYS_MUSIC_CONTROLS, 1) == 1;
setupMusicControls();

WindowManagerImpl.getDefault().addView(view, lp);
}

Expand Down Expand Up @@ -1129,6 +1157,7 @@ private void makeExpandedVisible() {
if (mExpandedVisible) {
return;
}
refreshMusicStatus();
mExpandedVisible = true;
panelSlightlyVisible(true);

Expand Down Expand Up @@ -1919,6 +1948,80 @@ public void onClick(View v) {
}
};

/** Music Control **/
private View.OnClickListener mPlayListener = new View.OnClickListener() {
public void onClick(View v) {
refreshMusicStatus();
mPlayIcon.setVisibility(View.GONE);
mPauseIcon.setVisibility(View.VISIBLE);
sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
}
};

private View.OnClickListener mPauseListener = new View.OnClickListener() {
public void onClick(View v) {
refreshMusicStatus();
mPauseIcon.setVisibility(View.GONE);
mPlayIcon.setVisibility(View.VISIBLE);
sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
}
};

private View.OnClickListener mRewindListener = new View.OnClickListener() {
public void onClick(View v) {
sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_PREVIOUS);
}
};

private View.OnClickListener mForwardListener = new View.OnClickListener() {
public void onClick(View v) {
sendMediaButtonEvent(KeyEvent.KEYCODE_MEDIA_NEXT);
}
};

private void sendMediaButtonEvent(int code) {
long eventtime = SystemClock.uptimeMillis();

Intent downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null);
KeyEvent downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, code, 0);
downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent);
mContext.sendOrderedBroadcast(downIntent, null);

Intent upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null);
KeyEvent upEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, code, 0);
upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent);
mContext.sendOrderedBroadcast(upIntent, null);
}

private void setupMusicControls() {
am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
refreshMusicStatus();
mPlayIcon.setOnClickListener(mPlayListener);
mPauseIcon.setOnClickListener(mPauseListener);
mRewindIcon.setOnClickListener(mRewindListener);
mForwardIcon.setOnClickListener(mForwardListener);
}

private void refreshMusicStatus() {
mIsMusicActive = am.isMusicActive();
if (mStatusMusicControls && (mIsMusicActive || mStatusAlwaysMusic)) {
mCarrierBox.setVisibility(View.GONE);
mStatusbarMusicControls.setVisibility(View.VISIBLE);
if (mIsMusicActive) {
mPauseIcon.setVisibility(View.VISIBLE);
mPlayIcon.setVisibility(View.GONE);
} else {
mPlayIcon.setVisibility(View.VISIBLE);
mPauseIcon.setVisibility(View.GONE);
}
} else {
mStatusbarMusicControls.setVisibility(View.GONE);
mCarrierBox.setVisibility(View.VISIBLE);
mPlayIcon.setVisibility(View.VISIBLE);
mPauseIcon.setVisibility(View.GONE);
}
}

/** Power Widget **/

private View.OnLongClickListener mPowerLongListener = new View.OnLongClickListener() {
Expand Down Expand Up @@ -2347,6 +2450,14 @@ public void observe() {
resolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.TORCH_STATE),
false, this);

resolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.STATUSBAR_MUSIC_CONTROLS),
false, this);

resolver.registerContentObserver(
Settings.System.getUriFor(Settings.System.STATUSBAR_ALWAYS_MUSIC_CONTROLS),
false, this);
}

@Override
Expand Down Expand Up @@ -2396,6 +2507,20 @@ public void update(Uri uri) {
mExpandedView.findViewById(R.id.exp_power_stat).
setVisibility(View.VISIBLE);
}
} else if (uri.equals(Settings.System.getUriFor(Settings.System.STATUSBAR_MUSIC_CONTROLS)) ||
uri.equals(Settings.System.getUriFor(Settings.System.STATUSBAR_ALWAYS_MUSIC_CONTROLS))) {
mStatusMusicControls = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.STATUSBAR_MUSIC_CONTROLS, 1) == 1;
mStatusAlwaysMusic = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.STATUSBAR_ALWAYS_MUSIC_CONTROLS, 1) == 1;
mIsMusicActive = am.isMusicActive();
if(!mStatusMusicControls || (!mStatusAlwaysMusic && !mIsMusicActive)) {
mStatusbarMusicControls.setVisibility(View.GONE);
mCarrierBox.setVisibility(View.VISIBLE);
} else if (mStatusMusicControls && mStatusAlwaysMusic) {
mStatusbarMusicControls.setVisibility(View.VISIBLE);
mCarrierBox.setVisibility(View.GONE);
}
}
updateWidget();
}
Expand Down