├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── LICENSE.md ├── README.md ├── keymaps └── android.cson ├── lib ├── android.coffee └── log-view.coffee ├── menus └── android.cson ├── package.json ├── spec ├── android-spec.coffee └── android-view-spec.coffee └── styles └── android.less /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Add `build-gradle` 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 LYK 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Atom Android 2 | 3 | Android development package 4 | -------------------------------------------------------------------------------- /keymaps/android.cson: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/behind-atom-keymaps-in-depth 10 | 'atom-workspace': 11 | 'ctrl-f9': 'android:build-gradle' 12 | -------------------------------------------------------------------------------- /lib/android.coffee: -------------------------------------------------------------------------------- 1 | LogView = require './log-view' 2 | {CompositeDisposable} = require 'atom' 3 | {spawn} = require 'child_process' 4 | AnsiHtmlStream = require 'ansi-html-stream' 5 | 6 | module.exports = Android = 7 | subscriptions: null 8 | logView: null 9 | 10 | activate: (state) -> 11 | @logView = new LogView 12 | 13 | # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable 14 | @subscriptions = new CompositeDisposable 15 | 16 | # Register command that toggles this view 17 | @subscriptions.add atom.commands.add 'atom-workspace', 'android:build-gradle': => @buildGradle() 18 | 19 | deactivate: -> 20 | @subscriptions.dispose() 21 | @logView.destroy() 22 | 23 | buildGradle: -> 24 | @logView.open() 25 | 26 | editor = atom.workspace.getActiveTextEditor() 27 | rootDirs = atom.project.rootDirectories 28 | 29 | for i in [0...rootDirs.length] 30 | if rootDirs[i].contains editor.getPath() 31 | currentRootDir = rootDirs[i].path 32 | break 33 | 34 | options = 35 | cwd: currentRootDir 36 | env: process.env 37 | build = spawn "gradle", ["assembleDebug", "--console=rich"], options 38 | 39 | ansiHtmlStream = AnsiHtmlStream() 40 | 41 | ansiHtmlStream.on 'data', (data) => 42 | @logView.addLine data 43 | 44 | build.stdout.pipe ansiHtmlStream 45 | 46 | build.stderr.on 'data', (data) -> 47 | console.log "stderr: #{data}" 48 | 49 | build.on 'close', (code) -> 50 | alert "Build completed successfully." if code is 0 51 | alert "Build faield. code #{code}" if code is not 0 52 | console.log "child process exited with code: #{code}" 53 | -------------------------------------------------------------------------------- /lib/log-view.coffee: -------------------------------------------------------------------------------- 1 | {ScrollView} = require 'atom-space-pen-views' 2 | 3 | module.exports = 4 | class LogView extends ScrollView 5 | @content: -> 6 | @div class: "log-view", => 7 | @button "Close", click: 'close' 8 | @div class: "detail", overflow: "auto", outlet: "container" 9 | 10 | initialize: -> 11 | super 12 | 13 | open: -> 14 | atom.workspace.addBottomPanel(item: this) unless @hasParent() 15 | 16 | close: -> 17 | @detach() 18 | 19 | toggle: -> 20 | if @hasParent() 21 | @close() 22 | else 23 | @open() 24 | 25 | addLine: (line) -> 26 | @container.append "

#{line}

" 27 | @container.scrollTop 99999 28 | -------------------------------------------------------------------------------- /menus/android.cson: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details 2 | 'context-menu': 3 | 'atom-text-editor': [ 4 | { 5 | 'label': 'Toggle android' 6 | 'command': 'android:toggle' 7 | } 8 | ] 9 | 'menu': [ 10 | { 11 | 'label': 'Packages' 12 | 'submenu': [ 13 | 'label': 'android' 14 | 'submenu': [ 15 | { 16 | 'label': 'Build debug' 17 | 'command': 'android:build-debug' 18 | } 19 | ] 20 | ] 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "android", 3 | "main": "./lib/android", 4 | "version": "0.1.0", 5 | "description": "Android development package for Atom", 6 | "keywords": [ 7 | "android", 8 | "atom" 9 | ], 10 | "activationCommands": { 11 | "atom-workspace": "android:build-gradle" 12 | }, 13 | "repository": "https://github.com/dalinaum/atom-android", 14 | "license": "MIT", 15 | "engines": { 16 | "atom": ">=1.0.0 <2.0.0" 17 | }, 18 | "dependencies": { 19 | "ansi-html-stream": "^0.0.3", 20 | "atom-space-pen-views": "^2.0.3" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spec/android-spec.coffee: -------------------------------------------------------------------------------- 1 | Android = require '../lib/android' 2 | 3 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 4 | # 5 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 6 | # or `fdescribe`). Remove the `f` to unfocus the block. 7 | 8 | describe "Android", -> 9 | [workspaceElement, activationPromise] = [] 10 | 11 | beforeEach -> 12 | workspaceElement = atom.views.getView(atom.workspace) 13 | activationPromise = atom.packages.activatePackage('android') 14 | 15 | describe "when the android:toggle event is triggered", -> 16 | it "hides and shows the modal panel", -> 17 | # Before the activation event the view is not on the DOM, and no panel 18 | # has been created 19 | expect(workspaceElement.querySelector('.android')).not.toExist() 20 | 21 | # This is an activation event, triggering it will cause the package to be 22 | # activated. 23 | atom.commands.dispatch workspaceElement, 'android:toggle' 24 | 25 | waitsForPromise -> 26 | activationPromise 27 | 28 | runs -> 29 | expect(workspaceElement.querySelector('.android')).toExist() 30 | 31 | androidElement = workspaceElement.querySelector('.android') 32 | expect(androidElement).toExist() 33 | 34 | androidPanel = atom.workspace.panelForItem(androidElement) 35 | expect(androidPanel.isVisible()).toBe true 36 | atom.commands.dispatch workspaceElement, 'android:toggle' 37 | expect(androidPanel.isVisible()).toBe false 38 | 39 | it "hides and shows the view", -> 40 | # This test shows you an integration test testing at the view level. 41 | 42 | # Attaching the workspaceElement to the DOM is required to allow the 43 | # `toBeVisible()` matchers to work. Anything testing visibility or focus 44 | # requires that the workspaceElement is on the DOM. Tests that attach the 45 | # workspaceElement to the DOM are generally slower than those off DOM. 46 | jasmine.attachToDOM(workspaceElement) 47 | 48 | expect(workspaceElement.querySelector('.android')).not.toExist() 49 | 50 | # This is an activation event, triggering it causes the package to be 51 | # activated. 52 | atom.commands.dispatch workspaceElement, 'android:toggle' 53 | 54 | waitsForPromise -> 55 | activationPromise 56 | 57 | runs -> 58 | # Now we can test for view visibility 59 | androidElement = workspaceElement.querySelector('.android') 60 | expect(androidElement).toBeVisible() 61 | atom.commands.dispatch workspaceElement, 'android:toggle' 62 | expect(androidElement).not.toBeVisible() 63 | -------------------------------------------------------------------------------- /spec/android-view-spec.coffee: -------------------------------------------------------------------------------- 1 | AndroidView = require '../lib/android-view' 2 | 3 | describe "AndroidView", -> 4 | it "has one valid test", -> 5 | expect("life").toBe "easy" 6 | -------------------------------------------------------------------------------- /styles/android.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .android { 8 | 9 | } 10 | 11 | .log-view { 12 | .detail { 13 | max-height: 100px; 14 | overflow: scroll; 15 | } 16 | } 17 | --------------------------------------------------------------------------------