RL Stat activitity refactor

This commit is contained in:
Milos Kozak 2022-04-20 19:41:18 +02:00
parent b59d816a19
commit 9a3aae09f3
14 changed files with 683 additions and 1005 deletions

View file

@ -24,6 +24,7 @@
<activity <activity
android:name="info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity" android:name="info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity"
android:theme="@style/AppTheme"
android:label="@string/title_activity_rileylink_settings" /> android:label="@string/title_activity_rileylink_settings" />
</application> </application>

View file

@ -1,11 +0,0 @@
package info.nightscout.androidaps.plugins.pump.common.dialog;
/**
* Created by andy on 5/19/18.
*/
public interface RefreshableInterface {
void refreshData();
}

View file

@ -1,104 +0,0 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
@Inject ResourceHelper rh;
private SectionsPagerAdapter sectionsPagerAdapter;
private TabLayout tabLayout;
/**
* The {@link ViewPager} that will host the section contents.
*/
private ViewPager viewPager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rileylink_status);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
// Set up the ViewPager with the sections adapter.
viewPager = findViewById(R.id.rileylink_settings_container);
// mViewPager.setAdapter(mSectionsPagerAdapter);
setupViewPager();
tabLayout = findViewById(R.id.rileylink_settings_tabs);
tabLayout.setupWithViewPager(viewPager);
FloatingActionButton floatingActionButton = findViewById(R.id.rileylink_settings_fab);
floatingActionButton.setOnClickListener(v -> {
RefreshableInterface selectableInterface = (RefreshableInterface) sectionsPagerAdapter
.getItem(tabLayout.getSelectedTabPosition());
selectableInterface.refreshData();
});
}
public void setupViewPager() {
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
sectionsPagerAdapter.addFragment(new RileyLinkStatusGeneralFragment(), rh.gs(R.string.rileylink_settings_tab1));
sectionsPagerAdapter.addFragment(new RileyLinkStatusHistoryFragment(), rh.gs(R.string.rileylink_settings_tab2));
viewPager.setAdapter(sectionsPagerAdapter);
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public static class SectionsPagerAdapter extends FragmentPagerAdapter {
List<Fragment> fragmentList = new ArrayList<>();
List<String> fragmentTitle = new ArrayList<>();
int lastSelectedPosition = 0;
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@NonNull @Override
public Fragment getItem(int position) {
this.lastSelectedPosition = position;
return fragmentList.get(position);
}
@Override
public int getCount() {
// Show 3 total pages.
return fragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
this.fragmentList.add(fragment);
this.fragmentTitle.add(title);
}
@Override
public CharSequence getPageTitle(int position) {
return fragmentTitle.get(position);
}
}
}

View file

@ -0,0 +1,48 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.tabs.TabLayoutMediator
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.databinding.RileylinkStatusBinding
class RileyLinkStatusActivity : NoSplashAppCompatActivity() {
private lateinit var binding: RileylinkStatusBinding
private var sectionsPagerAdapter: SectionsPagerAdapter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = RileylinkStatusBinding.inflate(layoutInflater)
setContentView(binding.root)
sectionsPagerAdapter = SectionsPagerAdapter(this)
sectionsPagerAdapter?.addFragment(RileyLinkStatusGeneralFragment::class.java.name, rh.gs(R.string.rileylink_settings_tab1))
sectionsPagerAdapter?.addFragment(RileyLinkStatusHistoryFragment::class.java.name, rh.gs(R.string.rileylink_settings_tab2))
binding.pager.adapter = sectionsPagerAdapter
TabLayoutMediator(binding.tabLayout, binding.pager) { tab, position ->
tab.text = sectionsPagerAdapter?.getPageTitle(position)
}.attach()
}
class SectionsPagerAdapter(private val activity: AppCompatActivity) : FragmentStateAdapter(activity) {
private val fragmentList: MutableList<String> = ArrayList()
private val fragmentTitle: MutableList<String> = ArrayList()
override fun getItemCount(): Int = fragmentList.size
override fun createFragment(position: Int): Fragment =
activity.supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), fragmentList[position])
fun getPageTitle(position: Int): CharSequence = fragmentTitle[position]
fun addFragment(fragment: String, title: String) {
fragmentList.add(fragment)
fragmentTitle.add(title)
}
}
}

