quick improvement of LocalRepoActivity layout
This is meant to try to make the on/off state of the webserver that serves the local repo more apparent.
This commit is contained in:
parent
8d3d325967
commit
7401366ac9
@ -4,23 +4,50 @@
|
|||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
<ToggleButton
|
<Button
|
||||||
|
android:id="@+id/enable_wifi"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/enable_wifi" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
android:id="@+id/repoSwitch"
|
android:id="@+id/repoSwitch"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="15dp"
|
||||||
|
android:text="@string/touch_to_turn_on_local_repo" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/sharing_uri" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sharing_uri"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:typeface="monospace" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" >
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifiNetwork"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:text="@string/wifi_network" />
|
android:text="@string/wifi_network" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifiNetworkName"
|
android:id="@+id/wifi_network"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginLeft="15dp"
|
android:layout_marginLeft="15dp"
|
||||||
|
@ -156,6 +156,8 @@
|
|||||||
<string name="local_repo_running">Your local FDroid repo is accessible.</string>
|
<string name="local_repo_running">Your local FDroid repo is accessible.</string>
|
||||||
<string name="setup_repo">Setup Local Repo</string>
|
<string name="setup_repo">Setup Local Repo</string>
|
||||||
<string name="touch_to_configure_local_repo">Touch to setup your local repo.</string>
|
<string name="touch_to_configure_local_repo">Touch to setup your local repo.</string>
|
||||||
|
<string name="touch_to_turn_on_local_repo">Touch to turn on your local repo.</string>
|
||||||
|
<string name="touch_to_turn_off_local_repo">Touch to turn off your local repo.</string>
|
||||||
<string name="updating">Updating…</string>
|
<string name="updating">Updating…</string>
|
||||||
<string name="update_repo">Update Repo</string>
|
<string name="update_repo">Update Repo</string>
|
||||||
<string name="deleting_repo">Deleting current repo…</string>
|
<string name="deleting_repo">Deleting current repo…</string>
|
||||||
@ -168,6 +170,7 @@
|
|||||||
<string name="icon">icon</string>
|
<string name="icon">icon</string>
|
||||||
<string name="fingerprint">Fingerprint:</string>
|
<string name="fingerprint">Fingerprint:</string>
|
||||||
<string name="wifi_network">WiFi Network:</string>
|
<string name="wifi_network">WiFi Network:</string>
|
||||||
|
<string name="sharing_uri">Sharing URL:</string>
|
||||||
<string name="enable_wifi">Enable WiFi</string>
|
<string name="enable_wifi">Enable WiFi</string>
|
||||||
<string name="enabling_wifi">Enabling WiFi…</string>
|
<string name="enabling_wifi">Enabling WiFi…</string>
|
||||||
<string name="same_wifi_instructions">To connect to other people\'s devices, make sure both devices are on the same WiFi network. Then either type the URL above into F-Droid, or scan this QR Code:</string>
|
<string name="same_wifi_instructions">To connect to other people\'s devices, make sure both devices are on the same WiFi network. Then either type the URL above into F-Droid, or scan this QR Code:</string>
|
||||||
|
@ -19,9 +19,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.TextView;
|
import android.widget.*;
|
||||||
import android.widget.Toast;
|
|
||||||
import android.widget.ToggleButton;
|
|
||||||
|
|
||||||
import org.fdroid.fdroid.*;
|
import org.fdroid.fdroid.*;
|
||||||
import org.fdroid.fdroid.net.WifiStateChangeService;
|
import org.fdroid.fdroid.net.WifiStateChangeService;
|
||||||
@ -33,7 +31,8 @@ public class LocalRepoActivity extends Activity {
|
|||||||
private ProgressDialog repoProgress;
|
private ProgressDialog repoProgress;
|
||||||
|
|
||||||
private WifiManager wifiManager;
|
private WifiManager wifiManager;
|
||||||
private ToggleButton repoSwitch;
|
private Button enableWifiButton;
|
||||||
|
private CheckBox repoSwitch;
|
||||||
|
|
||||||
private int SET_IP_ADDRESS = 7345;
|
private int SET_IP_ADDRESS = 7345;
|
||||||
private int UPDATE_REPO = 7346;
|
private int UPDATE_REPO = 7346;
|
||||||
@ -45,7 +44,8 @@ public class LocalRepoActivity extends Activity {
|
|||||||
((FDroidApp) getApplication()).applyTheme(this);
|
((FDroidApp) getApplication()).applyTheme(this);
|
||||||
setContentView(R.layout.local_repo_activity);
|
setContentView(R.layout.local_repo_activity);
|
||||||
|
|
||||||
repoSwitch = (ToggleButton) findViewById(R.id.repoSwitch);
|
enableWifiButton = (Button) findViewById(R.id.enable_wifi);
|
||||||
|
repoSwitch = (CheckBox) findViewById(R.id.repoSwitch);
|
||||||
wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,14 +80,17 @@ public class LocalRepoActivity extends Activity {
|
|||||||
if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
|
if (wifiState == WifiManager.WIFI_STATE_ENABLED) {
|
||||||
setUIFromWifi();
|
setUIFromWifi();
|
||||||
wireRepoSwitchToWebServer();
|
wireRepoSwitchToWebServer();
|
||||||
|
repoSwitch.setVisibility(View.VISIBLE);
|
||||||
|
enableWifiButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
repoSwitch.setChecked(false);
|
repoSwitch.setChecked(false);
|
||||||
repoSwitch.setText(R.string.enable_wifi);
|
repoSwitch.setVisibility(View.GONE);
|
||||||
repoSwitch.setTextOn(getString(R.string.enabling_wifi));
|
enableWifiButton.setVisibility(View.VISIBLE);
|
||||||
repoSwitch.setTextOff(getString(R.string.enable_wifi));
|
enableWifiButton.setText(R.string.enable_wifi);
|
||||||
repoSwitch.setOnClickListener(new View.OnClickListener() {
|
enableWifiButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
enableWifiButton.setText(R.string.enabling_wifi);
|
||||||
wifiManager.setWifiEnabled(true);
|
wifiManager.setWifiEnabled(true);
|
||||||
/*
|
/*
|
||||||
* Once the wifi is connected to a network, then
|
* Once the wifi is connected to a network, then
|
||||||
@ -161,8 +164,10 @@ public class LocalRepoActivity extends Activity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -174,9 +179,8 @@ public class LocalRepoActivity extends Activity {
|
|||||||
return;
|
return;
|
||||||
// the fingerprint is not useful on the button label
|
// the fingerprint is not useful on the button label
|
||||||
String buttonLabel = FDroidApp.repo.address.replaceAll("\\?.*$", "");
|
String buttonLabel = FDroidApp.repo.address.replaceAll("\\?.*$", "");
|
||||||
repoSwitch.setText(buttonLabel);
|
TextView sharingUriTextView = (TextView) findViewById(R.id.sharing_uri);
|
||||||
repoSwitch.setTextOn(buttonLabel);
|
sharingUriTextView.setText(buttonLabel);
|
||||||
repoSwitch.setTextOff(buttonLabel);
|
|
||||||
/*
|
/*
|
||||||
* Set URL to UPPER for compact QR Code, FDroid will translate it back.
|
* Set URL to UPPER for compact QR Code, FDroid will translate it back.
|
||||||
* Remove the SSID from the query string since SSIDs are case-sensitive.
|
* Remove the SSID from the query string since SSIDs are case-sensitive.
|
||||||
@ -192,7 +196,7 @@ public class LocalRepoActivity extends Activity {
|
|||||||
if (Build.VERSION.SDK_INT >= 8) // zxing requires >= 8
|
if (Build.VERSION.SDK_INT >= 8) // zxing requires >= 8
|
||||||
new QrGenAsyncTask(this, R.id.repoQrCode).execute(qrUriString);
|
new QrGenAsyncTask(this, R.id.repoQrCode).execute(qrUriString);
|
||||||
|
|
||||||
TextView wifiNetworkNameTextView = (TextView) findViewById(R.id.wifiNetworkName);
|
TextView wifiNetworkNameTextView = (TextView) findViewById(R.id.wifi_network);
|
||||||
wifiNetworkNameTextView.setText(FDroidApp.ssid);
|
wifiNetworkNameTextView.setText(FDroidApp.ssid);
|
||||||
|
|
||||||
TextView fingerprintTextView = (TextView) findViewById(R.id.fingerprint);
|
TextView fingerprintTextView = (TextView) findViewById(R.id.fingerprint);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user