Skip to content

Commit

Permalink
The HeatLegendUnits can be accessed from the settings and sensor list
Browse files Browse the repository at this point in the history
  • Loading branch information
obrok committed Apr 3, 2012
1 parent 0de6624 commit c983ada
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
6 changes: 4 additions & 2 deletions res/layout/stream.xml
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions res/layout/top_bar.xml
Expand Up @@ -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"
Expand Down
Expand Up @@ -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;

Expand All @@ -50,9 +51,10 @@ public class SettingsActivity extends RoboPreferenceActivity implements SharedPr

@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;

Expand Down Expand Up @@ -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();
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down
Expand Up @@ -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);
}
Expand Down

0 comments on commit c983ada

Please sign in to comment.