1 /* 2 * Copyright (C) 2020 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 package com.android.music 17 18 import android.app.ListActivity 19 import android.content.Intent 20 import android.net.Uri 21 import android.os.Bundle 22 import android.provider.MediaStore 23 import android.util.Log 24 import android.view.Menu 25 import android.view.MenuItem 26 import android.view.View 27 import android.widget.ListView 28 29 /** 30 * A placeholder class to handle android.intent.action.PICK Intent. 31 */ 32 class MusicPicker : ListActivity(), View.OnClickListener { 33 /** Uri to the directory of all music being displayed. */ 34 var mBaseUri: Uri? = null 35 36 /** Called when the activity is first created. */ 37 override fun onCreate(icicle: Bundle?) { 38 super.onCreate(icicle) 39 mBaseUri = if (Intent.ACTION_GET_CONTENT.equals(getIntent().getAction())) { 40 MediaStore.Audio.Media.EXTERNAL_CONTENT_URI 41 } else { 42 getIntent().getData() 43 } 44 Log.w("MusicPicker", "Doesn't handle for data URI given to PICK action") 45 } 46 47 override fun onRestart() { 48 super.onRestart() 49 } 50 51 override fun onOptionsItemSelected(item: MenuItem): Boolean { 52 return super.onOptionsItemSelected(item) 53 } 54 55 override fun onCreateOptionsMenu(menu: Menu?): Boolean { 56 super.onCreateOptionsMenu(menu) 57 return true 58 } 59 60 protected override fun onSaveInstanceState(icicle: Bundle) { 61 super.onSaveInstanceState(icicle) 62 } 63 64 override fun onPause() { 65 super.onPause() 66 } 67 68 override fun onStop() { 69 super.onStop() 70 } 71 72 protected override fun onListItemClick(l: ListView?, v: View?, position: Int, id: Long) {} 73 74 override fun onClick(v: View?) {} 75 76 companion object { 77 const val DBG = false 78 const val TAG = "MusicPicker" 79 } 80 }