mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Merge branch '184-background-threads' into 'master'
Do Bluetooth Adapter enabling/disabling in background thread Also set the default preferences in a background thread when app starts. Closes #184 See merge request !66
This commit is contained in:
@@ -17,6 +17,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.panic.PanicPreferencesActivity;
|
import org.briarproject.android.panic.PanicPreferencesActivity;
|
||||||
|
import org.briarproject.android.util.AndroidUtils;
|
||||||
import org.briarproject.android.util.FixedVerticalSpace;
|
import org.briarproject.android.util.FixedVerticalSpace;
|
||||||
import org.briarproject.android.util.HorizontalBorder;
|
import org.briarproject.android.util.HorizontalBorder;
|
||||||
import org.briarproject.android.util.LayoutUtils;
|
import org.briarproject.android.util.LayoutUtils;
|
||||||
@@ -330,8 +331,7 @@ OnClickListener {
|
|||||||
bluetoothSetting = !bluetoothSetting;
|
bluetoothSetting = !bluetoothSetting;
|
||||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
if (bluetoothSetting) adapter.enable();
|
AndroidUtils.setBluetooth(adapter, bluetoothSetting);
|
||||||
else adapter.disable();
|
|
||||||
}
|
}
|
||||||
storeBluetoothSetting();
|
storeBluetoothSetting();
|
||||||
displaySettings();
|
displaySettings();
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
logo.setImageResource(R.drawable.briar_logo_large);
|
logo.setImageResource(R.drawable.briar_logo_large);
|
||||||
layout.addView(logo);
|
layout.addView(logo);
|
||||||
|
|
||||||
PreferenceManager
|
setPreferencesDefaults();
|
||||||
.setDefaultValues(this, R.xml.panic_preferences, false);
|
|
||||||
|
|
||||||
setContentView(layout);
|
setContentView(layout);
|
||||||
}
|
}
|
||||||
@@ -111,4 +110,15 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
if (f.isFile()) f.delete();
|
if (f.isFile()) f.delete();
|
||||||
else if (f.isDirectory()) for (File child : f.listFiles()) delete(child);
|
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.R;
|
||||||
import org.briarproject.android.BriarActivity;
|
import org.briarproject.android.BriarActivity;
|
||||||
|
import org.briarproject.android.util.AndroidUtils;
|
||||||
import org.briarproject.api.TransportConfig;
|
import org.briarproject.api.TransportConfig;
|
||||||
import org.briarproject.api.TransportId;
|
import org.briarproject.api.TransportId;
|
||||||
import org.briarproject.api.android.ReferenceManager;
|
import org.briarproject.api.android.ReferenceManager;
|
||||||
@@ -333,7 +334,7 @@ implements InvitationListener {
|
|||||||
if (LOG.isLoggable(INFO)) LOG.info("Turning off Bluetooth again");
|
if (LOG.isLoggable(INFO)) LOG.info("Turning off Bluetooth again");
|
||||||
|
|
||||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
if (adapter != null) adapter.disable();
|
if (adapter != null) AndroidUtils.setBluetooth(adapter, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.android.util;
|
package org.briarproject.android.util;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
|
|
||||||
@@ -32,4 +33,16 @@ public class AndroidUtils {
|
|||||||
} else
|
} else
|
||||||
til.setError(null);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user