View file

@ -1,152 +0,0 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.CommandValueDefinition;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.CommandValueDefinitionType;
/**
* Created by andy on 5/19/18.
*/
// FIXME needs to be implemented
public class RileyLinkStatusDevice extends Fragment implements RefreshableInterface {
ListView listView;
RileyLinkCommandListAdapter adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.rileylink_status_device, container, false);
adapter = new RileyLinkCommandListAdapter();
return rootView;
}
@Override
public void onStart() {
super.onStart();
this.listView = getActivity().findViewById(R.id.rileyLinkDeviceList);
listView.setAdapter(adapter);
setElements();
}
private void setElements() {
}
@Override
public void refreshData() {
// adapter.addItemsAndClean(RileyLinkUtil.getRileyLinkHistory());
}
static class ViewHolder {
TextView itemDescription;
Button itemValue;
}
private class RileyLinkCommandListAdapter extends BaseAdapter {
private final List<CommandValueDefinition> commandValueList;
private Map<CommandValueDefinitionType, CommandValueDefinition> commandValueMap;
private final LayoutInflater mInflator;
public RileyLinkCommandListAdapter() {
super();
commandValueList = new ArrayList<>();
mInflator = RileyLinkStatusDevice.this.getLayoutInflater();
}
public void addItems(List<CommandValueDefinition> list) {
commandValueList.addAll(list);
for (CommandValueDefinition commandValueDefinition : list) {
commandValueMap.put(commandValueDefinition.definitionType, commandValueDefinition);
}
notifyDataSetChanged();
}
public CommandValueDefinition getCommandValueItem(int position) {
return commandValueList.get(position);
}
public void clear() {
commandValueList.clear();
notifyDataSetChanged();
}
@Override
public int getCount() {
return commandValueList.size();
}
@Override
public Object getItem(int i) {
return commandValueList.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
RileyLinkStatusDevice.ViewHolder viewHolder;
// General ListView optimization code.
if (view == null) {
view = mInflator.inflate(R.layout.rileylink_status_device_item, null);
viewHolder = new RileyLinkStatusDevice.ViewHolder();
viewHolder.itemDescription = view.findViewById(R.id.rileylink_device_label);
viewHolder.itemValue = view.findViewById(R.id.rileylink_device_action);
view.setTag(viewHolder);
} else {
viewHolder = (RileyLinkStatusDevice.ViewHolder) view.getTag();
}
// Z
// RLHistoryItem item = historyItemList.get(i);
// viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime()));
// viewHolder.itemSource.setText("Riley Link"); // for now
// viewHolder.itemDescription.setText(item.getDescription());
return view;
}
}
}

View file

@ -1,144 +0,0 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.joda.time.LocalDateTime;
import java.util.Optional;
import javax.inject.Inject;
import dagger.android.support.DaggerFragment;
import info.nightscout.androidaps.interfaces.ActivePlugin;
import info.nightscout.shared.logging.AAPSLogger;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpInfo;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.shared.sharedPreferences.SP;
/**
* Created by andy on 5/19/18.
*/
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
private static final String PLACEHOLDER = "-";
@Inject ActivePlugin activePlugin;
@Inject ResourceHelper rh;
@Inject AAPSLogger aapsLogger;
@Inject RileyLinkServiceData rileyLinkServiceData;
@Inject DateUtil dateUtil;
@Inject SP sp;
private TextView connectionStatus;
private TextView configuredRileyLinkAddress;
private TextView configuredRileyLinkName;
private View batteryLevelRow;
private TextView batteryLevel;
private TextView connectionError;
private View connectedDeviceDetails;
private TextView deviceType;
private TextView configuredDeviceModel;
private TextView connectedDeviceModel;
private TextView serialNumber;
private TextView pumpFrequency;
private TextView lastUsedFrequency;
private TextView lastDeviceContact;
private TextView firmwareVersion;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.rileylink_status_general, container, false);
}
@Override
public void onResume() {
super.onResume();
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
this.configuredRileyLinkAddress = getActivity().findViewById(R.id.rls_t1_configured_riley_link_address);
this.configuredRileyLinkName = getActivity().findViewById(R.id.rls_t1_configured_riley_link_name);
this.batteryLevelRow = getActivity().findViewById(R.id.rls_t1_battery_level_row);
this.batteryLevel = getActivity().findViewById(R.id.rls_t1_battery_level);
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
this.connectedDeviceDetails = getActivity().findViewById(R.id.rls_t1_connected_device_details);
this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
this.configuredDeviceModel = getActivity().findViewById(R.id.rls_t1_configured_device_model);
this.connectedDeviceModel = getActivity().findViewById(R.id.rls_t1_connected_device_model);
this.serialNumber = getActivity().findViewById(R.id.rls_t1_serial_number);
this.pumpFrequency = getActivity().findViewById(R.id.rls_t1_pump_frequency);
this.lastUsedFrequency = getActivity().findViewById(R.id.rls_t1_last_used_frequency);
this.lastDeviceContact = getActivity().findViewById(R.id.rls_t1_last_device_contact);
this.firmwareVersion = getActivity().findViewById(R.id.rls_t1_firmware_version);
refreshData();
}
@Override public void refreshData() {
RileyLinkTargetDevice targetDevice = rileyLinkServiceData.targetDevice;
this.connectionStatus.setText(rh.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
this.configuredRileyLinkAddress.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkAddress).orElse(PLACEHOLDER));
this.configuredRileyLinkName.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkName).orElse(PLACEHOLDER));
if (sp.getBoolean(rh.gs(R.string.key_riley_link_show_battery_level), false)) {
batteryLevelRow.setVisibility(View.VISIBLE);
Integer batteryLevel = rileyLinkServiceData.batteryLevel;
this.batteryLevel.setText(batteryLevel == null ? PLACEHOLDER : rh.gs(R.string.rileylink_battery_level_value, batteryLevel));
} else {
batteryLevelRow.setVisibility(View.GONE);
}
RileyLinkError rileyLinkError = rileyLinkServiceData.rileyLinkError;
this.connectionError.setText(rileyLinkError == null ? PLACEHOLDER : rh.gs(rileyLinkError.getResourceId(targetDevice)));
if (rileyLinkServiceData.isOrange && rileyLinkServiceData.versionOrangeFirmware!=null) {
this.firmwareVersion.setText(rh.gs(R.string.rileylink_firmware_version_value_orange,
rileyLinkServiceData.versionOrangeFirmware,
Optional.ofNullable(rileyLinkServiceData.versionOrangeHardware).orElse(PLACEHOLDER)));
} else {
this.firmwareVersion.setText(rh.gs(R.string.rileylink_firmware_version_value,
Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER),
Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER)));
}
RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
RileyLinkPumpInfo rileyLinkPumpInfo = rileyLinkPumpDevice.getPumpInfo();
this.deviceType.setText(targetDevice.getResourceId());
if (targetDevice == RileyLinkTargetDevice.MedtronicPump) {
this.connectedDeviceDetails.setVisibility(View.VISIBLE);
this.configuredDeviceModel.setText(activePlugin.getActivePump().getPumpDescription().getPumpType().getDescription());
this.connectedDeviceModel.setText(rileyLinkPumpInfo.getConnectedDeviceModel());
} else {
this.connectedDeviceDetails.setVisibility(View.GONE);
}
this.serialNumber.setText(rileyLinkPumpInfo.getConnectedDeviceSerialNumber());
this.pumpFrequency.setText(rileyLinkPumpInfo.getPumpFrequency());
if (rileyLinkServiceData.lastGoodFrequency != null) {
this.lastUsedFrequency.setText(rh.gs(R.string.rileylink_pump_frequency_value, rileyLinkServiceData.lastGoodFrequency));
}
long lastConnectionTimeMillis = rileyLinkPumpDevice.getLastConnectionTimeMillis();
if (lastConnectionTimeMillis == 0) {
this.lastDeviceContact.setText(rh.gs(R.string.riley_link_ble_config_connected_never));
} else {
this.lastDeviceContact.setText(StringUtil.toDateTimeString(dateUtil, new LocalDateTime(lastConnectionTimeMillis)));
}
}
}

