Android: Add Update and Delete buttons for each project listed, only make them visible when the project has been selected.

This commit is contained in:
Rom Walton 2013-02-23 12:43:10 -05:00 committed by Oliver Bock
parent 67f81b2eca
commit 0eafd4c96c
12 changed files with 52 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 967 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -30,7 +30,7 @@
android:clickable="false"
android:focusable="false" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:id="@+id/msgsRowVertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -42,7 +42,7 @@
android:layout_height="wrap_content"
android:layout_margin="2dp" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:id="@+id/msgsRowHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -21,17 +21,41 @@
android:id="@+id/projectsRow"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:orientation="horizontal" >
<TextView android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/project_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/project_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
<LinearLayout
android:id="@+id/projectsDescription"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/project_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
<TextView android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/project_username"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<ImageButton
android:id="@+id/project_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/projects_update"
android:src="@drawable/ic_menu_refresh"
android:visibility="gone" />
<ImageButton
android:id="@+id/project_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/projects_delete"
android:src="@drawable/ic_menu_delete"
android:visibility="gone" />
</LinearLayout>

View File

@ -131,7 +131,9 @@
<string name="confirm_deletion_confirm">Delete</string>
<string name="confirm_deletion_cancel">Cancel</string>
<string name="projects_add_button">+ Add project</string>
<string name="projects_delete">Delete project</string>
<string name="projects_update">Update project</string>
<!-- tasks tab strings -->
<string name="tasks_result_new">new</string>
<string name="tasks_result_files_downloading">waiting for download</string>

View File

@ -19,11 +19,8 @@
package edu.berkeley.boinc.adapter;
import java.util.ArrayList;
import java.util.Date;
import edu.berkeley.boinc.R;
import edu.berkeley.boinc.adapter.EventLogListAdapter.ViewEventLog;
import edu.berkeley.boinc.rpc.Message;
import edu.berkeley.boinc.rpc.Project;
import android.app.Activity;
@ -32,9 +29,9 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ImageButton;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@ -48,6 +45,8 @@ public class ProjectsListAdapter extends ArrayAdapter<Project> implements OnItem
int entryIndex;
TextView tvProjectName;
TextView tvUserName;
ImageButton ibProjectUpdate;
ImageButton ibProjectDelete;
}
public ProjectsListAdapter(Activity activity, ListView listView, int textViewResourceId, ArrayList<Project> entries) {
@ -97,6 +96,8 @@ public class ProjectsListAdapter extends ArrayAdapter<Project> implements OnItem
viewProject = new ViewProject();
viewProject.tvProjectName = (TextView)vi.findViewById(R.id.project_name);
viewProject.tvUserName = (TextView)vi.findViewById(R.id.project_username);
viewProject.ibProjectUpdate = (ImageButton)vi.findViewById(R.id.project_update);
viewProject.ibProjectDelete = (ImageButton)vi.findViewById(R.id.project_delete);
vi.setTag(viewProject);
@ -110,13 +111,18 @@ public class ProjectsListAdapter extends ArrayAdapter<Project> implements OnItem
viewProject.entryIndex = position;
viewProject.tvProjectName.setText(getProject(position));
viewProject.tvUserName.setText(getUserName(position));
if (listView.isItemChecked(position)) {
viewProject.ibProjectUpdate.setVisibility(View.VISIBLE);
viewProject.ibProjectDelete.setVisibility(View.VISIBLE);
} else {
viewProject.ibProjectUpdate.setVisibility(View.GONE);
viewProject.ibProjectDelete.setVisibility(View.GONE);
}
return vi;
}
public void onItemClick(AdapterView<?> adapter, View view, int position, long id ) {
ViewProject viewProject = (ViewProject)view.getTag();
notifyDataSetChanged();
}