Coder Social home page Coder Social logo

permissions-dispatcher / permissions-dispatcher-plugin Goto Github PK

View Code? Open in Web Editor NEW
706.0 22.0 57.0 783 KB

IntelliJ plugin for supporting PermissionsDispatcher

Home Page: https://plugins.jetbrains.com/plugin/8349

License: Apache License 2.0

Shell 3.77% Kotlin 87.87% Java 8.36%
permissionsdispatcher intellij-plugin

permissions-dispatcher-plugin's Introduction

PermissionsDispatcher plugin

IntelliJ plugin for supporting PermissionsDispatcher.

PermissionsDispatcher is wonderful library for Runtime Permissions. However, it asks developers "attach annotations" and "delegate to generated class" and then after that "rebuild". It's hard to follow all steps correctly. This plugin generates the skelton of methods for "attach annotations" and "delegate to generated class" using GUI.

How to install?

Use the IDE's plugin manager to install the latest version of the plugin.

How to use?

Add dependencies (Optional)

  • Open build.gradle and Generate -> Add PermissionsDispatcher dependencies

(If you already add the dependencies, there is no 'Add PermissionsDispatcher dependencies' menu.)

dep

Generate Runtime Permissions codes

  • Open Activity/Fragment
  • Generate -> Generate Runtime Permissions...
  • Choose permissions and enter method names for each annotations
  • Click Generate button
  • Done!

pd

(It skips "rebuild" for making gif small, but it is highly recommended to rebuild after generating codes.)

Add a generation method call

  • Generate -> Add a generation method call
  • (If there is multiple choices, dialog asks which method you want to delegate)
  • Done!

add_delegation

Settings

You can change PermissionsDispatcher plugin from Preferences... > Other Settings > PermissionsDispatcher plugin

Rebuild

There are 3 behaviors for rebuilding project after generating PermissionsDispatcher code.

Type Behavior
Prompt (Default) Show dialog
Always Always rebuild without dialog
Not Always Does not rebuild

Supported PermissionsDispatcher version

License

Copyright 2017 Yoshinori Isogai

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

permissions-dispatcher-plugin's People

Contributors

hotchemi avatar sckm avatar shiraji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

permissions-dispatcher-plugin's Issues

Add dependencies is old version

compile 'com.github.hotchemi:permissionsdispatcher:2.3.1'
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.3.1'

PermissionsDispatcher is now 2.3.2

i hope to update 'Add dependencies'

It doesn't work

gradle:

dependencies {
//permissions
compile appDependencies.permissionsDispatcher
annotationProcessor appDependencies.permissionsDispatcherProcessor
}

appDependencies = [
permissionsDispatcher : "com.github.hotchemi:permissionsdispatcher:${permissionsDispatcherVersion}",
permissionsDispatcherProcessor: "com.github.hotchemi:permissionsdispatcher-processor:${permissionsDispatcherVersion}",
]

It doesn't work ,,fragment or activity generate show :
image

Add kotlin support

I don't know how but because PermissionsDispatcher support Kotlin, this plugin should support that, too.

PD v2.2.0

PermissionsDispatcher v2.2.0 is available https://github.com/hotchemi/PermissionsDispatcher/releases/tag/2.2.0

I don't think there is no change for this plugin but make sure it is working.

I lie. This plugin need to support maxSdkVersion. Maybe add checkbox and then if the checkbox is selected, add maxSdkVersion = 18 from manifest file. (or just show text box for maxSdkVersion value)

  • Support maxSdkVersion
  • Update README

Insert method call for Kotlin

Same as #12, this plugin does not generate missing delegating method call. There are TODO comments where I should write the code...

Add setting for rebuild

It is annoying to ask me rebuild the project, since i always need to do it.

Provide "Don't show this dialog" and settings for always rebuild/don't rebuild project

  • create config
  • create preference
  • use config for dialog popup

can't install this plugin

android studio 2.2.2
when i install this plugin from browse repositories, it can't download.
so i use install plugin from disk, this can install but when i restart android studio, it warn this plugin has some problems.
please help me!

Add PermissionsDispatcher to dependencies

Add this to app/build.gradle

buildscript {
  dependencies {
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
  }
}

apply plugin: 'android-apt'

dependencies {
  compile 'com.github.hotchemi:permissionsdispatcher:2.1.3'
  apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.3'
}

