*/
package com.android.settings.dashboard;
-import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@Override
public void onClick(View v) {
//TODO: get rid of setTag/getTag
- mDashboardFeatureProvider.openTileIntent((Activity) mContext, (Tile) v.getTag());
+ mDashboardFeatureProvider.openTileIntent((FragmentActivity) mContext,
+ (Tile) v.getTag());
}
};
*/
package com.android.settings.dashboard;
-import android.app.Activity;
import android.content.Context;
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.Preference;
+
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import java.util.List;
-import androidx.preference.Preference;
-
/**
* FeatureProvider for dashboard (aka settings homepage).
*/
* of auto-ordering, progressive disclosure, auto-refreshing summary text etc.
*/
@Deprecated
- List<Preference> getPreferencesForCategory(Activity activity, Context context,
+ List<Preference> getPreferencesForCategory(FragmentActivity activity, Context context,
int sourceMetricsCategory, String key);
/**
/**
* Whether or not we should tint icons in setting pages.
+ *
* @deprecated in favor of color icons in homepage
*/
@Deprecated
* @param baseOrder The order offset value. When binding, pref's order is determined by
* both this value and tile's own priority.
*/
- void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
+ void bindPreferenceToTile(FragmentActivity activity, int sourceMetricsCategory, Preference pref,
Tile tile, String key, int baseOrder);
/**
/**
* Opens a tile to its destination intent.
*/
- void openTileIntent(Activity activity, Tile tile);
+ void openTileIntent(FragmentActivity activity, Tile tile);
}
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;
import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY_URI;
-import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.IContentProvider;
import android.util.Pair;
import androidx.annotation.VisibleForTesting;
+import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
}
@Override
- public List<Preference> getPreferencesForCategory(Activity activity, Context context,
+ public List<Preference> getPreferencesForCategory(FragmentActivity activity, Context context,
int sourceMetricsCategory, String key) {
final DashboardCategory category = getTilesForCategory(key);
if (category == null) {
}
@Override
- public void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
- Tile tile, String key, int baseOrder) {
+ public void bindPreferenceToTile(FragmentActivity activity, int sourceMetricsCategory,
+ Preference pref, Tile tile, String key, int baseOrder) {
if (pref == null) {
return;
}
}
@Override
- public void openTileIntent(Activity activity, Tile tile) {
+ public void openTileIntent(FragmentActivity activity, Tile tile) {
if (tile == null) {
Intent intent = new Intent(Settings.ACTION_SETTINGS).addFlags(
Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
}
- private void launchIntentOrSelectProfile(Activity activity, Tile tile, Intent intent,
+ private void launchIntentOrSelectProfile(FragmentActivity activity, Tile tile, Intent intent,
int sourceMetricCategory) {
if (!isIntentResolvable(intent)) {
Log.w(TAG, "Cannot resolve intent, skipping. " + intent);
mMetricsFeatureProvider.logDashboardStartIntent(mContext, intent, sourceMetricCategory);
activity.startActivityForResultAsUser(intent, 0, tile.userHandle.get(0));
} else {
- ProfileSelectDialog.show(activity.getFragmentManager(), tile);
+ ProfileSelectDialog.show(activity.getSupportFragmentManager(), tile);
}
}
package com.android.settings.dashboard.profileselector;
-import android.app.AlertDialog;
import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.FragmentManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.UserManager;
import android.util.Log;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.FragmentManager;
+
import com.android.settingslib.drawer.Tile;
import java.util.List;
com.android.settings.password.ChooseLockPattern$SaveAndFinishWorker
com.android.settings.RestrictedListPreference$RestrictedListPreferenceDialogFragment
com.android.settings.password.ConfirmDeviceCredentialBaseFragment$LastTryDialog
-com.android.settings.password.CredentialCheckResultTracker
\ No newline at end of file
+com.android.settings.password.CredentialCheckResultTracker
+com.android.settings.dashboard.profileselector.ProfileSelectDialog
\ No newline at end of file
import static org.mockito.Mockito.when;
import android.accounts.Account;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.UserHandle;
+import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import com.android.internal.logging.nano.MetricsProto;
tile.userHandle = null;
mFragment.displayTile(tile);
- final Activity activity = Robolectric.setupActivity(Activity.class);
+ final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
final Preference preference = new Preference(mContext);
dashboardFeatureProvider.bindPreferenceToTile(activity,
MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, "key",
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.UserHandle;
import android.os.UserManager;
+import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import com.android.internal.logging.nano.MetricsProto;
public class DashboardFeatureProviderImplTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Activity mActivity;
+ private FragmentActivity mActivity;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private UserManager mUserManager;
@Mock
preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
- verify(mActivity).getFragmentManager();
+ verify(mActivity).getSupportFragmentManager();
}
@Test
@Test
public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
- Activity activity = Robolectric.buildActivity(Activity.class).get();
+ FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.key = "key";
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
ReflectionHelpers.setField(
mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager());
- Activity activity = Robolectric.buildActivity(Activity.class).get();
+ FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
final ShadowApplication application = ShadowApplication.getInstance();
final Preference preference = new Preference(application.getApplicationContext());
final Tile tile = new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
verify(mActivity, never())
.startActivityForResult(any(Intent.class), eq(0));
- verify(mActivity).getFragmentManager();
+ verify(mActivity).getSupportFragmentManager();
}
@Test
verify(mActivity, never())
.startActivityForResult(any(Intent.class), eq(0));
- verify(mActivity).getFragmentManager();
+ verify(mActivity).getSupportFragmentManager();
}
@Test
verify(mActivity)
.startActivityForResult(any(Intent.class), eq(0));
- verify(mActivity, never()).getFragmentManager();
+ verify(mActivity, never()).getSupportFragmentManager();
}
}