Java Code Examples for android.view.ContextThemeWrapper

The following are top voted examples for showing how to use android.view.ContextThemeWrapper. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: boohee_v5.6   File: ToolbarActionBar.java   Source Code and License 7 votes vote down vote up
private void ensureListMenuPresenter(Menu menu) {
    if (this.mListMenuPresenter == null && (menu instanceof MenuBuilder)) {
        MenuBuilder mb = (MenuBuilder) menu;
        Context context = this.mDecorToolbar.getContext();
        TypedValue outValue = new TypedValue();
        Theme widgetTheme = context.getResources().newTheme();
        widgetTheme.setTo(context.getTheme());
        widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true);
        if (outValue.resourceId != 0) {
            widgetTheme.applyStyle(outValue.resourceId, true);
        }
        widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true);
        if (outValue.resourceId != 0) {
            widgetTheme.applyStyle(outValue.resourceId, true);
        } else {
            widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true);
        }
        Context context2 = new ContextThemeWrapper(context, 0);
        context2.getTheme().setTo(widgetTheme);
        this.mListMenuPresenter = new ListMenuPresenter(context2, R.layout.abc_list_menu_item_layout);
        this.mListMenuPresenter.setCallback(new PanelMenuPresenterCallback());
        mb.addMenuPresenter(this.mListMenuPresenter);
    }
}
 
Example 2
Project: https-github.com-hyb1996-NoRootScriptDroid   File: ScriptListNavigatorContent.java   Source Code and License 6 votes vote down vote up
public ScriptListNavigatorContent(Context context) {
    mScriptListWithProgressBarView = new ScriptListWithProgressBarView(new ContextThemeWrapper(context, R.style.AppTheme));
    mFloatingScriptFileListView = mScriptListWithProgressBarView.getScriptAndFolderListRecyclerView();
    mFloatingScriptFileListView.setViewHolderSupplier(mViewHolderSupplier);
    mFloatingScriptFileListView.setLayoutManager(new WrapContentLinearLayoutManager(context));
    mFloatingScriptFileListView.setStorageScriptProvider(StorageScriptProvider.getDefault());
    mFloatingScriptFileListView.setOnItemClickListener(new ScriptAndFolderListRecyclerView.OnScriptFileClickListener() {

        @Override
        public void onClick(ScriptFile file, int position) {
            Scripts.run(file);
            HoverMenuService.postIntent(new Intent(HoverMenuService.ACTION_COLLAPSE_MENU));
        }

    });
}
 
Example 3
Project: LaunchEnr   File: PendingAppWidgetHostView.java   Source Code and License 6 votes vote down vote up
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
                                IconCache cache, boolean disabledForSafeMode) {
    super(new ContextThemeWrapper(context, R.style.WidgetContainerTheme));

    mLauncher = Launcher.getLauncher(context);
    mInfo = info;
    mStartState = info.restoreStatus;
    mDisabledForSafeMode = disabledForSafeMode;

    mPaint = new TextPaint();
    mPaint.setColor(ThemeUtils.getAttrColor(getContext(), android.R.attr.textColorPrimary));
    mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
    setBackgroundResource(R.drawable.pending_widget_bg);
    setWillNotDraw(false);

    setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
    updateAppWidget(null);
    setOnClickListener(mLauncher);

    // Load icon
    PackageItemInfo item = new PackageItemInfo(info.providerName.getPackageName());
    item.user = info.user;
    cache.updateIconInBackground(this, item);
}
 
Example 4
Project: LaunchEnr   File: IconPackPreference.java   Source Code and License 6 votes vote down vote up
IconAdapter(Context context, Map<String, IconPackInfo> supportedPackages, String currentPack) {

            int theme = PreferencesState.isDarkThemeEnabled(context)? R.style.DialogStyleDark : R.style.DialogStyle;
            ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, theme);
            mLayoutInflater = LayoutInflater.from(contextThemeWrapper);
            mSupportedPackages = new ArrayList<>(supportedPackages.values());
            Collections.sort(mSupportedPackages, new Comparator<IconPackInfo>() {
                @Override
                public int compare(IconPackInfo lhs, IconPackInfo rhs) {
                    return lhs.label.toString().compareToIgnoreCase(rhs.label.toString());
                }
            });

            Resources res = context.getResources();
            String defaultLabel = res.getString(R.string.default_iconpack_title);
            Drawable icon = ContextCompat.getDrawable(context, R.mipmap.ic_default_icon_pack);
            mSupportedPackages.add(0, new IconPackInfo(defaultLabel, icon, ""));
            mCurrentIconPack = currentPack;
        }
 
Example 5
Project: DownloadableCalligraphy   File: CalligraphyUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Tries to pull the Font Path from the Text Appearance.
 *
 * @param context     Activity Context
 * @param attrs       View Attributes
 * @param attributeId if -1 returns null.
 * @return returns null if attribute is not defined or if no TextAppearance is found.
 */
@FontRes
static int pullFontPathFromTextAppearance(final Context context, AttributeSet attrs, int[] attributeId) {
    if (attributeId == null || attrs == null)
        return 0;
    int textAppearanceId = -1;
    // For prevent using default component font
    final ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, android.R.style.Theme_NoDisplay);
    final TypedArray typedArrayAttr = contextThemeWrapper.obtainStyledAttributes(attrs, ANDROID_ATTR_TEXT_APPEARANCE);
    if (typedArrayAttr != null) {
        try {
            textAppearanceId = typedArrayAttr.getResourceId(0, 0);
        } catch (Exception ignored) {
            // Failed for some reason
            return 0;
        } finally {
            typedArrayAttr.recycle();
        }
    }

    final Integer textAppearanceAttrs = getFontFromTextAppearance(context, attributeId, textAppearanceId);
    if (textAppearanceAttrs != null) return textAppearanceAttrs;
    return 0;
}
 
Example 6
Project: MyCalendar   File: FloatingActionsMenu.java   Source Code and License 6 votes vote down vote up
private void createLabels() {
  Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);

  for (int i = 0; i < mButtonsCount; i++) {
    FloatingActionButtonLibrary button = (FloatingActionButtonLibrary) getChildAt(i);
    String title = button.getTitle();

    if (button == mAddButton || title == null ||
        button.getTag(R.id.fab_label) != null) continue;

    TextView label = new TextView(context);
    label.setTextAppearance(getContext(), mLabelsStyle);
    label.setText(button.getTitle());
    addView(label);

    button.setTag(R.id.fab_label, label);
  }
}
 
