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
df90f988
Unverified
Commit
df90f988
authored
Apr 29, 2019
by
Filipe de Lima Brito
Committed by
GitHub
Apr 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 2254-nbamir
parents
58cef268
fdf25924
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
6 deletions
+45
-6
AndroidPermissionsHelper.kt
...va/chat/rocket/android/helper/AndroidPermissionsHelper.kt
+3
-3
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+42
-3
No files found.
app/src/main/java/chat/rocket/android/helper/AndroidPermissionsHelper.kt
View file @
df90f988
...
...
@@ -26,7 +26,7 @@ object AndroidPermissionsHelper {
}
fun
hasCameraPermission
(
context
:
Context
):
Boolean
{
return
AndroidPermissionsHelper
.
checkPermission
(
context
,
Manifest
.
permission
.
CAMERA
)
return
checkPermission
(
context
,
Manifest
.
permission
.
CAMERA
)
}
fun
getCameraPermission
(
fragment
:
Fragment
)
{
...
...
@@ -50,10 +50,10 @@ object AndroidPermissionsHelper {
fun
checkWritingPermission
(
context
:
Context
)
{
if
(
context
is
ContextThemeWrapper
)
{
val
activity
=
if
(
context
.
baseContext
is
Activity
)
context
.
baseContext
as
Activity
else
context
as
Activity
AndroidPermissionsHelper
.
requestPermission
(
requestPermission
(
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
AndroidPermissionsHelper
.
WRITE_EXTERNAL_STORAGE_CODE
WRITE_EXTERNAL_STORAGE_CODE
)
}
}
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
df90f988
...
...
@@ -3,6 +3,7 @@ package chat.rocket.android.profile.ui
import
DrawableHelper
import
android.app.Activity
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.graphics.Bitmap
import
android.os.Build
import
android.os.Bundle
...
...
@@ -21,6 +22,9 @@ import androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
import
chat.rocket.android.analytics.event.ScreenViewEvent
import
chat.rocket.android.helper.AndroidPermissionsHelper
import
chat.rocket.android.helper.AndroidPermissionsHelper.getCameraPermission
import
chat.rocket.android.helper.AndroidPermissionsHelper.hasCameraPermission
import
chat.rocket.android.main.ui.MainActivity
import
chat.rocket.android.profile.presentation.ProfilePresenter
import
chat.rocket.android.profile.presentation.ProfileView
...
...
@@ -35,12 +39,15 @@ import chat.rocket.android.util.invalidateFirebaseToken
import
chat.rocket.common.model.UserStatus
import
chat.rocket.common.model.userStatusOf
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.google.android.material.snackbar.Snackbar
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.rxkotlin.Observables
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.avatar_profile.*
import
kotlinx.android.synthetic.main.fragment_profile.*
import
kotlinx.android.synthetic.main.fragment_profile.view_dim
import
kotlinx.android.synthetic.main.fragment_profile.view_loading
import
kotlinx.android.synthetic.main.update_avatar_options.*
import
javax.inject.Inject
...
...
@@ -52,8 +59,10 @@ private const val REQUEST_CODE_FOR_PERFORM_CAMERA = 2
fun
newInstance
()
=
ProfileFragment
()
class
ProfileFragment
:
Fragment
(),
ProfileView
,
ActionMode
.
Callback
{
@Inject
lateinit
var
presenter
:
ProfilePresenter
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
lateinit
var
presenter
:
ProfilePresenter
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
private
var
currentStatus
=
""
private
var
currentName
=
""
private
var
currentUsername
=
""
...
...
@@ -223,7 +232,13 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
button_take_a_photo
.
setOnClickListener
{
dispatchTakePicture
(
REQUEST_CODE_FOR_PERFORM_CAMERA
)
context
?.
let
{
if
(
hasCameraPermission
(
it
))
{
dispatchTakePicture
(
REQUEST_CODE_FOR_PERFORM_CAMERA
)
}
else
{
getCameraPermission
(
this
)
}
}
hideUpdateAvatarOptions
()
}
...
...
@@ -331,4 +346,28 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}.
show
()
}
}
override
fun
onRequestPermissionsResult
(
requestCode
:
Int
,
permissions
:
Array
<
out
String
>,
grantResults
:
IntArray
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
)
when
(
requestCode
)
{
AndroidPermissionsHelper
.
CAMERA_CODE
->
{
if
(
grantResults
.
isNotEmpty
()
&&
grantResults
[
0
]
==
PackageManager
.
PERMISSION_GRANTED
)
{
// permission was granted
dispatchTakePicture
(
REQUEST_CODE_FOR_PERFORM_CAMERA
)
}
else
{
// permission denied
Snackbar
.
make
(
relative_layout
,
R
.
string
.
msg_camera_permission_denied
,
Snackbar
.
LENGTH_SHORT
).
show
()
}
return
}
}
}
}
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