-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathSettingsActivity.java
More file actions
159 lines (120 loc) · 6.78 KB
/
Copy pathSettingsActivity.java
File metadata and controls
159 lines (120 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.microntek.f1x.mtcdtools.activities;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TabHost;
import android.widget.TextView;
import com.microntek.f1x.mtcdtools.R;
import com.microntek.f1x.mtcdtools.service.ServiceActivity;
import java.util.Locale;
public class SettingsActivity extends ServiceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
TabHost tabHost = (TabHost)findViewById(R.id.tabHost);
tabHost.setup();
TabHost.TabSpec miscTab = tabHost.newTabSpec(this.getString(R.string.Misc));
miscTab.setContent(R.id.tabMiscSettings);
miscTab.setIndicator(this.getString(R.string.Misc));
tabHost.addTab(miscTab);
TabHost.TabSpec voiceCommandsTab = tabHost.newTabSpec(this.getString(R.string.VoiceCommands));
voiceCommandsTab.setContent(R.id.tabVoiceCommandsSettings);
voiceCommandsTab.setIndicator(this.getString(R.string.VoiceCommands));
tabHost.addTab(voiceCommandsTab);
TabHost.TabSpec storeSettingsTab = tabHost.newTabSpec(this.getString(R.string.StoreSettings));
storeSettingsTab.setContent(R.id.tabStoreSettings);
storeSettingsTab.setIndicator(this.getString(R.string.StoreSettings));
tabHost.addTab(storeSettingsTab);
mActionExecutionDelaySeekBar = (SeekBar)this.findViewById(R.id.seekBarActionExecutionDelay);
mActionExecutionDelayValueTextView = (TextView)this.findViewById(R.id.textViewActionExecutionDelayValue);
mActionExecutionDelaySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
mActionExecutionDelayValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mVoiceCommandExecutionDelaySeekBar = (SeekBar)this.findViewById(R.id.seekBarVoiceCommandExecutionDelay);
mVoiceCommandExecutionDelayValueTextView = (TextView)this.findViewById(R.id.textViewVoiceCommandExecutionDelayValue);
mVoiceCommandExecutionDelaySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
mVoiceCommandExecutionDelayValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mKeyPressSpeedSeekBar = (SeekBar)this.findViewById(R.id.seekBarKeyPressSpeed);
mKeyPressSpeedValueTextView = (TextView)this.findViewById(R.id.textViewKeyPressSpeedValue);
mKeyPressSpeedSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
mKeyPressSpeedValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", progress));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
Button cancelButton = (Button)this.findViewById(R.id.buttonCancel);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SettingsActivity.this.finish();
}
});
Button saveButton = (Button)this.findViewById(R.id.buttonSave);
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mServiceBinder.getConfiguration().setActionExecutionDelay(mActionExecutionDelaySeekBar.getProgress());
mServiceBinder.getConfiguration().setVoiceCommandExecutionDelay(mVoiceCommandExecutionDelaySeekBar.getProgress());
mServiceBinder.getConfiguration().setKeyPressSpeed(mKeyPressSpeedSeekBar.getProgress());
mServiceBinder.getConfiguration().getActionsVoiceDelimiter(mActionsVoiceDelimiterEditText.getText().toString());
SettingsActivity.this.finish();
}
});
mActionsVoiceDelimiterEditText = (EditText)this.findViewById(R.id.editTextActionsVoiceDelimiter);
}
@Override
protected void onResume() {
super.onResume();
if(mServiceBinder != null) {
mVoiceCommandExecutionDelaySeekBar.setProgress(mServiceBinder.getConfiguration().getVoiceCommandExecutionDelay());
mVoiceCommandExecutionDelayValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", mVoiceCommandExecutionDelaySeekBar.getProgress()));
mKeyPressSpeedSeekBar.setProgress(mServiceBinder.getConfiguration().getKeyPressSpeed());
mKeyPressSpeedValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", mKeyPressSpeedSeekBar.getProgress()));
}
}
@Override
protected void onServiceConnected() {
mActionExecutionDelaySeekBar.setProgress(mServiceBinder.getConfiguration().getActionExecutionDelay());
mActionExecutionDelayValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", mActionExecutionDelaySeekBar.getProgress()));
mVoiceCommandExecutionDelaySeekBar.setProgress(mServiceBinder.getConfiguration().getVoiceCommandExecutionDelay());
mVoiceCommandExecutionDelayValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", mVoiceCommandExecutionDelaySeekBar.getProgress()));
mKeyPressSpeedSeekBar.setProgress(mServiceBinder.getConfiguration().getKeyPressSpeed());
mKeyPressSpeedValueTextView.setText(String.format(Locale.getDefault(), "%d [ms]", mKeyPressSpeedSeekBar.getProgress()));
mActionsVoiceDelimiterEditText.setText(mServiceBinder.getConfiguration().getActionsVoiceDelimiter());
}
private SeekBar mActionExecutionDelaySeekBar;
private TextView mActionExecutionDelayValueTextView;
private SeekBar mVoiceCommandExecutionDelaySeekBar;
private TextView mVoiceCommandExecutionDelayValueTextView;
private SeekBar mKeyPressSpeedSeekBar;
private TextView mKeyPressSpeedValueTextView;
private EditText mActionsVoiceDelimiterEditText;
}