예제 #1
0
 /** @return Themed context for using in action bar */
 public Context getSupportActionBarContext() {
   if (mActionBarContext == null) {
     int theme = ThemeManager.getThemeType(this);
     if (theme != ThemeManager.LIGHT) {
       theme = ThemeManager.DARK;
     }
     theme = ThemeManager.getThemeResource(theme, false);
     if (mLastThemeResourceId == theme) {
       mActionBarContext = this;
     } else {
       mActionBarContext = new ContextThemeWrapperPlus(this, theme);
     }
   }
   return mActionBarContext;
 }
예제 #2
0
 @Override
 public Theme getTheme() {
   if (mLastThemeResourceId == 0) {
     setTheme(ThemeManager.getDefaultTheme());
   }
   return super.getTheme();
 }
예제 #3
0
 @Override
 public void startActivity(Intent intent, Bundle options) {
   if (config().isAlwaysUseParentTheme()) {
     ThemeManager.startActivity(this, intent, options);
   } else {
     superStartActivity(intent, -1, options);
   }
 }
예제 #4
0
 @Override
 public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
   if (HoloEverywhere.ALWAYS_USE_PARENT_THEME) {
     ThemeManager.startActivity(this, intent, requestCode, options);
   } else {
     superStartActivity(intent, requestCode, options);
   }
 }
예제 #5
0
 public void makeDefaultMenu(Context context) {
   setInverseTextColorWhenSelected(ThemeManager.getThemeType(mAddon.get()) != ThemeManager.LIGHT);
   ListFragment menuFragment = (ListFragment) mFragmentManager.findFragmentById(R.id.leftView);
   if (menuFragment == null) {
     mAddon.get().getSupportFragmentManager().findFragmentById(R.id.rightView);
   }
   if (menuFragment == null) {
     throw new IllegalStateException("Couldn't find ListFragment for menu");
   }
   bind(menuFragment, context);
 }
예제 #6
0
 public synchronized void setTheme(int resid, boolean modifyGlobal) {
   if (resid > ThemeManager._START_RESOURCES_ID) {
     if (mLastThemeResourceId != resid) {
       mActionBarContext = null;
       mMenuInflater = null;
       super.setTheme(mLastThemeResourceId = resid);
     }
   } else {
     if ((resid & ThemeManager.COLOR_SCHEME_MASK) == 0) {
       int theme = ThemeManager.getTheme(getIntent(), false);
       if (theme == 0) {
         final android.app.Activity activity = getParent();
         if (activity != null) {
           theme = ThemeManager.getTheme(activity.getIntent(), false);
         }
       }
       theme &= ThemeManager.COLOR_SCHEME_MASK;
       if (theme != 0) {
         resid |= theme;
       }
     }
     setTheme(ThemeManager.getThemeResource(resid, modifyGlobal));
   }
 }
예제 #7
0
 /**
  * Do not override this method. Use {@link #onPreInit(Holo, Bundle)} and {@link #onPostInit(Holo,
  * Bundle)}
  */
 protected void onInit(Holo config, Bundle savedInstanceState) {
   if (mInited) {
     throw new IllegalStateException("This instance was already inited");
   }
   mInited = true;
   if (config == null) {
     config = createConfig(savedInstanceState);
   }
   if (config == null) {
     config = Holo.defaultConfig();
   }
   onPreInit(config, savedInstanceState);
   if (!config.ignoreApplicationInstanceCheck && !(getApplication() instanceof Application)) {
     String text = "Application instance isn't HoloEverywhere.\n";
     if (getApplication().getClass() == android.app.Application.class) {
       text +=
           "Put attr 'android:name=\"org.holoeverywhere.app.Application\"'"
               + " in <application> tag of AndroidManifest.xml";
     } else {
       text +=
           "Please sure that you extend "
               + getApplication().getClass()
               + " from a org.holoeverywhere.app.Application";
     }
     throw new IllegalStateException(text);
   }
   getLayoutInflater().setFragmentActivity(this);
   if (this instanceof Activity) {
     Activity activity = (Activity) this;
     if (config.requireRoboguice) {
       activity.addon(Activity.ADDON_ROBOGUICE);
     }
     if (config.requireSlider) {
       activity.addon(Activity.ADDON_SLIDER);
     }
     if (config.requireSherlock) {
       activity.addonSherlock();
     }
     final SparseIntArray windowFeatures = config.windowFeatures;
     if (windowFeatures != null) {
       for (int i = 0; i < windowFeatures.size(); i++) {
         if (windowFeatures.valueAt(i) > 0) {
           requestWindowFeature((long) windowFeatures.keyAt(i));
         }
       }
     }
     ThemeManager.applyTheme(activity, mLastThemeResourceId == 0);
     if (!config.ignoreThemeCheck && ThemeManager.getThemeType(this) == ThemeManager.INVALID) {
       throw new HoloThemeException(activity);
     }
     TypedArray a =
         obtainStyledAttributes(
             new int[] {android.R.attr.windowActionBarOverlay, R.attr.windowActionBarOverlay});
     if (a.getBoolean(0, false) || a.getBoolean(1, false)) {
       requestWindowFeature((long) Window.FEATURE_ACTION_BAR_OVERLAY);
     }
     a.recycle();
   }
   onPostInit(config, savedInstanceState);
   lockAttaching();
 }