iii
This commit is contained in:
parent
5092d120a7
commit
9f7836f4f2
7 changed files with 96 additions and 198 deletions
|
@ -53,7 +53,6 @@ public class BluetoothChatFragment extends Fragment {
|
|||
|
||||
// Intent request codes
|
||||
private static final int REQUEST_CONNECT_DEVICE_SECURE = 1;
|
||||
private static final int REQUEST_CONNECT_DEVICE_INSECURE = 2;
|
||||
private static final int REQUEST_ENABLE_BT = 3;
|
||||
|
||||
// Layout Views
|
||||
|
@ -159,9 +158,9 @@ public class BluetoothChatFragment extends Fragment {
|
|||
mStopButton = (Button) view.findViewById(R.id.button_stop);
|
||||
mDisconnectButton = (Button) view.findViewById(R.id.button_disconnect);
|
||||
mLevel = (NumberPicker) view.findViewById(R.id.Level);
|
||||
mLevel.setMaxValue(16);
|
||||
mLevel.setMaxValue(32);
|
||||
mLevel.setMinValue(1);
|
||||
mLevel.setValue(5);
|
||||
mLevel.setValue(1);
|
||||
mLevel.setWrapSelectorWheel(false);
|
||||
mLevel.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||
mSpeedText = (TextView) view.findViewById(R.id.Speed);
|
||||
|
@ -411,12 +410,6 @@ public class BluetoothChatFragment extends Fragment {
|
|||
connectDevice(data, true);
|
||||
}
|
||||
break;
|
||||
case REQUEST_CONNECT_DEVICE_INSECURE:
|
||||
// When DeviceListActivity returns with a device to connect
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
connectDevice(data, false);
|
||||
}
|
||||
break;
|
||||
case REQUEST_ENABLE_BT:
|
||||
// When the request to enable Bluetooth returns
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
|
@ -463,17 +456,6 @@ public class BluetoothChatFragment extends Fragment {
|
|||
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_SECURE);
|
||||
return true;
|
||||
}
|
||||
case R.id.insecure_connect_scan: {
|
||||
// Launch the DeviceListActivity to see devices and do scan
|
||||
Intent serverIntent = new Intent(getActivity(), DeviceListActivity.class);
|
||||
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE_INSECURE);
|
||||
return true;
|
||||
}
|
||||
case R.id.discoverable: {
|
||||
// Ensure this device is discoverable by others
|
||||
ensureDiscoverable();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -196,10 +196,12 @@ public class BluetoothChatService extends Service {
|
|||
private void showNotification() {
|
||||
// In this sample, we'll use the same text for the ticker and the expanded notification
|
||||
CharSequence text = getText(R.string.local_service_started);
|
||||
Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
|
||||
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
// The PendingIntent to launch our activity if the user selects this notification
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
|
||||
new Intent(this, MainActivity.class), 0);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0,
|
||||
myIntent, 0);
|
||||
|
||||
// Set the info for the views that show in the notification panel.
|
||||
Notification notification = new Notification.Builder(this)
|
||||
|
|
|
@ -68,59 +68,6 @@ public class MainActivity extends FragmentActivity {
|
|||
Log.i(TAG, "Service started");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
|
||||
//logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
|
||||
logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
/*
|
||||
switch(item.getItemId()) {
|
||||
case R.id.menu_toggle_log:
|
||||
mLogShown = !mLogShown;
|
||||
ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
|
||||
if (mLogShown) {
|
||||
output.setDisplayedChild(1);
|
||||
} else {
|
||||
output.setDisplayedChild(0);
|
||||
}
|
||||
supportInvalidateOptionsMenu();
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
/*
|
||||
public void initializeLogging() {
|
||||
// Wraps Android's native log framework.
|
||||
LogWrapper logWrapper = new LogWrapper();
|
||||
// Using Log, front-end to the logging chain, emulates android.util.log method signatures.
|
||||
Log.setLogNode(logWrapper);
|
||||
|
||||
// Filter strips out everything except the message text.
|
||||
MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
|
||||
logWrapper.setNext(msgFilter);
|
||||
|
||||
// On screen logging via a fragment with a TextView.
|
||||
LogFragment logFragment = (LogFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.log_fragment);
|
||||
msgFilter.setNext(logFragment.getLogView());
|
||||
|
||||
Log.i(TAG, "Ready");
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
stopService(new Intent(this, BluetoothChatService.class));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue