Apply theme from intent. Only system use, don't call it!
540354
public static void applyTheme(Activity activity, boolean force) {
        if (force || ThemeManager.hasSpecifiedTheme(activity)) {
            activity.setTheme(ThemeManager.getTheme(activity));
        }
    }
755685
private void obtainFullscreen(@StyleRes final int themeResourceId) {
        TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
                new int[]{R.attr.materialDialogFullscreen});
        setFullscreen(typedArray.getBoolean(0, false));
    }
498788
@StyleRes
    private int resolveTheme() {
        // First check if getTheme() returns some usable theme.
        int theme = getTheme();
        if (theme != 0) {
            return theme;
        }

        // Get the light/dark attribute from the Activity's Theme.
        boolean useLightTheme = isActivityThemeLight();

        // Now check if developer overrides the Activity's Theme with an argument.
        Bundle args = getArguments();
        if (args != null) {
            if (args.getBoolean(BaseDialogBuilder.ARG_USE_DARK_THEME)) {
                // Developer is explicitly using the dark theme.
                useLightTheme = false;
            } else if (args.getBoolean(BaseDialogBuilder.ARG_USE_LIGHT_THEME)) {
                // Developer is explicitly using the light theme.
                useLightTheme = true;
            }
        }

        return useLightTheme ? R.style.SDL_Dialog : R.style.SDL_Dark_Dialog;
    }
1074392
public void setThemeIfCurrentEmpty(String themeName) {
        if (themeName == null || themeName.isEmpty()) return;
        String theme = getTheme();
        if (theme == null || theme.isEmpty()) {
            setTheme(themeName);
        }
    }
316492
public static void setDefaultTheme(int theme) {
        ThemeManager._DEFAULT_THEME = theme;
        if (theme < _START_RESOURCES_ID) {
            ThemeManager._DEFAULT_THEME &= ThemeManager._THEME_MASK;
        }
    }
429363
public static boolean maybeStartActivity(Context context, Intent intent) {
        if (hasHandler(context, intent)) {
            context.startActivity(intent);
            return true;
        } else {
            Toast.makeText(context, "There are no applications available to handle this action",
                Toast.LENGTH_LONG).show();
            return false;
        }
    }
10840
function getThemeFromPath(dir, program, cb) {
        var configPath = path.resolve(dir, "theme.json");
        program.log(2, constants.LOG_SEV_INFO, "Attempting to read " + configPath);
        fs.readFile(configPath, { encoding: 'utf-8' }, function (err, data) {
            if (err) {
                program.log(1, constants.LOG_SEV_ERROR, "Error reading " + configPath);
                return cb(err);
            }
            var config;
            try {
                config = eval('(' + data + ')');
            } catch (e) {
                program.log(1, constants.LOG_SEV_ERROR, "Error parsing " + configPath + ".");
                program.log(2, constants.LOG_SEV_ERROR, "\n\n" + data);
                return cb(e);
            }
            var themeConf = config.about;
            if (!themeConf) {
                var errorStr = "No about section found in " + configPath;
                program.log(1, constants.LOG_SEV_ERROR, errorStr);
                return cb(new Error(errorStr));
            }
            themeConf.baseDir = dir;
            themeConf.program = program;
            cb(null, new Theme(themeConf));
        });
    }
1333817
def removeApplicationManifest(self, pchApplicationManifestFullPath):
        """"""

        fn = self.function_table.removeApplicationManifest
        result = fn(pchApplicationManifestFullPath)
        return result
623626
public function theme_should_be_activated( $theme )
	{
		$theme = $this->replace_variables( $theme );
		$current_theme = $this->get_current_theme();

		if ( $theme !== $current_theme ) {
			throw new \Exception( sprintf(
				"The current theme is %s, but it should be %s",
				$current_theme,
				$theme
			) );
		}
	}
