Merge pull request #229 from AdrianLxM/adridev3
adaptions to small screen
This commit is contained in:
commit
2fabee85b4
|
@ -57,4 +57,7 @@ public class Constants {
|
|||
|
||||
//NSClientInternal
|
||||
public static final int MAX_LOG_LINES = 100;
|
||||
|
||||
//Screen: Threshold for width to go into small width layout
|
||||
public static final int SMALL_WIDTH = 320;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -21,6 +22,7 @@ import com.crashlytics.android.answers.CustomEvent;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
|
@ -78,6 +80,8 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
PluginCustomAdapter constraintsDataAdapter = null;
|
||||
PluginCustomAdapter generalDataAdapter = null;
|
||||
|
||||
boolean smallWidth;
|
||||
|
||||
// TODO: sorting
|
||||
|
||||
@Override
|
||||
|
@ -85,6 +89,12 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
||||
|
||||
//check screen width
|
||||
final DisplayMetrics dm = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
int screen_width = dm.widthPixels;
|
||||
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
||||
|
||||
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
|
||||
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
||||
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
||||
|
@ -134,44 +144,44 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
}
|
||||
|
||||
void setViews() {
|
||||
insulinDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginBase.INSULIN), PluginBase.INSULIN);
|
||||
insulinDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginBase.INSULIN), PluginBase.INSULIN);
|
||||
insulinListView.setAdapter(insulinDataAdapter);
|
||||
setListViewHeightBasedOnChildren(insulinListView);
|
||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginBase.BGSOURCE), PluginBase.BGSOURCE);
|
||||
bgsourceDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginBase.BGSOURCE), PluginBase.BGSOURCE);
|
||||
bgsourceListView.setAdapter(bgsourceDataAdapter);
|
||||
setListViewHeightBasedOnChildren(bgsourceListView);
|
||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.PUMP), PluginBase.PUMP);
|
||||
pumpDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.PUMP), PluginBase.PUMP);
|
||||
pumpListView.setAdapter(pumpDataAdapter);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.PUMP).size() == 0)
|
||||
pumpLabel.setVisibility(View.GONE);
|
||||
setListViewHeightBasedOnChildren(pumpListView);
|
||||
loopDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.LOOP), PluginBase.LOOP);
|
||||
loopDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.LOOP), PluginBase.LOOP);
|
||||
loopListView.setAdapter(loopDataAdapter);
|
||||
setListViewHeightBasedOnChildren(loopListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.LOOP).size() == 0)
|
||||
loopLabel.setVisibility(View.GONE);
|
||||
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.TREATMENT), PluginBase.TREATMENT);
|
||||
treatmentsDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.TREATMENT), PluginBase.TREATMENT);
|
||||
treatmentsListView.setAdapter(treatmentsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(treatmentsListView);
|
||||
tempsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.TEMPBASAL), PluginBase.TEMPBASAL);
|
||||
tempsDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.TEMPBASAL), PluginBase.TEMPBASAL);
|
||||
tempsListView.setAdapter(tempsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(tempsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.TEMPBASAL).size() == 0)
|
||||
tempsLabel.setVisibility(View.GONE);
|
||||
profileDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginBase.BGSOURCE), PluginBase.PROFILE);
|
||||
profileDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginBase.BGSOURCE), PluginBase.PROFILE);
|
||||
profileListView.setAdapter(profileDataAdapter);
|
||||
setListViewHeightBasedOnChildren(profileListView);
|
||||
apsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.APS), PluginBase.APS);
|
||||
apsDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.APS), PluginBase.APS);
|
||||
apsListView.setAdapter(apsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(apsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.APS).size() == 0)
|
||||
apsLabel.setVisibility(View.GONE);
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginBase.BGSOURCE), PluginBase.CONSTRAINTS);
|
||||
constraintsDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginBase.BGSOURCE), PluginBase.CONSTRAINTS);
|
||||
constraintsListView.setAdapter(constraintsDataAdapter);
|
||||
setListViewHeightBasedOnChildren(constraintsListView);
|
||||
if (MainApp.getSpecificPluginsVisibleInList(PluginBase.CONSTRAINTS).size() == 0)
|
||||
constraintsLabel.setVisibility(View.GONE);
|
||||
generalDataAdapter = new PluginCustomAdapter(getContext(), R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.GENERAL), PluginBase.GENERAL);
|
||||
generalDataAdapter = new PluginCustomAdapter(getContext(), smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, MainApp.getSpecificPluginsVisibleInList(PluginBase.GENERAL), PluginBase.GENERAL);
|
||||
generalListView.setAdapter(generalDataAdapter);
|
||||
setListViewHeightBasedOnChildren(generalListView);
|
||||
|
||||
|
@ -206,7 +216,7 @@ public class ConfigBuilderFragment extends Fragment {
|
|||
PluginViewHolder holder = null;
|
||||
|
||||
if (view == null) {
|
||||
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.configbuilder_simpleitem, null);
|
||||
view = LayoutInflater.from(parent.getContext()).inflate(smallWidth?R.layout.configbuilder_smallitem :R.layout.configbuilder_simpleitem, null);
|
||||
|
||||
holder = new PluginViewHolder();
|
||||
holder.name = (TextView) view.findViewById(R.id.configbuilder_simpleitem_name);
|
||||
|
|
|
@ -18,6 +18,8 @@ import android.support.v7.widget.CardView;
|
|||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -165,6 +167,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
Button acceptTempButton;
|
||||
Button quickWizardButton;
|
||||
|
||||
boolean smallWidth;
|
||||
|
||||
Handler sLoopHandler = new Handler();
|
||||
Runnable sRefreshLoop = null;
|
||||
|
||||
|
@ -187,10 +191,19 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
//check screen width
|
||||
final DisplayMetrics dm = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
int screen_width = dm.widthPixels;
|
||||
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
||||
|
||||
View view = inflater.inflate(R.layout.overview_fragment, container, false);
|
||||
|
||||
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
||||
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
|
||||
if(smallWidth){
|
||||
arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
|
||||
}
|
||||
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
|
||||
deltaView = (TextView) view.findViewById(R.id.overview_delta);
|
||||
avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
|
||||
|
|
48
app/src/main/res/layout/configbuilder_smallitem.xml
Normal file
48
app/src/main/res/layout/configbuilder_smallitem.xml
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/configbuilder_simpleitem_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text=""
|
||||
android:textStyle="bold" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/configbuilder_simpleitem_checkboxenabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:text="@string/enabled" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/configbuilder_simpleitem_checkboxvisible"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:text="@string/visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/configbuilder_simpleitem_upimage"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/arrow_up_float"
|
||||
android:contentDescription="@string/up" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -105,7 +105,7 @@
|
|||
android:layout_marginTop="-15dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="-5dp"
|
||||
android:paddingRight="-10dp"
|
||||
android:paddingRight="-5dp"
|
||||
android:text="→"
|
||||
android:textSize="70dp"
|
||||
android:textStyle="bold" />
|
||||
|
|
Loading…
Reference in a new issue