The old logging only include see_more, done, and clicked_out when hiding the panel page. We were missing many cases that user might use back button, app switch button to close the page. Update the hide page keys to change the clicked_out to others to include all the other cases which hide the page. Test: Manual verification Test: atest PanelFragmentTest SettingsPanelActivityTest Fixes: 130169553 Change-Id: Icede9a8dcb84565cba183963c9fb554507631c98
150 lines
5.3 KiB
Java
150 lines
5.3 KiB
Java
/*
|
|
* Copyright (C) 2018 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.panel;
|
|
|
|
import android.app.settings.SettingsEnums;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import com.android.internal.annotations.VisibleForTesting;
|
|
import com.android.settings.R;
|
|
import com.android.settings.overlay.FeatureFactory;
|
|
import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
|
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
|
import com.google.android.setupdesign.DividerItemDecoration;
|
|
|
|
public class PanelFragment extends Fragment {
|
|
|
|
private static final String TAG = "PanelFragment";
|
|
|
|
private TextView mTitleView;
|
|
private Button mSeeMoreButton;
|
|
private Button mDoneButton;
|
|
private RecyclerView mPanelSlices;
|
|
|
|
private PanelContent mPanel;
|
|
private MetricsFeatureProvider mMetricsProvider;
|
|
private String mPanelClosedKey;
|
|
|
|
@VisibleForTesting
|
|
PanelSlicesAdapter mAdapter;
|
|
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
|
@Nullable Bundle savedInstanceState) {
|
|
final FragmentActivity activity = getActivity();
|
|
final View view = inflater.inflate(R.layout.panel_layout, container, false);
|
|
|
|
mPanelSlices = view.findViewById(R.id.panel_parent_layout);
|
|
mSeeMoreButton = view.findViewById(R.id.see_more);
|
|
mDoneButton = view.findViewById(R.id.done);
|
|
mTitleView = view.findViewById(R.id.panel_title);
|
|
|
|
final Bundle arguments = getArguments();
|
|
final String panelType =
|
|
arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
|
|
final String callingPackageName =
|
|
arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
|
|
final String mediaPackageName =
|
|
arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
|
|
|
|
// TODO (b/124399577) transform interface to take a context and bundle.
|
|
mPanel = FeatureFactory.getFactory(activity)
|
|
.getPanelFeatureProvider()
|
|
.getPanel(activity, panelType, mediaPackageName);
|
|
|
|
mMetricsProvider = FeatureFactory.getFactory(activity).getMetricsFeatureProvider();
|
|
// Log panel opened.
|
|
mMetricsProvider.action(
|
|
0 /* attribution */,
|
|
SettingsEnums.PAGE_VISIBLE /* opened panel - Action */,
|
|
mPanel.getMetricsCategory(),
|
|
callingPackageName,
|
|
0 /* value */);
|
|
|
|
mAdapter = new PanelSlicesAdapter(this, mPanel);
|
|
|
|
mPanelSlices.setHasFixedSize(true);
|
|
mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
|
|
mPanelSlices.setAdapter(mAdapter);
|
|
|
|
DividerItemDecoration itemDecoration = new DividerItemDecoration(getActivity());
|
|
itemDecoration.setDividerCondition(DividerItemDecoration.DIVIDER_CONDITION_BOTH);
|
|
mPanelSlices.addItemDecoration(itemDecoration);
|
|
|
|
mTitleView.setText(mPanel.getTitle());
|
|
|
|
mSeeMoreButton.setOnClickListener(getSeeMoreListener());
|
|
mDoneButton.setOnClickListener(getCloseListener());
|
|
|
|
//If getSeeMoreIntent() is null, hide the mSeeMoreButton.
|
|
if (mPanel.getSeeMoreIntent() == null) {
|
|
mSeeMoreButton.setVisibility(View.GONE);
|
|
}
|
|
|
|
return view;
|
|
}
|
|
|
|
@Override
|
|
public void onDestroyView() {
|
|
super.onDestroyView();
|
|
|
|
if (TextUtils.isEmpty(mPanelClosedKey)) {
|
|
mPanelClosedKey = PanelClosedKeys.KEY_OTHERS;
|
|
}
|
|
|
|
mMetricsProvider.action(
|
|
0 /* attribution */,
|
|
SettingsEnums.PAGE_HIDE,
|
|
mPanel.getMetricsCategory(),
|
|
mPanelClosedKey,
|
|
0 /* value */);
|
|
}
|
|
|
|
@VisibleForTesting
|
|
View.OnClickListener getSeeMoreListener() {
|
|
return (v) -> {
|
|
mPanelClosedKey = PanelClosedKeys.KEY_SEE_MORE;
|
|
final FragmentActivity activity = getActivity();
|
|
activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
|
|
activity.finish();
|
|
};
|
|
}
|
|
|
|
@VisibleForTesting
|
|
View.OnClickListener getCloseListener() {
|
|
return (v) -> {
|
|
mPanelClosedKey = PanelClosedKeys.KEY_DONE;
|
|
getActivity().finish();
|
|
};
|
|
}
|
|
}
|