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 */ 16package com.android.settings.wifi; 17 18import android.app.Fragment; 19import android.content.Context; 20import android.support.v7.preference.PreferenceViewHolder; 21import android.util.AttributeSet; 22import com.android.settingslib.wifi.AccessPoint; 23import com.android.settingslib.wifi.AccessPointPreference; 24 25public class LongPressAccessPointPreference extends AccessPointPreference { 26 27 private final Fragment mFragment; 28 29 // Used for dummy pref. 30 public LongPressAccessPointPreference(Context context, AttributeSet attrs) { 31 super(context, attrs); 32 mFragment = null; 33 } 34 35 public LongPressAccessPointPreference(AccessPoint accessPoint, Context context, 36 UserBadgeCache cache, boolean forSavedNetworks, Fragment fragment) { 37 super(accessPoint, context, cache, forSavedNetworks); 38 mFragment = fragment; 39 } 40 41 public LongPressAccessPointPreference(AccessPoint accessPoint, Context context, 42 UserBadgeCache cache, boolean forSavedNetworks, int iconResId, Fragment fragment) { 43 super(accessPoint, context, cache, iconResId, forSavedNetworks); 44 mFragment = fragment; 45 } 46 47 @Override 48 public void onBindViewHolder(final PreferenceViewHolder view) { 49 super.onBindViewHolder(view); 50 if (mFragment != null) { 51 view.itemView.setOnCreateContextMenuListener(mFragment); 52 view.itemView.setTag(this); 53 view.itemView.setLongClickable(true); 54 } 55 } 56} 57