2016-09-20 20:28:52 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.activities;
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
|
|
import android.widget.SeekBar;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
|
|
|
|
|
|
|
|
public class VibrationActivity extends GBActivity {
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(VibrationActivity.class);
|
|
|
|
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
switch (intent.getAction()) {
|
|
|
|
case GBApplication.ACTION_QUIT: {
|
|
|
|
finish();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
private SeekBar seekBar;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_vibration);
|
|
|
|
|
|
|
|
IntentFilter filter = new IntentFilter();
|
|
|
|
filter.addAction(GBApplication.ACTION_QUIT);
|
|
|
|
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
|
|
|
|
registerReceiver(mReceiver, filter);
|
|
|
|
|
|
|
|
seekBar = (SeekBar) findViewById(R.id.vibration_seekbar);
|
|
|
|
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
2016-09-20 21:49:27 +02:00
|
|
|
if (progress > 0) { // 1-16
|
|
|
|
progress = progress * 16 - 1; // max 255
|
|
|
|
}
|
2016-09-20 20:28:52 +02:00
|
|
|
GBApplication.deviceService().onSetConstantVibration(progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
|
|
|
|
unregisterReceiver(mReceiver);
|
|
|
|
}
|
|
|
|
}
|