View file

@ -0,0 +1,95 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.databinding.RileylinkStatusGeneralBinding
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.shared.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import org.joda.time.LocalDateTime
import javax.inject.Inject
class RileyLinkStatusGeneralFragment : DaggerFragment() {
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rileyLinkServiceData: RileyLinkServiceData
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var sp: SP
private var _binding: RileylinkStatusGeneralBinding? = null
// This property is only valid between onCreateView and onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
RileylinkStatusGeneralBinding.inflate(inflater, container, false).also { _binding = it }.root
override fun onResume() {
super.onResume()
refreshData()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.refresh.setOnClickListener { refreshData() }
}
private fun refreshData() {
val targetDevice = rileyLinkServiceData.targetDevice
binding.connectionStatus.text = rh.gs(rileyLinkServiceData.rileyLinkServiceState.resourceId)
binding.configuredRileyLinkAddress.text = rileyLinkServiceData.rileyLinkAddress ?: EMPTY
binding.configuredRileyLinkName.text = rileyLinkServiceData.rileyLinkName ?: EMPTY
if (sp.getBoolean(rh.gs(R.string.key_riley_link_show_battery_level), false)) {
binding.batteryLevelRow.visibility = View.VISIBLE
val batteryLevel = rileyLinkServiceData.batteryLevel
binding.batteryLevel.text = batteryLevel?.let { rh.gs(R.string.rileylink_battery_level_value, it) } ?: EMPTY
} else binding.batteryLevelRow.visibility = View.GONE
binding.connectionError.text = rileyLinkServiceData.rileyLinkError?.let { rh.gs(it.getResourceId(targetDevice)) } ?: EMPTY
if (rileyLinkServiceData.isOrange && rileyLinkServiceData.versionOrangeFirmware != null) {
binding.firmwareVersion.text = rh.gs(
R.string.rileylink_firmware_version_value_orange,
rileyLinkServiceData.versionOrangeFirmware,
rileyLinkServiceData.versionOrangeHardware ?: EMPTY
)
} else {
binding.firmwareVersion.text = rh.gs(
R.string.rileylink_firmware_version_value,
rileyLinkServiceData.versionBLE113 ?: EMPTY,
rileyLinkServiceData.versionCC110 ?: EMPTY
)
}
val rileyLinkPumpDevice = activePlugin.activePump as RileyLinkPumpDevice
val rileyLinkPumpInfo = rileyLinkPumpDevice.pumpInfo
binding.deviceType.setText(targetDevice.resourceId)
if (targetDevice == RileyLinkTargetDevice.MedtronicPump) {
binding.connectedDeviceDetails.visibility = View.VISIBLE
binding.configuredDeviceModel.text = activePlugin.activePump.pumpDescription.pumpType.description
binding.connectedDeviceModel.text = rileyLinkPumpInfo.connectedDeviceModel
} else binding.connectedDeviceDetails.visibility = View.GONE
binding.serialNumber.text = rileyLinkPumpInfo.connectedDeviceSerialNumber
binding.pumpFrequency.text = rileyLinkPumpInfo.pumpFrequency
if (rileyLinkServiceData.lastGoodFrequency != null) {
binding.lastUsedFrequency.text = rh.gs(R.string.rileylink_pump_frequency_value, rileyLinkServiceData.lastGoodFrequency)
}
val lastConnectionTimeMillis = rileyLinkPumpDevice.lastConnectionTimeMillis
if (lastConnectionTimeMillis == 0L) binding.lastDeviceContact.text = rh.gs(R.string.riley_link_ble_config_connected_never)
else binding.lastDeviceContact.text = StringUtil.toDateTimeString(dateUtil, LocalDateTime(lastConnectionTimeMillis))
}
companion object {
private const val EMPTY = "-"
}
}

