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
a224f08a
Commit
a224f08a
authored
May 14, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rude fix for export chat crash #420
parent
877c7295
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
23 deletions
+19
-23
ChatExportDialogFragment.java
...om/xabber/android/ui/dialog/ChatExportDialogFragment.java
+19
-23
No files found.
app/src/main/java/com/xabber/android/ui/dialog/ChatExportDialogFragment.java
View file @
a224f08a
...
...
@@ -14,6 +14,7 @@
*/
package
com
.
xabber
.
android
.
ui
.
dialog
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.app.AlertDialog.Builder
;
import
android.app.DialogFragment
;
...
...
@@ -42,29 +43,26 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
private
String
user
;
private
EditText
nameView
;
private
CheckBox
sendView
;
private
Activity
activity
;
/**
* @param account
* @param user
* @return
*/
public
static
DialogFragment
newInstance
(
String
account
,
String
user
)
{
return
new
ChatExportDialogFragment
().
putAgrument
(
ACCOUNT
,
account
).
putAgrument
(
USER
,
user
);
}
@Override
protected
Builder
getBuilder
()
{
activity
=
getActivity
();
account
=
getArguments
().
getString
(
ACCOUNT
);
user
=
getArguments
().
getString
(
USER
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
getActivity
()
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
activity
);
builder
.
setTitle
(
R
.
string
.
export_chat_title
);
View
layout
=
getActivity
().
getLayoutInflater
().
inflate
(
R
.
layout
.
export_chat
,
null
);
View
layout
=
activity
.
getLayoutInflater
().
inflate
(
R
.
layout
.
export_chat
,
null
);
nameView
=
(
EditText
)
layout
.
findViewById
(
R
.
id
.
name
);
sendView
=
(
CheckBox
)
layout
.
findViewById
(
R
.
id
.
send
);
nameView
.
setText
(
getString
(
R
.
string
.
export_chat_mask
,
AccountManager
.
getInstance
().
getVerboseName
(
account
),
RosterManager
.
getInstance
().
getName
(
account
,
user
)));
nameView
.
setText
(
getString
(
R
.
string
.
export_chat_mask
,
AccountManager
.
getInstance
().
getVerboseName
(
account
),
RosterManager
.
getInstance
().
getName
(
account
,
user
)));
builder
.
setView
(
layout
);
return
builder
;
}
...
...
@@ -72,10 +70,10 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
@Override
protected
boolean
onPositiveClick
()
{
String
name
=
nameView
.
getText
().
toString
();
if
(
""
.
equals
(
name
))
if
(
""
.
equals
(
name
))
{
return
false
;
new
ChatExportAsyncTask
(
account
,
user
,
name
,
sendView
.
isChecked
())
.
execute
();
}
new
ChatExportAsyncTask
(
account
,
user
,
name
,
sendView
.
isChecked
())
.
execute
();
return
true
;
}
...
...
@@ -86,8 +84,7 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
private
final
String
name
;
private
final
boolean
send
;
public
ChatExportAsyncTask
(
String
account
,
String
user
,
String
name
,
boolean
send
)
{
public
ChatExportAsyncTask
(
String
account
,
String
user
,
String
name
,
boolean
send
)
{
this
.
account
=
account
;
this
.
user
=
user
;
this
.
name
=
name
;
...
...
@@ -97,8 +94,7 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
@Override
protected
File
doInBackground
(
Void
...
params
)
{
try
{
return
MessageManager
.
getInstance
().
exportChat
(
account
,
user
,
name
);
return
MessageManager
.
getInstance
().
exportChat
(
account
,
user
,
name
);
}
catch
(
NetworkException
e
)
{
Application
.
getInstance
().
onError
(
e
);
return
null
;
...
...
@@ -107,19 +103,19 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
@Override
public
void
onPostExecute
(
File
result
)
{
if
(
result
==
null
)
if
(
result
==
null
||
activity
==
null
)
{
return
;
}
// TODO: Use notification bar to notify about success.
if
(
send
)
{
Intent
intent
=
new
Intent
(
android
.
content
.
Intent
.
ACTION_SEND
);
intent
.
setType
(
"text/plain"
);
Uri
uri
=
Uri
.
fromFile
(
result
);
intent
.
putExtra
(
android
.
content
.
Intent
.
EXTRA_STREAM
,
uri
);
startActivity
(
Intent
.
createChooser
(
intent
,
getString
(
R
.
string
.
export_chat
)));
activity
.
startActivity
(
Intent
.
createChooser
(
intent
,
activity
.
getString
(
R
.
string
.
export_chat
)));
}
else
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
export_chat_done
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
R
.
string
.
export_chat_done
,
Toast
.
LENGTH_LONG
).
show
();
}
}
...
...
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