private void reloadDnsSettings() {
   DependencyHolder holder = DependencyHolder.get(this);
   final Dns dns = holder.getDns();
   if (dns instanceof TwidereDns) {
     ((TwidereDns) dns).reloadDnsSettings();
   }
 }
 public void reloadConnectivitySettings() {
   DependencyHolder holder = DependencyHolder.get(this);
   final RestHttpClient client = holder.getRestHttpClient();
   if (client instanceof OkHttpRestClient) {
     HttpClientFactory.initDefaultHttpClient(
         this, getSharedPreferences(), ((OkHttpRestClient) client).getClient());
   }
 }
 @Override
 public void onSharedPreferenceChanged(final SharedPreferences preferences, final String key) {
   switch (key) {
     case KEY_REFRESH_INTERVAL:
       stopService(new Intent(this, RefreshService.class));
       startRefreshServiceIfNeeded(this);
       break;
     case KEY_ENABLE_PROXY:
     case KEY_CONNECTION_TIMEOUT:
     case KEY_PROXY_HOST:
     case KEY_PROXY_PORT:
     case KEY_PROXY_TYPE:
     case KEY_PROXY_USERNAME:
     case KEY_PROXY_PASSWORD:
       reloadConnectivitySettings();
       break;
     case KEY_DNS_SERVER:
     case KEY_TCP_DNS_QUERY:
       reloadDnsSettings();
       break;
     case KEY_CONSUMER_KEY:
     case KEY_CONSUMER_SECRET:
     case KEY_API_URL_FORMAT:
     case KEY_AUTH_TYPE:
     case KEY_SAME_OAUTH_SIGNING_URL:
     case KEY_THUMBOR_ENABLED:
     case KEY_THUMBOR_ADDRESS:
     case KEY_THUMBOR_SECURITY_KEY:
       final Editor editor = preferences.edit();
       editor.putLong(KEY_API_LAST_CHANGE, System.currentTimeMillis());
       editor.apply();
       break;
     case KEY_EMOJI_SUPPORT:
       DependencyHolder.get(this).getExternalThemeManager().initEmojiSupport();
       break;
   }
 }
 @Override
 public void onLowMemory() {
   final DependencyHolder holder = DependencyHolder.get(this);
   super.onLowMemory();
 }
  @Override
  public void onCreate() {
    if (BuildConfig.DEBUG) {
      StrictModeUtils.detectAllVmPolicy();
    }
    super.onCreate();
    initDebugMode();
    initBugReport();
    mHandler = new Handler();
    initializeAsyncTask();
    initAccountColor(this);

    final PackageManager pm = getPackageManager();
    final ComponentName main = new ComponentName(this, MainActivity.class);
    final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class);
    final boolean mainDisabled =
        pm.getComponentEnabledSetting(main) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    final boolean main2Disabled =
        pm.getComponentEnabledSetting(main2) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
    final boolean noEntry = mainDisabled && main2Disabled;
    if (noEntry) {
      pm.setComponentEnabledSetting(
          main, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
    } else if (!mainDisabled) {
      pm.setComponentEnabledSetting(
          main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }
    if (!Utils.isComposeNowSupported(this)) {
      final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class);
      pm.setComponentEnabledSetting(
          assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    }

    migrateUsageStatisticsPreferences();
    startRefreshServiceIfNeeded(this);

    reloadConnectivitySettings();

    DependencyHolder holder = DependencyHolder.get(this);
    registerActivityLifecycleCallbacks(holder.getActivityTracker());

    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    registerReceiver(
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1);
            final String[] packages = getPackageManager().getPackagesForUid(uid);
            DependencyHolder holder = DependencyHolder.get(context);
            final ExternalThemeManager manager = holder.getExternalThemeManager();
            if (ArrayUtils.contains(packages, manager.getEmojiPackageName())) {
              manager.reloadEmojiPreferences();
            }
          }
        },
        packageFilter);
  }