Example 7
Project: TestChat   File: FloatingActionsMenu.java   Source Code and License 6 votes vote down vote up
private void createLabels() {
        Context context = new ContextThemeWrapper(getContext(), mLabelsStyle);

        for (int i = 0; i < mButtonsCount; i++) {
                FloatingActionButton button = (FloatingActionButton) getChildAt(i);
                String title = button.getTitle();

                if (button == mAddButton || title == null ||
                        button.getTag(R.id.fab_label) != null) continue;

                TextView label = new TextView(context);
                label.setTextAppearance(getContext(), mLabelsStyle);
                label.setText(button.getTitle());
                addView(label);

                button.setTag(R.id.fab_label, label);
        }
}
 
Example 8
Project: Auto.js   File: LayoutBoundsFloatyWindow.java   Source Code and License 6 votes vote down vote up
@Override
protected View inflateView(FloatyService service) {
    mContext = new ContextThemeWrapper(service, R.style.AppTheme);
    mLayoutBoundsView = new LayoutBoundsView(mContext) {
        @Override
        public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                close();
                return true;
            }
            return super.dispatchKeyEvent(event);
        }
    };
    setupView();
    return mLayoutBoundsView;
}
 
Example 9
Project: Auto.js   File: LayoutHierarchyFloatyWindow.java   Source Code and License 6 votes vote down vote up
@Override
protected View inflateView(FloatyService service) {
    mContext = new ContextThemeWrapper(service, R.style.AppTheme);
    mLayoutHierarchyView = new LayoutHierarchyView(mContext) {
        @Override
        public boolean dispatchKeyEvent(KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                close();
                return true;
            }
            return super.dispatchKeyEvent(event);
        }
    };
    setupView();
    return mLayoutHierarchyView;
}
 
Example 10
Project: Auto.js   File: CircularMenu.java   Source Code and License 6 votes vote down vote up
private void initFloaty() {
    mWindow = new CircularActionMenuFloatingWindow(new CircularActionMenuFloaty() {

        @Override
        public View inflateActionView(FloatyService service, CircularActionMenuFloatingWindow window) {
            View actionView = View.inflate(service, R.layout.circular_action_view, null);
            mActionViewIcon = (ImageView) actionView.findViewById(R.id.icon);
            return actionView;
        }

        @Override
        public CircularActionMenu inflateMenuItems(FloatyService service, CircularActionMenuFloatingWindow window) {
            CircularActionMenu menu = (CircularActionMenu) View.inflate(new ContextThemeWrapper(service, R.style.AppTheme), R.layout.circular_action_menu, null);
            ButterKnife.bind(CircularMenu.this, menu);
            return menu;
        }
    });
    mWindow.setKeepToSideHiddenWidthRadio(0.25f);
    FloatyService.addWindow(mWindow);
}
 
Example 11
Project: BBSSDK-for-Android   File: Theme1ForumThreadPullToRequestView.java   Source Code and License 6 votes vote down vote up
public void popFilterMenu(View rootview) {
	int style = ResHelper.getStyleRes(getContext(), "BBS_PopupMenu");
	Context wrapper = new ContextThemeWrapper(getContext(), style);
	//Creating the instance of PopupMenu
	PopupMenu popup = new PopupMenu(wrapper, rootview);
	//Inflating the Popup using xml file
	popup.getMenuInflater().inflate(PageForumThreadDetail.getMenuRes(getContext(), "bbs_popup_forumthread"), popup.getMenu());

	//registering popup with OnMenuItemClickListener
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		public boolean onMenuItemClick(MenuItem item) {
			//only one menu item.
			if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebycomment")) {
				orderType = ThreadListOrderType.LAST_POST;
				performPullingDown(true);
			} else if (item.getItemId() == ResHelper.getIdRes(getContext(), "action_arrangebypost")) {
				orderType = ThreadListOrderType.CREATE_ON;
				performPullingDown(true);
			}
			return true;
		}
	});
	popup.show();
}
 
Example 12
Project: chromium-for-android-56-debug-video   File: AboutChromePreferences.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActivity().setTitle(R.string.prefs_about_chrome);
    addPreferencesFromResource(R.xml.about_chrome_preferences);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        ChromeBasePreference deprecationWarning = new ChromeBasePreference(
                new ContextThemeWrapper(getActivity(),
                        R.style.DeprecationWarningPreferenceTheme));
        deprecationWarning.setOrder(-1);
        deprecationWarning.setTitle(R.string.deprecation_warning);
        deprecationWarning.setIcon(R.drawable.exclamation_triangle);
        getPreferenceScreen().addPreference(deprecationWarning);
    }

    PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();
    AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
    Preference p = findPreference(PREF_APPLICATION_VERSION);
    p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion()));
    p = findPreference(PREF_OS_VERSION);
    p.setSummary(versionStrings.getOSVersion());
    p = findPreference(PREF_LEGAL_INFORMATION);
    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    p.setSummary(getString(R.string.legal_information_summary, currentYear));
}
 
