Update compose ./studiow with Android Sutdiow Jetpack Compose Preview

Test: ./studiow -y
Change-Id: I7624d1c3ec9e61ce38d35c9a699df73732982961
diff --git a/ui/idea.properties b/ui/idea.properties
new file mode 100644
index 0000000..ffd922a
--- /dev/null
+++ b/ui/idea.properties
@@ -0,0 +1,182 @@
+# Use ${idea.home.path} macro to specify location relative to IDE installation home.
+# Use ${xxx} where xxx is any Java property (including defined in previous lines of this file) to refer to its value.
+# Note for Windows users: please make sure you're using forward slashes (e.g. c:/idea/system).
+
+#---------------------------------------------------------------------
+# Uncomment this option if you want to customize path to IDE config folder. Make sure you're using forward slashes.
+#---------------------------------------------------------------------
+idea.config.path=${user.home}/.AndroidStudioAndroidX-compose/config
+
+#---------------------------------------------------------------------
+# Uncomment this option if you want to customize path to IDE system folder. Make sure you're using forward slashes.
+#---------------------------------------------------------------------
+idea.system.path=${user.home}/.AndroidStudioAndroidX-compose/system
+
+#---------------------------------------------------------------------
+# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
+#---------------------------------------------------------------------
+# idea.plugins.path=${idea.config.path}/plugins
+
+#---------------------------------------------------------------------
+# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
+#---------------------------------------------------------------------
+# idea.log.path=${idea.system.path}/log
+
+#---------------------------------------------------------------------
+# Maximum file size (kilobytes) IDE should provide code assistance for.
+# The larger file is the slower its editor works and higher overall system memory requirements are
+# if code assistance is enabled. Remove this property or set to very large number if you need
+# code assistance for any files available regardless their size.
+#---------------------------------------------------------------------
+idea.max.intellisense.filesize=2500
+
+#---------------------------------------------------------------------
+# Maximum file size (kilobytes) IDE is able to open.
+#---------------------------------------------------------------------
+idea.max.content.load.filesize=20000
+
+#---------------------------------------------------------------------
+# This option controls console cyclic buffer: keeps the console output size not higher than the specified buffer size (Kb).
+# Older lines are deleted. In order to disable cycle buffer use idea.cycle.buffer.size=disabled
+#---------------------------------------------------------------------
+idea.cycle.buffer.size=1024
+
+#---------------------------------------------------------------------
+# Configure if a special launcher should be used when running processes from within IDE.
+# Using Launcher enables "soft exit" and "thread dump" features
+#---------------------------------------------------------------------
+idea.no.launcher=false
+
+#---------------------------------------------------------------------
+# To avoid too long classpath
+#---------------------------------------------------------------------
+idea.dynamic.classpath=false
+
+#---------------------------------------------------------------------
+# Uncomment this property to prevent IDE from throwing ProcessCanceledException when user activity
+# detected. This option is only useful for plugin developers, while debugging PSI related activities
+# performed in background error analysis thread.
+# DO NOT UNCOMMENT THIS UNLESS YOU'RE DEBUGGING IDE ITSELF. Significant slowdowns and lockups will happen otherwise.
+#---------------------------------------------------------------------
+#idea.ProcessCanceledException=disabled
+
+#---------------------------------------------------------------------
+# There are two possible values of idea.popup.weight property: "heavy" and "medium".
+# If you have WM configured as "Focus follows mouse with Auto Raise" then you have to
+# set this property to "medium". It prevents problems with popup menus on some
+# configurations.
+#---------------------------------------------------------------------
+idea.popup.weight=heavy
+
+#---------------------------------------------------------------------
+# Removing this property may lead to editor performance degradation under Windows.
+#---------------------------------------------------------------------
+sun.java2d.d3d=false
+
+#---------------------------------------------------------------------
+# Set swing.bufferPerWindow=false to workaround a slow scrolling in JDK6 (see IDEA-35883),
+# But this may lead to performance degradation in JDK8, because it disables a double buffering,
+# which is needed to eliminate tearing on blit-accelerated scrolling and to restore
+# a frame buffer content without the usual repainting, even when the EDT is blocked.
+#---------------------------------------------------------------------
+swing.bufferPerWindow=true
+
+#---------------------------------------------------------------------
+# Removing this property may lead to editor performance degradation under X Window.
+#---------------------------------------------------------------------
+sun.java2d.pmoffscreen=false
+
+#---------------------------------------------------------------------
+# Enables HiDPI support in JBRE
+#---------------------------------------------------------------------
+sun.java2d.uiScale.enabled=true
+
+#---------------------------------------------------------------------
+# Applicable to the Swing text components displaying HTML (except JEditorPane).
+# Rebases CSS size map depending on the component's font size to let relative
+# font size values (smaller, larger) scale properly. JBRE only.
+#---------------------------------------------------------------------
+javax.swing.rebaseCssSizeMap=true
+
+#---------------------------------------------------------------------
+# Workaround to avoid long hangs while accessing clipboard under Mac OS X.
+#---------------------------------------------------------------------
+#ide.mac.useNativeClipboard=True
+
+#---------------------------------------------------------------------
+# Maximum size (kilobytes) IDEA will load for showing past file contents -
+# in Show Diff or when calculating Digest Diff
+#---------------------------------------------------------------------
+#idea.max.vcs.loaded.size.kb=20480
+
+#---------------------------------------------------------------------
+# IDEA file chooser peeks inside directories to detect whether they contain a valid project
+# (to mark such directories with a corresponding icon).
+# Uncommenting the option prevents this behavior outside of user home directory.
+#---------------------------------------------------------------------
+#idea.chooser.lookup.for.project.dirs=false
+
+#-----------------------------------------------------------------------
+# Experimental option that does a number of things to make truly smooth scrolling possible:
+#
+# * Enables hardware-accelerated scrolling.
+#     Blit-acceleration copies as much of the rendered area as possible and then repaints only newly exposed region.
+#     This helps to improve scrolling performance and to reduce CPU usage (especially if drawing is compute-intensive).
+#
+# * Enables "true double buffering".
+#     True double buffering is needed to eliminate tearing on blit-accelerated scrolling and to restore
+#     frame buffer content without the usual repainting, even when the EDT is blocked.
+#
+# * Adds "idea.true.smooth.scrolling.debug" option.
+#     Checks whether blit-accelerated scrolling is feasible, and if so, checks whether true double buffering is available.
+#
+# * Enables handling of high-precision mouse wheel events.
+#     Although Java 7 introduced MouseWheelEven.getPreciseWheelRotation() method, JScrollPane doesn't use it so far.
+#     Depends on the Editor / General / Smooth Scrolling setting, remote desktop detection and power save mode state.
+#     Ideally, we need to patch the runtime (on Windows, Linux and Mac OS) to improve handling of the fine-grained input data.
+#     This feature can be toggled via "idea.true.smooth.scrolling.high.precision" option.
+#
+# * Enables handling of pixel-perfect scrolling events.
+#     Currently this mode is available only under Mac OS with JetBrains Runtime.
+#     This feature can be toggled via "idea.true.smooth.scrolling.pixel.perfect" option.
+#
+# * Enables interpolation of scrolling input (scrollbar, mouse wheel, touchpad, keys, etc).
+#     Smooths input which lacks both spatial and temporal resolution, performs the rendering asynchronously.
+#     Depends on the Editor / General / Smooth Scrolling setting, remote desktop detection and power save mode state.
+#     The feature can be tweaked using the following options:
+#       "idea.true.smooth.scrolling.interpolation" - the main switch
+#       "idea.true.smooth.scrolling.interpolation.scrollbar" - scrollbar interpolation
+#       "idea.true.smooth.scrolling.interpolation.scrollbar.delay" - initial delay for scrollbar interpolation (ms)
+#       "idea.true.smooth.scrolling.interpolation.mouse.wheel" - mouse wheel / touchpad interpolation
+#       "idea.true.smooth.scrolling.interpolation.mouse.wheel.delay.min" - minimum initial delay for mouse wheel interpolation (ms)
+#       "idea.true.smooth.scrolling.interpolation.mouse.wheel.delay.max" - maximum initial delay for mouse wheel interpolation (ms)
+#       "idea.true.smooth.scrolling.interpolation.precision.touchpad" - precision touchpad interpolation
+#       "idea.true.smooth.scrolling.interpolation.precision.touchpad.delay" - initial delay for precision touchpad interpolation (ms)
+#       "idea.true.smooth.scrolling.interpolation.other" - interpolation of other input sources
+#       "idea.true.smooth.scrolling.interpolation.other.delay" - initial delay for other input source interpolation (ms)
+#
+# * Adds on-demand horizontal scrollbar in editor.
+#     The horizontal scrollbar is shown only when it's actually needed for currently visible content.
+#     This helps to save editor space and to prevent occasional horizontal "jitter" on vertical touchpad scrolling.
+#     This feature can be toggled via "idea.true.smooth.scrolling.dynamic.scrollbars" option.
+#-----------------------------------------------------------------------
+#idea.true.smooth.scrolling=true
+
+#---------------------------------------------------------------------
+# IDEA can copy library .jar files to prevent their locking.
+# By default this behavior is enabled on Windows and disabled on other platforms.
+# Uncomment this property to override.
+#---------------------------------------------------------------------
+# idea.jars.nocopy=false
+
+#---------------------------------------------------------------------
+# The VM option value to be used to start a JVM in debug mode.
+# Some JREs define it in a different way (-XXdebug in Oracle VM)
+#---------------------------------------------------------------------
+idea.xdebug.key=-Xdebug
+
+#-----------------------------------------------------------------------
+# Change to 'disabled' if you don't want to receive instant visual notifications
+# about fatal errors that happen to an IDE or plugins installed.
+#-----------------------------------------------------------------------
+idea.fatal.error.notification=enabled
diff --git a/ui/studio_versions.properties b/ui/studio_versions.properties
index 8027bee..5314dfe 100644
--- a/ui/studio_versions.properties
+++ b/ui/studio_versions.properties
@@ -4,6 +4,6 @@
 # the version of the Android Gradle Plugin
 agp=3.4.0
 # version properties for studiow, which should correspond to the version of AGP
