Files
packages_apps_Settings/src/com/android/settings/search2/IntentSearchViewHolder.java
Fan Zhang c49ab99007 Add misc logging:
- Button clicks in app detail page:
  uninstall/disable/clear data/clear cache
- More logging in search:
  log inline search result click, and its metadata such as
  name/value/rank.

Fix: 32652772
Fix: 32798201
Test: make RunSettingsRoboTests
Change-Id: I90cef7c9ea9ea69ea9cf083013a38417097f8594
2017-03-13 16:30:55 -07:00

58 lines
2.1 KiB
Java

/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.search2;
import android.content.ComponentName;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Pair;
import android.view.View;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.SettingsActivity;
/**
* ViewHolder for intent based search results.
* The DatabaseResultLoader is the primary use case for this ViewHolder.
*/
public class IntentSearchViewHolder extends SearchViewHolder {
public IntentSearchViewHolder(View view) {
super(view);
}
@Override
public void onBind(final SearchFragment fragment, final SearchResult result) {
super.onBind(fragment, result);
itemView.setOnClickListener(v -> {
fragment.onSearchResultClicked();
final Intent intent = ((IntentPayload) result.payload).intent;
final ComponentName cn = intent.getComponent();
final Pair<Integer, Object> rank = Pair.create(
MetricsEvent.FIELD_SETTINGS_SERACH_RESULT_RANK, getAdapterPosition());
String resultName = intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT);
if (TextUtils.isEmpty(resultName) && cn != null) {
resultName = cn.flattenToString();
}
mMetricsFeatureProvider.action(v.getContext(),
MetricsEvent.ACTION_CLICK_SETTINGS_SEARCH_RESULT,
resultName, rank);
fragment.startActivity(intent);
});
}
}