@@ -21,6 +21,7 @@ public class KeyStoreManager extends JFrame {
2121 "http://developer.android.com/tools/publishing/app-signing.html#cert" ;
2222
2323 File keyStore ;
24+ AndroidEditor editor ;
2425
2526 JPasswordField passwordField ;
2627 JPasswordField repeatPasswordField ;
@@ -34,8 +35,15 @@ public class KeyStoreManager extends JFrame {
3435
3536 public KeyStoreManager (final AndroidEditor editor ) {
3637 super ("Android keystore manager" );
38+ this .editor = editor ;
3739
40+ createLayout ();
41+ }
42+
43+ private void createLayout () {
3844 Container outer = getContentPane ();
45+ outer .removeAll ();
46+
3947 Box pain = Box .createVerticalBox ();
4048 pain .setBorder (new EmptyBorder (13 , 13 , 13 , 13 ));
4149 outer .add (pain );
@@ -86,13 +94,44 @@ public void actionPerformed(ActionEvent e) {
8694 });
8795 cancelButton .setEnabled (true );
8896
97+ JButton resetKeystoreButton = new JButton ("Reset password" );
98+ dim = new Dimension (Preferences .BUTTON_WIDTH *2 ,
99+ okButton .getPreferredSize ().height );
100+ resetKeystoreButton .setPreferredSize (dim );
101+ resetKeystoreButton .addActionListener (new ActionListener () {
102+ public void actionPerformed (ActionEvent e ) {
103+ setVisible (false );
104+ int result = Base .showYesNoQuestion (editor , "Android keystore" ,
105+ "Are you sure you want to reset the password?" , "<html><body>We will have to reset the keystore to do this, " +
106+ "which means you won't be able to upload an update for your app signed with the new keystore to Google Play.<br/><br/>" +
107+ "We will make a backup for the old keystore.</body></html>" );
108+
109+ if (result == JOptionPane .NO_OPTION ) {
110+ setVisible (true );
111+ } else {
112+ if (!AndroidKeyStore .resetKeyStore ()) {
113+ Base .showWarning ("Android keystore" , "Failed to remove keystore" );
114+ setVisible (true );
115+ } else {
116+ keyStore = null ;
117+ createLayout ();
118+ }
119+ }
120+ }
121+ });
122+ resetKeystoreButton .setEnabled (true );
123+
89124 // think different, biznatchios!
90125 if (Base .isMacOS ()) {
91126 buttons .add (cancelButton );
127+
128+ if (keyStore != null ) buttons .add (resetKeystoreButton );
92129// buttons.add(Box.createHorizontalStrut(8));
93130 buttons .add (okButton );
94131 } else {
95132 buttons .add (okButton );
133+
134+ if (keyStore != null ) buttons .add (resetKeystoreButton );
96135// buttons.add(Box.createHorizontalStrut(8));
97136 buttons .add (cancelButton );
98137 }
0 commit comments