-studio_version=
-idea_major_version=
-studio_build_number=20190503
+studio_version=3.4.1.0
+idea_major_version=183
+studio_build_number=5535458
diff --git a/ui/studiow b/ui/studiow
index 8982c3b..db74d69 100755
--- a/ui/studiow
+++ b/ui/studiow
@@ -11,8 +11,12 @@
   ideaMajorVersion="$(grep "idea_major_version=" ${propertiesFile} | sed 's/[^=]*=//')"
   buildNumber="$(grep "studio_build_number=" ${propertiesFile} | sed 's/[^=]*=//')"
   osName="$1"
-  # Trusted server maintained by the Compose team to host internal builds of compose in a maven repository.
-  studioUrl="https://us-central1-kompose-219700.cloudfunctions.net/as-r4a/$buildNumber/android-studio-$buildNumber.$osName.zip"
+  if [ "${osName}" == "linux" ]; then
+    extension="tar.gz"
+  else
+    extension="zip"
+  fi
+  studioUrl="https://dl.google.com/dl/android/studio/ide-zips/${version}/android-studio-ide-${ideaMajorVersion}.${buildNumber}-${osName}.${extension}"
   echo "${studioUrl}"
 }
 
@@ -34,7 +38,7 @@
 studioUrl="$(getStudioUrl $osName)"
 studioDestName="$(basename ${studioUrl})"
 studioZipPath="${tempDir}/${studioDestName}"
