From 16399b760be576b5b73049b04bfcf9567d1c091e Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 7 May 2014 22:30:26 -0400 Subject: [PATCH] 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. --- .../fdroid/fdroid/views/LocalRepoActivity.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/org/fdroid/fdroid/views/LocalRepoActivity.java b/src/org/fdroid/fdroid/views/LocalRepoActivity.java index d71d30129..84b7a912f 100644 --- a/src/org/fdroid/fdroid/views/LocalRepoActivity.java +++ b/src/org/fdroid/fdroid/views/LocalRepoActivity.java @@ -53,6 +53,11 @@ public class LocalRepoActivity extends Activity { public void onResume() { super.onResume(); resetNetworkInfo(); + + // start repo by default + setRepoSwitchChecked(true); + FDroidApp.startLocalRepoService(LocalRepoActivity.this); + LocalBroadcastManager.getInstance(this).registerReceiver(onWifiChange, new IntentFilter(WifiStateChangeService.BROADCAST)); // 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() { @Override public void onClick(View v) { + setRepoSwitchChecked(repoSwitch.isChecked()); if (repoSwitch.isChecked()) { FDroidApp.startLocalRepoService(LocalRepoActivity.this); - repoSwitch.setText(R.string.local_repo_running); } else { 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) private void setUIFromWifi() { if (TextUtils.isEmpty(FDroidApp.repo.address))