2.1.3 is hard coded for first release.

Update for v2.4.0

It now bundle support v13. I think when add dependemcies, ask user if the app include android.app.Fragment or not.

PD 2.3.2

PD 2.3.2 is released. AFAIK, there is no issue to this plugin with v2.3.2. Check if there is no issue and update README.

Refactoring...

Currently, we have a lot of duplicated methods and logics in View classes.

After createing generating missing functions, I think it's time to refactoring code.

Fix exclude syntax

compile('com.github.hotchemi:permissionsdispatcher:2.4.0')

or

compile('com.github.hotchemi:permissionsdispatcher:2.4.0') { exclude module: "support-v13" } 

"Generate Runtime Permissions" not work in Kotlin file

When I trying to generate some methods with "Generate Runtime Permissions" in kotlin file, I'm getting the following error

[ 139300]  ERROR - llij.ide.plugins.PluginManager - org.jetbrains.kotlin.resolve.ImportPath.<init>(Ljava/lang/String;)V 
java.lang.NoSuchMethodError: org.jetbrains.kotlin.resolve.ImportPath.<init>(Ljava/lang/String;)V
	at com.github.shiraji.permissionsdispatcherplugin.handlers.GeneratePMCodeHandlerKt.addImport(GeneratePMCodeHandlerKt.kt:115)
	at com.github.shiraji.permissionsdispatcherplugin.handlers.GeneratePMCodeHandler.addRuntimePermissionAnnotation(GeneratePMCodeHandler.kt:33)
	at com.github.shiraji.permissionsdispatcherplugin.handlers.GeneratePMCodeHandler.invoke(GeneratePMCodeHandler.kt:19)
	at com.github.shiraji.permissionsdispatcherplugin.handlers.GeneratePMCodeHandlerKt.invoke(GeneratePMCodeHandlerKt.kt:17)
	at com.intellij.codeInsight.actions.CodeInsightAction.lambda$null$0(CodeInsightAction.java:59)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:898)
	at com.intellij.codeInsight.actions.CodeInsightAction.lambda$actionPerformedImpl$1(CodeInsightAction.java:62)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:129)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:100)
	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:86)
	at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl(CodeInsightAction.java:55)
	at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(CodeInsightAction.java:41)
	at com.github.shiraji.permissionsdispatcherplugin.actions.GeneratePMCodeAction.access$actionPerformed$s-307674507(GeneratePMCodeAction.kt:30)
	at com.github.shiraji.permissionsdispatcherplugin.actions.GeneratePMCodeAction$actionPerformed$2.invoke(GeneratePMCodeAction.kt:102)
	at com.github.shiraji.permissionsdispatcherplugin.actions.GeneratePMCodeAction.actionPerformed(GeneratePMCodeAction.kt:124)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:156)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:211)
	at com.intellij.ui.popup.PopupFactoryImpl$ActionPopupStep.performAction(PopupFactoryImpl.java:875)
	at com.intellij.ui.popup.PopupFactoryImpl$ActionPopupStep.lambda$onChosen$0(PopupFactoryImpl.java:863)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:199)
	at com.intellij.ui.popup.AbstractPopup.lambda$null$7(AbstractPopup.java:1390)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:795)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:631)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
[ 139306]  ERROR - llij.ide.plugins.PluginManager - Android Studio 2.3.3  Build #AI-162.4069837 
[ 139308]  ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_92 
[ 139308]  ERROR - llij.ide.plugins.PluginManager - VM: Java HotSpot(TM) 64-Bit Server VM 
[ 139308]  ERROR - llij.ide.plugins.PluginManager - Vendor: Oracle Corporation 
[ 139308]  ERROR - llij.ide.plugins.PluginManager - OS: Mac OS X 
[ 139308]  ERROR - llij.ide.plugins.PluginManager - Last Action: Generate 

Refactoring!!!

There are many place use file.classes[0]. At this moment, it only supports first class...but at least use local variable!

Make kotlin optional

It maybe too late but this plugin should not require org.jetbrains.kotlin. It should be optional.

Generate Runtime Permissions codes hope

i think better

select line on existed function on generete Runtime Permissions,
NeedPermission into functionName in TextBox

and Generate push
existing function above additonal Annotation.


This is too much hope

Existed function using replace

XXXDispacher.functionWith (this)

It is awesome if you can

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.