コード例 #1
0
  @SuppressWarnings("ConstantConditions")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Default config
    if (!ATE.config(this, "light_theme").isConfigured(2)) {
      ATE.config(this, "light_theme")
          .activityTheme(R.style.AppTheme)
          .primaryColorRes(R.color.colorPrimaryLightDefault)
          .accentColorRes(R.color.colorAccentLightDefault)
          .coloredNavigationBar(false)
          .navigationViewSelectedIconRes(R.color.colorAccentLightDefault)
          .navigationViewSelectedTextRes(R.color.colorAccentLightDefault)
          .commit();
    }
    if (!ATE.config(this, "dark_theme").isConfigured(2)) {
      ATE.config(this, "dark_theme")
          .activityTheme(R.style.AppThemeDark)
          .primaryColorRes(R.color.colorPrimaryDarkDefault)
          .accentColorRes(R.color.colorAccentDarkDefault)
          .coloredNavigationBar(true)
          .navigationViewSelectedIconRes(R.color.colorAccentDarkDefault)
          .navigationViewSelectedTextRes(R.color.colorAccentDarkDefault)
          .commit();
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.appbar_toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(R.string.app_name);
    toolbar.setNavigationIcon(R.drawable.ic_menu);

    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawer.setDrawerListener(
        new ActionBarDrawerToggle(
            this, mDrawer, toolbar, R.string.drawer_open, R.string.drawer_close));

    final NavigationView navView = (NavigationView) findViewById(R.id.navigation_view);
    navView.setNavigationItemSelectedListener(this);
  }
コード例 #2
0
 @SuppressWarnings("ResourceType")
 @Override
 public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
   if (which == DialogAction.POSITIVE) {
     dismiss();
     if (getActivity() == null) return;
     ATE.config(getActivity(), getArguments().getString(KEY_ATEKEY))
         .textSizeSpForMode(mSeeker.getProgress() + 1, getArguments().getString(KEY_MODE))
         .apply(getActivity());
     if (getArguments().getBoolean(KEY_RECREATE)) getActivity().recreate();
   } else if (which == DialogAction.NEUTRAL) {
     @Config.TextSizeMode final String mode = getArguments().getString(KEY_MODE);
     assert mode != null;
     int size;
     switch (mode) {
       default:
       case Config.TEXTSIZE_CAPTION:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_caption);
         break;
       case Config.TEXTSIZE_BODY:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_body);
         break;
       case Config.TEXTSIZE_SUBHEADING:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_subheading);
         break;
       case Config.TEXTSIZE_TITLE:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_title);
         break;
       case Config.TEXTSIZE_HEADLINE:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_headline);
         break;
       case Config.TEXTSIZE_DISPLAY1:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_display1);
         break;
       case Config.TEXTSIZE_DISPLAY2:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_display2);
         break;
       case Config.TEXTSIZE_DISPLAY3:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_display3);
         break;
       case Config.TEXTSIZE_DISPLAY4:
         size = getResources().getDimensionPixelSize(R.dimen.ate_default_textsize_display4);
         break;
     }
     mPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
     final int dpValue = pxToSp(this, size);
     mValue.setText(String.format("%dsp", dpValue));
     mSeeker.setProgress(dpValue - 1);
   } else {
     dismiss();
   }
 }