Example 13
Project: VirtualAPK   File: VAInstrumentation.java   Source Code and License 6 votes vote down vote up
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
    final Intent intent = activity.getIntent();
    if (PluginUtil.isIntentFromPlugin(intent)) {
        Context base = activity.getBaseContext();
        try {
            LoadedPlugin plugin = this.mPluginManager.getLoadedPlugin(intent);
            ReflectUtil.setField(base.getClass(), base, "mResources", plugin.getResources());
            ReflectUtil.setField(ContextWrapper.class, activity, "mBase", plugin.getPluginContext());
            ReflectUtil.setField(Activity.class, activity, "mApplication", plugin.getApplication());
            ReflectUtil.setFieldNoException(ContextThemeWrapper.class, activity, "mBase", plugin.getPluginContext());

            // set screenOrientation
            ActivityInfo activityInfo = plugin.getActivityInfo(PluginUtil.getComponent(intent));
            if (activityInfo.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
                activity.setRequestedOrientation(activityInfo.screenOrientation);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    mBase.callActivityOnCreate(activity, icicle);
}
 
Example 14
Project: ChromeLikeTabSwitcher   File: AbstractTabSwitcherLayout.java   Source Code and License 6 votes vote down vote up
/**
 * Inflates the layout.
 *
 * @param tabsOnly
 *         True, if only the tabs should be inflated, false otherwise
 */
public final void inflateLayout(final boolean tabsOnly) {
    int themeResourceId = style.getThemeHelper().getThemeResourceId(tabSwitcher.getLayout());
    LayoutInflater inflater =
            LayoutInflater.from(new ContextThemeWrapper(getContext(), themeResourceId));
    onInflateLayout(inflater, tabsOnly);
    registerEventHandlerCallbacks();
    adaptDecorator();
    adaptLogLevel();

    if (!tabsOnly) {
        adaptToolbarVisibility();
        adaptToolbarTitle();
        adaptToolbarNavigationIcon();
        inflateToolbarMenu();
    }
}
 
Example 15
Project: superglue   File: TelescopeViewContainer.java   Source Code and License 6 votes vote down vote up
public void showTelescopeDialog(final Activity activity) {
  LayoutInflater inflater = LayoutInflater.from(activity);
  TelescopeLayout content =
      (TelescopeLayout) inflater.inflate(R.layout.telescope_tutorial_dialog, null);
  final AlertDialog dialog =
      new AlertDialog.Builder(activity).setView(content).setCancelable(false).create();

  content.setLens(new Lens() {
    @Override public void onCapture(File file) {
      dialog.dismiss();

      Context toastContext = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Dialog);
      LayoutInflater toastInflater = LayoutInflater.from(toastContext);
      Toast toast = Toast.makeText(toastContext, "", Toast.LENGTH_SHORT);
      View toastView = toastInflater.inflate(R.layout.telescope_tutorial_toast, null);
      toast.setView(toastView);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    }
  });

  dialog.show();
}
 
Example 16
Project: superglue   File: TelescopeViewContainer.java   Source Code and License 6 votes vote down vote up
public void showTelescopeDialog(final Activity activity) {
  LayoutInflater inflater = LayoutInflater.from(activity);
  TelescopeLayout content =
      (TelescopeLayout) inflater.inflate(R.layout.telescope_tutorial_dialog, null);
  final AlertDialog dialog =
      new AlertDialog.Builder(activity).setView(content).setCancelable(false).create();

  content.setLens(new Lens() {
    @Override public void onCapture(File file) {
      dialog.dismiss();

      Context toastContext = new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Dialog);
      LayoutInflater toastInflater = LayoutInflater.from(toastContext);
      Toast toast = Toast.makeText(toastContext, "", Toast.LENGTH_SHORT);
      View toastView = toastInflater.inflate(R.layout.telescope_tutorial_toast, null);
      toast.setView(toastView);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    }
  });

  dialog.show();
}
 
Example 17
Project: firefox-tv   File: OpenWithFragment.java   Source Code and License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ContextThemeWrapper wrapper = new ContextThemeWrapper(getContext(), android.R.style.Theme_Material_Light);

    @SuppressLint("InflateParams") // This View will have it's params ignored anyway:
    final View view = LayoutInflater.from(wrapper).inflate(R.layout.fragment_open_with, null);

    final Dialog dialog = new CustomWidthBottomSheetDialog(wrapper);
    dialog.setContentView(view);

    final RecyclerView appList = view.findViewById(R.id.apps);
    appList.setLayoutManager(new LinearLayoutManager(wrapper, LinearLayoutManager.VERTICAL, false));

    AppAdapter adapter = new AppAdapter(
            wrapper,
            (ActivityInfo[]) getArguments().getParcelableArray(ARGUMENT_KEY_APPS),
            (ActivityInfo) getArguments().getParcelable(ARGUMENT_STORE));
    adapter.setOnAppSelectedListener(this);
    appList.setAdapter(adapter);

    return dialog;
}
 
Example 18
Project: Android_watch_magpie   File: MainActivity.java   Source Code and License 6 votes vote down vote up
private void showAboutDialog() {
    // Transform text into URL link
    View aboutView = getLayoutInflater().inflate(R.layout.dialog_about, null, false);
    TextView txtView = (TextView) aboutView.findViewById(R.id.aboutTxtView);
    Pattern pattern = Pattern.compile("here");
    Linkify.addLinks(txtView, pattern, getString(R.string.magpie_url));
    // Create and show the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(
                    this,
                    android.R.style.Theme_Material_Light_NoActionBar_Fullscreen));
    builder.setTitle(getString(R.string.about_app))
            .setView(aboutView)
            .create()
            .show();
}
 
Example 19
Project: GravityBox   File: UnlockActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void run() {
    dismissProgressDialog();
    AlertDialog.Builder builder = new AlertDialog.Builder(
            new ContextThemeWrapper(UnlockActivity.this, mDlgThemeId))
        .setTitle(R.string.app_name)
        .setMessage(R.string.gb_startup_error)
        .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
    mAlertDialog = builder.create();
    mAlertDialog.show();
}
 
Example 20
Project: GravityBox   File: UnlockActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    File file = new File(getFilesDir() + "/" + GravityBoxSettings.FILE_THEME_DARK_FLAG);
    mDlgThemeId = file.exists() ? android.R.style.Theme_Material_Dialog :
        android.R.style.Theme_Material_Light_Dialog;
    super.onCreate(savedInstanceState);

    mHandler = new Handler();
    mReceiver = new GravityBoxResultReceiver(mHandler);
    mReceiver.setReceiver(this);
    Intent intent = new Intent();
    intent.setAction(SystemPropertyProvider.ACTION_GET_SYSTEM_PROPERTIES);
    intent.putExtra("receiver", mReceiver);
    intent.putExtra("settings_uuid", SettingsManager.getInstance(this).getOrCreateUuid());
    mProgressDialog = new ProgressDialog(
            new ContextThemeWrapper(UnlockActivity.this, mDlgThemeId));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setTitle(R.string.app_name);
    mProgressDialog.setMessage(getString(R.string.gb_startup_progress));
    mProgressDialog.setCancelable(false);
    mProgressDialog.show();
    mHandler.postDelayed(mGetSystemPropertiesTimeout, 5000);
    sendBroadcast(intent);
}
 