424777
def format_theme(selection):
    """"""
    global themefile

    text = open(THEMEDIR + '/' + selection).read()
    if '!dotcolors' in text[:10]:
        themefile = text
        return

    lines = ['!dotcolors auto formatted\n']
    for line in text.split('\n'):
        lline = line.lower()
        background = 'background' in lline
        foreground = 'foreground' in lline
        color = 'color' in lline

        if background:
            if 'rgb' in line:
                # rbga: 0000/0000/0000/dddd
                rgb = line.split(':')[2].replace(' ', '')
                rgb = rgb_to_hex(rgb)
                lines.append('*background:\t%s' % rgb)
            else:
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))

        if foreground:
            if 'rgb' in line:
                # rbga: 0000/0000/0000/dddd
                rgb = line.split(':')[2].replace(' ', '')
                rgb = rgb_to_hex(rgb)
                lines.append('*foreground:\t%s' % rgb)
            else:
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))

        if color:
            if lline[0] != '!':
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))
    
    themefile = '\n'.join(lines) + '\n'
    fd, tmpfile = tempfile.mkstemp()
    if exists( THEMEDIR + '/' + selection ):
        old = open( THEMEDIR + '/' + selection )
        new = os.fdopen(fd, 'w')
        os.write(fd, themefile)
        old.close()
        new.close()
        move( tmpfile, THEMEDIR + '/' + selection )
845238
@SuppressLint("InlinedApi")
    public static void restartWithTheme(Activity activity, int theme, boolean force) {
        if (theme < _START_RESOURCES_ID && theme > 0) {
            if (ThemeManager._THEME_MODIFIER > 0) {
                theme |= ThemeManager._THEME_MODIFIER;
            }
            theme &= ThemeManager._THEME_MASK;
        }
        if (force || ThemeManager.getTheme(activity) != theme) {
            Intent intent = new Intent(activity.getIntent());
            intent.setClass(activity, activity.getClass());
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            if (theme > 0) {
                intent.putExtra(ThemeManager._THEME_TAG, theme);
            }
            intent.putExtra(KEY_INSTANCE_STATE, activity.saveInstanceState());
            intent.putExtra(KEY_CREATED_BY_THEME_MANAGER, true);
            if (activity.isRestricted()) {
                Application app = Application.getLastInstance();
                if (app != null && !app.isRestricted()) {
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    app.superStartActivity(intent, -1, null);
                }
            } else {
                if (!activity.isFinishing()) {
                    activity.finish();
                    activity.overridePendingTransition(0, 0);
                }
                if (activity != null) {
                    activity.superStartActivity(intent, -1, null);
                }
            }
        }
    }
943049
@SuppressLint("NewApi")
    public static void startActivity(Context context, Intent intent,
                                     int requestCode, Bundle options) {
        final Activity activity = context instanceof Activity ? (Activity) context
                : null;
        if (activity != null && HoloEverywhere.ALWAYS_USE_PARENT_THEME) {
            ThemeManager.cloneTheme(activity.getIntent(), intent, true);
        }
        final int parentColorScheme = ThemeManager.getThemeType(activity);
        if (parentColorScheme != INVALID) {
            intent.putExtra(_PARENT_SCHEME_TAG, parentColorScheme);
        }
        if (context instanceof SuperStartActivity) {
            ((SuperStartActivity) context).superStartActivity(intent,
                    requestCode, options);
        } else if (VERSION.SDK_INT >= 16) {
            context.startActivity(intent, options);
        } else {
            context.startActivity(intent);
        }
    }