View file

@ -1,171 +0,0 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import dagger.android.support.DaggerFragment;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
/**
* Created by andy on 5/19/18.
*/
public class RileyLinkStatusHistoryFragment extends DaggerFragment implements RefreshableInterface {
@Inject RileyLinkUtil rileyLinkUtil;
@Inject ResourceHelper rh;
@Inject DateUtil dateUtil;
RecyclerView recyclerView;
RecyclerViewAdapter recyclerViewAdapter;
LinearLayoutManager llm;
List<RLHistoryItem> filteredHistoryList = new ArrayList<>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.rileylink_status_history, container, false);
recyclerView = rootView.findViewById(R.id.rileylink_history_list);
recyclerView.setHasFixedSize(true);
llm = new LinearLayoutManager(rootView.getContext());
recyclerView.setLayoutManager(llm);
recyclerViewAdapter = new RecyclerViewAdapter(filteredHistoryList);
recyclerView.setAdapter(recyclerViewAdapter);
return rootView;
}
@Override
public void onStart() {
super.onStart();
refreshData();
}
@Override
public void refreshData() {
if (rileyLinkUtil.getRileyLinkHistory() != null) {
recyclerViewAdapter.addItemsAndClean(rileyLinkUtil.getRileyLinkHistory());
}
}
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
List<RLHistoryItem> historyList;
RecyclerViewAdapter(List<RLHistoryItem> historyList) {
this.historyList = historyList;
}
public void setHistoryList(List<RLHistoryItem> historyList) {
this.historyList = historyList;
}
public void addItemsAndClean(List<RLHistoryItem> items) {
this.historyList.clear();
Collections.sort(items, new RLHistoryItem.Comparator());
for (RLHistoryItem item : items) {
if (!historyList.contains(item) && isValidItem(item)) {
historyList.add(item);
}
}
notifyDataSetChanged();
}
private boolean isValidItem(RLHistoryItem item) {
PumpDeviceState pumpState = item.getPumpDeviceState();
//
//
return pumpState != PumpDeviceState.Sleeping && //
pumpState != PumpDeviceState.Active && //
pumpState != PumpDeviceState.WakingUp;
}
@NonNull
@Override
public RecyclerViewAdapter.HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.rileylink_status_history_item, //
viewGroup, false);
return new RecyclerViewAdapter.HistoryViewHolder(v);
}
@Override
public void onBindViewHolder(RecyclerViewAdapter.HistoryViewHolder holder, int position) {
RLHistoryItem item = historyList.get(position);
if (item != null) {
holder.timeView.setText(dateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis()));
holder.typeView.setText(item.getSource().getDesc());
holder.valueView.setText(item.getDescription(rh));
}
}
@Override
public int getItemCount() {
return historyList.size();
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
class HistoryViewHolder extends RecyclerView.ViewHolder {
TextView timeView;
TextView typeView;
TextView valueView;
HistoryViewHolder(View itemView) {
super(itemView);
timeView = itemView.findViewById(R.id.rileylink_history_time);
typeView = itemView.findViewById(R.id.rileylink_history_source);
valueView = itemView.findViewById(R.id.rileylink_history_description);
}
}
}
}

View file

