Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-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
AloqaIM-Android
Commits
c12261d1
Commit
c12261d1
authored
Jan 28, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hoge
parent
d0cfaf64
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
18 deletions
+180
-18
AbstractUploadActionItem.java
...thelper/extra_action/upload/AbstractUploadActionItem.java
+73
-3
AudioUploadActionItem.java
...youthelper/extra_action/upload/AudioUploadActionItem.java
+40
-5
ImageUploadActionItem.java
...youthelper/extra_action/upload/ImageUploadActionItem.java
+22
-5
VideoUploadActionItem.java
...youthelper/extra_action/upload/VideoUploadActionItem.java
+41
-5
strings.xml
app/src/main/res/values/strings.xml
+4
-0
No files found.
app/src/main/java/chat/rocket/android/layouthelper/extra_action/upload/AbstractUploadActionItem.java
View file @
c12261d1
package
chat
.
rocket
.
android
.
layouthelper
.
extra_action
.
upload
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.StringRes
;
import
android.support.v4.app.Fragment
;
import
android.support.v7.app.AlertDialog
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ArrayAdapter
;
import
android.widget.TextView
;
import
chat.rocket.android.R
;
import
chat.rocket.android.layouthelper.extra_action.AbstractExtraActionItem
;
...
...
@@ -13,15 +21,77 @@ public abstract class AbstractUploadActionItem extends AbstractExtraActionItem {
@Override
public
void
handleItemSelectedOnActivity
(
Activity
activity
)
{
activity
.
startActivityForResult
(
getIntentForPickFile
(),
RC_UPL
);
DetailItemInfo
[]
itemList
=
getDetailItemList
();
if
(
itemList
.
length
>=
2
)
{
showSelectionDialog
(
activity
,
itemList
,
index
->
handleDetailItemInfo
(
activity
,
itemList
[
index
]));
}
else
if
(
itemList
.
length
==
1
)
{
handleDetailItemInfo
(
activity
,
itemList
[
0
]);
}
}
@Override
public
void
handleItemSelectedOnFragment
(
Fragment
fragment
)
{
fragment
.
startActivityForResult
(
getIntentForPickFile
(),
RC_UPL
);
DetailItemInfo
[]
itemList
=
getDetailItemList
();
if
(
itemList
.
length
>=
2
)
{
showSelectionDialog
(
fragment
.
getContext
(),
itemList
,
index
->
handleDetailItemInfo
(
fragment
,
itemList
[
index
]));
}
else
if
(
itemList
.
length
==
1
)
{
handleDetailItemInfo
(
fragment
,
itemList
[
0
]);
}
}
private
void
handleDetailItemInfo
(
Activity
activity
,
DetailItemInfo
info
)
{
if
(
info
!=
null
)
{
activity
.
startActivityForResult
(
info
.
getIntent
(),
info
.
getReturnCode
());
}
}
private
void
handleDetailItemInfo
(
Fragment
fragment
,
DetailItemInfo
info
)
{
if
(
info
!=
null
)
{
fragment
.
startActivityForResult
(
info
.
getIntent
(),
info
.
getReturnCode
());
}
}
private
interface
OnSelectedCallback
{
void
onSelected
(
int
index
);
}
protected
abstract
Intent
getIntentForPickFile
();
private
void
showSelectionDialog
(
Context
context
,
DetailItemInfo
[]
itemList
,
OnSelectedCallback
callback
)
{
ArrayAdapter
<
DetailItemInfo
>
adapter
=
new
ArrayAdapter
<
DetailItemInfo
>(
context
,
android
.
R
.
layout
.
simple_list_item_1
,
android
.
R
.
id
.
text1
,
itemList
)
{
@NonNull
@Override
public
View
getView
(
int
position
,
View
convertView
,
ViewGroup
parent
)
{
TextView
text
=
(
TextView
)
super
.
getView
(
position
,
convertView
,
parent
);
text
.
setText
(
itemList
[
position
].
getCaption
());
return
text
;
}
};
// TODO: BottomSheet...
new
AlertDialog
.
Builder
(
context
,
R
.
style
.
AppTheme_Dialog
)
.
setAdapter
(
adapter
,
(
dialogInterface
,
index
)
->
callback
.
onSelected
(
index
))
.
show
();
}
protected
abstract
DetailItemInfo
[]
getDetailItemList
();
protected
interface
DetailItemInfo
{
Intent
getIntent
();
@StringRes
int
getCaption
();
/**
* code used for param of startActivityForResult.
*/
int
getReturnCode
();
}
@Override
public
int
getBackgroundTint
()
{
...
...
app/src/main/java/chat/rocket/android/layouthelper/extra_action/upload/AudioUploadActionItem.java
View file @
c12261d1
package
chat
.
rocket
.
android
.
layouthelper
.
extra_action
.
upload
;
import
android.content.Intent
;
import
android.provider.MediaStore
;
import
chat.rocket.android.R
;
...
...
@@ -12,11 +13,45 @@ public class AudioUploadActionItem extends AbstractUploadActionItem {
}
@Override
protected
Intent
getIntentForPickFile
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"audio/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select Audio to Upload"
);
protected
DetailItemInfo
[]
getDetailItemList
()
{
return
new
DetailItemInfo
[]
{
new
DetailItemInfo
()
{
@Override
public
Intent
getIntent
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"audio/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select Audio to Upload"
);
}
@Override
public
int
getCaption
()
{
return
R
.
string
.
title_pick_file
;
}
@Override
public
int
getReturnCode
()
{
return
RC_UPL
;
}
},
new
DetailItemInfo
()
{
@Override
public
Intent
getIntent
()
{
Intent
intent
=
new
Intent
(
MediaStore
.
Audio
.
Media
.
RECORD_SOUND_ACTION
);
return
Intent
.
createChooser
(
intent
,
"Select audio recorder"
);
}
@Override
public
int
getCaption
()
{
return
R
.
string
.
title_record_audio
;
}
@Override
public
int
getReturnCode
()
{
return
RC_UPL
;
}
}
};
}
@Override
...
...
app/src/main/java/chat/rocket/android/layouthelper/extra_action/upload/ImageUploadActionItem.java
View file @
c12261d1
...
...
@@ -12,11 +12,28 @@ public class ImageUploadActionItem extends AbstractUploadActionItem {
}
@Override
protected
Intent
getIntentForPickFile
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"image/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select Picture to Upload"
);
protected
DetailItemInfo
[]
getDetailItemList
()
{
return
new
DetailItemInfo
[]
{
new
DetailItemInfo
()
{
@Override
public
Intent
getIntent
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"image/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select Picture to Upload"
);
}
@Override
public
int
getCaption
()
{
return
R
.
string
.
title_pick_file
;
}
@Override
public
int
getReturnCode
()
{
return
RC_UPL
;
}
}
};
}
@Override
...
...
app/src/main/java/chat/rocket/android/layouthelper/extra_action/upload/VideoUploadActionItem.java
View file @
c12261d1
package
chat
.
rocket
.
android
.
layouthelper
.
extra_action
.
upload
;
import
android.content.Intent
;
import
android.provider.MediaStore
;
import
chat.rocket.android.R
;
...
...
@@ -12,11 +13,46 @@ public class VideoUploadActionItem extends AbstractUploadActionItem {
}
@Override
protected
Intent
getIntentForPickFile
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"video/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select Video to Upload"
);
protected
DetailItemInfo
[]
getDetailItemList
()
{
return
new
DetailItemInfo
[]
{
new
DetailItemInfo
()
{
@Override
public
Intent
getIntent
()
{
Intent
intent
=
new
Intent
();
intent
.
setType
(
"video/*"
);
intent
.
setAction
(
Intent
.
ACTION_GET_CONTENT
);
return
Intent
.
createChooser
(
intent
,
"Select Video to Upload"
);
}
@Override
public
int
getCaption
()
{
return
R
.
string
.
title_pick_file
;
}
@Override
public
int
getReturnCode
()
{
return
RC_UPL
;
}
},
new
DetailItemInfo
()
{
@Override
public
Intent
getIntent
()
{
Intent
intent
=
new
Intent
(
MediaStore
.
ACTION_VIDEO_CAPTURE
);
intent
.
putExtra
(
MediaStore
.
EXTRA_VIDEO_QUALITY
,
0
);
//low quality.
return
Intent
.
createChooser
(
intent
,
"Select video recorder"
);
}
@Override
public
int
getCaption
()
{
return
R
.
string
.
title_record_video
;
}
@Override
public
int
getReturnCode
()
{
return
RC_UPL
;
}
}
};
}
@Override
...
...
app/src/main/res/values/strings.xml
View file @
c12261d1
...
...
@@ -41,6 +41,10 @@
<string
name=
"image_upload_message_spec_title"
>
Attach image
</string>
<string
name=
"audio_upload_message_spec_title"
>
Attach audio
</string>
<string
name=
"video_upload_message_spec_title"
>
Attach video
</string>
<string
name=
"title_pick_file"
>
Select file
</string>
<string
name=
"title_take_picture"
>
Take picture
</string>
<string
name=
"title_record_audio"
>
Record audio
</string>
<string
name=
"title_record_video"
>
Record video
</string>
<string
name=
"input_hostname_invalid_server_message"
>
Invalid server version
</string>
<string
name=
"connection_error_try_later"
>
There\'s a connection error. Please try later.
</string>
...
...
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