@Override public void onReceive(Context context, Intent intent) { /* * Close the notification bar in order to see the toast that module * was enabled successfully. Furthermore, if SU permissions haven't * been granted yet, the SU dialog will be prompted behind the * expanded notification panel and is therefore not visible to the * user. */ sContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); cancelAll(); if (intent.hasExtra(EXTRA_ACTIVATE_MODULE)) { String packageName = intent.getStringExtra(EXTRA_ACTIVATE_MODULE); ModuleUtil moduleUtil = ModuleUtil.getInstance(); moduleUtil.setModuleEnabled(packageName, true); moduleUtil.updateModulesList(false); Toast.makeText(sContext, R.string.module_activated, Toast.LENGTH_SHORT).show(); if (intent.hasExtra(EXTRA_ACTIVATE_MODULE_AND_RETURN)) return; } RootUtil rootUtil = new RootUtil(); if (!rootUtil.startShell()) { Log.e(XposedApp.TAG, "Could not start root shell"); return; } boolean isSoftReboot = intent.getBooleanExtra(EXTRA_SOFT_REBOOT, false); rootUtil.reboot( isSoftReboot ? RootUtil.RebootMode.SOFT : RootUtil.RebootMode.NORMAL, new RootUtil.LogLineCallback()); AssetUtil.removeBusybox(); }
/** * Create and return animation drawable * * @param assetsFramesPath Path to folder with animation frames relative to "assets" folder of * android application * @param defaultDuration How long in milliseconds a single frame should appear * @param oneShot Play once (true) or repeat (false) * @return AnimationDrawable instance */ public AnimationDrawable create( final String assetsFramesPath, final int defaultDuration, final boolean oneShot) { final List<String> files = assetUtil.getFileList(assetsFramesPath); final SortedMap<Integer, String> frames = frameUtil.extractFrames(files); final AnimationDrawable animationDrawable = new AnimationDrawable(); animationDrawable.setOneShot(oneShot); for (final Integer key : frames.keySet()) { final Bitmap frame = BitmapFactory.decodeStream(assetUtil.open(frames.get(key))); animationDrawable.addFrame(new BitmapDrawable(frame), defaultDuration); } return animationDrawable; }
@Override public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { if (this.visible) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.mouseDragged(minecraft, mouseX, mouseY); int textOffsetX = 0; if (this.chap != null) { if (this.chap.displayStack != null) { GL11.glPushMatrix(); BookletPage.renderItem( this.gui, this.chap.displayStack, this.xPosition - 4, this.yPosition, 0.725F); GL11.glPopMatrix(); textOffsetX = 10; } } if (this.field_146123_n) { GL11.glPushMatrix(); AssetUtil.drawHorizontalGradientRect( this.xPosition + textOffsetX - 1, this.yPosition + this.height - 1, this.xPosition + this.gui.getFontRenderer().getStringWidth(this.displayString) + textOffsetX + 1, this.yPosition + this.height, 0x80 << 24 | 22271, 22271); GL11.glPopMatrix(); } this.gui .getFontRenderer() .drawString( this.displayString, this.xPosition + textOffsetX, this.yPosition + (this.height - 8) / 2, 0); } }