169474
@Override
    public void applyDesign(Design design, int themeColor) {
        Context ctx = mInputField.getContext();

        int smallPadId = design.isMaterial() ? R.dimen.default_margin : R.dimen.default_margin_small;
        int largePadId = design.isMaterial() ? R.dimen.material_edittext_spacing : R.dimen.default_margin_small;

        int padLR = ctx.getResources().getDimensionPixelSize(largePadId);
        int padTB = ctx.getResources().getDimensionPixelSize(smallPadId);

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(padLR, padTB, padLR, padTB);
        mInputField.setLayoutParams(params);

        if(design.isLight())
            mInputField.setTextColor(mInputField.getResources().getColor(R.color.background_material_dark));
        else
            mInputField.setTextColor(mInputField.getResources().getColor(R.color.background_material_light));

        Drawable drawable;
        if(design.isMaterial()) {
            drawable = mInputField.getResources().getDrawable(R.drawable.edittext_mtrl_alpha);
        }else{
            drawable = mInputField.getBackground();
        }

        drawable.setColorFilter(themeColor, PorterDuff.Mode.SRC_ATOP);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
            mInputField.setBackground(drawable);
        else
            mInputField.setBackgroundDrawable(drawable);

    }
526900
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
    public void disableFullScreen() {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
            setImeOptions(getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
        }
    }
512139
private void useOurUIs() {
        for (String uiName : UI_LIST) {
            uiName = uiName + "UI";
            uiDefaults.put(uiName, UI_PACKAGE_PREFIX + uiName);
        }
    }