-studioUnzippedPath="$(echo ${studioZipPath} | sed 's/\.zip$//')"
+studioUnzippedPath="$(echo ${studioZipPath} | sed 's/\.zip$//' | sed 's/\.tar.gz$//')"
 
 function error_exit {
     echo "$1" >&2   ## Send message to stderr.
@@ -45,13 +49,29 @@
   fromUrl="$1"
   destPath="$2"
   tempPath="${destPath}.tmp"
-  r4a_username=$(grep 'r4a_username=' ~/.gradle/gradle.properties | sed 's/^[^=]*=//')
-  r4a_password=$(grep 'r4a_password=' ~/.gradle/gradle.properties | sed 's/^[^=]*=//')
-  [ -z "$r4a_username" ] && error_exit "r4a_username could not be found in ~/.gradle/gradle.properties.
-  [ -z "$r4a_password" ] && error_exit "r4a_password could not be found in ~/.gradle/gradle.properties.
-  echo "Downloading ${fromUrl} to ${destPath}"
-  curl -L -u $r4a_username:$r4a_password "${fromUrl}" > "${tempPath}"
-  mv "${tempPath}" "${destPath}"
+  if [ -f "${destPath}" ]; then
+    read -r -n 1 -p "File already exists. Do you want to delete and re-download? [Y/n]? " reply
+
+    if [ ! -z "${reply}" ]; then
+      # Fix missing newline
+      echo
+    fi
+
+    case "${reply}" in
+      [yY]|"")
+        rm "${destPath}"
+        ;;
+      *)
+    esac
+  fi
+
+  if [ -f "${destPath}" ]; then
+    echo "Using existing file from ${destPath}"
+  else
+    echo "Downloading ${fromUrl} to ${destPath}"
+    curl "${fromUrl}" > "${tempPath}"
+    mv "${tempPath}" "${destPath}"
+  fi
 }
 
 function findStudioMacAppPath() {
@@ -110,7 +130,12 @@
   ls "${tempDir}" | grep -v "^${studioDestName}\$" | sed "s|^|${tempDir}/|" | xargs rm -rf
 
   echo "Unzipping"
-  unzip "${studioZipPath}" -d "${studioUnzippedPath}"
+  if [ "${osName}" == "linux" ]; then
+    mkdir $studioUnzippedPath
+    tar -xzf "${studioZipPath}" --directory "${studioUnzippedPath}"
+  else
+    unzip "${studioZipPath}" -d "${studioUnzippedPath}"
+  fi
 }
 
 function ensureComposeAt() {
@@ -149,7 +174,7 @@
 function runStudioLinux() {
   studioPath="${studioUnzippedPath}/android-studio/bin/studio.sh"
   echo "$studioPath &"
-  env STUDIO_PROPERTIES="${projectDir}/../development/studio/idea.properties" \
+  env STUDIO_PROPERTIES="${projectDir}/idea.properties" \
       STUDIO_VM_OPTIONS="${projectDir}/../development/studio/studio.vmoptions" \
       KOTLIN_OVERRIDE="1.3.30-compose-20190503" \
       "${studioPath}" "${projectDir}" &
@@ -158,7 +183,7 @@
 function runStudioMac() {
   appPath="$(findStudioMacAppPath)"
   echo "open ${appPath}"
-  env STUDIO_PROPERTIES="${projectDir}/../development/studio/idea.properties" \
+  env STUDIO_PROPERTIES="${projectDir}/idea.properties" \
       STUDIO_VM_OPTIONS="${projectDir}/../development/studio/studio.vmoptions" \
       KOTLIN_OVERRIDE="1.3.30-compose-20190503" \
       open -a "${appPath}" "${projectDir}"