mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-26 20:06:52 +01:00
72 lines
2.3 KiB
Java
72 lines
2.3 KiB
Java
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) {
|
|
if (progress > 0) { // 1-16
|
|
progress = progress * 16 - 1; // max 255
|
|
}
|
|
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);
|
|
}
|
|
}
|