Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
c8cc287f
Commit
c8cc287f
authored
10 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Delete contacts. Dev task #85.
parent
6b79cbfc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-android/src/org/briarproject/android/contact/ContactListActivity.java
+47
-5
47 additions, 5 deletions
...org/briarproject/android/contact/ContactListActivity.java
with
47 additions
and
5 deletions
briar-android/src/org/briarproject/android/contact/ContactListActivity.java
+
47
−
5
View file @
c8cc287f
...
...
@@ -2,9 +2,11 @@ package org.briarproject.android.contact;
import
static
android
.
view
.
Gravity
.
CENTER
;
import
static
android
.
view
.
Gravity
.
CENTER_HORIZONTAL
;
import
static
android
.
view
.
Menu
.
NONE
;
import
static
android
.
view
.
View
.
GONE
;
import
static
android
.
view
.
View
.
VISIBLE
;
import
static
android
.
widget
.
LinearLayout
.
VERTICAL
;
import
static
android
.
widget
.
Toast
.
LENGTH_SHORT
;
import
static
java
.
util
.
logging
.
Level
.
INFO
;
import
static
java
.
util
.
logging
.
Level
.
WARNING
;
import
static
org
.
briarproject
.
android
.
util
.
CommonLayoutParams
.
MATCH_MATCH
;
...
...
@@ -41,19 +43,26 @@ import org.briarproject.api.transport.ConnectionRegistry;
import
android.content.Intent
;
import
android.content.res.Resources
;
import
android.os.Bundle
;
import
android.view.ContextMenu
;
import
android.view.ContextMenu.ContextMenuInfo
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.view.View.OnClickListener
;
import
android.view.View.OnCreateContextMenuListener
;
import
android.widget.AdapterView
;
import
android.widget.AdapterView.AdapterContextMenuInfo
;
import
android.widget.AdapterView.OnItemClickListener
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
public
class
ContactListActivity
extends
BriarActivity
implements
OnClickListener
,
OnItemClickListener
,
Event
Listener
,
ConnectionListener
{
implements
OnClickListener
,
OnItemClickListener
,
OnCreateContextMenu
Listener
,
EventListener
,
ConnectionListener
{
private
static
final
int
MENU_ITEM_DELETE
=
1
;
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
ContactListActivity
.
class
.
getName
());
...
...
@@ -88,6 +97,7 @@ ConnectionListener {
list
.
setLayoutParams
(
MATCH_WRAP_1
);
list
.
setAdapter
(
adapter
);
list
.
setOnItemClickListener
(
this
);
list
.
setOnCreateContextMenuListener
(
this
);
list
.
setVisibility
(
GONE
);
layout
.
addView
(
list
);
...
...
@@ -223,13 +233,45 @@ ConnectionListener {
startActivity
(
i
);
}
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
view
,
ContextMenu
.
ContextMenuInfo
info
)
{
String
delete
=
getString
(
R
.
string
.
delete_contact
);
menu
.
add
(
NONE
,
MENU_ITEM_DELETE
,
NONE
,
delete
);
}
@Override
public
boolean
onContextItemSelected
(
MenuItem
menuItem
)
{
if
(
menuItem
.
getItemId
()
==
MENU_ITEM_DELETE
)
{
ContextMenuInfo
info
=
menuItem
.
getMenuInfo
();
int
position
=
((
AdapterContextMenuInfo
)
info
).
position
;
ContactListItem
item
=
adapter
.
getItem
(
position
);
removeContact
(
item
.
getContact
().
getId
());
String
deleted
=
getString
(
R
.
string
.
contact_deleted_toast
);
Toast
.
makeText
(
this
,
deleted
,
LENGTH_SHORT
).
show
();
}
return
true
;
}
private
void
removeContact
(
final
ContactId
c
)
{
runOnDbThread
(
new
Runnable
()
{
public
void
run
()
{
try
{
db
.
removeContact
(
c
);
}
catch
(
DbException
e
)
{
if
(
LOG
.
isLoggable
(
WARNING
))
LOG
.
log
(
WARNING
,
e
.
toString
(),
e
);
}
}
});
}
public
void
eventOccurred
(
Event
e
)
{
if
(
e
instanceof
ContactAddedEvent
)
{
loadContacts
();
}
else
if
(
e
instanceof
ContactRemovedEvent
)
{
// Reload the conversation, expecting NoSuchContactException
LOG
.
info
(
"Contact removed, reloading"
);
reloadContact
(((
ContactRemovedEvent
)
e
).
getContactId
());
LOG
.
info
(
"Contact removed"
);
removeItem
(((
ContactRemovedEvent
)
e
).
getContactId
());
}
else
if
(
e
instanceof
MessageAddedEvent
)
{
LOG
.
info
(
"Message added, reloading"
);
ContactId
source
=
((
MessageAddedEvent
)
e
).
getContactId
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment