reorder dev menu, surface live reload and perf monitor

Differential Revision: D2663707

fb-gh-sync-id: 42663a14e1bda7896867692473ae0bf3753aafe2
This commit is contained in:
Felix Oghină
2015-11-17 08:11:04 -08:00
committed by facebook-github-bot-7
parent 8491b579c8
commit e22fb312d2
4 changed files with 69 additions and 47 deletions

View File

@@ -50,6 +50,10 @@ public class DevInternalSettings implements
return mPreferences.getBoolean(PREFS_FPS_DEBUG_KEY, false);
}
public void setFpsDebugEnabled(boolean enabled) {
mPreferences.edit().putBoolean(PREFS_FPS_DEBUG_KEY, enabled).apply();
}
@Override
public boolean isAnimationFpsDebugEnabled() {
return mPreferences.getBoolean(PREFS_ANIMATIONS_DEBUG_KEY, false);
@@ -75,4 +79,8 @@ public class DevInternalSettings implements
public boolean isReloadOnJSChangeEnabled() {
return mPreferences.getBoolean(PREFS_RELOAD_ON_JS_CHANGE_KEY, false);
}
public void setReloadOnJSChangeEnabled(boolean enabled) {
mPreferences.edit().putBoolean(PREFS_RELOAD_ON_JS_CHANGE_KEY, enabled).apply();
}
}

View File

@@ -255,12 +255,13 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler {
}
});
options.put(
mApplicationContext.getString(R.string.catalyst_settings), new DevOptionHandler() {
mDevSettings.isReloadOnJSChangeEnabled()
? mApplicationContext.getString(R.string.catalyst_live_reload_off)
: mApplicationContext.getString(R.string.catalyst_live_reload),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
Intent intent = new Intent(mApplicationContext, DevSettingsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mApplicationContext.startActivity(intent);
mDevSettings.setReloadOnJSChangeEnabled(!mDevSettings.isReloadOnJSChangeEnabled());
}
});
options.put(
@@ -271,12 +272,21 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler {
mReactInstanceCommandsHandler.toggleElementInspector();
}
});
options.put(
mDevSettings.isFpsDebugEnabled()
? mApplicationContext.getString(R.string.catalyst_perf_monitor_off)
: mApplicationContext.getString(R.string.catalyst_perf_monitor),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
mDevSettings.setFpsDebugEnabled(!mDevSettings.isFpsDebugEnabled());
}
});
if (mCurrentContext != null &&
mCurrentContext.getCatalystInstance() != null &&
!mCurrentContext.getCatalystInstance().isDestroyed() &&
mCurrentContext.getCatalystInstance().getBridge() != null &&
mCurrentContext.getCatalystInstance().getBridge().supportsProfiling()) {
mCurrentContext.getCatalystInstance() != null &&
!mCurrentContext.getCatalystInstance().isDestroyed() &&
mCurrentContext.getCatalystInstance().getBridge() != null &&
mCurrentContext.getCatalystInstance().getBridge().supportsProfiling()) {
options.put(
mApplicationContext.getString(
mIsCurrentlyProfiling ? R.string.catalyst_stop_profile :
@@ -310,6 +320,15 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler {
}
});
}
options.put(
mApplicationContext.getString(R.string.catalyst_settings), new DevOptionHandler() {
@Override
public void onOptionSelected() {
Intent intent = new Intent(mApplicationContext, DevSettingsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mApplicationContext.startActivity(intent);
}
});
if (mCustomDevOptions.size() > 0) {
options.putAll(mCustomDevOptions);
@@ -317,21 +336,24 @@ public class DevSupportManager implements NativeModuleCallExceptionHandler {
final DevOptionHandler[] optionHandlers = options.values().toArray(new DevOptionHandler[0]);
mDevOptionsDialog = new AlertDialog.Builder(mApplicationContext)
.setItems(options.keySet().toArray(new String[0]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
optionHandlers[which].onOptionSelected();
mDevOptionsDialog = null;
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mDevOptionsDialog = null;
}
})
.create();
mDevOptionsDialog =
new AlertDialog.Builder(mApplicationContext)
.setItems(
options.keySet().toArray(new String[0]),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
optionHandlers[which].onOptionSelected();
mDevOptionsDialog = null;
}
})
.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mDevOptionsDialog = null;
}
})
.create();
mDevOptionsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mDevOptionsDialog.show();
}