1155258
private static void applyStyle(TextView v, AttributeSet attrs, int defStyleAttr, int defStyleRes){
        String fontFamily = null;
        int typefaceIndex = -1;
        int styleIndex = -1;
        int shadowColor = 0;
        float dx = 0, dy = 0, r = 0;

        Drawable drawableLeft = null, drawableTop = null, drawableRight = null,
                drawableBottom = null, drawableStart = null, drawableEnd = null;
        boolean drawableDefined = false;
        boolean drawableRelativeDefined = false;

        /*
         * Look the appearance up without checking first if it exists because
         * almost every TextView has one and it greatly simplifies the logic
         * to be able to parse the appearance first and then let specific tags
         * for this View override it.
         */
        TypedArray a = v.getContext().obtainStyledAttributes(attrs, R.styleable.TextViewAppearance, defStyleAttr, defStyleRes);
        TypedArray appearance = null;
        int ap = a.getResourceId(R.styleable.TextViewAppearance_android_textAppearance, 0);
        a.recycle();

        if (ap != 0)
            appearance = v.getContext().obtainStyledAttributes(ap, R.styleable.TextAppearance);

        if (appearance != null) {
            int n = appearance.getIndexCount();
            for (int i = 0; i < n; i++) {
                int attr = appearance.getIndex(i);

                if (attr == R.styleable.TextAppearance_android_textColorHighlight) {
                    v.setHighlightColor(appearance.getColor(attr, 0));

                } else if (attr == R.styleable.TextAppearance_android_textColor) {
                    v.setTextColor(appearance.getColorStateList(attr));

                } else if (attr == R.styleable.TextAppearance_android_textColorHint) {
                    v.setHintTextColor(appearance.getColorStateList(attr));

                } else if (attr == R.styleable.TextAppearance_android_textColorLink) {
                    v.setLinkTextColor(appearance.getColorStateList(attr));

                } else if (attr == R.styleable.TextAppearance_android_textSize) {
                    v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0));

                } else if (attr == R.styleable.TextAppearance_android_typeface) {
                    typefaceIndex = appearance.getInt(attr, -1);

                } else if (attr == R.styleable.TextAppearance_android_fontFamily) {
                    fontFamily = appearance.getString(attr);

                } else if (attr == R.styleable.TextAppearance_tv_fontFamily) {
                    fontFamily = appearance.getString(attr);

                } else if (attr == R.styleable.TextAppearance_android_textStyle) {
                    styleIndex = appearance.getInt(attr, -1);

                } else if (attr == R.styleable.TextAppearance_android_textAllCaps) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                        v.setAllCaps(appearance.getBoolean(attr, false));

                } else if (attr == R.styleable.TextAppearance_android_shadowColor) {
                    shadowColor = appearance.getInt(attr, 0);

                } else if (attr == R.styleable.TextAppearance_android_shadowDx) {
                    dx = appearance.getFloat(attr, 0);

                } else if (attr == R.styleable.TextAppearance_android_shadowDy) {
                    dy = appearance.getFloat(attr, 0);

                } else if (attr == R.styleable.TextAppearance_android_shadowRadius) {
                    r = appearance.getFloat(attr, 0);

                } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                        v.setElegantTextHeight(appearance.getBoolean(attr, false));

                } else if (attr == R.styleable.TextAppearance_android_letterSpacing) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                        v.setLetterSpacing(appearance.getFloat(attr, 0));

                } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                        v.setFontFeatureSettings(appearance.getString(attr));

                }
            }

            appearance.recycle();
        }

        a = v.getContext().obtainStyledAttributes(attrs, R.styleable.TextView, defStyleAttr, defStyleRes);

        int n = a.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = a.getIndex(i);

            if (attr == R.styleable.TextView_android_drawableLeft) {
                drawableLeft = a.getDrawable(attr);
                drawableDefined = true;

            } else if (attr == R.styleable.TextView_android_drawableTop) {
                drawableTop = a.getDrawable(attr);
                drawableDefined = true;

            } else if (attr == R.styleable.TextView_android_drawableRight) {
                drawableRight = a.getDrawable(attr);
                drawableDefined = true;

            } else if (attr == R.styleable.TextView_android_drawableBottom) {
                drawableBottom = a.getDrawable(attr);
                drawableDefined = true;

            } else if (attr == R.styleable.TextView_android_drawableStart) {
                drawableStart = a.getDrawable(attr);
                drawableRelativeDefined = true;

            } else if (attr == R.styleable.TextView_android_drawableEnd) {
                drawableEnd = a.getDrawable(attr);
                drawableRelativeDefined = true;

            } else if (attr == R.styleable.TextView_android_drawablePadding) {
                v.setCompoundDrawablePadding(a.getDimensionPixelSize(attr, 0));

            } else if (attr == R.styleable.TextView_android_maxLines) {
                v.setMaxLines(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_maxHeight) {
                v.setMaxHeight(a.getDimensionPixelSize(attr, -1));

            } else if (attr == R.styleable.TextView_android_lines) {
                v.setLines(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_height) {
                v.setHeight(a.getDimensionPixelSize(attr, -1));

            } else if (attr == R.styleable.TextView_android_minLines) {
                v.setMinLines(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_minHeight) {
                v.setMinHeight(a.getDimensionPixelSize(attr, -1));

            } else if (attr == R.styleable.TextView_android_maxEms) {
                v.setMaxEms(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_maxWidth) {
                v.setMaxWidth(a.getDimensionPixelSize(attr, -1));

            } else if (attr == R.styleable.TextView_android_ems) {
                v.setEms(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_width) {
                v.setWidth(a.getDimensionPixelSize(attr, -1));

            } else if (attr == R.styleable.TextView_android_minEms) {
                v.setMinEms(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_minWidth) {
                v.setMinWidth(a.getDimensionPixelSize(attr, -1));

            } else if (attr == R.styleable.TextView_android_gravity) {
                v.setGravity(a.getInt(attr, -1));

            } else if (attr == R.styleable.TextView_android_scrollHorizontally) {
                v.setHorizontallyScrolling(a.getBoolean(attr, false));

            } else if (attr == R.styleable.TextView_android_includeFontPadding) {
                v.setIncludeFontPadding(a.getBoolean(attr, true));

            } else if (attr == R.styleable.TextView_android_cursorVisible) {
                v.setCursorVisible(a.getBoolean(attr, true));

            } else if (attr == R.styleable.TextView_android_textScaleX) {
                v.setTextScaleX(a.getFloat(attr, 1.0f));

            } else if (attr == R.styleable.TextView_android_shadowColor) {
                shadowColor = a.getInt(attr, 0);

            } else if (attr == R.styleable.TextView_android_shadowDx) {
                dx = a.getFloat(attr, 0);

            } else if (attr == R.styleable.TextView_android_shadowDy) {
                dy = a.getFloat(attr, 0);

            } else if (attr == R.styleable.TextView_android_shadowRadius) {
                r = a.getFloat(attr, 0);

            } else if (attr == R.styleable.TextView_android_textColorHighlight) {
                v.setHighlightColor(a.getColor(attr, 0));

            } else if (attr == R.styleable.TextView_android_textColor) {
                v.setTextColor(a.getColorStateList(attr));

            } else if (attr == R.styleable.TextView_android_textColorHint) {
                v.setHintTextColor(a.getColorStateList(attr));

            } else if (attr == R.styleable.TextView_android_textColorLink) {
                v.setLinkTextColor(a.getColorStateList(attr));

            } else if (attr == R.styleable.TextView_android_textSize) {
                v.setTextSize(TypedValue.COMPLEX_UNIT_PX, a.getDimensionPixelSize(attr, 0));

            } else if (attr == R.styleable.TextView_android_typeface) {
                typefaceIndex = a.getInt(attr, -1);

            } else if (attr == R.styleable.TextView_android_textStyle) {
                styleIndex = a.getInt(attr, -1);

            } else if (attr == R.styleable.TextView_android_fontFamily) {
                fontFamily = a.getString(attr);

            } else if (attr == R.styleable.TextView_tv_fontFamily) {
                fontFamily = a.getString(attr);

            } else if (attr == R.styleable.TextView_android_textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                    v.setAllCaps(a.getBoolean(attr, false));

            } else if (attr == R.styleable.TextView_android_elegantTextHeight) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setElegantTextHeight(a.getBoolean(attr, false));

            } else if (attr == R.styleable.TextView_android_letterSpacing) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setLetterSpacing(a.getFloat(attr, 0));

            } else if (attr == R.styleable.TextView_android_fontFeatureSettings) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                    v.setFontFeatureSettings(a.getString(attr));

            }
        }
        a.recycle();

        if (shadowColor != 0)
            v.setShadowLayer(r, dx, dy, shadowColor);

        if(drawableDefined) {
            Drawable[] drawables = v.getCompoundDrawables();
            if (drawableStart != null)
                drawables[0] = drawableStart;
            else if (drawableLeft != null)
                drawables[0] = drawableLeft;
            if (drawableTop != null)
                drawables[1] = drawableTop;
            if (drawableEnd != null)
                drawables[2] = drawableEnd;
            else if (drawableRight != null)
                drawables[2] = drawableRight;
            if (drawableBottom != null)
                drawables[3] = drawableBottom;
            v.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], drawables[2], drawables[3]);
        }

        if(drawableRelativeDefined && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
            Drawable[] drawables = v.getCompoundDrawablesRelative();
            if (drawableStart != null)
                drawables[0] = drawableStart;
            if (drawableEnd != null)
                drawables[2] = drawableEnd;
            v.setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], drawables[1], drawables[2], drawables[3]);
        }

        Typeface tf = null;
        if (fontFamily != null) {
            tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex);
            if (tf != null)
                v.setTypeface(tf);
        }
        if(tf != null) {
            switch (typefaceIndex) {
                case 1:
                    tf = Typeface.SANS_SERIF;
                    break;
                case 2:
                    tf = Typeface.SERIF;
                    break;
                case 3:
                    tf = Typeface.MONOSPACE;
                    break;
            }
            v.setTypeface(tf, styleIndex);
        }

        if(v instanceof AutoCompleteTextView)
            applyStyle((AutoCompleteTextView)v, attrs, defStyleAttr, defStyleRes);
    }
891523
def devpiserver_cmdline_run(xom):
    '''
    
    '''
    if xom.config.args.theme == 'semantic-ui':
        xom.config.args.theme = resource_filename('devpi_semantic_ui', '')
        xom.log.info("Semantic UI Theme loaded")