Skip to content

Commit

Permalink
FutureRestore GUI — v1.74
Browse files Browse the repository at this point in the history
Merge pull request #35 from CoocooFroggy/dev
  • Loading branch information
CoocooFroggy authored May 5, 2021
2 parents 681938b + c0a7424 commit fd07cd5
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 49 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
implementation group: 'org.tukaani', name: 'xz', version: '1.8'
implementation group: 'org.rauschig', name: 'jarchivelib', version: '0.7.1'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation 'com.github.Dansoftowner:jSystemThemeDetector:2.1'
implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.6'
implementation 'com.github.oshi:oshi-core:5.6.1'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
}
Expand Down
65 changes: 44 additions & 21 deletions src/main/java/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.regex.Pattern;

public class MainMenu {
static String futureRestoreGUIVersion = "1.73";
static String futureRestoreGUIVersion = "1.74";

private JButton selectBlobFileButton;
private JButton selectTargetIPSWFileButton;
Expand Down Expand Up @@ -215,21 +215,21 @@ public MainMenu() {
}

//If blob name has a build number in it
Pattern blobPattern = Pattern.compile(".*([A-Z0-9]{5})_");
Pattern blobPattern = Pattern.compile("(?<=_|-)[A-Z0-9]{5,10}[a-z]?(?=_|-)");
Matcher blobMatcher = blobPattern.matcher(blobName);
String blobBuild = null;
if (blobMatcher.find()) {
System.out.println("Blob build is " + blobMatcher.group(1));
blobBuild = blobMatcher.group(1);
// System.out.println("Blob build is " + blobMatcher.group(0));
blobBuild = blobMatcher.group(0);
}

//If IPSW has a build name in it
Pattern ipswPattern = Pattern.compile(".*_([A-Z0-9]{5})");
Pattern ipswPattern = Pattern.compile("(?<=_|-)[A-Z0-9]{5,10}[a-z]?(?=_|-)");
Matcher ipswMatcher = ipswPattern.matcher(targetIpswName);
String targetIpswBuild = null;
if (ipswMatcher.find()) {
System.out.println("IPSW build is " + ipswMatcher.group(1));
targetIpswBuild = ipswMatcher.group(1);
// System.out.println("IPSW build is " + ipswMatcher.group(0));
targetIpswBuild = ipswMatcher.group(0);
}

//If they're different
Expand Down Expand Up @@ -295,6 +295,7 @@ public MainMenu() {

runCommand(new ArrayList<>(Arrays.asList("--exit-recovery")), false);
});

