diff --git a/__mocks__/electron.tsx b/__mocks__/electron.tsx index ee2e4bbe6..f1323d833 100644 --- a/__mocks__/electron.tsx +++ b/__mocks__/electron.tsx @@ -13,6 +13,7 @@ module.exports = { env: {}, }, app: { + getPath: (path: string) => `/${path}`, getAppPath: process.cwd, getVersion: () => '0.9.99', relaunch: () => {}, diff --git a/src/chrome/SettingsSheet.tsx b/src/chrome/SettingsSheet.tsx index b8130aef7..247a4c855 100644 --- a/src/chrome/SettingsSheet.tsx +++ b/src/chrome/SettingsSheet.tsx @@ -17,7 +17,7 @@ import { } from '../reducers/launcherSettings'; import {connect} from 'react-redux'; import {State as Store} from '../reducers'; -import {Settings} from '../reducers/settings'; +import {Settings, DEFAULT_ANDROID_SDK_PATH} from '../reducers/settings'; import {flush} from '../utils/persistor'; import ToggledSection from './settings/ToggledSection'; import {FilePathConfigField, ConfigText} from './settings/configFields'; @@ -90,6 +90,7 @@ class SettingsSheet extends Component { }}> { this.setState({ diff --git a/src/chrome/settings/configFields.tsx b/src/chrome/settings/configFields.tsx index 5019ac7d3..527d90cb1 100644 --- a/src/chrome/settings/configFields.tsx +++ b/src/chrome/settings/configFields.tsx @@ -51,6 +51,7 @@ const GreyedOutOverlay = styled.div({ export function FilePathConfigField(props: { label: string; + resetValue?: string; defaultValue: string; onChange: (path: string) => void; frozen?: boolean; @@ -103,6 +104,16 @@ export function FilePathConfigField(props: { }> + {props.resetValue && ( + { + setValue(props.resetValue!); + props.onChange(props.resetValue!); + }}> + + + )} {isValid ? null : ( )} diff --git a/src/reducers/settings.tsx b/src/reducers/settings.tsx index 5dc9cba27..571bd13cc 100644 --- a/src/reducers/settings.tsx +++ b/src/reducers/settings.tsx @@ -42,14 +42,10 @@ export type Action = payload: Settings; }; -function getWindowsSdkPath() { - const app = electron.app || electron.remote.app; - return `${app.getPath('userData')}\\android\\sdk`; -} +export const DEFAULT_ANDROID_SDK_PATH = getDefaultAndroidSdkPath(); const initialState: Settings = { - androidHome: - os.platform() == 'win32' ? getWindowsSdkPath() : '/opt/android_sdk', + androidHome: getDefaultAndroidSdkPath(), enableAndroid: true, enablePrefetching: Tristate.Unset, jsApps: { @@ -77,3 +73,12 @@ export function updateSettings(settings: Settings): Action { payload: settings, }; } + +function getDefaultAndroidSdkPath() { + return os.platform() === 'win32' ? getWindowsSdkPath() : '/opt/android_sdk'; +} + +function getWindowsSdkPath() { + const app = electron.app || electron.remote.app; + return `${app.getPath('home')}\\AppData\\Local\\android\\sdk`; +} diff --git a/static/icons.json b/static/icons.json index 47cae0825..d4c2e5f81 100644 --- a/static/icons.json +++ b/static/icons.json @@ -326,5 +326,8 @@ ], "code": [ 12 + ], + "undo-outline": [ + 16 ] -} +} \ No newline at end of file