2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.music;
19 import android.app.Activity;
20 import android.app.SearchManager;
21 import android.content.BroadcastReceiver;
22 import android.content.ComponentName;
23 import android.content.Context;
24 import android.content.Intent;
25 import android.content.IntentFilter;
26 import android.content.ServiceConnection;
27 import android.content.SharedPreferences;
28 import android.graphics.drawable.Drawable;
29 import android.media.AudioManager;
30 import android.media.MediaFile;
31 import android.net.Uri;
32 import android.os.Bundle;
33 import android.os.RemoteException;
34 import android.os.IBinder;
35 import android.provider.MediaStore;
36 import android.util.Log;
37 import android.view.Menu;
38 import android.view.MenuItem;
39 import android.view.MotionEvent;
40 import android.view.View;
41 import android.view.Window;
42 import android.widget.ImageButton;
43 import android.widget.TextView;
45 public class MusicBrowserActivity extends Activity
46 implements MusicUtils.Defs {
48 public MusicBrowserActivity() {
52 * Called when the activity is first created.
55 public void onCreate(Bundle icicle) {
56 super.onCreate(icicle);
57 int activeTab = MusicUtils.getIntPref(this, "activetab", R.id.artisttab);
58 if (activeTab != R.id.artisttab
59 && activeTab != R.id.albumtab
60 && activeTab != R.id.songtab
61 && activeTab != R.id.playlisttab) {
62 activeTab = R.id.artisttab;
64 MusicUtils.activateTab(this, activeTab);
66 String shuf = getIntent().getStringExtra("autoshuffle");
67 if ("true".equals(shuf)) {
68 bindService((new Intent()).setClass(this, MediaPlaybackService.class), autoshuffle, 0);
73 public void onDestroy() {
74 MusicUtils.unbindFromService(this);
78 private ServiceConnection autoshuffle = new ServiceConnection() {
79 public void onServiceConnected(ComponentName classname, IBinder obj) {
80 // we need to be able to bind again, so unbind
83 } catch (IllegalArgumentException e) {
85 IMediaPlaybackService serv = IMediaPlaybackService.Stub.asInterface(obj);
88 serv.setShuffleMode(MediaPlaybackService.SHUFFLE_AUTO);
89 } catch (RemoteException ex) {
94 public void onServiceDisconnected(ComponentName classname) {