Refactored ConfirmationDialogFragment to use default construcutor.

Test: manual verification
Test: make RunSettingsRoboTests -j90

Fixes: 38397850

Change-Id: Ie724e7e92a6a34d4db16e4406bf821f00d98d180
This commit is contained in:
Felipe Leme
2017-05-18 14:32:13 -07:00
parent c7299663e7
commit e78e851fff
2 changed files with 41 additions and 23 deletions

View File

@@ -18,6 +18,7 @@ package com.android.settings.applications.defaultapps;
import android.Manifest;
import android.app.Activity;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
@@ -60,7 +61,7 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
/**
* Set when the fragment is implementing ACTION_REQUEST_SET_AUTOFILL_SERVICE.
*/
public DialogInterface.OnClickListener mCancelListener;
private DialogInterface.OnClickListener mCancelListener;
private final Handler mHandler = new Handler();
@Override
@@ -75,15 +76,33 @@ public class DefaultAutofillPicker extends DefaultAppPickerFragment {
};
}
mSettingsPackageMonitor.register(getActivity(), getActivity().getMainLooper(), false);
mSettingsPackageMonitor.register(activity, activity.getMainLooper(), false);
update();
}
@Override
protected ConfirmationDialogFragment newConfirmationDialogFragment(String selectedKey,
CharSequence confirmationMessage) {
return ConfirmationDialogFragment.newInstance(this, selectedKey, confirmationMessage,
mCancelListener);
final AutofillPickerConfirmationDialogFragment fragment =
new AutofillPickerConfirmationDialogFragment();
fragment.init(this, selectedKey, confirmationMessage);
return fragment;
}
/**
* Custom dialog fragment that has a cancel listener used to propagate the result back to
* caller (for the cases where the picker is launched by
* {@code android.settings.REQUEST_SET_AUTOFILL_SERVICE}.
*/
public static class AutofillPickerConfirmationDialogFragment
extends ConfirmationDialogFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
final DefaultAutofillPicker target = (DefaultAutofillPicker) getTargetFragment();
setCancelListener(target.mCancelListener);
super.onCreate(savedInstanceState);
}
}
@Override