Skip to content
Snippets Groups Projects
Verified Commit f9f3696f authored by Torsten Grote's avatar Torsten Grote
Browse files

run bluetooth adapter enabling/disabling in background thread

also run setting the default preferences in a background thread

Closes #184
parent 05a83dc3
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ import android.widget.TextView;
import org.briarproject.R;
import org.briarproject.android.panic.PanicPreferencesActivity;
import org.briarproject.android.util.AndroidUtils;
import org.briarproject.android.util.FixedVerticalSpace;
import org.briarproject.android.util.HorizontalBorder;
import org.briarproject.android.util.LayoutUtils;
......@@ -330,8 +331,7 @@ OnClickListener {
bluetoothSetting = !bluetoothSetting;
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
if (bluetoothSetting) adapter.enable();
else adapter.disable();
AndroidUtils.setBluetooth(adapter, bluetoothSetting);
}
storeBluetoothSetting();
displaySettings();
......
......@@ -65,8 +65,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
logo.setImageResource(R.drawable.briar_logo_large);
layout.addView(logo);
PreferenceManager
.setDefaultValues(this, R.xml.panic_preferences, false);
setPreferencesDefaults();
setContentView(layout);
}
......@@ -111,4 +110,15 @@ public class SplashScreenActivity extends RoboSplashActivity {
if (f.isFile()) f.delete();
else if (f.isDirectory()) for (File child : f.listFiles()) delete(child);
}
private void setPreferencesDefaults() {
new Thread() {
@Override
public void run() {
PreferenceManager
.setDefaultValues(SplashScreenActivity.this,
R.xml.panic_preferences, false);
}
}.start();
}
}
......@@ -7,6 +7,7 @@ import android.widget.Toast;
import org.briarproject.R;
import org.briarproject.android.BriarActivity;
import org.briarproject.android.util.AndroidUtils;
import org.briarproject.api.TransportConfig;
import org.briarproject.api.TransportId;
import org.briarproject.api.android.ReferenceManager;
......@@ -333,7 +334,7 @@ implements InvitationListener {
if (LOG.isLoggable(INFO)) LOG.info("Turning off Bluetooth again");
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) adapter.disable();
if (adapter != null) AndroidUtils.setBluetooth(adapter, false);
}
}
......
package org.briarproject.android.util;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.os.Build;
import android.support.design.widget.TextInputLayout;
......@@ -32,4 +33,16 @@ public class AndroidUtils {
} else
til.setError(null);
}
public static void setBluetooth(final BluetoothAdapter adapter,
final boolean activate) {
new Thread() {
@Override
public void run() {
if (activate) adapter.enable();
else adapter.disable();
}
}.start();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment