jetpack compliance, code cleanup, extracted resources

This commit is contained in:
Milos Kozak 2019-07-11 18:18:05 +01:00
parent 829ef9b6ad
commit 4df1127a8c
13 changed files with 197 additions and 223 deletions

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;

View file

@ -118,7 +118,7 @@ public class TriggerProfilePercent extends Trigger {
@Override @Override
public Optional<Integer> icon() { public Optional<Integer> icon() {
return Optional.of(R.drawable.remove); return Optional.of(R.drawable.icon_actions_profileswitch);
} }
@Override @Override

View file

@ -16,9 +16,10 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_trash_outline" app:srcCompat="@drawable/ic_trash_outline"
android:layout_alignParentRight="true" android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"/> android:layout_alignParentBottom="true"
android:contentDescription="@string/overview_quickwizard_item_remove_button" />
<LinearLayout <LinearLayout
android:id="@+id/layoutText" android:id="@+id/layoutText"
@ -27,8 +28,8 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/iconTrash" android:layout_toStartOf="@id/iconTrash"
android:layout_alignParentLeft="true"> android:layout_alignParentStart="true">
<TextView <TextView
android:id="@+id/viewActionTitle" android:id="@+id/viewActionTitle"

View file

@ -1,39 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:minWidth="300dp" android:minWidth="300dp"
android:padding="10dp"> android:padding="10dp">
<ScrollView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <TextView
android:id="@+id/viewActionTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:layout_gravity="center_horizontal"
android:paddingBottom="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView <LinearLayout
android:id="@+id/viewActionTitle" android:id="@+id/layout_root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:focusableInTouchMode="true"
android:paddingBottom="10dp" android:orientation="vertical"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:padding="10dp" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <include layout="@layout/mdtp_done_button" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="10dp"
android:id="@+id/layout_root" />
<include layout="@layout/mdtp_done_button" /> </LinearLayout>
</LinearLayout> </ScrollView>
</ScrollView>
</LinearLayout>

View file

@ -1,36 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
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="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog"> tools:context="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog">
<ScrollView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusableInTouchMode="true" android:text="@string/please_choose_an_action_type" />
android:orientation="vertical"
android:padding="10dp">
<TextView <RadioGroup
android:layout_width="match_parent" android:id="@+id/radioGroup"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:text="Please choose an action type:"/> android:layout_height="match_parent"
android:layout_marginVertical="5dp" />
<RadioGroup <include layout="@layout/mdtp_done_button" />
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="5dp"/>
<include layout="@layout/mdtp_done_button" /> </LinearLayout>
</LinearLayout> </ScrollView>
</ScrollView>
</FrameLayout>

View file

@ -1,36 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
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="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog"> tools:context="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog">
<ScrollView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusableInTouchMode="true" android:text="@string/please_choose_a_trigger_type" />
android:orientation="vertical"
android:padding="10dp">
<TextView <RadioGroup
android:layout_width="match_parent" android:id="@+id/radioGroup"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:text="Please choose a trigger type:"/> android:layout_height="match_parent"
android:layout_marginVertical="5dp" />
<RadioGroup <include layout="@layout/mdtp_done_button" />
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="5dp"/>
<include layout="@layout/mdtp_done_button" /> </LinearLayout>
</LinearLayout> </ScrollView>
</ScrollView>
</FrameLayout>

View file

@ -1,15 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
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="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog"> tools:context="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog">
<ScrollView <LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
@ -20,7 +16,7 @@
android:id="@+id/inputEventTitle" android:id="@+id/inputEventTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Event Name" /> android:hint="@string/eventname" />
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -36,7 +32,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="if:"/> android:text="@string/if_label"/>
<TextView <TextView
android:id="@+id/editTrigger" android:id="@+id/editTrigger"
@ -44,7 +40,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:text="Edit" /> android:text="@string/edit_short" />
</RelativeLayout> </RelativeLayout>
@ -70,7 +66,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="then:"/> android:text="@string/then_label"/>
<TextView <TextView
android:id="@+id/editAction" android:id="@+id/editAction"
@ -78,7 +74,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:text="Edit" /> android:text="@string/edit_short" />
</RelativeLayout> </RelativeLayout>
@ -94,6 +90,4 @@
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout>

View file

@ -1,38 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
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="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog"> tools:context="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog">
<ScrollView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusableInTouchMode="true" android:text="@string/triggers" />
android:orientation="vertical"
android:padding="10dp">
<TextView <LinearLayout
android:layout_width="match_parent" android:id="@+id/layoutTrigger"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:text="Triggers:"/> android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical" />
<LinearLayout <include layout="@layout/mdtp_done_button" />
android:id="@+id/layoutTrigger"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical" />
<include layout="@layout/mdtp_done_button" /> </LinearLayout>
</LinearLayout> </ScrollView>
</ScrollView>
</FrameLayout>

View file

@ -1,102 +1,96 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
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="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog"> tools:context="info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog">
<ScrollView <LinearLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputEventTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusableInTouchMode="true" android:hint="@string/taskname" />
android:orientation="vertical"
android:padding="10dp">
<android.support.design.widget.TextInputEditText <View
android:id="@+id/inputEventTitle" android:layout_width="fill_parent"
android:layout_width="match_parent" android:layout_height="2dip"
android:layout_height="wrap_content" android:layout_marginTop="5dp"
android:hint="Task Name" /> android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" />
<View <RelativeLayout
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="2dip" android:layout_height="wrap_content">
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/condition"/>
<TextView
android:id="@+id/editTrigger"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:padding="8dp"
android:background="@color/ribbonDefault"
android:text="Edit" />
</RelativeLayout>
<TextView <TextView
android:id="@+id/triggerDescription" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" android:text="@string/condition" />
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical" />
<View <TextView
android:layout_width="fill_parent" android:id="@+id/editTrigger"
android:layout_height="2dip" android:layout_width="wrap_content"
android:layout_marginBottom="5dp" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_alignParentTop="true"
android:background="@color/listdelimiter" /> android:layout_alignParentEnd="true"
android:background="@color/ribbonDefault"
android:padding="8dp"
android:text="@string/edit_short" />
<RelativeLayout </RelativeLayout>
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/triggerDescription"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:text="@string/action"/> android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical" />
<TextView <View
android:id="@+id/editAction" android:layout_width="fill_parent"
android:layout_width="wrap_content" android:layout_height="2dip"
android:layout_height="wrap_content" android:layout_marginTop="5dp"
android:layout_alignParentEnd="true" android:layout_marginBottom="5dp"
android:layout_alignParentTop="true" android:background="@color/listdelimiter" />
android:padding="8dp"
android:background="@color/ribbonDefault"
android:text="Add" />
</RelativeLayout> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView <TextView
android:id="@+id/actionListView" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent" android:text="@string/action" />
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>
<include layout="@layout/mdtp_done_button" /> <TextView
android:id="@+id/editAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:background="@color/ribbonDefault"
android:padding="8dp"
android:text="@string/add_short" />
</LinearLayout> </RelativeLayout>
</ScrollView> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/actionListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</FrameLayout> <include layout="@layout/mdtp_done_button" />
</LinearLayout>
</ScrollView>

View file

@ -1,34 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:id="@+id/rootLayout" android:id="@+id/rootLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:padding="8dp" android:layout_marginEnd="8dp"
android:background="@color/ribbonDefault"> android:layout_marginBottom="8dp"
android:background="@color/ribbonDefault"
android:padding="8dp">
<ImageView <ImageView
android:id="@+id/iconTrash" android:id="@+id/iconTrash"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentRight="true" android:layout_alignParentEnd="true"
android:src="@drawable/ic_trash_outline" android:contentDescription="@string/remove_label"
android:contentDescription="Remove"/> android:orientation="horizontal"
android:src="@drawable/ic_trash_outline" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/iconTrash" android:layout_toStartOf="@id/iconTrash"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<TextView <TextView

View file

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout 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="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
tools:context="info.nightscout.androidaps.plugins.general.automation.AutomationFragment"> tools:context="info.nightscout.androidaps.plugins.general.automation.AutomationFragment">
<android.support.v7.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/eventListView" android:id="@+id/eventListView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -15,22 +14,23 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginBottom="-100dp" /> android:layout_marginBottom="-100dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabAddEvent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:src="@drawable/ic_add_black_24dp"
app:backgroundTint="@color/defaulttext" />
<TextView <TextView
android:id="@+id/logView" android:id="@+id/logView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="100dp"
android:layout_alignParentBottom="true" /> android:layout_alignParentBottom="true" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabAddEvent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:clickable="true"
android:focusable="true"
android:src="@drawable/ic_add_black_24dp"
tools:ignore="RelativeOverlap" />
</RelativeLayout> </RelativeLayout>

View file

@ -1422,6 +1422,15 @@
<string name="lastboluscompared">Last bolus time %1$s %2$s min ago</string> <string name="lastboluscompared">Last bolus time %1$s %2$s min ago</string>
<string name="triggercoblabel">COB</string> <string name="triggercoblabel">COB</string>
<string name="cobcompared">COB %1$s %2$.0f</string> <string name="cobcompared">COB %1$s %2$.0f</string>
<string name="taskname">Task name</string>
<string name="eventname">Event name</string>
<string name="edit_short">EDIT</string>
<string name="please_choose_an_action_type">Please choose an action type:</string>
<string name="please_choose_a_trigger_type">Please choose a trigger type:</string>
<string name="if_label">If:</string>
<string name="then_label">Then:</string>
<string name="triggers">Triggers:</string>
<string name="remove_label">REMOVE</string>
<plurals name="objective_days"> <plurals name="objective_days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>

View file

@ -39,7 +39,7 @@ public class ActionProfileSwitchPercentTest {
@Test @Test
public void iconTest() { public void iconTest() {
Assert.assertEquals(Optional.of(R.drawable.remove), actionProfileSwitchPercent.icon()); Assert.assertEquals(Optional.of(R.drawable.icon_actions_profileswitch), actionProfileSwitchPercent.icon());
} }
@Test @Test