@Test public void testLoginNoAccounts() { AppUtils.showLogin(context, null); assertThat(shadowOf(context).getNextStartedActivity()) .hasComponent(context, LoginActivity.class); }
@SuppressLint("MissingPermission") public static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder) { Account[] accounts = AccountManager.get(context).getAccountsByType(BuildConfig.APPLICATION_ID); if (accounts.length == 0) { context.startActivity(new Intent(context, LoginActivity.class)); } else if (!TextUtils.isEmpty(Preferences.getUsername(context))) { context.startActivity(new Intent(context, LoginActivity.class)); } else { showAccountChooser(context, alertDialogBuilder, accounts); } }
AppUtils { @SuppressLint("MissingPermission") public static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder) { Account[] accounts = AccountManager.get(context).getAccountsByType(BuildConfig.APPLICATION_ID); if (accounts.length == 0) { context.startActivity(new Intent(context, LoginActivity.class)); } else if (!TextUtils.isEmpty(Preferences.getUsername(context))) { context.startActivity(new Intent(context, LoginActivity.class)); } else { showAccountChooser(context, alertDialogBuilder, accounts); } } }
AppUtils { @SuppressLint("MissingPermission") public static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder) { Account[] accounts = AccountManager.get(context).getAccountsByType(BuildConfig.APPLICATION_ID); if (accounts.length == 0) { context.startActivity(new Intent(context, LoginActivity.class)); } else if (!TextUtils.isEmpty(Preferences.getUsername(context))) { context.startActivity(new Intent(context, LoginActivity.class)); } else { showAccountChooser(context, alertDialogBuilder, accounts); } }  }
AppUtils { @SuppressLint("MissingPermission") public static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder) { Account[] accounts = AccountManager.get(context).getAccountsByType(BuildConfig.APPLICATION_ID); if (accounts.length == 0) { context.startActivity(new Intent(context, LoginActivity.class)); } else if (!TextUtils.isEmpty(Preferences.getUsername(context))) { context.startActivity(new Intent(context, LoginActivity.class)); } else { showAccountChooser(context, alertDialogBuilder, accounts); } }  static void openWebUrlExternal(Context context, @Nullable WebItem item,
                                          String url, @Nullable CustomTabsSession session); static void setTextWithLinks(TextView textView, CharSequence html); static CharSequence fromHtml(String htmlText); static CharSequence fromHtml(String htmlText, boolean compact); static Intent makeSendIntentChooser(Context context, Uri data); static void openExternal(@NonNull final Context context,
                             @NonNull PopupMenu popupMenu,
                             @NonNull View anchor,
                             @NonNull final WebItem item,
                             final CustomTabsSession session); static void share(@NonNull final Context context,
                             @NonNull PopupMenu popupMenu,
                             @NonNull View anchor,
                             @NonNull final WebItem item); static int getThemedResId(Context context, @AttrRes int attr); static float getDimension(Context context, @StyleRes int styleResId, @AttrRes int attr); static boolean isHackerNewsUrl(WebItem item); static int getDimensionInDp(Context context, @DimenRes int dimenResId); static void restart(Activity activity, boolean transition); static String getAbbreviatedTimeSpan(long timeMillis); static boolean isOnWiFi(Context context); static boolean hasConnection(Context context); @SuppressLint("MissingPermission") static Pair<String, String> getCredentials(Context context); @SuppressLint("MissingPermission") static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder); @SuppressLint("MissingPermission") static void registerAccountsUpdatedListener(final Context context); @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.LOLLIPOP) static void openPlayStore(Context context); @SuppressLint("MissingPermission") static void showAccountChooser(final Context context, AlertDialogBuilder alertDialogBuilder,
                                           Account[] accounts); static void toggleFab(FloatingActionButton fab, boolean visible); static void toggleFabAction(FloatingActionButton fab, WebItem item, boolean commentMode); static String toHtmlColor(Context context, @AttrRes int colorAttr); static void toggleWebViewZoom(WebSettings webSettings, boolean enabled); static void setStatusBarDim(Window window, boolean dim); static void setStatusBarColor(Window window, int color); static void navigate(int direction, AppBarLayout appBarLayout, Navigable navigable); static int getDisplayHeight(Context context); static LayoutInflater createLayoutInflater(Context context); static void share(Context context, String subject, String text); static Uri createItemUri(@NonNull String itemId); static Uri createUserUri(@NonNull String userId); static String getDataUriId(@NonNull Intent intent, String altParamId); static String wrapHtml(Context context, String html); @SuppressLint("InlinedApi") static Intent multiWindowIntent(Activity activity, Intent intent); static void setTextAppearance(TextView textView, @StyleRes int textAppearance); static boolean urlEquals(String thisUrl, String thatUrl); }
AppUtils { @SuppressLint("MissingPermission") public static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder) { Account[] accounts = AccountManager.get(context).getAccountsByType(BuildConfig.APPLICATION_ID); if (accounts.length == 0) { context.startActivity(new Intent(context, LoginActivity.class)); } else if (!TextUtils.isEmpty(Preferences.getUsername(context))) { context.startActivity(new Intent(context, LoginActivity.class)); } else { showAccountChooser(context, alertDialogBuilder, accounts); } }  static void openWebUrlExternal(Context context, @Nullable WebItem item,
                                          String url, @Nullable CustomTabsSession session); static void setTextWithLinks(TextView textView, CharSequence html); static CharSequence fromHtml(String htmlText); static CharSequence fromHtml(String htmlText, boolean compact); static Intent makeSendIntentChooser(Context context, Uri data); static void openExternal(@NonNull final Context context,
                             @NonNull PopupMenu popupMenu,
                             @NonNull View anchor,
                             @NonNull final WebItem item,
                             final CustomTabsSession session); static void share(@NonNull final Context context,
                             @NonNull PopupMenu popupMenu,
                             @NonNull View anchor,
                             @NonNull final WebItem item); static int getThemedResId(Context context, @AttrRes int attr); static float getDimension(Context context, @StyleRes int styleResId, @AttrRes int attr); static boolean isHackerNewsUrl(WebItem item); static int getDimensionInDp(Context context, @DimenRes int dimenResId); static void restart(Activity activity, boolean transition); static String getAbbreviatedTimeSpan(long timeMillis); static boolean isOnWiFi(Context context); static boolean hasConnection(Context context); @SuppressLint("MissingPermission") static Pair<String, String> getCredentials(Context context); @SuppressLint("MissingPermission") static void showLogin(Context context, AlertDialogBuilder alertDialogBuilder); @SuppressLint("MissingPermission") static void registerAccountsUpdatedListener(final Context context); @SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.LOLLIPOP) static void openPlayStore(Context context); @SuppressLint("MissingPermission") static void showAccountChooser(final Context context, AlertDialogBuilder alertDialogBuilder,
                                           Account[] accounts); static void toggleFab(FloatingActionButton fab, boolean visible); static void toggleFabAction(FloatingActionButton fab, WebItem item, boolean commentMode); static String toHtmlColor(Context context, @AttrRes int colorAttr); static void toggleWebViewZoom(WebSettings webSettings, boolean enabled); static void setStatusBarDim(Window window, boolean dim); static void setStatusBarColor(Window window, int color); static void navigate(int direction, AppBarLayout appBarLayout, Navigable navigable); static int getDisplayHeight(Context context); static LayoutInflater createLayoutInflater(Context context); static void share(Context context, String subject, String text); static Uri createItemUri(@NonNull String itemId); static Uri createUserUri(@NonNull String userId); static String getDataUriId(@NonNull Intent intent, String altParamId); static String wrapHtml(Context context, String html); @SuppressLint("InlinedApi") static Intent multiWindowIntent(Activity activity, Intent intent); static void setTextAppearance(TextView textView, @StyleRes int textAppearance); static boolean urlEquals(String thisUrl, String thatUrl); static final int HOT_THRESHOLD_HIGH; static final int HOT_THRESHOLD_NORMAL; static final int HOT_FACTOR; }