Add prompt for keystore password on android
This commit is contained in:
committed by
Joshua Granick
parent
534d7bd279
commit
6f935f137d
@@ -1,3 +1,8 @@
|
|||||||
|
import groovy.swing.SwingBuilder
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -14,6 +19,16 @@ android {
|
|||||||
|
|
||||||
::if KEY_STORE::
|
::if KEY_STORE::
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
if (project.KEY_STORE_PASSWORD == 'null') {
|
||||||
|
def keyStoreFile = project.KEY_STORE.split('/')
|
||||||
|
keyStoreFile = keyStoreFile[keyStoreFile.length - 1]
|
||||||
|
project.KEY_STORE_PASSWORD = getPassword('\nPlease enter key password for ' + keyStoreFile + ':');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project.KEY_STORE_ALIAS_PASSWORD == 'null') {
|
||||||
|
project.KEY_STORE_ALIAS_PASSWORD = getPassword("\nPlease enter key alias password for alias " + project.KEY_STORE_ALIAS + ":")
|
||||||
|
}
|
||||||
|
|
||||||
release {
|
release {
|
||||||
storeFile file(project.KEY_STORE)
|
storeFile file(project.KEY_STORE)
|
||||||
storePassword project.KEY_STORE_PASSWORD
|
storePassword project.KEY_STORE_PASSWORD
|
||||||
@@ -64,4 +79,60 @@ dependencies {
|
|||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
::if (ANDROID_LIBRARY_PROJECTS)::::foreach (ANDROID_LIBRARY_PROJECTS)::compile project(':deps:::name::')
|
::if (ANDROID_LIBRARY_PROJECTS)::::foreach (ANDROID_LIBRARY_PROJECTS)::compile project(':deps:::name::')
|
||||||
::end::::end::
|
::end::::end::
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getPassword(message) {
|
||||||
|
def password = '';
|
||||||
|
if (System.console() == null) {
|
||||||
|
new SwingBuilder().edt {
|
||||||
|
dialog(
|
||||||
|
title: 'Enter password',
|
||||||
|
alwaysOnTop: true,
|
||||||
|
size: [350, 150],
|
||||||
|
resizable: false,
|
||||||
|
locationRelativeTo: null,
|
||||||
|
pack: true,
|
||||||
|
modal: true,
|
||||||
|
show: true
|
||||||
|
) {
|
||||||
|
lookAndFeel('system')
|
||||||
|
|
||||||
|
panel(border: new EmptyBorder(10, 10, 10, 10)) {
|
||||||
|
gridBagLayout()
|
||||||
|
def gbc = new GridBagConstraints();
|
||||||
|
|
||||||
|
gbc.gridx = 0
|
||||||
|
gbc.gridy = 0
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL
|
||||||
|
gbc.insets = [0, 0, 10, 0]
|
||||||
|
label(
|
||||||
|
text: '<html>' +
|
||||||
|
'<body style="width: 350px">' +
|
||||||
|
message +
|
||||||
|
'</body>' +
|
||||||
|
'</html>',
|
||||||
|
constraints: gbc)
|
||||||
|
|
||||||
|
gbc.gridy = 1
|
||||||
|
input = passwordField(constraints: gbc)
|
||||||
|
|
||||||
|
gbc.gridy = 2
|
||||||
|
gbc.fill = GridBagConstraints.NONE
|
||||||
|
gbc.insets = [0, 0, 0, 0]
|
||||||
|
gbc.ipadx = 50
|
||||||
|
button = button(
|
||||||
|
defaultButton: true,
|
||||||
|
text: 'OK',
|
||||||
|
actionPerformed: {
|
||||||
|
password = input.password
|
||||||
|
dispose()
|
||||||
|
},
|
||||||
|
constraints: gbc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
password = System.console().readPassword(message)
|
||||||
|
}
|
||||||
|
return new String(password)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user