Example 21
Project: SimpleUILauncher   File: PendingAppWidgetHostView.java   Source Code and License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
        boolean disabledForSafeMode) {
    super(new ContextThemeWrapper(context, R.style.WidgetContainerTheme));

    mLauncher = Launcher.getLauncher(context);
    mInfo = info;
    mStartState = info.restoreStatus;
    mIconLookupIntent = new Intent().setComponent(info.providerName);
    mDisabledForSafeMode = disabledForSafeMode;

    mPaint = new TextPaint();
    mPaint.setColor(0xFFFFFFFF);
    mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
    setBackgroundResource(R.drawable.quantum_panel_dark);
    setWillNotDraw(false);

    if (Utilities.ATLEAST_LOLLIPOP) {
        setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
    }
}
 
Example 22
Project: FlickLauncher   File: PendingAppWidgetHostView.java   Source Code and License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
        boolean disabledForSafeMode) {
    super(new ContextThemeWrapper(context, R.style.WidgetContainerTheme));

    mLauncher = Launcher.getLauncher(context);
    mInfo = info;
    mStartState = info.restoreStatus;
    mIconLookupIntent = new Intent().setComponent(info.providerName);
    mDisabledForSafeMode = disabledForSafeMode;

    mPaint = new TextPaint();
    mPaint.setColor(0xFFFFFFFF);
    mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
            mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
    setBackgroundResource(R.drawable.quantum_panel_dark);
    setWillNotDraw(false);

    if (Utilities.ATLEAST_LOLLIPOP) {
        setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
    }
}
 
Example 23
Project: https-github.com-hyb1996-NoRootScriptDroid   File: RecordNavigatorContent.java   Source Code and License 5 votes vote down vote up
public RecordNavigatorContent(Context context) {
    mContext = new ContextThemeWrapper(context, R.style.AppTheme);
    mView = View.inflate(mContext, R.layout.floating_window_record, null);
    ButterKnife.bind(this, mView);
    HoverMenuService.getEventBus().register(this);
    mRecorder = GlobalRecorder.getSingleton(context);
    mRecorder.addOnStateChangedListener(this);
    setState(mRecorder.getState());
    GlobalKeyObserver.getSingleton().addVolumeDownListener(this);
}
 
Example 24
Project: https-github.com-hyb1996-NoRootScriptDroid   File: HoverMenuService.java   Source Code and License 5 votes vote down vote up
private void initViews() {
    mThemeWrapper = new ContextThemeWrapper(this, R.style.AppTheme);
    mFloatingLayoutHierarchyView = new FloatingLayoutHierarchyView(mThemeWrapper);
    mFloatingLayoutBoundsView = new FloatingLayoutBoundsView(mThemeWrapper);
    initWindowMenu();
    mWindowViewController.addView(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true, mFloatingLayoutHierarchyView);
    mWindowViewController.addView(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, true, mFloatingLayoutBoundsView);
}
 
Example 25
Project: https-github.com-hyb1996-NoRootScriptDroid   File: GlobalRecorder.java   Source Code and License 5 votes vote down vote up
public GlobalRecorder(Context context) {
    mContext = new ContextThemeWrapper(context.getApplicationContext(), R.style.AppTheme);
    mTouchRecorder = new TouchRecorder(context) {
        @Override
        protected InputEventRecorder createInputEventRecorder() {
            if (Pref.rootRecordGeneratesBinary())
                return new InputEventToAutoFileRecorder(mContext);
            else
                return new InputEventToRootAutomatorRecorder();
        }
    };
    EventBus.getDefault().register(this);
}
 
Example 26
Project: SkinFramework   File: SkinResource.java   Source Code and License 5 votes vote down vote up
public SkinThemeContext(Context base) {
    super();
    if (base instanceof ContextThemeWrapper) {
        attachBaseContext(((ContextThemeWrapper) base).getBaseContext());
        mContextRef = new WeakReference<Context>(base);
    } else {
        attachBaseContext(base);
    }
    int themeRes = getThemeRes();
    if (themeRes <= 0) {
        themeRes = android.R.style.Theme_Light;
    }
    setTheme(themeRes);
}
 
Example 27
Project: LaunchEnr   File: PopupContainerWithArrow.java   Source Code and License 5 votes vote down vote up
/**
 * Shows the notifications and deep shortcuts associated with {@param icon}.
 * @return the container if shown or null.
 */
public static PopupContainerWithArrow showForIcon(BubbleTextView icon) {
    Launcher launcher = Launcher.getLauncher(icon.getContext());
    if (getOpen(launcher) != null) {
        // There is already an items container open, so don't open this one.
        icon.clearFocus();
        return null;
    }
    ItemInfo itemInfo = (ItemInfo) icon.getTag();
    if (!DeepShortcutManager.supportsShortcuts(itemInfo)) {
        return null;
    }

    PopupDataProvider popupDataProvider = launcher.getPopupDataProvider();
    List<String> shortcutIds = popupDataProvider.getShortcutIdsForItem(itemInfo);
    List<NotificationKeyData> notificationKeys = popupDataProvider
            .getNotificationKeysForItem(itemInfo);
    List<SystemShortcut> systemShortcuts = popupDataProvider
            .getEnabledSystemShortcutsForItem(itemInfo);

    final PopupContainerWithArrow container =
            (PopupContainerWithArrow) LayoutInflater.from(new ContextThemeWrapper(launcher, R.style.Base_Theme)).inflate(
                    R.layout.popup_container, launcher.getDragLayer(), false);
    container.setVisibility(View.INVISIBLE);
    launcher.getDragLayer().addView(container);
    container.populateAndShow(icon, shortcutIds, notificationKeys, systemShortcuts);
    return container;
}
 
Example 28
Project: adyen-android   File: IssuerSelectionFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView()");
    final View fragmentView;
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    fragmentView = localInflater.inflate(R.layout.issuer_selection_fragment, container, false);

    for (InputDetail inputDetail : paymentMethod.getInputDetails()) {
        if (inputDetail.getKey().equals("idealIssuer") || inputDetail.getKey().equals("issuer")) {
            issuers = inputDetail.getItems();
            break;
        }
    }

    final IssuerListAdapter issuerListAdapter = new IssuerListAdapter(getActivity(), issuers);
    final ListView listView = (ListView) fragmentView.findViewById(R.id.issuer_methods_list);
    listView.setAdapter(issuerListAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> adapterView, final View view, final int i, final long l) {
            String selectedIssuer = issuers.get(i).getId();
            issuerSelectionListener.onIssuerSelected(selectedIssuer);
        }
    });

    if (getActivity() instanceof CheckoutActivity) {
        ((CheckoutActivity) getActivity()).setActionBarTitle(paymentMethod.getName());
    }
    return fragmentView;
}
 
Example 29
Project: mobile-store   File: InstallExtensionDialogActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();

    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
            FDroidApp.getCurThemeResId());

    progressDialog = new ProgressDialog(theme);
    progressDialog.setMessage(getString(R.string.requesting_root_access_body));
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.show();
}
 
Example 30
Project: mobile-store   File: InstallExtensionDialogActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onPostExecute(Boolean rootGranted) {
    super.onPostExecute(rootGranted);

    progressDialog.dismiss();

    if (rootGranted) {
        // root access granted

        switch (getIntent().getAction()) {
            case ACTION_UNINSTALL:
                uninstallTask.execute();
                break;
            case ACTION_INSTALL:
                installTask.execute();
                break;
        }
    } else {
        // root access denied
        // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
        ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
                FDroidApp.getCurThemeResId());

        AlertDialog.Builder alertBuilder = new AlertDialog.Builder(theme)
                .setTitle(R.string.root_access_denied_title)
                .setMessage(getString(R.string.root_access_denied_body))
                .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
                        InstallExtensionDialogActivity.this.finish();
                    }
                });
        alertBuilder.create().show();
    }
}
 
Example 31
Project: mobile-store   File: InstallExtensionDialogActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();

    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
            FDroidApp.getCurThemeResId());

    progressDialog = new ProgressDialog(theme);
    progressDialog.setMessage(InstallExtension.create(getApplicationContext()).getInstallingString());
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.show();
}
 
Example 32
Project: mobile-store   File: InstallExtensionDialogActivity.java   Source Code and License 5 votes vote down vote up
private void uninstall() {
    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    final boolean isInstalled = PrivilegedInstaller.isExtensionInstalled(this);

    if (isInstalled) {
        String message = InstallExtension.create(getApplicationContext()).getWarningString();

        AlertDialog.Builder builder = new AlertDialog.Builder(theme)
                .setTitle(R.string.system_uninstall)
                .setMessage(Html.fromHtml(message))
                .setPositiveButton(R.string.system_uninstall_button, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        checkRootTask.execute();
                    }
                })
                .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        InstallExtensionDialogActivity.this.setResult(Activity.RESULT_CANCELED);
                        InstallExtensionDialogActivity.this.finish();
                    }
                });
        builder.create().show();
    } else {
        throw new RuntimeException("Uninstall invoked, but extension is not installed!");
    }
}
 
Example 33
Project: mobile-store   File: InstallExtensionDialogActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();

    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(InstallExtensionDialogActivity.this,
            FDroidApp.getCurThemeResId());

    progressDialog = new ProgressDialog(theme);
    progressDialog.setMessage(getString(R.string.system_install_uninstalling));
    progressDialog.setIndeterminate(true);
    progressDialog.setCancelable(false);
    progressDialog.show();
}
 
Example 34
Project: SOS-The-Healthcare-Companion   File: LoginFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.DarkTheme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    View view = localInflater.inflate(R.layout.fragment_login, container, false);
    ButterKnife.bind(this, view);

    sharedPreferences = getActivity().getSharedPreferences("Profile", MODE_PRIVATE);
    return view;
}
 
Example 35
Project: CSipSimple   File: IcsListPopupWindow.java   Source Code and License 5 votes vote down vote up
public IcsListPopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    mContext = context;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        Context wrapped = new ContextThemeWrapper(context, defStyleRes);
        mPopup = new PopupWindowCompat(wrapped, attrs, defStyleAttr);
    } else {
        mPopup = new PopupWindowCompat(context, attrs, defStyleAttr, defStyleRes);
    }
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
}
 
Example 36
Project: react-native-recyclerview-list   File: RecyclerViewBackedScrollView.java   Source Code and License 5 votes vote down vote up
public RecyclerViewBackedScrollView(Context context) {
    super(new ContextThemeWrapper(context, R.style.ScrollbarRecyclerView));
    setHasFixedSize(true);
    ((DefaultItemAnimator)getItemAnimator()).setSupportsChangeAnimations(false);
    setLayoutManager(new LinearLayoutManager(context));
    setAdapter(new ReactListAdapter(this));
}
 
Example 37
Project: sctalk   File: IMUIHelper.java   Source Code and License 5 votes vote down vote up
public static void showCustomDialog(Context context,int visibale,String title, final dialogCallback callback)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Light_Dialog));
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialog_view = inflater.inflate(R.layout.tt_custom_dialog, null);
    final EditText editText = (EditText)dialog_view.findViewById(R.id.dialog_edit_content);
    editText.setVisibility(visibale);
    TextView textText = (TextView)dialog_view.findViewById(R.id.dialog_title);
    textText.setText(title);
    builder.setView(dialog_view);

    builder.setPositiveButton(context.getString(R.string.tt_ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            callback.callback();
            dialog.dismiss();
        }
    });

    builder.setNegativeButton(context.getString(R.string.tt_cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    });
    builder.show();
}
 
Example 38
Project: Auto.js   File: CircularMenu.java   Source Code and License 5 votes vote down vote up
public CircularMenu(Context context) {
    mContext = new ContextThemeWrapper(context, R.style.AppTheme);
    initFloaty();
    setupListeners();
    mRecorder = GlobalActionRecorder.getSingleton(context);
    mRecorder.addOnStateChangedListener(this);
}
 
Example 39
Project: Auto.js   File: GlobalActionRecorder.java   Source Code and License 5 votes vote down vote up
public GlobalActionRecorder(Context context) {
    mContext = new ContextThemeWrapper(context.getApplicationContext(), R.style.AppTheme);
    mTouchRecorder = new TouchRecorder(context) {
        @Override
        protected InputEventRecorder createInputEventRecorder() {
            if (Pref.rootRecordGeneratesBinary())
                return new InputEventToAutoFileRecorder(mContext);
            else
                return new InputEventToRootAutomatorRecorder();
        }
    };
}
 
Example 40
Project: atlas   File: AtlasHacks.java   Source Code and License 5 votes vote down vote up
public static void allClasses() throws HackAssertionException {
    if (android.os.Build.VERSION.SDK_INT <= 8) {
        LoadedApk = Hack.into("android.app.ActivityThread$PackageInfo");
    } else {
        LoadedApk = Hack.into("android.app.LoadedApk");
    }
    ActivityThread = Hack.into("android.app.ActivityThread");
    Resources = Hack.into(Resources.class);
    Application = Hack.into(Application.class);
    AssetManager = Hack.into(android.content.res.AssetManager.class);
    IPackageManager = Hack.into("android.content.pm.IPackageManager");
    Service = Hack.into(android.app.Service.class);
    ContextImpl = Hack.into("android.app.ContextImpl");
    ContextThemeWrapper = Hack.into(ContextThemeWrapper.class);
    ContextWrapper = Hack.into("android.content.ContextWrapper");
    sIsIgnoreFailure = true;
    ClassLoader = Hack.into(java.lang.ClassLoader.class);
    DexClassLoader = Hack.into(dalvik.system.DexClassLoader.class);
    LexFile = Hack.into("dalvik.system.LexFile");
    PackageParser$Component = Hack.into("android.content.pm.PackageParser$Component");
    PackageParser$Activity = Hack.into("android.content.pm.PackageParser$Activity");
    PackageParser$Service = Hack.into("android.content.pm.PackageParser$Service");
    PackageParser$Provider = Hack.into("android.content.pm.PackageParser$Provider");

    PackageParser = Hack.into("android.content.pm.PackageParser");
    PackageParser$Package = Hack.into("android.content.pm.PackageParser$Package");
    PackageParser$ActivityIntentInfo = Hack.into("android.content.pm.PackageParser$ActivityIntentInfo");
    PackageParser$ServiceIntentInfo = Hack.into("android.content.pm.PackageParser$ServiceIntentInfo");
    PackageParser$ProviderIntentInfo = Hack.into("android.content.pm.PackageParser$ProviderIntentInfo");

    ActivityManagerNative = Hack.into("android.app.ActivityManagerNative");
    Singleton = Hack.into("android.util.Singleton");
    ActivityThread$AppBindData = Hack.into("android.app.ActivityThread$AppBindData");
    ActivityManager = Hack.into("android.app.ActivityManager");
    StringBlock=Hack.into("android.content.res.StringBlock");
    sIsIgnoreFailure = false;
}
 
Example 41
Project: BBSSDK-for-Android   File: PageForumThreadDetail.java   Source Code and License 5 votes vote down vote up
@Override
protected void onTitleRightClick(TitleBar titleBar) {
	super.onTitleRightClick(titleBar);
	int style = ResHelper.getStyleRes(getContext(), "BBS_PopupMenu");
	Context wrapper = new ContextThemeWrapper(getContext(), style);
	//Creating the instance of PopupMenu
	PopupMenu popup = new PopupMenu(wrapper, titleBar.getRightImageView());
	//Inflating the Popup using xml file
	popup.getMenuInflater().inflate(getMenuRes(getContext(), "bbs_popup_threaddetail"), popup.getMenu());

	//registering popup with OnMenuItemClickListener
	popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
		public boolean onMenuItemClick(MenuItem item) {
			//only one menu item.
			if(forumThread == null) {
				return true;
			}

			User user = null;
			try {
				user = BBSSDK.getApi(UserAPI.class).getCurrentUser();
			} catch (Exception e) {
				user = null;
			}
			if (user != null && user.uid == forumThread.authorId) {
				ToastUtils.showToast(getContext(), ResHelper.getStringRes(getContext(), "bbs_cant_reportaccusation_self"));
				return true;
			}
			PageReportAccusation page = BBSViewBuilder.getInstance().buildPageReportAccusation();
			page.initPage(forumThread.tid, forumThread.fid);
			page.show(getContext());
			return true;
		}
	});
	popup.show();
}
 
Example 42
Project: sctalk   File: IMUIHelper.java   Source Code and License 5 votes vote down vote up
public static void handleContactItemLongClick(final UserEntity contact, final Context ctx){
    if(contact == null || ctx == null){
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, android.R.style.Theme_Holo_Light_Dialog));
    builder.setTitle(contact.getMainName());
    String[] items = new String[]{ctx.getString(R.string.check_profile),
            ctx.getString(R.string.start_session)};

    final long userId = contact.getPeerId();
    builder.setItems(items, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case 0 :
                    IMUIHelper.openUserProfileActivity(ctx, userId);
                    break;
                case 1 :
                    IMUIHelper.openChatActivity(ctx,contact.getSessionKey());
                    break;
            }
        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(true);
    alertDialog.show();
}
 
Example 43
Project: VirtualAPK   File: PluginUtil.java   Source Code and License 5 votes vote down vote up
public static void hookActivityResources(Activity activity, String packageName) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isVivo(activity.getResources())) {
        // for 5.0+ vivo
        return;
    }

    // designed for 5.0 - only, but some bad phones not work, eg:letv
    try {
        Context base = activity.getBaseContext();
        final LoadedPlugin plugin = PluginManager.getInstance(activity).getLoadedPlugin(packageName);
        final Resources resources = plugin.getResources();
        if (resources != null) {
            ReflectUtil.setField(base.getClass(), base, "mResources", resources);

            // copy theme
            Resources.Theme theme = resources.newTheme();
            theme.setTo(activity.getTheme());
            int themeResource = (int)ReflectUtil.getField(ContextThemeWrapper.class, activity, "mThemeResource");
            theme.applyStyle(themeResource, true);
            ReflectUtil.setField(ContextThemeWrapper.class, activity, "mTheme", theme);

            ReflectUtil.setField(ContextThemeWrapper.class, activity, "mResources", resources);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 44
Project: VirtualAPK   File: VAInstrumentation.java   Source Code and License 5 votes vote down vote up
@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    try {
        cl.loadClass(className);
    } catch (ClassNotFoundException e) {
        LoadedPlugin plugin = this.mPluginManager.getLoadedPlugin(intent);
        String targetClassName = PluginUtil.getTargetActivity(intent);

        Log.i(TAG, String.format("newActivity[%s : %s]", className, targetClassName));

        if (targetClassName != null) {
            Activity activity = mBase.newActivity(plugin.getClassLoader(), targetClassName, intent);
            activity.setIntent(intent);

            try {
                // for 4.1+
                ReflectUtil.setField(ContextThemeWrapper.class, activity, "mResources", plugin.getResources());
            } catch (Exception ignored) {
                // ignored.
            }

            return activity;
        }
    }

    return mBase.newActivity(cl, className, intent);
}
 
Example 45
Project: DateRangePickerLibrary   File: DefaultDayViewAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public void makeCellView(CalendarCellView parent) {
    TextView textView = new TextView(
            new ContextThemeWrapper(parent.getContext(), R.style.CalendarCell_CalendarDate));
    textView.setDuplicateParentStateEnabled(true);
    parent.addView(textView);
    parent.setDayOfMonthTextView(textView);
}
 
Example 46
Project: Blockly   File: BlocklyTestActivity.java   Source Code and License 5 votes vote down vote up
@Override
public BlocklyActivityHelper onCreateActivityHelper() {
    return new BlocklyActivityHelper(this) {
        @Override
        public BlockViewFactory onCreateBlockViewFactory(WorkspaceHelper workspaceHelper) {
            return new VerticalBlockViewFactory(
                    new ContextThemeWrapper(
                            BlocklyTestActivity.this,
                            R.style.BlocklyVerticalTheme),
                    workspaceHelper);
        }
    };
}
 
Example 47
Project: Blockly   File: TestWorkspaceViewActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mThemeWrapper = new ContextThemeWrapper(this, R.style.BlocklyVerticalTheme);
    mController = new BlocklyController.Builder(this).build();
    mWorkspace = mController.getWorkspace();
    mWorkspaceHelper = mController.getWorkspaceHelper();
    mViewFactory = new VerticalBlockViewFactory(mThemeWrapper, mWorkspaceHelper);

    mWorkspaceView = new WorkspaceView(this);
    mController.initWorkspaceView(mWorkspaceView);

    setContentView(mWorkspaceView);
}
 
Example 48
Project: Phial   File: OverlayFactory.java   Source Code and License 5 votes vote down vote up
private static OverlayView createView(Context baseContext, PhialCore phialCore) {
    final ContextThemeWrapper wrappedContext = new ContextThemeWrapper(baseContext, R.style.Theme_Phial);
    final PositionStorage storage = new PositionStorage(phialCore.getSharedPreferences());

    return new OverlayView(
            wrappedContext,
            new DragHelper(storage, R.dimen.phial_content_padding),
            new ExpandedView(wrappedContext)
    );
}
 
Example 49
Project: DailyStudy   File: LeafLoadingView.java   Source Code and License 5 votes vote down vote up
/**
 * 初始化
 *
 * @param context 上下文
 */
private void init(ContextThemeWrapper context) {
    initResources(context);
    initBitmap();
    initPaint();
    mLeafFactory = new LeafFactory();
    mLeafInfos = mLeafFactory.generateLeafs();
    mFan = new FanFactory().generateFan();
}
 
Example 50
Project: DailyStudy   File: LeafLoadingView.java   Source Code and License 5 votes vote down vote up
/**
 * 初始化资源
 *
 * @param context 上下文
 */
private void initResources(ContextThemeWrapper context) {
    mResources = getResources();
    mLeafFloatTime = LEAF_FLOAT_TIME;
    mLeafRotateTime = LEAF_ROTATE_TIME;
    mDefaultWidth = UiUtils.dipToPx(context, mDefaultWidth);
    mDefaultHeight = UiUtils.dipToPx(context, mDefaultHeight);
}
 
Example 51
Project: NightLight   File: StartActivity.java   Source Code and License 5 votes vote down vote up
private void showAlertDialog(int caption, int msg) {
    if (isFinishing()) return;
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AppTheme));
    builder.setTitle(caption);
    builder.setMessage(msg);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            finish();
        }
    });
    builder.show();
}
 
Example 52
Project: boohee_v5.6   File: ListMenuPresenter.java   Source Code and License 5 votes vote down vote up
public void initForMenu(Context context, MenuBuilder menu) {
    if (this.mThemeRes != 0) {
        this.mContext = new ContextThemeWrapper(context, this.mThemeRes);
        this.mInflater = LayoutInflater.from(this.mContext);
    } else if (this.mContext != null) {
        this.mContext = context;
        if (this.mInflater == null) {
            this.mInflater = LayoutInflater.from(this.mContext);
        }
    }
    this.mMenu = menu;
    if (this.mAdapter != null) {
        this.mAdapter.notifyDataSetChanged();
    }
}
 
Example 53
Project: boohee_v5.6   File: WindowDecorActionBar.java   Source Code and License 5 votes vote down vote up
public Context getThemedContext() {
    if (this.mThemedContext == null) {
        TypedValue outValue = new TypedValue();
        this.mContext.getTheme().resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0) {
            this.mThemedContext = new ContextThemeWrapper(this.mContext, targetThemeRes);
        } else {
            this.mThemedContext = this.mContext;
        }
    }
    return this.mThemedContext;
}
 
