From 27597da217373f88a574b2073dc889772fb24b51 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 11 Nov 2018 14:09:46 +0000 Subject: [PATCH] Layout improvements --- .../eu/faircode/email/FragmentAccount.java | 11 ++++++----- .../eu/faircode/email/FragmentCompose.java | 14 +++++++------- .../eu/faircode/email/FragmentIdentity.java | 14 ++++++++------ .../main/res/layout/spinner_dropdown_item.xml | 11 ----------- app/src/main/res/layout/spinner_item.xml | 12 ------------ app/src/main/res/layout/spinner_item1.xml | 3 ++- .../main/res/layout/spinner_item1_dropdown.xml | 18 ++++++++++++++++++ app/src/main/res/layout/spinner_item2.xml | 4 ++-- 8 files changed, 43 insertions(+), 44 deletions(-) delete mode 100644 app/src/main/res/layout/spinner_dropdown_item.xml delete mode 100644 app/src/main/res/layout/spinner_item.xml create mode 100644 app/src/main/res/layout/spinner_item1_dropdown.xml diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index afaa58ca70..9adca11f00 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -864,8 +864,8 @@ public class FragmentAccount extends FragmentEx { } }); - adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item, new ArrayList()); - adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, new ArrayList()); + adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown); spDrafts.setAdapter(adapter); spSent.setAdapter(adapter); @@ -931,9 +931,10 @@ public class FragmentAccount extends FragmentEx { providers.add(0, new Provider(getString(R.string.title_select))); providers.add(1, new Provider(getString(R.string.title_custom))); - ArrayAdapter padapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item, providers); - padapter.setDropDownViewResource(R.layout.spinner_dropdown_item); - spProvider.setAdapter(padapter); + ArrayAdapter aaProvider = + new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, providers); + aaProvider.setDropDownViewResource(R.layout.spinner_item1_dropdown); + spProvider.setAdapter(aaProvider); if (savedInstanceState == null) { if (account != null) { diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index bca5b622d5..60ac726b9e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1318,7 +1318,7 @@ public class FragmentCompose extends FragmentEx { // Show accounts AccountAdapter adapter = new AccountAdapter(getContext(), accounts); - adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown); spAccount.setAdapter(adapter); spAccount.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @@ -1345,7 +1345,7 @@ public class FragmentCompose extends FragmentEx { // Show identities IdentityAdapter adapter = new IdentityAdapter(getContext(), identities); - adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown); spIdentity.setAdapter(adapter); boolean found = false; @@ -1387,7 +1387,7 @@ public class FragmentCompose extends FragmentEx { @Override public void onNothingSelected(AdapterView parent) { IdentityAdapter adapter = new IdentityAdapter(getContext(), new ArrayList()); - adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown); spIdentity.setAdapter(adapter); } }); @@ -1675,16 +1675,16 @@ public class FragmentCompose extends FragmentEx { @NonNull @Override public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { - return getLayout(position, convertView, parent); + return getLayout(position, convertView, parent, R.layout.spinner_item1); } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { - return getLayout(position, convertView, parent); + return getLayout(position, convertView, parent, R.layout.spinner_item1_dropdown); } - View getLayout(int position, View convertView, ViewGroup parent) { - View view = LayoutInflater.from(context).inflate(R.layout.spinner_item1, parent, false); + View getLayout(int position, View convertView, ViewGroup parent, int resid) { + View view = LayoutInflater.from(context).inflate(resid, parent, false); EntityAccount account = accounts.get(position); diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java index b5c1162bb2..1b1589886d 100644 --- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java +++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java @@ -645,17 +645,19 @@ public class FragmentIdentity extends FragmentEx { unselected.primary = false; accounts.add(0, unselected); - ArrayAdapter aa = new ArrayAdapter<>(getContext(), R.layout.spinner_item, accounts); - aa.setDropDownViewResource(R.layout.spinner_dropdown_item); - spAccount.setAdapter(aa); + ArrayAdapter aaAccount = + new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, accounts); + aaAccount.setDropDownViewResource(R.layout.spinner_item1_dropdown); + spAccount.setAdapter(aaAccount); // Get providers List providers = Provider.loadProfiles(getContext()); providers.add(0, new Provider(getString(R.string.title_custom))); - ArrayAdapter adapterProfile = new ArrayAdapter<>(getContext(), R.layout.spinner_item, providers); - adapterProfile.setDropDownViewResource(R.layout.spinner_dropdown_item); - spProvider.setAdapter(adapterProfile); + ArrayAdapter aaProfile = + new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, providers); + aaProfile.setDropDownViewResource(R.layout.spinner_item1_dropdown); + spProvider.setAdapter(aaProfile); if (savedInstanceState == null) { spProvider.setTag(0); diff --git a/app/src/main/res/layout/spinner_dropdown_item.xml b/app/src/main/res/layout/spinner_dropdown_item.xml deleted file mode 100644 index e962770262..0000000000 --- a/app/src/main/res/layout/spinner_dropdown_item.xml +++ /dev/null @@ -1,11 +0,0 @@ - - diff --git a/app/src/main/res/layout/spinner_item.xml b/app/src/main/res/layout/spinner_item.xml deleted file mode 100644 index 32c6e6bfa9..0000000000 --- a/app/src/main/res/layout/spinner_item.xml +++ /dev/null @@ -1,12 +0,0 @@ - - diff --git a/app/src/main/res/layout/spinner_item1.xml b/app/src/main/res/layout/spinner_item1.xml index 5b92a57b5d..dbb02c92c3 100644 --- a/app/src/main/res/layout/spinner_item1.xml +++ b/app/src/main/res/layout/spinner_item1.xml @@ -10,8 +10,9 @@ android:id="@android:id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Name" + android:text="Text1" android:textAppearance="@style/TextAppearance.AppCompat.Medium" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/spinner_item1_dropdown.xml b/app/src/main/res/layout/spinner_item1_dropdown.xml new file mode 100644 index 0000000000..dbb02c92c3 --- /dev/null +++ b/app/src/main/res/layout/spinner_item1_dropdown.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/spinner_item2.xml b/app/src/main/res/layout/spinner_item2.xml index ec5062ecaa..1572d5deba 100644 --- a/app/src/main/res/layout/spinner_item2.xml +++ b/app/src/main/res/layout/spinner_item2.xml @@ -10,7 +10,7 @@ android:id="@android:id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Name" + android:text="Text1" android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -19,7 +19,7 @@ android:id="@android:id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Email" + android:text="Text2" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@android:id/text1" />