Setitngs: button to reset Android SDK path to default
Summary: Added button to reset Android SDK path to default + fixed default SDK path on Windows which I introduced in a previous diff and which before might be wrongly resolved to roaming data instead of local data folder Reviewed By: jknoxville Differential Revision: D19498899 fbshipit-source-id: e10865b528f55ea6b56873bdf9369c4b60dca89f
This commit is contained in:
committed by
Facebook Github Bot
parent
4f63d6435f
commit
7c03366136
@@ -13,6 +13,7 @@ module.exports = {
|
|||||||
env: {},
|
env: {},
|
||||||
},
|
},
|
||||||
app: {
|
app: {
|
||||||
|
getPath: (path: string) => `/${path}`,
|
||||||
getAppPath: process.cwd,
|
getAppPath: process.cwd,
|
||||||
getVersion: () => '0.9.99',
|
getVersion: () => '0.9.99',
|
||||||
relaunch: () => {},
|
relaunch: () => {},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
} from '../reducers/launcherSettings';
|
} from '../reducers/launcherSettings';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import {State as Store} from '../reducers';
|
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 {flush} from '../utils/persistor';
|
||||||
import ToggledSection from './settings/ToggledSection';
|
import ToggledSection from './settings/ToggledSection';
|
||||||
import {FilePathConfigField, ConfigText} from './settings/configFields';
|
import {FilePathConfigField, ConfigText} from './settings/configFields';
|
||||||
@@ -90,6 +90,7 @@ class SettingsSheet extends Component<Props, State> {
|
|||||||
}}>
|
}}>
|
||||||
<FilePathConfigField
|
<FilePathConfigField
|
||||||
label="Android SDK Location"
|
label="Android SDK Location"
|
||||||
|
resetValue={DEFAULT_ANDROID_SDK_PATH}
|
||||||
defaultValue={this.state.updatedSettings.androidHome}
|
defaultValue={this.state.updatedSettings.androidHome}
|
||||||
onChange={v => {
|
onChange={v => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const GreyedOutOverlay = styled.div({
|
|||||||
|
|
||||||
export function FilePathConfigField(props: {
|
export function FilePathConfigField(props: {
|
||||||
label: string;
|
label: string;
|
||||||
|
resetValue?: string;
|
||||||
defaultValue: string;
|
defaultValue: string;
|
||||||
onChange: (path: string) => void;
|
onChange: (path: string) => void;
|
||||||
frozen?: boolean;
|
frozen?: boolean;
|
||||||
@@ -103,6 +104,16 @@ export function FilePathConfigField(props: {
|
|||||||
}>
|
}>
|
||||||
<CenteredGlyph name="dots-3-circle" variant="outline" />
|
<CenteredGlyph name="dots-3-circle" variant="outline" />
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
|
{props.resetValue && (
|
||||||
|
<FlexColumn
|
||||||
|
title={`Reset to default path ${props.resetValue}`}
|
||||||
|
onClick={() => {
|
||||||
|
setValue(props.resetValue!);
|
||||||
|
props.onChange(props.resetValue!);
|
||||||
|
}}>
|
||||||
|
<CenteredGlyph name="undo" variant="outline" />
|
||||||
|
</FlexColumn>
|
||||||
|
)}
|
||||||
{isValid ? null : (
|
{isValid ? null : (
|
||||||
<CenteredGlyph name="caution-triangle" color={colors.yellow} />
|
<CenteredGlyph name="caution-triangle" color={colors.yellow} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -42,14 +42,10 @@ export type Action =
|
|||||||
payload: Settings;
|
payload: Settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getWindowsSdkPath() {
|
export const DEFAULT_ANDROID_SDK_PATH = getDefaultAndroidSdkPath();
|
||||||
const app = electron.app || electron.remote.app;
|
|
||||||
return `${app.getPath('userData')}\\android\\sdk`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const initialState: Settings = {
|
const initialState: Settings = {
|
||||||
androidHome:
|
androidHome: getDefaultAndroidSdkPath(),
|
||||||
os.platform() == 'win32' ? getWindowsSdkPath() : '/opt/android_sdk',
|
|
||||||
enableAndroid: true,
|
enableAndroid: true,
|
||||||
enablePrefetching: Tristate.Unset,
|
enablePrefetching: Tristate.Unset,
|
||||||
jsApps: {
|
jsApps: {
|
||||||
@@ -77,3 +73,12 @@ export function updateSettings(settings: Settings): Action {
|
|||||||
payload: settings,
|
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`;
|
||||||
|
}
|
||||||
|
|||||||
@@ -326,5 +326,8 @@
|
|||||||
],
|
],
|
||||||
"code": [
|
"code": [
|
||||||
12
|
12
|
||||||
|
],
|
||||||
|
"undo-outline": [
|
||||||
|
16
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user