From 34719e704d691d619c2fcd7e0529ba4baeff7d2c Mon Sep 17 00:00:00 2001 From: "Ravikumar.N" Date: Sat, 9 Jan 2016 20:40:51 +0530 Subject: [PATCH 01/29] Added XML codestyle to format android:name tag. --- configs/codestyles/SquareAndroid.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configs/codestyles/SquareAndroid.xml b/configs/codestyles/SquareAndroid.xml index 74c58f8..07f554d 100644 --- a/configs/codestyles/SquareAndroid.xml +++ b/configs/codestyles/SquareAndroid.xml @@ -308,6 +308,16 @@ + +
+ + + + .*:name + http://schemas.android.com/apk/res/android + + +
From 7731303e4743df11c16e089a3d4c9481b1d1b237 Mon Sep 17 00:00:00 2001 From: Matt Precious Date: Tue, 19 Jan 2016 16:58:52 -0500 Subject: [PATCH 02/29] Don't insert blank lines before tags --- configs/codestyles/SquareAndroid.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/codestyles/SquareAndroid.xml b/configs/codestyles/SquareAndroid.xml index 74c58f8..fb29ac9 100644 --- a/configs/codestyles/SquareAndroid.xml +++ b/configs/codestyles/SquareAndroid.xml @@ -73,6 +73,7 @@ From 6ede41e1934ee00a93d9ee427a15301532b2ee24 Mon Sep 17 00:00:00 2001 From: Jack Danger Canty Date: Fri, 5 Feb 2016 11:33:07 -0800 Subject: [PATCH 03/29] using double brackets for safety --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b7617b1..aacb8e9 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ for i in $HOME/Library/Preferences/IntelliJIdea* \ $HOME/.IdeaIC*/config \ $HOME/.AndroidStudio*/config do - if [ -d $i ]; then + if [[ -d $i ]]; then # Install codestyles mkdir -p $i/codestyles From ae3cd94bbab2068530bb030f36806d7955ae0134 Mon Sep 17 00:00:00 2001 From: Tai Le Tien Date: Fri, 4 Mar 2016 02:00:47 +0700 Subject: [PATCH 04/29] Support for Windows. --- README.md | 2 +- install.bat | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 install.bat diff --git a/README.md b/README.md index dcc3aac..9ad7c0e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ IntelliJ IDEA code style settings for Square's Java and Android projects. Installation ------------ - * Run the `install.sh` script. + * On Unix, run the `install.sh` script. Windows users should use `install.bat` instead. * Restart IntelliJ if it's running. * Open IntelliJ Project Settings -> Code Styles, change the code style for the project to the one you want. diff --git a/install.bat b/install.bat new file mode 100644 index 0000000..a2b416c --- /dev/null +++ b/install.bat @@ -0,0 +1,22 @@ +REM Installs Square's IntelliJ configs into your user configs. +@echo off +echo Installing Square IntelliJ configs... + +setlocal enableDelayedExpansion + +for /D %%i in (%userprofile%\.AndroidStudio*) do call :copy_config %%i +for /D %%i in (%userprofile%\.IdeaIC*) do call :copy_config %%i +for /D %%i in (%userprofile%\.IntelliJIdea*) do call :copy_config %%i + +echo. +echo Restart IntelliJ and/or AndroidStudio, go to preferences, and apply 'Square' or 'SquareAndroid'. +exit /b + +REM sub function for copy config files +:copy_config +set config_dir=%~1\config +echo Installing to !config_dir! +xcopy /s configs !config_dir! +echo Done. +echo. +exit /b From de33186e6f975e2682896bfd5201d06692b3a7b5 Mon Sep 17 00:00:00 2001 From: Inez Korczynski Date: Wed, 27 Jul 2016 10:00:28 -0700 Subject: [PATCH 05/29] Automatically configure Auto Import Exclude from Import and Completion list --- configs/options/editor.codeinsight.xml | 17 +++++++++++++++++ install.sh | 4 ++++ 2 files changed, 21 insertions(+) create mode 100644 configs/options/editor.codeinsight.xml diff --git a/configs/options/editor.codeinsight.xml b/configs/options/editor.codeinsight.xml new file mode 100644 index 0000000..8733999 --- /dev/null +++ b/configs/options/editor.codeinsight.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/install.sh b/install.sh index aacb8e9..a03a9a1 100755 --- a/install.sh +++ b/install.sh @@ -21,6 +21,10 @@ do # Install inspections mkdir -p $i/inspection cp -frv "$CONFIGS/inspection"/* $i/inspection + + # Install options ("Exclude from Import and Completion") + mkdir -p $i/options + cp -frv "$CONFIGS/options"/* $i/options fi done From 790e7d32e0b6a6533562ca42e68d8a805b23008c Mon Sep 17 00:00:00 2001 From: Savelii Zagurskii Date: Fri, 11 Nov 2016 16:13:49 +0300 Subject: [PATCH 06/29] Added support for usernames with spaces. If a Windows user has a space character in the username, 1. `userprofile` breaks into 2 variables and must be saved with `" "`. 2. `call :copy_config` is supplied with an argument but if there is a space in the argument value, it breaks into 2 arguments. 3. command `xcopy /s configs C:\Users\John Doe` is also supplied with 2 arguments because of the space character. --- install.bat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.bat b/install.bat index a2b416c..e1ffa85 100644 --- a/install.bat +++ b/install.bat @@ -4,9 +4,9 @@ echo Installing Square IntelliJ configs... setlocal enableDelayedExpansion -for /D %%i in (%userprofile%\.AndroidStudio*) do call :copy_config %%i -for /D %%i in (%userprofile%\.IdeaIC*) do call :copy_config %%i -for /D %%i in (%userprofile%\.IntelliJIdea*) do call :copy_config %%i +for /D %%i in ("%userprofile%"\.AndroidStudio*) do call :copy_config "%%i" +for /D %%i in ("%userprofile%"\.IdeaIC*) do call :copy_config "%%i" +for /D %%i in ("%userprofile%"\.IntelliJIdea*) do call :copy_config "%%i" echo. echo Restart IntelliJ and/or AndroidStudio, go to preferences, and apply 'Square' or 'SquareAndroid'. @@ -15,8 +15,8 @@ exit /b REM sub function for copy config files :copy_config set config_dir=%~1\config -echo Installing to !config_dir! -xcopy /s configs !config_dir! +echo Installing to "!config_dir!" +xcopy /s configs "!config_dir!" echo Done. echo. exit /b From 36abb69fd0d47a517b164f7c54831828094f397a Mon Sep 17 00:00:00 2001 From: Tai Le Date: Thu, 1 Jun 2017 16:13:44 +0800 Subject: [PATCH 07/29] Change kotlin indent size to same with Java (2 spaces) --- configs/codestyles/Square.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/configs/codestyles/Square.xml b/configs/codestyles/Square.xml index 0d5bd27..9109861 100644 --- a/configs/codestyles/Square.xml +++ b/configs/codestyles/Square.xml @@ -278,4 +278,11 @@
-
+
From c021bf581bf01a6913bf98b90511bd268d562a22 Mon Sep 17 00:00:00 2001 From: Zachary Klippenstein Date: Fri, 19 Jan 2018 07:12:35 -0800 Subject: [PATCH 10/29] Set from Kotlin Style Guide using the new Kotlin plugin with fuller formatting support. --- configs/codestyles/SquareAndroid.xml | 49 ++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/configs/codestyles/SquareAndroid.xml b/configs/codestyles/SquareAndroid.xml index d4ce731..81f90bb 100644 --- a/configs/codestyles/SquareAndroid.xml +++ b/configs/codestyles/SquareAndroid.xml @@ -6,11 +6,6 @@
+
+ + + + app:layout_.* + http://schemas.android.com/apk/res-auto + + + BY_NAME + +
From edfc51e801bf538d661be5484be684bbc3a786df Mon Sep 17 00:00:00 2001 From: Peter Evjan Date: Thu, 21 May 2020 11:09:06 +1000 Subject: [PATCH 19/29] IntelliJ 2020 support The same config files work for IntelliJ 2020, but the location has changed so added that directory. Also quoting the variable derefences since the new path contains a space and it doesn't work without it --- install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index a03a9a1..98a2e1c 100755 --- a/install.sh +++ b/install.sh @@ -8,23 +8,23 @@ CONFIGS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/configs" for i in $HOME/Library/Preferences/IntelliJIdea* \ $HOME/Library/Preferences/IdeaIC* \ $HOME/Library/Preferences/AndroidStudio* \ + $HOME/Library/Application\ Support/JetBrains/IntelliJIdea* \ $HOME/.IntelliJIdea*/config \ $HOME/.IdeaIC*/config \ $HOME/.AndroidStudio*/config do - if [[ -d $i ]]; then - + if [[ -d "$i" ]]; then # Install codestyles - mkdir -p $i/codestyles - cp -frv "$CONFIGS/codestyles"/* $i/codestyles + mkdir -p "$i/codestyles" + cp -frv "$CONFIGS/codestyles"/* "$i/codestyles" # Install inspections - mkdir -p $i/inspection - cp -frv "$CONFIGS/inspection"/* $i/inspection + mkdir -p "$i/inspection" + cp -frv "$CONFIGS/inspection"/* "$i/inspection" # Install options ("Exclude from Import and Completion") - mkdir -p $i/options - cp -frv "$CONFIGS/options"/* $i/options + mkdir -p "$i/options" + cp -frv "$CONFIGS/options"/* "$i/options" fi done From f621070f011f6356ff1c91d216a34288772d3eaa Mon Sep 17 00:00:00 2001 From: Ralf Wondratschek Date: Tue, 11 Aug 2020 09:59:20 -0700 Subject: [PATCH 20/29] Stop always wrapping chained function calls in Kotlin. The old setting used "Always wrap", the new setting uses "Chop down if long". The Java code style uses "Chop down if long", too. The old setting made code harder to read in many scenarios: // Old assertThat(myList).containsExactly("a", "b", "c") .inOrder() // New assertThat(myList).containsExactly("a", "b", "c").inOrder() // Old if (project.file("src/debug") .exists() || project.file("src/release") .exists() ) { return } // New if (project.file("src/debug").exists() || project.file("src/release").exists()) { return } // Old val string = "The project path is ${ project.path.substring(1) .replace(':', '/') }" // New val string = "The project path is ${project.path.substring(1).replace(':', '/')}" // Old stringList .filter {..} .map { it.trim() .substring(1) } // New stringList .filter {..} .map { it.trim().substring(1) } --- configs/codestyles/Square.xml | 2 +- configs/codestyles/SquareAndroid.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/codestyles/Square.xml b/configs/codestyles/Square.xml index 458ef16..62a867e 100644 --- a/configs/codestyles/Square.xml +++ b/configs/codestyles/Square.xml @@ -303,7 +303,7 @@