Exemplo n.º 1
0
 @Override
 public void onCreateOptionsMenu(Menu menu) {
   PageHolder pageHolder = getPageHolder();
   menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_filter)
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
   menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh)
       .setIcon(obtainIcon(R.attr.actionRefresh))
       .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
   menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance);
   menu.add(0, OPTIONS_MENU_MAKE_HOME_PAGE, 0, R.string.action_make_home_page);
   menu.findItem(OPTIONS_MENU_MAKE_HOME_PAGE)
       .setVisible(Preferences.getDefaultBoardName(pageHolder.chanName) != null);
 }
Exemplo n.º 2
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case OPTIONS_MENU_REFRESH:
       {
         refreshBoards(!getAdapter().isEmpty());
         return true;
       }
     case OPTIONS_MENU_MAKE_HOME_PAGE:
       {
         Preferences.setDefaultBoardName(getPageHolder().chanName, null);
         item.setVisible(false);
         return true;
       }
   }
   return false;
 }
Exemplo n.º 3
0
 @SuppressWarnings("deprecation")
 @TargetApi(Build.VERSION_CODES.N)
 public void apply(Context context, boolean configChanged) {
   if (!ConcurrentUtils.isMain()) {
     return;
   }
   Resources resources = context.getApplicationContext().getResources();
   Configuration configuration = resources.getConfiguration();
   if (systemLocales == null) {
     systemLocales = list(configuration);
   }
   if (configChanged) {
     ArrayList<Locale> locales = list(configuration);
     if (previousLocales != null) {
       if (locales.equals(previousLocales)) {
         return;
       }
       systemLocales = locales;
     }
   }
   Locale locale = VALUES_LOCALE_OBJECTS.get(Preferences.getLocale());
   boolean applySystem = false;
   if (locale == null) {
     locale = systemLocales.isEmpty() ? Locale.getDefault() : systemLocales.get(0);
     applySystem = true;
   }
   if (C.API_NOUGAT) {
     if (applySystem) {
       configuration.setLocales(new LocaleList(CommonUtils.toArray(systemLocales, Locale.class)));
       previousLocales = systemLocales;
     } else {
       ArrayList<Locale> locales = new ArrayList<>();
       if (!locale.equals(Locale.US)) {
         locales.add(locale);
       }
       locales.add(Locale.US);
       configuration.setLocales(new LocaleList(CommonUtils.toArray(locales, Locale.class)));
       previousLocales = locales;
     }
   } else {
     configuration.locale = locale;
     previousLocales = list(configuration);
   }
   resources.updateConfiguration(configuration, resources.getDisplayMetrics());
   ChanManager.getInstance().updateConfiguration(configuration, resources.getDisplayMetrics());
 }