DeleteItems.java revision 6cb8bc92e0ca524a76a6fa3f6814b43ea9a3b30d
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
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
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17package com.android.music;
18
19import android.app.Activity;
20import android.content.ContentResolver;
21import android.content.ContentValues;
22import android.content.Intent;
23import android.database.Cursor;
24import android.media.AudioManager;
25import android.net.Uri;
26import android.os.Bundle;
27import android.provider.MediaStore;
28import android.text.TextWatcher;
29import android.util.Log;
30import android.view.KeyEvent;
31import android.view.View;
32import android.view.Window;
33import android.view.WindowManager;
34import android.widget.Button;
35import android.widget.EditText;
36import android.widget.TextView;
37import android.widget.Toast;
38
39public class DeleteItems extends Activity
40{
41    private TextView mPrompt;
42    private Button mButton;
43    private int [] mItemList;
44
45    @Override
46    public void onCreate(Bundle icicle) {
47        super.onCreate(icicle);
48        setVolumeControlStream(AudioManager.STREAM_MUSIC);
49
50        requestWindowFeature(Window.FEATURE_NO_TITLE);
51        setContentView(R.layout.confirm_delete);
52        getWindow().setLayout(WindowManager.LayoutParams.FILL_PARENT,
53                                    WindowManager.LayoutParams.WRAP_CONTENT);
54
55        mPrompt = (TextView)findViewById(R.id.prompt);
56        mButton = (Button) findViewById(R.id.delete);
57        mButton.setOnClickListener(mButtonClicked);
58
59        ((Button)findViewById(R.id.cancel)).setOnClickListener(new View.OnClickListener() {
60            public void onClick(View v) {
61                finish();
62            }
63        });
64
65        Bundle b = getIntent().getExtras();
66        String desc = b.getString("description");
67        mItemList = b.getIntArray("items");
68
69        String promptformat = getString(R.string.delete_confirm_prompt);
70        String prompt = String.format(promptformat, desc);
71        mPrompt.setText(prompt);
72    }
73
74    private View.OnClickListener mButtonClicked = new View.OnClickListener() {
75        public void onClick(View v) {
76            // delete the selected item(s)
77            MusicUtils.deleteTracks(DeleteItems.this, mItemList);
78            finish();
79        }
80    };
81}
82