Skip to content

Commit

Permalink
Доработки интерфейса. Добавил температуру из сервиса BAS
Browse files Browse the repository at this point in the history
  • Loading branch information
denisn73 committed Nov 2, 2018
1 parent ca081a7 commit 6f7522e
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 18
targetSdkVersion 27
versionCode 5
versionName "4.0.5"
versionName "4.1.0"
resConfigs "en"
}

Expand Down
Binary file added app/release/VegaSeal_4.1.0.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":5},"path":"VegaSeal_4.0.5.apk","properties":{"packageId":"no.nordicsemi.android.vega","split":"","minSdkVersion":"18"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":5},"path":"VegaSeal_4.1.0.apk","properties":{"packageId":"no.nordicsemi.android.vega","split":"","minSdkVersion":"18"}}]
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ else if(value==6) {
});

viewModel.getStatusBat().observe(this, value -> {
TextView info_bat = findViewById(R.id.info_device_bat_value);
//TextView info_bat = findViewById(R.id.info_device_bat_value);
TextView info_bat = findViewById(R.id.battery);
info_bat.setText(String.valueOf(value) + "%");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

package no.nordicsemi.android.vega.adapter;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
Expand Down Expand Up @@ -109,6 +110,13 @@ public boolean isEmpty() {
return getItemCount() == 0;
}


public void onBatteryValueReceived(final BluetoothDevice device) {
final int position = mDevices.indexOf(device);
if (position >= 0)
notifyItemChanged(position);
}

final class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.device_address) TextView deviceAddress;
@BindView(R.id.device_data) TextView deviceData;
Expand All @@ -117,6 +125,7 @@ final class ViewHolder extends RecyclerView.ViewHolder {

private ViewHolder(final View view) {
super(view);

ButterKnife.bind(this, view);

view.findViewById(R.id.device_container).setOnClickListener(v -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void onDataReceived(final byte[] data) {
// CHAR_INFO_BAT
case 1 : {
int bat = ByteBuffer.wrap(valdata).order(ByteOrder.LITTLE_ENDIAN).getInt();
mStatusBat.postValue(bat);
//mStatusBat.postValue(bat);
Log.e("CHAR_INFO_BAT", String.valueOf(bat));
} break;
// CHAR_INFO_TEMP
Expand Down Expand Up @@ -408,13 +408,13 @@ public void onDeviceReady(final BluetoothDevice device) {

@Override
public boolean shouldEnableBatteryLevelNotifications(final BluetoothDevice device) {
// Blinky doesn't have Battery Service
return false;
return true;
}

@Override
public void onBatteryValueReceived(final BluetoothDevice device, final int value) {
// Blinky doesn't have Battery Service
Log.e("Test", "Battery = " + value);
mStatusBat.postValue(value);
}

@Override
Expand Down
Binary file added app/src/main/res/drawable-hdpi/battery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/drawable-hdpi/nordic_logo.png
Binary file not shown.
Binary file removed app/src/main/res/drawable-land-xhdpi/nordic_logo.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions app/src/main/res/layout/activity_blinky.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
app:popupTheme="@style/AppTheme.PopupOverlay" >

<TextView
android:id="@+id/battery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="8dp"
android:background="@drawable/battery"
android:freezesText="true"
android:gravity="center"
android:text="n/a"
android:textColor="#FFFFFF"
android:textSize="12sp"/>

</android.support.v7.widget.Toolbar>


</android.support.design.widget.AppBarLayout>

Expand Down Expand Up @@ -188,6 +205,7 @@
android:layout_marginEnd="8dp"
android:padding="5dp"
android:text="@string/device_battery"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/info_device_temp" />

Expand All @@ -200,6 +218,7 @@
android:padding="5dp"
android:text="value"
android:gravity="right"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/info_device_bat"
app:layout_constraintTop_toBottomOf="@+id/info_device_temp" />
Expand Down Expand Up @@ -316,7 +335,7 @@
<ListView
android:id="@+id/LoraListView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="180dp"
app:layout_constraintTop_toBottomOf="@+id/add_lora_item" />

<Button
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_splash_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
android:layout_gravity="center"
android:layout_marginTop="0dp"
android:scaleType="center"
android:scaleX="1.2"
android:scaleY="1.2"
android:src="@drawable/logo_v"/>
android:scaleX="1.4"
android:scaleY="1.4"
android:src="@drawable/glosav_logo_portrait"/>

</RelativeLayout>
36 changes: 17 additions & 19 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,35 @@
-->

<resources>
<string name="app_name">VegaSeal</string>
<string name="feature_name">TEST</string>
<string name="app_name">GlosavES</string>
<string name="feature_name">VegaSeal</string>

<string name="title">@string/app_name</string>

<string name="unknown_device">Unknown Device</string>
<string name="title_device_name">Информация</string>
<string name="device_serial_number"><b>Серийный номер</b></string>
<string name="device_temperature"><b>Температура</b></string>
<string name="device_battery"><b>Заряд АКБ:</b></string>
<string name="device_state"><b>Потребление:</b></string>
<string name="device_oid"><b>OID:</b></string>
<string name="device_is_sleep"><b>Состояние:</b></string>
<string name="title_arm_control">Управление охраной</string>
<string name="arm_state">Не активна</string>
<string name="title_lora_manager">Менеджер LPWAN</string>

<string name="arm_check">проверка...</string>
<string name="arm_state_prepare">Ожидание троса...</string>
<string name="arm_button_prepare">Подготовка к охране</string>
<string name="arm_button_arm">Поставить на охрану</string>
<string name="arm_button_disarm">Снять с охраны</string>
<string name="arm_gamma_error">Ошибка модуля</string>
<string name="arm_check">проверка...</string>
<string name="arm_state_unknown">неизвестно</string>
<string name="arm_state_true">Охрана активна</string>
<string name="arm_state_false">Охрана снята</string>
<string name="arm_state_prepare">Ожидание троса...</string>
<string name="arm_state_unknown">неизвестно</string>
<string name="arm_state_timeout">Таймаут ожидания</string>
<string name="arm_alarm">ТРЕВОГА!</string>
<string name="turn_on">On</string>
<string name="turn_off">Off</string>
<string name="title_led_state">LED</string>
<string name="title_lora_manager">Менеджер LoRa</string>
<string name="state">State</string>

<string name="device_serial_number"><b>Серийный номер</b></string>
<string name="device_temperature"><b>Температура</b></string>
<string name="device_battery"><b>Заряд АКБ:</b></string>
<string name="device_state"><b>Потребление:</b></string>
<string name="device_oid"><b>OID:</b></string>
<string name="device_is_sleep"><b>Состояние:</b></string>

<string name="unknown_device">Неизвестное уст-во</string>

<string name="button_unknown">UNKNOWN</string>
<string name="charge_percent">95%</string>

Expand Down

0 comments on commit 6f7522e

Please sign in to comment.