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
a377458f
Commit
a377458f
authored
Apr 29, 2019
by
Cool-fire
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/issue-profile-render' into issue-profile-render
parents
09e920ba
dfd6437c
Changes
2
Show 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 @
a377458f
...
@@ -26,7 +26,7 @@ object AndroidPermissionsHelper {
...
@@ -26,7 +26,7 @@ object AndroidPermissionsHelper {
}
}
fun
hasCameraPermission
(
context
:
Context
):
Boolean
{
fun
hasCameraPermission
(
context
:
Context
):
Boolean
{
return
AndroidPermissionsHelper
.
checkPermission
(
context
,
Manifest
.
permission
.
CAMERA
)
return
checkPermission
(
context
,
Manifest
.
permission
.
CAMERA
)
}
}
fun
getCameraPermission
(
fragment
:
Fragment
)
{
fun
getCameraPermission
(
fragment
:
Fragment
)
{
...
@@ -50,10 +50,10 @@ object AndroidPermissionsHelper {
...
@@ -50,10 +50,10 @@ object AndroidPermissionsHelper {
fun
checkWritingPermission
(
context
:
Context
)
{
fun
checkWritingPermission
(
context
:
Context
)
{
if
(
context
is
ContextThemeWrapper
)
{
if
(
context
is
ContextThemeWrapper
)
{
val
activity
=
if
(
context
.
baseContext
is
Activity
)
context
.
baseContext
as
Activity
else
context
as
Activity
val
activity
=
if
(
context
.
baseContext
is
Activity
)
context
.
baseContext
as
Activity
else
context
as
Activity
AndroidPermissionsHelper
.
requestPermission
(
requestPermission
(
activity
,
activity
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
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 @
a377458f
...
@@ -3,6 +3,7 @@ package chat.rocket.android.profile.ui
...
@@ -3,6 +3,7 @@ package chat.rocket.android.profile.ui
import
DrawableHelper
import
DrawableHelper
import
android.app.Activity
import
android.app.Activity
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.graphics.Bitmap
import
android.graphics.Bitmap
import
android.os.Build
import
android.os.Build
import
android.os.Bundle
import
android.os.Bundle
...
@@ -21,6 +22,9 @@ import androidx.fragment.app.Fragment
...
@@ -21,6 +22,9 @@ import androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.analytics.AnalyticsManager
import
chat.rocket.android.analytics.AnalyticsManager
import
chat.rocket.android.analytics.event.ScreenViewEvent
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.main.ui.MainActivity
import
chat.rocket.android.profile.presentation.ProfilePresenter
import
chat.rocket.android.profile.presentation.ProfilePresenter
import
chat.rocket.android.profile.presentation.ProfileView
import
chat.rocket.android.profile.presentation.ProfileView
...
@@ -35,12 +39,15 @@ import chat.rocket.android.util.invalidateFirebaseToken
...
@@ -35,12 +39,15 @@ import chat.rocket.android.util.invalidateFirebaseToken
import
chat.rocket.common.model.UserStatus
import
chat.rocket.common.model.UserStatus
import
chat.rocket.common.model.userStatusOf
import
chat.rocket.common.model.userStatusOf
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.google.android.material.snackbar.Snackbar
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.rxkotlin.Observables
import
io.reactivex.rxkotlin.Observables
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.avatar_profile.*
import
kotlinx.android.synthetic.main.avatar_profile.*
import
kotlinx.android.synthetic.main.fragment_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
kotlinx.android.synthetic.main.update_avatar_options.*
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -52,8 +59,10 @@ private const val REQUEST_CODE_FOR_PERFORM_CAMERA = 2
...
@@ -52,8 +59,10 @@ private const val REQUEST_CODE_FOR_PERFORM_CAMERA = 2
fun
newInstance
()
=
ProfileFragment
()
fun
newInstance
()
=
ProfileFragment
()
class
ProfileFragment
:
Fragment
(),
ProfileView
,
ActionMode
.
Callback
{
class
ProfileFragment
:
Fragment
(),
ProfileView
,
ActionMode
.
Callback
{
@Inject
lateinit
var
presenter
:
ProfilePresenter
@Inject
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
lateinit
var
presenter
:
ProfilePresenter
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
private
var
currentStatus
=
""
private
var
currentStatus
=
""
private
var
currentName
=
""
private
var
currentName
=
""
private
var
currentUsername
=
""
private
var
currentUsername
=
""
...
@@ -223,7 +232,13 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -223,7 +232,13 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
}
button_take_a_photo
.
setOnClickListener
{
button_take_a_photo
.
setOnClickListener
{
context
?.
let
{
if
(
hasCameraPermission
(
it
))
{
dispatchTakePicture
(
REQUEST_CODE_FOR_PERFORM_CAMERA
)
dispatchTakePicture
(
REQUEST_CODE_FOR_PERFORM_CAMERA
)
}
else
{
getCameraPermission
(
this
)
}
}
hideUpdateAvatarOptions
()
hideUpdateAvatarOptions
()
}
}
...
@@ -331,4 +346,28 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -331,4 +346,28 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}.
show
()
}.
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