Skip to content
Browse files

The HeatLegendUnits can be accessed from the settings and sensor list

  • Loading branch information...
1 parent 0de6624 commit c983adaae6fafcb41e0970558fa9c58a88718f56 @obrok obrok committed Apr 3, 2012
View
6 res/layout/stream.xml
@@ -19,21 +19,23 @@
android:layout_centerHorizontal="true"
/>
+
<include layout="@layout/top_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/gauge_container"
+ android:id="@+id/top_bar"
/>
<ImageButton style="@style/Wrap"
- android:background="@drawable/minus"
+ android:background="@drawable/rec_active"
android:layout_margin="2dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:id="@+id/record_stream"
/>
<ImageButton style="@style/Wrap"
- android:background="@drawable/minus"
+ android:background="@drawable/view_inactive"
android:layout_margin="2dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
View
1 res/layout/top_bar.xml
@@ -25,6 +25,7 @@
android:layout_alignParentTop="true"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
+ android:id="@+id/top_bar"
>
<LinearLayout style="@style/TopBarElement"
View
8 src/main/java/pl/llp/aircasting/activity/SettingsActivity.java
@@ -33,6 +33,7 @@
import pl.llp.aircasting.R;
import pl.llp.aircasting.activity.menu.MainMenu;
import pl.llp.aircasting.helper.SettingsHelper;
+import pl.llp.aircasting.model.SensorManager;
import roboguice.activity.RoboPreferenceActivity;
import roboguice.inject.InjectResource;
@@ -50,9 +51,10 @@
@Inject Application context;
- @Inject MainMenu mainMenu;
- @Inject SettingsHelper settingsHelper;
@Inject SharedPreferences sharedPreferences;
+ @Inject SettingsHelper settingsHelper;
+ @Inject SensorManager sensorManager;
+ @Inject MainMenu mainMenu;
@InjectResource(R.string.profile_template) String profileTemplate;
@@ -82,7 +84,7 @@ protected void onResume() {
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (preference.getKey().equals(COLOR_SCALE_KEY)) {
- startActivity(new Intent(this, ThresholdsActivity.class));
+ Intents.thresholdsEditor(this, sensorManager.getVisibleSensor());
return true;
} else if (preference.getKey().equals(ACCOUNT_KEY)) {
signInOrOut();
View
14 src/main/java/pl/llp/aircasting/activity/adapter/StreamAdapter.java
@@ -5,6 +5,7 @@
import android.widget.SimpleAdapter;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
+import pl.llp.aircasting.Intents;
import pl.llp.aircasting.R;
import pl.llp.aircasting.activity.ButtonsActivity;
import pl.llp.aircasting.event.sensor.SensorEvent;
@@ -48,11 +49,11 @@ public int compare(@Nullable Map<String, Object> left, @Nullable Map<String, Obj
};
public static final String SENSOR = "sensor";
- GaugeHelper gaugeHelper;
- EventBus eventBus;
- TopBarHelper topBarHelper;
SensorManager sensorManager;
+ TopBarHelper topBarHelper;
+ GaugeHelper gaugeHelper;
ButtonsActivity context;
+ EventBus eventBus;
private List<Map<String, Object>> data;
private Map<String, Map<String, Object>> sensors = newHashMap();
@@ -128,6 +129,10 @@ private void initializeButtons(View view, Sensor sensor) {
} else {
viewButton.setBackgroundResource(R.drawable.view_inactive);
}
+
+ View topBar = view.findViewById(R.id.top_bar);
+ topBar.setTag(sensor);
+ topBar.setOnClickListener(this);
}
private void update() {
@@ -177,6 +182,9 @@ public void onClick(View view) {
case R.id.record_stream:
sensorManager.toggleSensor(sensor);
break;
+ case R.id.top_bar:
+ Intents.thresholdsEditor(context, sensor);
+ break;
}
context.suppressNextTap();
View
2 src/main/java/pl/llp/aircasting/sensor/builtin/SimpleAudioReader.java
@@ -80,7 +80,7 @@ public void onReadComplete(short[] buffer) {
Double power = signalPower.calculatePowerDb(buffer);
if (power != null) {
double calibrated = calibrationHelper.calibrate(power);
- SensorEvent event = new SensorEvent(SENSOR_NAME, MEASUREMENT_TYPE, SHORT_TYPE, UNIT, SYMBOL,
+ SensorEvent event = new SensorEvent(SENSOR_NAME + (int)(Math.random() * 5), MEASUREMENT_TYPE, SHORT_TYPE, UNIT, SYMBOL,
VERY_LOW, LOW, MID, HIGH, VERY_HIGH, calibrated);
eventBus.post(event);
}

0 comments on commit c983ada

Please sign in to comment.
Something went wrong with that request. Please try again.