basebandComboBox.addActionListener(e -> {
switch (basebandComboBox.getSelectedItem().toString()) {
case "Latest Baseband":
Expand Down Expand Up @@ -439,17 +440,41 @@ public void actionPerformed(ActionEvent e) {
static JFrame settingsMenuFrame;

public static void main(String[] args) {
final OsThemeDetector detector = OsThemeDetector.getDetector();
final boolean isDarkThemeUsed = detector.isDark();
//Must set L&F before we create instance of MainMenu
if (isDarkThemeUsed) {
FlatDarculaLaf.install();
} else {
//Only set if not Mac
if (!System.getProperty("os.name").toLowerCase().contains("mac"))
FlatIntelliJLaf.install();
//load and init prefs
initializePreferences();

boolean isDarkThemeUsed = false;
switch (properties.getProperty("theme_preference")) {
case "auto": {
final OsThemeDetector detector = OsThemeDetector.getDetector();
isDarkThemeUsed = detector.isDark();
//Must set L&F before we create instance of MainMenu
if (isDarkThemeUsed) {
FlatDarculaLaf.install();
} else {
//Only set if not Mac
if (!System.getProperty("os.name").toLowerCase().contains("mac"))
FlatIntelliJLaf.install();
}
break;
}
case "light": {
//Good practice
isDarkThemeUsed = false;
//Only set if not Mac
if (!System.getProperty("os.name").toLowerCase().contains("mac"))
FlatIntelliJLaf.install();
break;
}
case "dark": {
isDarkThemeUsed = true;
FlatDarculaLaf.install();
break;
}

}

final boolean finalIsDarkThemeUsed = isDarkThemeUsed;
SwingUtilities.invokeLater(() -> {
mainMenuFrame = new JFrame("FutureRestore GUI");
settingsMenuFrame = new JFrame("Settings");
Expand All @@ -471,9 +496,6 @@ public static void main(String[] args) {
//Centers it on screen
mainMenuFrame.setLocationRelativeTo(null);

//load and init prefs
initializePreferences();

// init SettingsMenu
SettingsMenu.initializeSettingsMenu(settingsMenuInstance);

Expand All @@ -486,7 +508,7 @@ public static void main(String[] args) {
settingsMenuFrame.setLocationRelativeTo(null);

//Prepare for dark mode
if (isDarkThemeUsed)
if (finalIsDarkThemeUsed)
turnDark(mainMenuInstance);
else {
//Custom light UI setup
Expand Down Expand Up @@ -531,7 +553,6 @@ public static void main(String[] args) {
}

});

}

/*UTILITIES*/
Expand Down Expand Up @@ -952,6 +973,8 @@ static void initializePreferences() {
properties.setProperty("preview_command", "false");
if (properties.getProperty("check_updates") == null)
properties.setProperty("check_updates", "true");
if (properties.getProperty("theme_preference") == null)
properties.setProperty("theme_preference", "auto");

savePreferences();
}
Expand Down
93 changes: 76 additions & 17 deletions src/main/java/SettingsMenu.form
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="SettingsMenu">
<grid id="27dc6" binding="settingsMenuView" layout-manager="GridBagLayout">
<constraints>
<xy x="169" y="171" width="665" height="234"/>
<xy x="169" y="171" width="1123" height="234"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9c8b6" class="javax.swing.JCheckBox" binding="shareLogsCheckBox" default-binding="true">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="10" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -18,7 +18,7 @@
</component>
<component id="b97c4" class="javax.swing.JSeparator">
<constraints>
<grid row="2" column="1" row-span="2" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="3" row-span="2" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -27,13 +27,13 @@
</component>
<vspacer id="15365">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
</vspacer>
<component id="31395" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="0" bottom="0" right="10" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -42,13 +42,13 @@
</component>
<vspacer id="92e3c">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="10" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
</vspacer>
<component id="68620" class="javax.swing.JCheckBox" binding="previewCommandCheckBox" default-binding="true">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="10" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -57,7 +57,7 @@
</component>
<component id="fd766" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="0" bottom="0" right="10" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -66,7 +66,7 @@
</component>
<component id="97ae" class="javax.swing.JTextArea" binding="discordTextArea">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
<gridbag top="0" left="10" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
Expand All @@ -79,7 +79,7 @@
</component>
<component id="6b4b5" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="0" bottom="0" right="10" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -88,7 +88,7 @@
</component>
<component id="6a94d" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="10" left="10" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -99,21 +99,21 @@
</component>
<component id="30376" class="javax.swing.JSeparator">
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="5" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties/>
</component>
<component id="bf41e" class="javax.swing.JSeparator">
<constraints>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="5" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties/>
</component>
<component id="80d80" class="javax.swing.JSeparator">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="5" column="3" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -122,7 +122,7 @@
</component>
<component id="f64b2" class="javax.swing.JCheckBox" binding="GUIUpdatesCheckBox" default-binding="true">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="10" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -132,7 +132,7 @@
</component>
<component id="15bb7" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="7" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="0" bottom="0" right="10" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
Expand All @@ -141,13 +141,72 @@
</component>
<component id="93e05" class="javax.swing.JSeparator">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="7" column="3" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<orientation value="1"/>
</properties>
</component>
<component id="c42a1" class="javax.swing.JRadioButton" binding="autoRadioButton" default-binding="true">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="10" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value="Auto"/>
</properties>
</component>
<component id="dd8ef" class="javax.swing.JRadioButton" binding="lightRadioButton" default-binding="true">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value="Light"/>
</properties>
</component>
<component id="10c49" class="javax.swing.JRadioButton" binding="darkRadioButton" default-binding="true">
<constraints>
<grid row="9" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value="Dark"/>
</properties>
</component>
<component id="33de3" class="javax.swing.JSeparator">
<constraints>
<grid row="8" column="0" row-span="1" col-span="5" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties/>
</component>
<component id="11d31" class="javax.swing.JSeparator">
<constraints>
<grid row="9" column="3" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<orientation value="1"/>
</properties>
</component>
<component id="562dc" class="javax.swing.JLabel">
<constraints>
<grid row="9" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag top="0" left="0" bottom="0" right="10" weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value="Set the theme of the GUI. Requires a restart to take effect."/>
</properties>
</component>
</children>
</grid>
<buttonGroups>
<group name="themeSettingRadioGroup">
<member id="c42a1"/>
<member id="dd8ef"/>
<member id="10c49"/>
</group>
</buttonGroups>
</form>
Loading

0 comments on commit fd07cd5

Please sign in to comment.