WIP: Fixing swap UI for earlier versions of Android.
Replaced `Switch` with `SwitchCompat`. In the future, should completely remove F-Droid's `SwitchCompat` class. Fixed paddingLeft/paddingStart, except for some places where lint complained. Apparantly that is for some Samsung tablets on Android-16. Will have to create a layout-v17 version in the end for these.
This commit is contained in:
parent
0e5c039536
commit
760eae5a7b
@ -10,6 +10,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:titleTextAppearance="@style/SwapTheme.Wizard.Text"
|
||||
titleTextAppearance="@style/SwapTheme.Wizard.Text"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary" />
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- TODO: Add paddingStart in places where there is only paddingLeft. However Android Studio lint
|
||||
gives an error, which is discussed here:
|
||||
http://stackoverflow.com/questions/27449776/conflicting-lint-messages-regarding-paddingstart-usage?lq=1
|
||||
-->
|
||||
<org.fdroid.fdroid.views.swap.StartSwapView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
@ -27,8 +31,10 @@
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_info_white"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
/>
|
||||
@ -39,7 +45,8 @@
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:padding="20dp"
|
||||
android:paddingStart="30dp"
|
||||
android:paddingLeft="30dp"
|
||||
android:paddingRight="30dp"
|
||||
android:paddingEnd="30dp"
|
||||
android:textAlignment="center"
|
||||
android:text="@string/swap_intro"
|
||||
@ -65,6 +72,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingStart="15dp"
|
||||
android:layout_weight="1.00">
|
||||
|
||||
@ -84,7 +92,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Switch
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:checked="true"
|
||||
@ -108,6 +116,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingStart="15dp"
|
||||
android:layout_weight="1.00">
|
||||
|
||||
@ -135,7 +144,7 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Switch
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:checked="false"
|
||||
@ -178,7 +187,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/swap_cant_find_peers"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:textColor="@color/swap_light_text" />
|
||||
|
||||
@ -191,10 +200,12 @@
|
||||
android:id="@+id/btn_send_fdroid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@drawable/ic_fdroid_grey"
|
||||
android:drawableStart="@drawable/ic_fdroid_grey"
|
||||
android:text="@string/swap_send_fdroid"
|
||||
android:drawablePadding="10dp"
|
||||
android:paddingStart="25dp"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingRight="25dp"
|
||||
android:paddingEnd="25dp"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
@ -202,10 +213,12 @@
|
||||
android:id="@+id/btn_qr_scanner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@drawable/ic_qr_grey"
|
||||
android:drawableStart="@drawable/ic_qr_grey"
|
||||
android:text="@string/swap_scan_qr_code"
|
||||
android:drawablePadding="10dp"
|
||||
android:paddingStart="25dp"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingRight="25dp"
|
||||
android:paddingEnd="25dp"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
|
@ -1,72 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/fdroid_blue"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/device_name_prefix"
|
||||
android:text="@string/swap_bluetooth_your_device"
|
||||
android:gravity="center_horizontal"
|
||||
style="@style/SwapTheme.BluetoothDeviceList.Heading"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/device_name"
|
||||
tools:text="Phone v2.0"
|
||||
android:gravity="center_horizontal"
|
||||
style="@style/SwapTheme.BluetoothDeviceList.Heading"
|
||||
android:paddingBottom="5dp"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/device_address"
|
||||
tools:text="(01:02:03:ab:cd:ef)"
|
||||
android:gravity="center_horizontal"
|
||||
style="@style/SwapTheme.BluetoothDeviceList.Heading"
|
||||
android:paddingBottom="10dp"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/swap_bluetooth_select_or_scan"
|
||||
android:gravity="center_horizontal"
|
||||
style="@style/SwapTheme.BluetoothDeviceList.Text"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:textColor="@color/white"
|
||||
|
||||
/>
|
||||
|
||||
<android.support.v4.widget.ContentLoadingProgressBar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/loading_indicator"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:visibility="gone"
|
||||
android:indeterminate="true"
|
||||
style="?android:attr/android:progressBarStyleHorizontal"/>
|
||||
|
||||
</LinearLayout>
|
@ -34,13 +34,11 @@
|
||||
</style>
|
||||
|
||||
<style name="SwapTheme.Wizard" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!--<item name="android:windowBackground">@drawable/swap_window_background</item>-->
|
||||
<!--<item name="android:actionBarStyle">@style/Widget.AppCompat.ActionBar.Solid</item>-->
|
||||
<item name="actionButtonStyle">@style/SwapTheme.Wizard.ActionButton</item>
|
||||
<item name="colorButtonNormal">@color/swap_bright_blue</item>
|
||||
<item name="android:windowBackground">@drawable/swap_window_background</item>
|
||||
<item name="android:actionBarStyle">@style/Widget.AppCompat.ActionBar.Solid</item>
|
||||
<item name="android:actionButtonStyle">@style/SwapTheme.Wizard.ActionButton</item>
|
||||
<item name="actionButtonStyle">@style/SwapTheme.Wizard.ActionButton</item>
|
||||
<item name="actionBarStyle">@style/Widget.AppCompat.ActionBar.Solid</item>
|
||||
</style>
|
||||
|
||||
<style name="SwapTheme.StartSwap" parent="AppThemeLight">
|
||||
@ -53,16 +51,6 @@
|
||||
<style name="SwapTheme.BluetoothDeviceList" parent="@style/SwapTheme.Wizard">
|
||||
</style>
|
||||
|
||||
<style name="SwapTheme.BluetoothDeviceList.ListItem" parent="AppThemeDark">
|
||||
</style>
|
||||
|
||||
<style name="SwapTheme.BluetoothDeviceList.Text" parent="@style/SwapTheme.BluetoothDeviceList">
|
||||
</style>
|
||||
|
||||
<style name="SwapTheme.BluetoothDeviceList.Heading" parent="@style/SwapTheme.BluetoothDeviceList.Text">
|
||||
<item name="android:textSize">32.5dp</item> <!-- 58px * 96dpi / 160dpi = 32.5sp -->
|
||||
</style>
|
||||
|
||||
<style name="SwapTheme.AppList" parent="AppThemeLight">
|
||||
</style>
|
||||
|
||||
|
@ -66,6 +66,7 @@ import java.util.TimerTask;
|
||||
* TODO: Remove peers from list of peers when no longer "visible".
|
||||
* TODO: Show feedback for "Setting up (wifi|bluetooth)" in start swap view.
|
||||
* TODO: Turn off bluetooth after cancelling/timing out if we turned it on.
|
||||
* TODO: Disable the Scan QR button unless visible via something. Could equally show relevant feedback.
|
||||
*
|
||||
*/
|
||||
public class SwapService extends Service {
|
||||
|
@ -43,6 +43,8 @@ public class WifiSwap extends SwapType {
|
||||
public void start() {
|
||||
|
||||
Log.d(TAG, "Preparing swap webserver.");
|
||||
sendBroadcast(SwapService.EXTRA_STARTING);
|
||||
|
||||
Runnable webServer = new Runnable() {
|
||||
// Tell Eclipse this is not a leak because of Looper use.
|
||||
@SuppressLint("HandlerLeak")
|
||||
@ -66,7 +68,6 @@ public class WifiSwap extends SwapType {
|
||||
};
|
||||
try {
|
||||
Log.d(TAG, "Starting swap webserver...");
|
||||
sendBroadcast(SwapService.EXTRA_STARTING);
|
||||
localHttpd.start();
|
||||
setConnected(true);
|
||||
Log.d(TAG, "Swap webserver started.");
|
||||
@ -92,12 +93,12 @@ public class WifiSwap extends SwapType {
|
||||
public void stop() {
|
||||
if (webServerThreadHandler == null) {
|
||||
Log.i(TAG, "null handler in stopWebServer");
|
||||
return;
|
||||
} else {
|
||||
Log.d(TAG, "Sending message to swap webserver to stop it.");
|
||||
Message msg = webServerThreadHandler.obtainMessage();
|
||||
msg.obj = webServerThreadHandler.getLooper().getThread().getName() + " says stop";
|
||||
webServerThreadHandler.sendMessage(msg);
|
||||
}
|
||||
Log.d(TAG, "Sending message to swap webserver to stop it.");
|
||||
Message msg = webServerThreadHandler.obtainMessage();
|
||||
msg.obj = webServerThreadHandler.getLooper().getThread().getName() + " says stop";
|
||||
webServerThreadHandler.sendMessage(msg);
|
||||
bonjourBroadcast.stop();
|
||||
}
|
||||
|
||||
|
@ -163,11 +163,11 @@ public class WifiStateChangeService extends Service {
|
||||
WifiStateChangeService.this.stopSelf();
|
||||
|
||||
Intent swapService = new Intent(WifiStateChangeService.this, SwapService.class);
|
||||
bindService(swapService, new ServiceConnection() {
|
||||
getApplicationContext().bindService(swapService, new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
((SwapService.Binder)service).getService().restartWifiIfEnabled();
|
||||
unbindService(this);
|
||||
((SwapService.Binder) service).getService().restartWifiIfEnabled();
|
||||
getApplicationContext().unbindService(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ public class BluetoothConstants {
|
||||
// This can be an offline process, as long as it can be reproduced by other people who
|
||||
// want to do so.
|
||||
// This UUID is just from mashing random hex characters on the keyboard.
|
||||
return UUID.fromString("cd59ba31-5729-b3bb-cb29-732b59eu6gaa");
|
||||
return UUID.fromString("cd59ba31-5729-b3bb-cb29-732b59eb61aa");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@ -26,7 +27,6 @@ import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
@ -168,6 +168,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Unregister this receiver at the right time.
|
||||
LocalBroadcastManager.getInstance(getContext()).registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@ -211,7 +212,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
|
||||
int textResource = getManager().isBluetoothDiscoverable() ? R.string.swap_visible_bluetooth : R.string.swap_not_visible_bluetooth;
|
||||
textBluetoothVisible.setText(textResource);
|
||||
|
||||
final Switch bluetoothSwitch = ((Switch) findViewById(R.id.switch_bluetooth));
|
||||
final SwitchCompat bluetoothSwitch = ((SwitchCompat) findViewById(R.id.switch_bluetooth));
|
||||
bluetoothSwitch.setChecked(getManager().isBluetoothDiscoverable());
|
||||
bluetoothSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
@ -265,7 +266,7 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
|
||||
viewWifiId = (TextView)findViewById(R.id.device_id_wifi);
|
||||
viewWifiNetwork = (TextView)findViewById(R.id.wifi_network);
|
||||
|
||||
final Switch wifiSwitch = (Switch)findViewById(R.id.switch_wifi);
|
||||
final SwitchCompat wifiSwitch = (SwitchCompat)findViewById(R.id.switch_wifi);
|
||||
wifiSwitch.setChecked(getManager().isBonjourDiscoverable());
|
||||
wifiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
@ -281,6 +282,8 @@ public class StartSwapView extends ScrollView implements SwapWorkflowActivity.In
|
||||
});
|
||||
|
||||
final TextView textWifiVisible = (TextView)findViewById(R.id.wifi_visible);
|
||||
int textResource = getManager().isBonjourDiscoverable() ? R.string.swap_visible_wifi : R.string.swap_not_visible_wifi;
|
||||
textWifiVisible.setText(textResource);
|
||||
|
||||
// TODO: Unregister receiver correctly...
|
||||
LocalBroadcastManager.getInstance(getContext()).registerReceiver(new BroadcastReceiver() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user