harbor run -t openthoughts/tasktrove-exp-rpt-crosscodeeval-java-crosscodeeval-java-0815harbor download openthoughts/tasktrove-exp-rpt-crosscodeeval-java-crosscodeeval-java-0815solution file
/*
* Copyright (C) 2015 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.traceur;
import android.annotation.Nullable;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.icu.text.MessageFormat;
import android.net.Uri;
import android.os.Bundle;
import androidx.preference.MultiSelectListPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragment;
import androidx.preference.PreferenceManager;
import androidx.preference.SwitchPreference;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.Toast;
import com.android.settingslib.HelpUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class MainFragment extends PreferenceFragment {
static final String TAG = TraceUtils.TAG;
public static final String ACTION_REFRESH_TAGS = "com.android.traceur.REFRESH_TAGS";
private static final String BETTERBUG_PACKAGE_NAME =
"com.google.android.apps.internal.betterbug";
private static final String ROOT_MIME_TYPE = "vnd.android.document/root";
private static final String STORAGE_URI = "content://com.android.traceur.documents/root";
private SwitchPreference mTracingOn;
private AlertDialog mAlertDialog;
private SharedPreferences mPrefs;
private MultiSelectListPreference mTags;
private boolean mRefreshing;
private BroadcastReceiver mRefreshReceiver;
OnSharedPreferenceChangeListener mSharedPreferenceChangeListener =
new OnSharedPreferenceChangeListener () {
public void onSharedPreferenceChanged(
SharedPreferences sharedPreferences, String key) {
refreshUi();
}
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Receiver.updateDeveloperOptionsWatcher(getContext());
mPrefs = PreferenceManager.getDefaultSharedPreferences(
getActivity().getApplicationContext());
mTracingOn = (SwitchPreference) findPreference(getActivity().getString(R.string.pref_key_tracing_on));
mTracingOn.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Receiver.updateTracing(getContext());
return true;
}
});
mTags = (MultiSelectListPreference) findPreference(getContext().getString(R.string.pref_key_tags));
mTags.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (mRefreshing) {
return true;
}
Set<String> set = (Set<String>) newValue;
TreeMap<String
Complete the code above, taking into account the cross-file context provided. Your solution must work correctly with the related files in the project.
Place your complete solution in /app/solution.py