Example 54
Project: sctalk   File: ChatFragment.java   Source Code and License 5 votes vote down vote up
private void handleGroupItemLongClick(final Context ctx, final RecentInfo recentInfo) {

        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, android.R.style.Theme_Holo_Light_Dialog));
        builder.setTitle(recentInfo.getName());

        final boolean isTop = imService.getConfigSp().isTopSession(recentInfo.getSessionKey());
        final boolean isForbidden = recentInfo.isForbidden();
        int topMessageRes = isTop?R.string.cancel_top_message:R.string.top_message;
        int forbidMessageRes =isForbidden?R.string.cancel_forbid_group_message:R.string.forbid_group_message;

        String[] items = new String[]{ctx.getString(R.string.delete_session),ctx.getString(topMessageRes),ctx.getString(forbidMessageRes)};

        builder.setItems(items, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case 0 :
                        imService.getSessionManager().reqRemoveSession(recentInfo);
                        break;
                    case 1:{
                        imService.getConfigSp().setSessionTop(recentInfo.getSessionKey(),!isTop);
                    }break;
                    case 2:{
                        // 底层成功会事件通知
                        int shieldType = isForbidden?DBConstant.GROUP_STATUS_ONLINE:DBConstant.GROUP_STATUS_SHIELD;
                        imService.getGroupManager().reqShieldGroup(recentInfo.getPeerId(),shieldType);
                    }
                    break;
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.show();
    }
 
Example 55
Project: boohee_v5.6   File: Toolbar.java   Source Code and License 5 votes vote down vote up
public void setPopupTheme(@StyleRes int resId) {
    if (this.mPopupTheme != resId) {
        this.mPopupTheme = resId;
        if (resId == 0) {
            this.mPopupContext = getContext();
        } else {
            this.mPopupContext = new ContextThemeWrapper(getContext(), resId);
        }
    }
}
 
Example 56
Project: boohee_v5.6   File: ActionMenuView.java   Source Code and License 5 votes vote down vote up
public void setPopupTheme(@StyleRes int resId) {
    if (this.mPopupTheme != resId) {
        this.mPopupTheme = resId;
        if (resId == 0) {
            this.mPopupContext = getContext();
        } else {
            this.mPopupContext = new ContextThemeWrapper(getContext(), resId);
        }
    }
}
 
Example 57
Project: GravityBox   File: UnlockActivity.java   Source Code and License 5 votes vote down vote up
@Override
public void onReceiveResult(int resultCode, Bundle resultData) {
    if (mHandler != null) {
        mHandler.removeCallbacks(mGetSystemPropertiesTimeout);
        mHandler = null;
    }
    dismissProgressDialog();
    if (resultCode == SystemPropertyProvider.RESULT_SYSTEM_PROPERTIES) {
        dismissProgressDialog();
        Intent intent = new Intent(SystemPropertyProvider.ACTION_REGISTER_UUID);
        intent.putExtra(SystemPropertyProvider.EXTRA_UUID,
                SettingsManager.getInstance(this).getOrCreateUuid());
        intent.putExtra(SystemPropertyProvider.EXTRA_UUID_TYPE, "Unlocker");
        sendBroadcast(intent);
        AlertDialog.Builder builder = new AlertDialog.Builder(
                new ContextThemeWrapper(UnlockActivity.this, mDlgThemeId))
            .setTitle(R.string.app_name)
            .setMessage(R.string.premium_unlocked_message)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
        mAlertDialog = builder.create();
        mAlertDialog.show();
    } else {
        finish();
    }
}
 
Example 58
Project: logcatviewer   File: FloatingLogcatService.java   Source Code and License 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    ContextThemeWrapper context = new ContextThemeWrapper(this, R.style.AppTheme_NoActionBar);
    mRoot = View.inflate(context, R.layout.activity_logcat, null);
    mToolbar = mRoot.findViewById(R.id.toolbar);
    mSpinner = mRoot.findViewById(R.id.spinner);
    mList = mRoot.findViewById(R.id.list);

    initViews();
    startReadLogcat();

    return super.onStartCommand(intent, flags, startId);
}
 
Example 59
Project: an2linuxclient   File: ThemedNumberPicker.java   Source Code and License 4 votes vote down vote up
public ThemedNumberPicker(Context context, AttributeSet attrs) {
    super(new ContextThemeWrapper(context, R.style.NumberPickerStyle), attrs);
}
 
Example 60
Project: LaunchEnr   File: PopupContainerWithArrow.java   Source Code and License 4 votes vote down vote up
private void addDummyViews(PopupPopulator.Item[] itemTypesToPopulate,
        boolean notificationFooterHasIcons) {
    final Resources res = getResources();
    final int spacing = res.getDimensionPixelSize(R.dimen.popup_items_spacing);
    final LayoutInflater inflater = LayoutInflater.from(new ContextThemeWrapper(mLauncher, R.style.Base_Theme));

    int numItems = itemTypesToPopulate.length;
    for (int i = 0; i < numItems; i++) {
        PopupPopulator.Item itemTypeToPopulate = itemTypesToPopulate[i];
        PopupPopulator.Item nextItemTypeToPopulate =
                i < numItems - 1 ? itemTypesToPopulate[i + 1] : null;
        final View item = inflater.inflate(itemTypeToPopulate.layoutId, this, false);

        if (itemTypeToPopulate == PopupPopulator.Item.NOTIFICATION) {
            mNotificationItemView = (NotificationItemView) item;
            int footerHeight = notificationFooterHasIcons ?
                    res.getDimensionPixelSize(R.dimen.notification_footer_height) : 0;
            item.findViewById(R.id.footer).getLayoutParams().height = footerHeight;
            mNotificationItemView.getMainView().setAccessibilityDelegate(mAccessibilityDelegate);
        } else if (itemTypeToPopulate == PopupPopulator.Item.SHORTCUT) {
            item.setAccessibilityDelegate(mAccessibilityDelegate);
        }

        boolean shouldAddBottomMargin = nextItemTypeToPopulate != null
                && itemTypeToPopulate.isShortcut ^ nextItemTypeToPopulate.isShortcut;

        if (itemTypeToPopulate.isShortcut) {
            if (mShortcutsItemView == null) {
                mShortcutsItemView = (ShortcutsItemView) inflater.inflate(
                        R.layout.shortcuts_item, this, false);
                addView(mShortcutsItemView);
            }
            mShortcutsItemView.addShortcutView(item, itemTypeToPopulate);
            if (shouldAddBottomMargin) {
                ((LayoutParams) mShortcutsItemView.getLayoutParams()).bottomMargin = spacing;
            }
        } else {
            addView(item);
            if (shouldAddBottomMargin) {
                ((LayoutParams) item.getLayoutParams()).bottomMargin = spacing;
            }
        }
    }
}