start the local repo webserver by default when going to LocalRepoActivity

To make it dead simple to swap repos when going to the Local Repos screen.
This commit is contained in:
Hans-Christoph Steiner 2014-05-07 22:30:26 -04:00
parent 2256cd00e1
commit 16399b760b

View File

@ -53,6 +53,11 @@ public class LocalRepoActivity extends Activity {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
resetNetworkInfo(); resetNetworkInfo();
// start repo by default
setRepoSwitchChecked(true);
FDroidApp.startLocalRepoService(LocalRepoActivity.this);
LocalBroadcastManager.getInstance(this).registerReceiver(onWifiChange, LocalBroadcastManager.getInstance(this).registerReceiver(onWifiChange,
new IntentFilter(WifiStateChangeService.BROADCAST)); new IntentFilter(WifiStateChangeService.BROADCAST));
// if no local repo exists, create one with only FDroid in it // if no local repo exists, create one with only FDroid in it
@ -162,17 +167,25 @@ public class LocalRepoActivity extends Activity {
repoSwitch.setOnClickListener(new View.OnClickListener() { repoSwitch.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setRepoSwitchChecked(repoSwitch.isChecked());
if (repoSwitch.isChecked()) { if (repoSwitch.isChecked()) {
FDroidApp.startLocalRepoService(LocalRepoActivity.this); FDroidApp.startLocalRepoService(LocalRepoActivity.this);
repoSwitch.setText(R.string.local_repo_running);
} else { } else {
FDroidApp.stopLocalRepoService(LocalRepoActivity.this); FDroidApp.stopLocalRepoService(LocalRepoActivity.this);
repoSwitch.setText(R.string.touch_to_turn_on_local_repo);
} }
} }
}); });
} }
private void setRepoSwitchChecked(boolean checked) {
repoSwitch.setChecked(checked);
if (checked) {
repoSwitch.setText(R.string.local_repo_running);
} else {
repoSwitch.setText(R.string.touch_to_turn_on_local_repo);
}
}
@TargetApi(14) @TargetApi(14)
private void setUIFromWifi() { private void setUIFromWifi() {
if (TextUtils.isEmpty(FDroidApp.repo.address)) if (TextUtils.isEmpty(FDroidApp.repo.address))