Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
fb9ff774
Commit
fb9ff774
authored
Aug 17, 2014
by
skylot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14 from NeoSpb/gui_preferences
gui: add saving preferences (open/save paths, flatten packages)
parents
5545a94a
cdfb46d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
9 deletions
+147
-9
MainWindow.java
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
+41
-9
JadxPreferences.java
jadx-gui/src/main/java/jadx/gui/utils/JadxPreferences.java
+106
-0
No files found.
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
View file @
fb9ff774
...
...
@@ -4,6 +4,7 @@ import jadx.gui.JadxWrapper;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JRoot
;
import
jadx.gui.utils.JadxPreferences
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.Position
;
import
jadx.gui.utils.Utils
;
...
...
@@ -79,6 +80,10 @@ public class MainWindow extends JFrame {
private
JRoot
treeRoot
;
private
TabbedPane
tabbedPane
;
private
JCheckBoxMenuItem
flatPkgMenuItem
;
private
JToggleButton
flatPkgButton
;
private
boolean
isFlattenPackage
;
public
MainWindow
(
JadxWrapper
wrapper
)
{
this
.
wrapper
=
wrapper
;
...
...
@@ -91,8 +96,16 @@ public class MainWindow extends JFrame {
fileChooser
.
setAcceptAllFileFilterUsed
(
true
);
fileChooser
.
setFileFilter
(
new
FileNameExtensionFilter
(
"supported files"
,
"dex"
,
"apk"
,
"jar"
));
fileChooser
.
setToolTipText
(
NLS
.
str
(
"file.open"
));
String
currentDirectory
=
JadxPreferences
.
getLastOpenFilePath
();
if
(!
currentDirectory
.
isEmpty
())
{
fileChooser
.
setCurrentDirectory
(
new
File
(
currentDirectory
));
}
int
ret
=
fileChooser
.
showDialog
(
mainPanel
,
NLS
.
str
(
"file.open"
));
if
(
ret
==
JFileChooser
.
APPROVE_OPTION
)
{
JadxPreferences
.
putLastOpenFilePath
(
fileChooser
.
getCurrentDirectory
().
getPath
());
openFile
(
fileChooser
.
getSelectedFile
());
}
}
...
...
@@ -107,9 +120,16 @@ public class MainWindow extends JFrame {
JFileChooser
fileChooser
=
new
JFileChooser
();
fileChooser
.
setFileSelectionMode
(
JFileChooser
.
DIRECTORIES_ONLY
);
fileChooser
.
setToolTipText
(
NLS
.
str
(
"file.save_all_msg"
));
String
currentDirectory
=
JadxPreferences
.
getLastSaveFilePath
();
if
(!
currentDirectory
.
isEmpty
())
{
fileChooser
.
setCurrentDirectory
(
new
File
(
currentDirectory
));
}
int
ret
=
fileChooser
.
showDialog
(
mainPanel
,
NLS
.
str
(
"file.select"
));
if
(
ret
==
JFileChooser
.
APPROVE_OPTION
)
{
JadxPreferences
.
putLastSaveFilePath
(
fileChooser
.
getCurrentDirectory
().
getPath
());
ProgressMonitor
progressMonitor
=
new
ProgressMonitor
(
mainPanel
,
"Saving sources"
,
""
,
0
,
100
);
progressMonitor
.
setMillisToPopup
(
500
);
wrapper
.
saveAll
(
fileChooser
.
getSelectedFile
(),
progressMonitor
);
...
...
@@ -118,19 +138,27 @@ public class MainWindow extends JFrame {
private
void
initTree
()
{
treeRoot
=
new
JRoot
(
wrapper
);
treeRoot
.
setFlatPackages
(
isFlattenPackage
);
treeModel
.
setRoot
(
treeRoot
);
treeModel
.
reload
();
tree
.
expandRow
(
0
);
}
private
void
toggleFlattenPackage
(
JToggleButton
btn
,
JCheckBoxMenuItem
menuItem
)
{
private
void
toggleFlattenPackage
()
{
setFlattenPackage
(!
isFlattenPackage
);
}
private
void
setFlattenPackage
(
boolean
value
)
{
isFlattenPackage
=
value
;
JadxPreferences
.
putFlattenPackage
(
isFlattenPackage
);
flatPkgButton
.
setSelected
(
isFlattenPackage
);
flatPkgMenuItem
.
setState
(
isFlattenPackage
);
Object
root
=
treeModel
.
getRoot
();
if
(
root
instanceof
JRoot
)
{
JRoot
treeRoot
=
(
JRoot
)
root
;
boolean
flatPkg
=
!
treeRoot
.
isFlatPackages
();
btn
.
setSelected
(
flatPkg
);
menuItem
.
setState
(
flatPkg
);
treeRoot
.
setFlatPackages
(
flatPkg
);
treeRoot
.
setFlatPackages
(
isFlattenPackage
);
treeModel
.
reload
();
tree
.
expandRow
(
0
);
}
...
...
@@ -212,8 +240,11 @@ public class MainWindow extends JFrame {
JMenu
view
=
new
JMenu
(
NLS
.
str
(
"menu.view"
));
view
.
setMnemonic
(
KeyEvent
.
VK_V
);
final
JCheckBoxMenuItem
flatPkgMenuItem
=
new
JCheckBoxMenuItem
(
NLS
.
str
(
"menu.flatten"
),
ICON_FLAT_PKG
);
isFlattenPackage
=
JadxPreferences
.
getFlattenPackage
();
flatPkgMenuItem
=
new
JCheckBoxMenuItem
(
NLS
.
str
(
"menu.flatten"
),
ICON_FLAT_PKG
);
view
.
add
(
flatPkgMenuItem
);
flatPkgMenuItem
.
setState
(
isFlattenPackage
);
JMenuItem
syncItem
=
new
JMenuItem
(
NLS
.
str
(
"menu.sync"
),
ICON_SYNC
);
view
.
add
(
syncItem
);
...
...
@@ -300,11 +331,12 @@ public class MainWindow extends JFrame {
syncButton
.
setToolTipText
(
NLS
.
str
(
"menu.sync"
));
toolbar
.
add
(
syncButton
);
final
JToggleButton
flatPkgButton
=
new
JToggleButton
(
ICON_FLAT_PKG
);
flatPkgButton
=
new
JToggleButton
(
ICON_FLAT_PKG
);
flatPkgButton
.
setSelected
(
isFlattenPackage
);
ActionListener
flatPkgAction
=
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
toggleFlattenPackage
(
flatPkgButton
,
flatPkgMenuItem
);
toggleFlattenPackage
();
}
};
flatPkgButton
.
addActionListener
(
flatPkgAction
);
...
...
jadx-gui/src/main/java/jadx/gui/utils/JadxPreferences.java
0 → 100644
View file @
fb9ff774
package
jadx
.
gui
.
utils
;
import
java.util.prefs.Preferences
;
public
class
JadxPreferences
{
public
static
String
getLastOpenFilePath
()
{
String
result
=
""
;
try
{
result
=
getPreferences
().
get
(
KEY_LAST_OPEN_FILE_PATH
,
""
);
if
(
result
.
isEmpty
())
{
result
=
System
.
getProperty
(
"user.home"
);
}
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
return
result
;
}
public
static
void
putLastOpenFilePath
(
String
path
)
{
try
{
Preferences
prefs
=
getPreferences
();
prefs
.
put
(
KEY_LAST_OPEN_FILE_PATH
,
path
);
prefs
.
sync
();
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
}
public
static
String
getLastSaveFilePath
()
{
String
result
=
""
;
try
{
result
=
getPreferences
().
get
(
KEY_LAST_SAVE_FILE_PATH
,
""
);
if
(
result
.
isEmpty
())
{
result
=
getLastOpenFilePath
();
}
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
return
result
;
}
public
static
void
putLastSaveFilePath
(
String
path
)
{
try
{
Preferences
prefs
=
getPreferences
();
prefs
.
put
(
KEY_LAST_SAVE_FILE_PATH
,
path
);
prefs
.
sync
();
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
}
public
static
boolean
getFlattenPackage
()
{
boolean
result
=
false
;
try
{
Preferences
prefs
=
getPreferences
();
result
=
prefs
.
getBoolean
(
KEY_FLATTEN_PACKAGE
,
false
);
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
return
result
;
}
public
static
void
putFlattenPackage
(
boolean
value
)
{
try
{
Preferences
prefs
=
getPreferences
();
prefs
.
putBoolean
(
KEY_FLATTEN_PACKAGE
,
value
);
prefs
.
sync
();
}
catch
(
Exception
anyEx
)
{
/* do nothing, no preferences */
}
}
private
static
final
String
KEY_LAST_OPEN_FILE_PATH
=
"lastOpenFilePath"
;
private
static
final
String
KEY_LAST_SAVE_FILE_PATH
=
"lastSaveFilePath"
;
private
static
final
String
KEY_FLATTEN_PACKAGE
=
"flattenPackage"
;
private
static
Preferences
prefs
=
null
;
private
static
Preferences
getPreferences
()
{
if
(
prefs
==
null
)
{
prefs
=
Preferences
.
userRoot
();
}
return
prefs
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment