1 /* 2 * Copyright (C) 2015 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.settings.wifi; 17 18 import android.app.Fragment; 19 import android.content.Context; 20 import android.content.pm.PackageManager; 21 import android.graphics.drawable.Drawable; 22 import android.graphics.drawable.StateListDrawable; 23 import android.net.wifi.WifiConfiguration; 24 import android.os.Looper; 25 import android.os.UserHandle; 26 import android.support.v7.preference.Preference; 27 import android.support.v7.preference.PreferenceViewHolder; 28 import android.text.TextUtils; 29 import android.util.AttributeSet; 30 import android.util.SparseArray; 31 import android.view.View; 32 import android.widget.TextView; 33 34 import com.android.settings.R; 35 import com.android.settingslib.wifi.AccessPoint; 36 import com.android.settingslib.wifi.AccessPointPreference; 37 38 public class LongPressAccessPointPreference extends AccessPointPreference { 39 40 private final Fragment mFragment; 41 42 // Used for dummy pref. 43 public LongPressAccessPointPreference(Context context, AttributeSet attrs) { 44 super(context, attrs); 45 mFragment = null; 46 } 47 48 public LongPressAccessPointPreference(AccessPoint accessPoint, Context context, 49 UserBadgeCache cache, boolean forSavedNetworks, Fragment fragment) { 50 super(accessPoint, context, cache, forSavedNetworks); 51 mFragment = fragment; 52 } 53 54 @Override 55 public void onBindViewHolder(final PreferenceViewHolder view) { 56 super.onBindViewHolder(view); 57 if (mFragment != null) { 58 view.itemView.setOnCreateContextMenuListener(mFragment); 59 view.itemView.setTag(this); 60 view.itemView.setLongClickable(true); 61 } 62 } 63 } 64