@ -0,0 +1,82 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.R
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.databinding.RileylinkStatusHistoryBinding
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.databinding.RileylinkStatusHistoryItemBinding
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject
class RileyLinkStatusHistoryFragment : DaggerFragment() {
@Inject lateinit var rileyLinkUtil: RileyLinkUtil
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var dateUtil: DateUtil
private var _binding: RileylinkStatusHistoryBinding? = null
// This property is only valid between onCreateView and onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
RileylinkStatusHistoryBinding.inflate(inflater, container, false).also { _binding = it }.root
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.historyList.setHasFixedSize(true)
binding.historyList.layoutManager = LinearLayoutManager(view.context)
binding.refresh.setOnClickListener { refreshData() }
}
override fun onResume() {
super.onResume()
refreshData()
}
private fun refreshData() {
binding.historyList.adapter =
RecyclerViewAdapter(rileyLinkUtil.rileyLinkHistory
?.filter { isValidItem(it) }
?.sortedWith(RLHistoryItem.Comparator())
?: ArrayList()
)
}
private fun isValidItem(item: RLHistoryItem): Boolean =
item.pumpDeviceState !== PumpDeviceState.Sleeping &&
item.pumpDeviceState !== PumpDeviceState.Active &&
item.pumpDeviceState !== PumpDeviceState.WakingUp
inner class RecyclerViewAdapter internal constructor(private val historyList: List<RLHistoryItem>) : RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder>() {
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): HistoryViewHolder {
val v = LayoutInflater.from(viewGroup.context).inflate(R.layout.rileylink_status_history_item, viewGroup, false)
return HistoryViewHolder(v)
}
override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) {
val item = historyList[position]
holder.binding.historyTime.text = dateUtil.dateAndTimeAndSecondsString(item.dateTime.toDateTime().millis)
holder.binding.historySource.text = item.source.desc
holder.binding.historyDescription.text = item.getDescription(rh)
}
override fun getItemCount(): Int = historyList.size
inner class HistoryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val binding = RileylinkStatusHistoryItemBinding.bind(itemView)
}
}
}

View file

