Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
920eb760
Commit
920eb760
authored
Feb 18, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FingerprintViewer and QuestionViewer: old contact title removed.
Light refactoring.
parent
3b651f6e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
102 deletions
+71
-102
SMProgress.java
...ava/com/xabber/android/data/extension/otr/SMProgress.java
+1
-1
FingerprintViewer.java
...rc/main/java/com/xabber/android/ui/FingerprintViewer.java
+42
-56
QuestionViewer.java
app/src/main/java/com/xabber/android/ui/QuestionViewer.java
+28
-39
fingerprint_viewer.xml
app/src/main/res/layout/fingerprint_viewer.xml
+0
-2
question_viewer.xml
app/src/main/res/layout/question_viewer.xml
+0
-2
secret_viewer.xml
app/src/main/res/layout/secret_viewer.xml
+0
-2
No files found.
app/src/main/java/com/xabber/android/data/extension/otr/SMProgress.java
View file @
920eb760
...
...
@@ -31,7 +31,7 @@ public class SMProgress extends BaseEntity implements EntityNotificationItem {
@Override
public
Intent
getIntent
()
{
return
QuestionViewer
.
createCanelIntent
(
return
QuestionViewer
.
createCan
c
elIntent
(
Application
.
getInstance
(),
account
,
user
);
}
...
...
app/src/main/java/com/xabber/android/ui/FingerprintViewer.java
View file @
920eb760
...
...
@@ -48,7 +48,6 @@ import com.xabber.android.ui.dialog.DialogBuilder;
import
com.xabber.android.ui.dialog.NotificationDialogBuilder
;
import
com.xabber.android.ui.dialog.NotificationDialogListener
;
import
com.xabber.android.ui.helper.ContactTitleActionBarInflater
;
import
com.xabber.android.ui.helper.ContactTitleInflater
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
import
com.xabber.xmpp.address.Jid
;
...
...
@@ -88,30 +87,26 @@ public class FingerprintViewer extends ManagedActivity implements
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
isFinishing
())
if
(
isFinishing
())
{
return
;
}
setContentView
(
R
.
layout
.
fingerprint_viewer
);
integrator
=
new
IntentIntegrator
(
this
);
Intent
intent
=
getIntent
();
account
=
getAccount
(
intent
);
user
=
getUser
(
intent
);
if
(
AccountManager
.
getInstance
().
getAccount
(
account
)
==
null
||
user
==
null
)
{
if
(
AccountManager
.
getInstance
().
getAccount
(
account
)
==
null
||
user
==
null
)
{
Application
.
getInstance
().
onError
(
R
.
string
.
ENTRY_IS_NOT_FOUND
);
finish
();
return
;
}
if
(
savedInstanceState
!=
null
)
{
remoteFingerprint
=
savedInstanceState
.
getString
(
SAVED_REMOTE_FINGERPRINT
);
localFingerprint
=
savedInstanceState
.
getString
(
SAVED_LOCAL_FINGERPRINT
);
remoteFingerprint
=
savedInstanceState
.
getString
(
SAVED_REMOTE_FINGERPRINT
);
localFingerprint
=
savedInstanceState
.
getString
(
SAVED_LOCAL_FINGERPRINT
);
}
else
{
remoteFingerprint
=
OTRManager
.
getInstance
().
getRemoteFingerprint
(
account
,
user
);
localFingerprint
=
OTRManager
.
getInstance
().
getLocalFingerprint
(
account
);
remoteFingerprint
=
OTRManager
.
getInstance
().
getRemoteFingerprint
(
account
,
user
);
localFingerprint
=
OTRManager
.
getInstance
().
getLocalFingerprint
(
account
);
}
verifiedView
=
(
CheckBox
)
findViewById
(
R
.
id
.
verified
);
verifiedView
.
setOnCheckedChangeListener
(
this
);
...
...
@@ -130,20 +125,16 @@ public class FingerprintViewer extends ManagedActivity implements
@Override
protected
void
onResume
()
{
super
.
onResume
();
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
update
();
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
Application
.
getInstance
().
removeUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnContactChangedListener
.
class
,
this
);
}
@Override
...
...
@@ -169,36 +160,39 @@ public class FingerprintViewer extends ManagedActivity implements
String
code
=
scanResult
.
getContents
();
boolean
equals
=
code
!=
null
&&
code
.
equals
(
remoteFingerprint
);
verifiedView
.
setChecked
(
equals
);
if
(
equals
)
if
(
equals
)
{
showDialog
(
R
.
string
.
action_otr_smp_verified
);
else
}
else
{
showDialog
(
R
.
string
.
action_otr_smp_unverified
);
}
}
}
@Override
public
void
onContactsChanged
(
Collection
<
BaseEntity
>
entities
)
{
String
thisBareAddress
=
Jid
.
getBareAddress
(
user
);
for
(
BaseEntity
entity
:
entities
)
for
(
BaseEntity
entity
:
entities
)
{
if
(
entity
.
equals
(
account
,
thisBareAddress
))
{
update
();
break
;
}
}
}
@Override
public
void
onAccountsChanged
(
Collection
<
String
>
accounts
)
{
if
(
accounts
.
contains
(
account
))
if
(
accounts
.
contains
(
account
))
{
update
();
}
}
@Override
public
void
onCheckedChanged
(
CompoundButton
buttonView
,
boolean
isChecked
)
{
switch
(
buttonView
.
getId
())
{
case
R
.
id
.
verified
:
if
(!
isUpdating
)
OTRManager
.
getInstance
().
setVerify
(
account
,
user
,
remoteFingerprint
,
isChecked
);
if
(!
isUpdating
)
{
OTRManager
.
getInstance
().
setVerify
(
account
,
user
,
remoteFingerprint
,
isChecked
);
}
break
;
default
:
break
;
...
...
@@ -211,8 +205,9 @@ public class FingerprintViewer extends ManagedActivity implements
* @param alertDialog
*/
private
void
wrapInstallDialog
(
AlertDialog
alertDialog
)
{
if
(
alertDialog
==
null
)
if
(
alertDialog
==
null
)
{
return
;
}
alertDialog
.
dismiss
();
showDialog
(
R
.
string
.
zxing_install_message
);
}
...
...
@@ -221,16 +216,14 @@ public class FingerprintViewer extends ManagedActivity implements
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
scan
:
wrapInstallDialog
(
integrator
.
initiateScan
(
IntentIntegrator
.
QR_CODE_TYPES
));
wrapInstallDialog
(
integrator
.
initiateScan
(
IntentIntegrator
.
QR_CODE_TYPES
));
break
;
case
R
.
id
.
show
:
wrapInstallDialog
(
integrator
.
shareText
(
localFingerprint
));
break
;
case
R
.
id
.
copy
:
((
ClipboardManager
)
getSystemService
(
CLIPBOARD_SERVICE
))
.
setText
(((
TextView
)
findViewById
(
R
.
id
.
otr_local_fingerprint
))
.
getText
());
.
setText
(((
TextView
)
findViewById
(
R
.
id
.
otr_local_fingerprint
)).
getText
());
break
;
default
:
break
;
...
...
@@ -241,17 +234,17 @@ public class FingerprintViewer extends ManagedActivity implements
protected
Dialog
onCreateDialog
(
int
id
)
{
switch
(
id
)
{
case
R
.
string
.
zxing_install_message
:
return
new
ConfirmDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
zxing_install_message
).
create
();
return
new
ConfirmDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
zxing_install_message
).
create
();
case
R
.
string
.
zxing_install_fail
:
return
new
NotificationDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
zxing_install_fail
).
create
();
return
new
NotificationDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
zxing_install_fail
).
create
();
case
R
.
string
.
action_otr_smp_verified
:
return
new
NotificationDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
action_otr_smp_verified
).
create
();
return
new
NotificationDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
action_otr_smp_verified
).
create
();
case
R
.
string
.
action_otr_smp_unverified
:
return
new
NotificationDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
action_otr_smp_unverified
).
create
();
return
new
NotificationDialogBuilder
(
this
,
id
,
this
)
.
setMessage
(
R
.
string
.
action_otr_smp_unverified
).
create
();
default
:
return
super
.
onCreateDialog
(
id
);
}
...
...
@@ -261,8 +254,7 @@ public class FingerprintViewer extends ManagedActivity implements
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
R
.
string
.
zxing_install_message
:
Uri
uri
=
Uri
.
parse
(
"market://details?id="
+
IntentIntegrator
.
BS_PACKAGE
);
Uri
uri
=
Uri
.
parse
(
"market://details?id="
+
IntentIntegrator
.
BS_PACKAGE
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
uri
);
try
{
startActivity
(
intent
);
...
...
@@ -286,30 +278,24 @@ public class FingerprintViewer extends ManagedActivity implements
private
void
update
()
{
isUpdating
=
true
;
AbstractContact
abstractContact
=
RosterManager
.
getInstance
()
.
getBestContact
(
account
,
user
);
ContactTitleInflater
.
updateTitle
(
findViewById
(
R
.
id
.
title
),
this
,
abstractContact
);
verifiedView
.
setChecked
(
OTRManager
.
getInstance
().
isVerified
(
account
,
user
));
AbstractContact
abstractContact
=
RosterManager
.
getInstance
().
getBestContact
(
account
,
user
);
verifiedView
.
setChecked
(
OTRManager
.
getInstance
().
isVerified
(
account
,
user
));
scanView
.
setEnabled
(
remoteFingerprint
!=
null
);
verifiedView
.
setEnabled
(
remoteFingerprint
!=
null
);
((
TextView
)
findViewById
(
R
.
id
.
otr_remote_fingerprint
))
.
setText
(
remoteFingerprint
==
null
?
getString
(
R
.
string
.
unknown
)
:
CertificateManager
.
showFingerprint
(
remoteFingerprint
));
((
TextView
)
findViewById
(
R
.
id
.
otr_remote_fingerprint
)).
setText
(
remoteFingerprint
==
null
?
getString
(
R
.
string
.
unknown
)
:
CertificateManager
.
showFingerprint
(
remoteFingerprint
));
showView
.
setEnabled
(
localFingerprint
!=
null
);
copyView
.
setEnabled
(
localFingerprint
!=
null
);
((
TextView
)
findViewById
(
R
.
id
.
otr_local_fingerprint
))
.
setText
(
localFingerprint
==
null
?
getString
(
R
.
string
.
unknown
)
:
CertificateManager
.
showFingerprint
(
localFingerprint
));
((
TextView
)
findViewById
(
R
.
id
.
otr_local_fingerprint
)).
setText
(
localFingerprint
==
null
?
getString
(
R
.
string
.
unknown
)
:
CertificateManager
.
showFingerprint
(
localFingerprint
));
contactTitleActionBarInflater
.
update
(
abstractContact
);
isUpdating
=
false
;
}
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
)
{
return
new
EntityIntentBuilder
(
context
,
FingerprintViewer
.
class
)
.
setAccount
(
account
).
setUser
(
user
).
build
();
}
...
...
app/src/main/java/com/xabber/android/ui/QuestionViewer.java
View file @
920eb760
...
...
@@ -34,7 +34,6 @@ import com.xabber.android.data.roster.AbstractContact;
import
com.xabber.android.data.roster.OnContactChangedListener
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.helper.ContactTitleActionBarInflater
;
import
com.xabber.android.ui.helper.ContactTitleInflater
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
import
com.xabber.xmpp.address.Jid
;
...
...
@@ -64,14 +63,14 @@ public class QuestionViewer extends ManagedActivity implements
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
isFinishing
())
if
(
isFinishing
())
{
return
;
}
Intent
intent
=
getIntent
();
account
=
QuestionViewer
.
getAccount
(
intent
);
user
=
QuestionViewer
.
getUser
(
intent
);
if
(
AccountManager
.
getInstance
().
getAccount
(
account
)
==
null
||
user
==
null
)
{
if
(
AccountManager
.
getInstance
().
getAccount
(
account
)
==
null
||
user
==
null
)
{
Application
.
getInstance
().
onError
(
R
.
string
.
ENTRY_IS_NOT_FOUND
);
finish
();
return
;
...
...
@@ -86,18 +85,19 @@ public class QuestionViewer extends ManagedActivity implements
return
;
}
showQuestion
=
intent
.
getBooleanExtra
(
EXTRA_FIELD_SHOW_QUESTION
,
true
);
answerRequest
=
intent
.
getBooleanExtra
(
EXTRA_FIELD_ANSWER_REQUEST
,
false
);
answerRequest
=
intent
.
getBooleanExtra
(
EXTRA_FIELD_ANSWER_REQUEST
,
false
);
if
(
showQuestion
)
{
setContentView
(
R
.
layout
.
question_viewer
);
questionView
=
(
EditText
)
findViewById
(
R
.
id
.
question
);
questionView
.
setEnabled
(!
answerRequest
);
if
(
answerRequest
)
if
(
answerRequest
)
{
questionView
.
setText
(
intent
.
getStringExtra
(
Intent
.
EXTRA_TEXT
));
else
}
else
{
findViewById
(
R
.
id
.
cancel
).
setVisibility
(
View
.
GONE
);
}
else
}
}
else
{
setContentView
(
R
.
layout
.
secret_viewer
);
}
findViewById
(
R
.
id
.
cancel
).
setOnClickListener
(
this
);
findViewById
(
R
.
id
.
send
).
setOnClickListener
(
this
);
...
...
@@ -108,53 +108,48 @@ public class QuestionViewer extends ManagedActivity implements
@Override
protected
void
onResume
()
{
super
.
onResume
();
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
addUIListener
(
OnContactChangedListener
.
class
,
this
);
update
();
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
Application
.
getInstance
().
removeUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnContactChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnAccountChangedListener
.
class
,
this
);
Application
.
getInstance
().
removeUIListener
(
OnContactChangedListener
.
class
,
this
);
}
@Override
public
void
onContactsChanged
(
Collection
<
BaseEntity
>
entities
)
{
String
thisBareAddress
=
Jid
.
getBareAddress
(
user
);
for
(
BaseEntity
entity
:
entities
)
for
(
BaseEntity
entity
:
entities
)
{
if
(
entity
.
equals
(
account
,
thisBareAddress
))
{
update
();
break
;
}
}
}
@Override
public
void
onAccountsChanged
(
Collection
<
String
>
accounts
)
{
if
(
accounts
.
contains
(
account
))
if
(
accounts
.
contains
(
account
))
{
update
();
}
}
@Override
public
void
onClick
(
View
view
)
{
switch
(
view
.
getId
())
{
case
R
.
id
.
send
:
String
question
=
showQuestion
?
questionView
.
getText
().
toString
()
:
null
;
String
answer
=
((
TextView
)
findViewById
(
R
.
id
.
answer
)).
getText
()
.
toString
();
String
question
=
showQuestion
?
questionView
.
getText
().
toString
()
:
null
;
String
answer
=
((
TextView
)
findViewById
(
R
.
id
.
answer
)).
getText
().
toString
();
try
{
if
(
answerRequest
)
OTRManager
.
getInstance
().
respondSmp
(
account
,
user
,
question
,
answer
);
else
OTRManager
.
getInstance
().
initSmp
(
account
,
user
,
question
,
answer
);
if
(
answerRequest
)
{
OTRManager
.
getInstance
().
respondSmp
(
account
,
user
,
question
,
answer
);
}
else
{
OTRManager
.
getInstance
().
initSmp
(
account
,
user
,
question
,
answer
);
}
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
}
...
...
@@ -173,11 +168,7 @@ public class QuestionViewer extends ManagedActivity implements
}
private
void
update
()
{
AbstractContact
abstractContact
=
RosterManager
.
getInstance
()
.
getBestContact
(
account
,
user
);
ContactTitleInflater
.
updateTitle
(
findViewById
(
R
.
id
.
title
),
this
,
abstractContact
);
AbstractContact
abstractContact
=
RosterManager
.
getInstance
().
getBestContact
(
account
,
user
);
contactTitleActionBarInflater
.
update
(
abstractContact
);
}
...
...
@@ -187,8 +178,7 @@ public class QuestionViewer extends ManagedActivity implements
* @param user
* @return Intent to cancel negotiation.
*/
public
static
Intent
createCanelIntent
(
Context
context
,
String
account
,
String
user
)
{
public
static
Intent
createCancelIntent
(
Context
context
,
String
account
,
String
user
)
{
Intent
intent
=
new
EntityIntentBuilder
(
context
,
QuestionViewer
.
class
)
.
setAccount
(
account
).
setUser
(
user
).
build
();
intent
.
putExtra
(
EXTRA_FIELD_CANCEL
,
true
);
...
...
@@ -205,9 +195,8 @@ public class QuestionViewer extends ManagedActivity implements
* answerRequest are <code>true</code>.
* @return
*/
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
,
boolean
showQuestion
,
boolean
answerRequest
,
String
question
)
{
public
static
Intent
createIntent
(
Context
context
,
String
account
,
String
user
,
boolean
showQuestion
,
boolean
answerRequest
,
String
question
)
{
Intent
intent
=
new
EntityIntentBuilder
(
context
,
QuestionViewer
.
class
)
.
setAccount
(
account
).
setUser
(
user
).
build
();
intent
.
putExtra
(
EXTRA_FIELD_SHOW_QUESTION
,
showQuestion
);
...
...
app/src/main/res/layout/fingerprint_viewer.xml
View file @
920eb760
...
...
@@ -19,8 +19,6 @@
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/contact_title"
/>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
...
...
app/src/main/res/layout/question_viewer.xml
View file @
920eb760
...
...
@@ -19,8 +19,6 @@
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/contact_title"
/>
<ScrollView
android:orientation=
"vertical"
android:layout_width=
"match_parent"
...
...
app/src/main/res/layout/secret_viewer.xml
View file @
920eb760
...
...
@@ -19,8 +19,6 @@
android:layout_height=
"match_parent"
>
<include
layout=
"@layout/contact_title"
/>
<ScrollView
android:orientation=
"vertical"
android:layout_width=
"match_parent"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment