mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Android support for changing bundle location
Summary: With this, you can load the bundle from another server on the fly. This makes it much easier to hit a named server. Reviewed By: makovkastar Differential Revision: D16076020 fbshipit-source-id: 46d78ccd55b9b11481628f4585030494f9282003
This commit is contained in:
committed by
Facebook Github Bot
parent
10d80b8a78
commit
3468af54ce
@@ -18,6 +18,7 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Pair;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.common.logging.FLog;
|
||||
@@ -457,6 +458,41 @@ public class DevSupportManagerImpl
|
||||
}
|
||||
});
|
||||
}
|
||||
options.put(
|
||||
mApplicationContext.getString(R.string.catalyst_change_bundle_location),
|
||||
new DevOptionHandler() {
|
||||
@Override
|
||||
public void onOptionSelected() {
|
||||
Activity context = mReactInstanceManagerHelper.getCurrentActivity();
|
||||
if (context == null || context.isFinishing()) {
|
||||
FLog.e(
|
||||
ReactConstants.TAG,
|
||||
"Unable to launch change bundle location because react activity is not available");
|
||||
return;
|
||||
}
|
||||
|
||||
final EditText input = new EditText(context);
|
||||
input.setHint("localhost:8081");
|
||||
|
||||
AlertDialog bundleLocationDialog =
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(
|
||||
mApplicationContext.getString(R.string.catalyst_change_bundle_location))
|
||||
.setView(input)
|
||||
.setPositiveButton(
|
||||
android.R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String host = input.getText().toString();
|
||||
mDevSettings.getPackagerConnectionSettings().setDebugServerHost(host);
|
||||
handleReloadJS();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
bundleLocationDialog.show();
|
||||
}
|
||||
});
|
||||
options.put(
|
||||
// NOTE: `isElementInspectorEnabled` is not guaranteed to be accurate.
|
||||
mApplicationContext.getString(R.string.catalyst_inspector),
|
||||
|
||||
+4
@@ -52,6 +52,10 @@ public class PackagerConnectionSettings {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setDebugServerHost(String host) {
|
||||
mPreferences.edit().putString(PREFS_DEBUG_SERVER_HOST_KEY, host).apply();
|
||||
}
|
||||
|
||||
public String getInspectorServerHost() {
|
||||
return AndroidInfoHelpers.getInspectorProxyHost(mAppContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user