@ -1,41 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:orientation="vertical"
tools:context="info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity"> tools:context="info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"> android:paddingTop="@dimen/appbar_padding_top">
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/rileylink_settings_tabs" android:id="@+id/tabLayout"
app:tabTextColor="?attr/tabTextColor"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent" />
</com.google.android.material.tabs.TabLayout> </com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout> <androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
<androidx.viewpager.widget.ViewPager
android:id="@+id/rileylink_settings_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:layout_editor_absoluteY="55dp" /> tools:layout_editor_absoluteY="55dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton </LinearLayout>
android:id="@+id/rileylink_settings_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:contentDescription="@string/refresh"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/ic_refresh" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,21 +0,0 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusDevice">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rileyLinkDeviceList"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,12 +1,9 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusGeneralFragment"> tools:context="info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusGeneralFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -14,28 +11,41 @@
android:orientation="vertical"> android:orientation="vertical">
<!-- Group - RL --> <!-- Group - RL -->
<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="false"
app:contentPadding="2dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="vertical">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="25pt" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/rileylink_title" android:text="@string/rileylink_title"
android:textColor="@android:color/holo_blue_dark" /> android:textColor="@android:color/holo_blue_dark" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -46,14 +56,15 @@
android:text="@string/rileylink_address" /> android:text="@string/rileylink_address" />
<TextView <TextView
android:id="@+id/rls_t1_configured_riley_link_address" android:id="@+id/configured_riley_link_address"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -61,9 +72,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -74,26 +85,27 @@
android:text="@string/rileylink_name" /> android:text="@string/rileylink_name" />
<TextView <TextView
android:id="@+id/rls_t1_configured_riley_link_name" android:id="@+id/configured_riley_link_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/rls_t1_battery_level_row" android:id="@+id/battery_level_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone" android:visibility="gone">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -104,14 +116,15 @@
android:text="@string/rileylink_battery_level" /> android:text="@string/rileylink_battery_level" />
<TextView <TextView
android:id="@+id/rls_t1_battery_level" android:id="@+id/battery_level"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -119,9 +132,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -132,14 +145,15 @@
android:text="@string/rileylink_connection_status" /> android:text="@string/rileylink_connection_status" />
<TextView <TextView
android:id="@+id/rls_t1_connection_status" android:id="@+id/connection_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -159,14 +173,15 @@
android:text="@string/rileylink_connection_error" /> android:text="@string/rileylink_connection_error" />
<TextView <TextView
android:id="@+id/rls_t1_connection_error" android:id="@+id/connection_error"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -174,9 +189,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -187,39 +202,57 @@
android:text="@string/rileylink_firmware_version" /> android:text="@string/rileylink_firmware_version" />
<TextView <TextView
android:id="@+id/rls_t1_firmware_version" android:id="@+id/firmware_version"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- Group - Device --> <!-- Group - Device -->
<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="false"
app:contentPadding="2dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="vertical">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="25pt" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/rileylink_device" android:text="@string/rileylink_device"
android:textColor="@android:color/holo_blue_dark" /> android:textColor="@android:color/holo_blue_dark" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -230,18 +263,19 @@
android:text="@string/rileylink_device_type" /> android:text="@string/rileylink_device_type" />
<TextView <TextView
android:id="@+id/rls_t1_device_type" android:id="@+id/device_type"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/rls_t1_connected_device_details" android:id="@+id/connected_device_details"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
@ -252,9 +286,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -265,14 +299,15 @@
android:text="@string/rileylink_configured_device_model" /> android:text="@string/rileylink_configured_device_model" />
<TextView <TextView
android:id="@+id/rls_t1_configured_device_model" android:id="@+id/configured_device_model"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -280,9 +315,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -293,14 +328,15 @@
android:text="@string/rileylink_connected_device_model" /> android:text="@string/rileylink_connected_device_model" />
<TextView <TextView
android:id="@+id/rls_t1_connected_device_model" android:id="@+id/connected_device_model"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@ -310,9 +346,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -323,14 +359,14 @@
android:text="@string/rileylink_pump_serial_number" /> android:text="@string/rileylink_pump_serial_number" />
<TextView <TextView
android:id="@+id/rls_t1_serial_number" android:id="@+id/serial_number"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -338,9 +374,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -351,14 +387,14 @@
android:text="@string/rileylink_pump_frequency" /> android:text="@string/rileylink_pump_frequency" />
<TextView <TextView
android:id="@+id/rls_t1_pump_frequency" android:id="@+id/pump_frequency"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -366,9 +402,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -379,14 +415,14 @@
android:text="@string/rileylink_last_used_frequency" /> android:text="@string/rileylink_last_used_frequency" />
<TextView <TextView
android:id="@+id/rls_t1_last_used_frequency" android:id="@+id/last_used_frequency"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -394,9 +430,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:focusable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:focusable="true">
<TextView <TextView
android:layout_width="58dp" android:layout_width="58dp"
@ -407,18 +443,30 @@
android:text="@string/rileylink_last_device_contact" /> android:text="@string/rileylink_last_device_contact" />
<TextView <TextView
android:id="@+id/rls_t1_last_device_contact" android:id="@+id/last_device_contact"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_weight="65" android:layout_weight="65"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text=" " android:textAlignment="center"
android:textAlignment="center" /> tools:ignore="RtlCompat" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout> <com.google.android.material.button.MaterialButton
android:id="@+id/refresh"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_refresh"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/refresh" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -9,17 +9,20 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:id="@+id/rileylink_historystatus"
android:layout_width="match_parent"
android:layout_height="10dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rileylink_history_list" android:id="@+id/history_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent"/> android:layout_height="wrap_content" />
<com.google.android.material.button.MaterialButton
android:id="@+id/refresh"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_refresh"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:text="@string/refresh" />
</LinearLayout> </LinearLayout>

View file

@ -1,14 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/extended_bolus_card"
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="4dp"
android:layout_marginBottom="4dp"
app:cardCornerRadius="4dp"
app:contentPadding="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="20dp" android:paddingStart="10dp"
android:paddingEnd="0dp"> android:paddingTop="5dp"
android:paddingEnd="0dp"
android:paddingBottom="5dp">
<TextView <TextView
android:id="@+id/rileylink_history_time" android:id="@+id/history_time"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -16,7 +30,7 @@
tools:text="Date" /> tools:text="Date" />
<TextView <TextView
android:id="@+id/rileylink_history_source" android:id="@+id/history_source"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -24,7 +38,7 @@
tools:text="Source" /> tools:text="Source" />
<TextView <TextView
android:id="@+id/rileylink_history_description" android:id="@+id/history_description"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -32,3 +46,5 @@
tools:text="Description" /> tools:text="Description" />
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView>