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: {},
|
||||
},
|
||||
app: {
|
||||
getPath: (path: string) => `/${path}`,
|
||||
getAppPath: process.cwd,
|
||||
getVersion: () => '0.9.99',
|
||||
relaunch: () => {},
|
||||
|
||||
@@ -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<Props, State> {
|
||||
}}>
|
||||
<FilePathConfigField
|
||||
label="Android SDK Location"
|
||||
resetValue={DEFAULT_ANDROID_SDK_PATH}
|
||||
defaultValue={this.state.updatedSettings.androidHome}
|
||||
onChange={v => {
|
||||
this.setState({
|
||||
|
||||
@@ -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: {
|
||||
}>
|
||||
<CenteredGlyph name="dots-3-circle" variant="outline" />
|
||||
</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 : (
|
||||
<CenteredGlyph name="caution-triangle" color={colors.yellow} />
|
||||
)}
|
||||
|
||||
@@ -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`;
|
||||
}
|
||||
|
||||
@@ -326,5 +326,8 @@
|
||||
],
|
||||
"code": [
|
||||
12
|
||||
],
|
||||
"undo-outline": [
|
||||
16
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user