mirror of
https://github.com/etesync/android
synced 2024-12-23 15:18:14 +00:00
Account view: cleanup and share collection list items and adapter.
They were redundant and needed some cleanup, now they are better, and shared between calendar and contact.
This commit is contained in:
parent
17d90a4569
commit
89731519e9
@ -231,7 +231,7 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
listCardDAV.setEnabled(!info.carddav.refreshing);
|
||||
listCardDAV.setAlpha(info.carddav.refreshing ? 0.5f : 1);
|
||||
|
||||
AddressBookAdapter adapter = new AddressBookAdapter(this);
|
||||
CollectionListAdapter adapter = new CollectionListAdapter(this);
|
||||
adapter.addAll(info.carddav.collections);
|
||||
listCardDAV.setAdapter(adapter);
|
||||
listCardDAV.setOnItemClickListener(onItemClickListener);
|
||||
@ -247,7 +247,7 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
listCalDAV.setEnabled(!info.caldav.refreshing);
|
||||
listCalDAV.setAlpha(info.caldav.refreshing ? 0.5f : 1);
|
||||
|
||||
final CalendarAdapter adapter = new CalendarAdapter(this);
|
||||
final CollectionListAdapter adapter = new CollectionListAdapter(this);
|
||||
adapter.addAll(info.caldav.collections);
|
||||
listCalDAV.setAdapter(adapter);
|
||||
listCalDAV.setOnItemClickListener(onItemClickListener);
|
||||
@ -352,15 +352,15 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
|
||||
/* LIST ADAPTERS */
|
||||
|
||||
public static class AddressBookAdapter extends ArrayAdapter<CollectionInfo> {
|
||||
public AddressBookAdapter(Context context) {
|
||||
super(context, R.layout.account_carddav_item);
|
||||
public static class CollectionListAdapter extends ArrayAdapter<CollectionInfo> {
|
||||
public CollectionListAdapter(Context context) {
|
||||
super(context, R.layout.account_collection_item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View v, ViewGroup parent) {
|
||||
if (v == null)
|
||||
v = LayoutInflater.from(getContext()).inflate(R.layout.account_carddav_item, parent, false);
|
||||
v = LayoutInflater.from(getContext()).inflate(R.layout.account_collection_item, parent, false);
|
||||
|
||||
final CollectionInfo info = getItem(position);
|
||||
|
||||
@ -375,45 +375,19 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
tv.setText(info.description);
|
||||
}
|
||||
|
||||
tv = (TextView)v.findViewById(R.id.read_only);
|
||||
tv.setVisibility(info.readOnly ? View.VISIBLE : View.GONE);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CalendarAdapter extends ArrayAdapter<CollectionInfo> {
|
||||
public CalendarAdapter(Context context) {
|
||||
super(context, R.layout.account_caldav_item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View v, ViewGroup parent) {
|
||||
if (v == null)
|
||||
v = LayoutInflater.from(getContext()).inflate(R.layout.account_caldav_item, parent, false);
|
||||
|
||||
final CollectionInfo info = getItem(position);
|
||||
|
||||
View vColor = v.findViewById(R.id.color);
|
||||
if (info.color != null) {
|
||||
vColor.setBackgroundColor(info.color);
|
||||
final View vColor = v.findViewById(R.id.color);
|
||||
if (info.type.equals(CollectionInfo.Type.ADDRESS_BOOK)) {
|
||||
vColor.setVisibility(View.GONE);
|
||||
} else {
|
||||
vColor.setBackgroundColor(LocalCalendar.defaultColor);
|
||||
if (info.color != null) {
|
||||
vColor.setBackgroundColor(info.color);
|
||||
} else {
|
||||
vColor.setBackgroundColor(LocalCalendar.defaultColor);
|
||||
}
|
||||
}
|
||||
|
||||
TextView tv = (TextView)v.findViewById(R.id.title);
|
||||
tv.setText(TextUtils.isEmpty(info.displayName) ? info.uid : info.displayName);
|
||||
|
||||
tv = (TextView)v.findViewById(R.id.description);
|
||||
if (TextUtils.isEmpty(info.description))
|
||||
tv.setVisibility(View.GONE);
|
||||
else {
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
tv.setText(info.description);
|
||||
}
|
||||
|
||||
tv = (TextView)v.findViewById(R.id.read_only);
|
||||
tv.setVisibility(info.readOnly ? View.VISIBLE : View.GONE);
|
||||
View readOnly = v.findViewById(R.id.read_only);
|
||||
readOnly.setVisibility(info.readOnly ? View.VISIBLE : View.GONE);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
|
||||
~ All rights reserved. This program and the accompanying materials
|
||||
~ are made available under the terms of the GNU Public License v3.0
|
||||
~ which accompanies this distribution, and is available at
|
||||
~ http://www.gnu.org/licenses/gpl.html
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<LinearLayout android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="My Address Book"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
tools:text="Address Book Description"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/read_only"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_remove_circle_dark"/>
|
||||
|
||||
</LinearLayout>
|
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
|
||||
~ All rights reserved. This program and the accompanying materials
|
||||
~ are made available under the terms of the GNU Public License v3.0
|
||||
@ -8,18 +7,18 @@
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:gravity="center_vertical">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
@ -27,27 +26,27 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
tools:text="My Calendar"/>
|
||||
tools:text="Title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
tools:text="Calendar Description"/>
|
||||
tools:text="Description" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/read_only"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:background="@drawable/ic_remove_circle_dark"/>
|
||||
android:src="@drawable/ic_remove_circle_dark" />
|
||||
|
||||
<View
|
||||
android:id="@+id/color"
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_marginRight="4dp"
|
||||
tools:background="@color/green700"/>
|
||||
tools:background="@color/green700" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user