• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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.car.settings.storage;
17 
18 import android.car.drivingstate.CarUxRestrictions;
19 import android.content.Context;
20 
21 import androidx.preference.Preference;
22 
23 import com.android.car.settings.R;
24 import com.android.car.settings.common.FragmentController;
25 import com.android.settingslib.applications.ApplicationsState;
26 
27 import java.util.ArrayList;
28 
29 /**
30  * Controller extends the {@link StorageApplicationListPreferenceController} which adds all the
31  * application in the parent controller and in addition one more application specific for listing
32  * audio files.
33  */
34 public class StorageMediaCategoryDetailPreferenceController extends
35         StorageApplicationListPreferenceController {
36 
37     private long mExternalAudioBytes;
38 
StorageMediaCategoryDetailPreferenceController(Context context, String preferenceKey, FragmentController fragmentController, CarUxRestrictions uxRestrictions)39     public StorageMediaCategoryDetailPreferenceController(Context context,
40             String preferenceKey, FragmentController fragmentController,
41             CarUxRestrictions uxRestrictions) {
42         super(context, preferenceKey, fragmentController, uxRestrictions);
43     }
44 
45     @Override
onDataLoaded(ArrayList<ApplicationsState.AppEntry> apps)46     public void onDataLoaded(ArrayList<ApplicationsState.AppEntry> apps) {
47         super.onDataLoaded(apps);
48         Preference preference = createPreference(
49                 getContext().getString(R.string.storage_audio_files_title),
50                 Long.toString(mExternalAudioBytes),
51                 getContext().getDrawable(R.drawable.ic_headset),
52                 getContext().getString(R.string.pk_storage_music_audio_files));
53         // remove the onClickListener which was set above with null key. This preference should
54         // do nothing on click.
55         preference.setOnPreferenceClickListener(null);
56         getPreference().addPreference(preference);
57     }
58 
59     /**
60      * Sets the external audio bytes
61      */
setExternalAudioBytes(long externalAudioBytes)62     public void setExternalAudioBytes(long externalAudioBytes) {
63         mExternalAudioBytes = externalAudioBytes;
64     }
65 }
66