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
e329ca22
Unverified
Commit
e329ca22
authored
Aug 14, 2018
by
Filipe de Lima Brito
Committed by
GitHub
Aug 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1570 from RocketChat/new/admin-panel
[NEW] Adds the admin panel.
parents
960de03e
13f383d4
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
293 additions
and
151 deletions
+293
-151
CreateChannelFragment.kt
.../rocket/android/createchannel/ui/CreateChannelFragment.kt
+1
-1
UserHelper.kt
app/src/main/java/chat/rocket/android/helper/UserHelper.kt
+17
-41
MainNavigator.kt
...va/chat/rocket/android/main/presentation/MainNavigator.kt
+7
-0
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+5
-3
MainActivity.kt
...src/main/java/chat/rocket/android/main/ui/MainActivity.kt
+17
-32
Menu.kt
app/src/main/java/chat/rocket/android/main/ui/Menu.kt
+69
-0
PermissionsInteractor.kt
...hat/rocket/android/server/domain/PermissionsInteractor.kt
+35
-16
PermissionsRepository.kt
...hat/rocket/android/server/domain/PermissionsRepository.kt
+6
-6
SettingsFragment.kt
.../java/chat/rocket/android/settings/ui/SettingsFragment.kt
+4
-3
String.kt
...c/main/java/chat/rocket/android/util/extensions/String.kt
+2
-0
AdminPanelWebViewFragment.kt
...ndroid/webview/adminpanel/ui/AdminPanelWebViewFragment.kt
+76
-0
ic_logout_black_24dp.xml
app/src/main/res/drawable/ic_logout_black_24dp.xml
+3
-3
activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-2
fragment_admin_panel_web_view.xml
app/src/main/res/layout/fragment_admin_panel_web_view.xml
+29
-0
navigation.xml
app/src/main/res/menu/navigation.xml
+0
-44
strings.xml
app/src/main/res/values-de/strings.xml
+1
-0
strings.xml
app/src/main/res/values-es/strings.xml
+1
-0
strings.xml
app/src/main/res/values-fr/strings.xml
+1
-0
strings.xml
app/src/main/res/values-hi-rIN/strings.xml
+1
-0
strings.xml
app/src/main/res/values-pt-rBR/strings.xml
+1
-0
strings.xml
app/src/main/res/values-ru/strings.xml
+1
-0
ids.xml
app/src/main/res/values/ids.xml
+14
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/chat/rocket/android/createchannel/ui/CreateChannelFragment.kt
View file @
e329ca22
...
...
@@ -161,7 +161,7 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
override
fun
prepareToShowChatList
()
{
with
(
activity
as
MainActivity
)
{
setCheckedNavDrawerItem
(
R
.
id
.
action_chat_room
s
)
setCheckedNavDrawerItem
(
R
.
id
.
menu_action_chat
s
)
openDrawer
()
getDrawerLayout
().
postDelayed
(
1000
)
{
closeDrawer
()
...
...
app/src/main/java/chat/rocket/android/helper/UserHelper.kt
View file @
e329ca22
...
...
@@ -2,7 +2,6 @@ package chat.rocket.android.helper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.PublicSettings
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.common.model.SimpleUser
...
...
@@ -12,43 +11,13 @@ import javax.inject.Inject
class
UserHelper
@Inject
constructor
(
private
val
localRepository
:
LocalRepository
,
private
val
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
settingsRepository
:
SettingsRepository
private
val
settingsRepository
:
SettingsRepository
)
{
private
val
settings
:
PublicSettings
=
settingsRepository
.
get
(
getCurrentServerInteractor
.
get
()
!!
)
/**
* Return the display name for the given [user].
* If setting 'Use_Real_Name' is true then the real name will be given, or else
* the username without the '@' is yielded. The fallback for any case is the username, which
* could be null.
*/
fun
displayName
(
user
:
User
):
String
?
{
return
if
(
settings
.
useRealName
())
user
.
name
?:
user
.
username
else
user
.
username
}
fun
displayName
(
user
:
SimpleUser
):
String
{
return
if
(
settings
.
useRealName
())
user
.
name
?:
user
.
username
?:
""
else
user
.
username
?:
""
}
/**
* Return current logged user's display name.
*
* @see displayName
*/
fun
displayName
():
String
?
{
user
()
?.
let
{
return
displayName
(
it
)
}
return
null
}
/**
* Return current logged [User].
*/
fun
user
():
User
?
{
return
localRepository
.
getCurrentUser
(
serverUrl
())
}
fun
user
():
User
?
=
getCurrentServerInteractor
.
get
()
?.
let
{
localRepository
.
getCurrentUser
(
it
)
}
/**
* Return the username for the current logged [User].
...
...
@@ -56,13 +25,20 @@ class UserHelper @Inject constructor(
fun
username
():
String
?
=
localRepository
.
get
(
LocalRepository
.
CURRENT_USERNAME_KEY
,
null
)
/**
* Whether current [User] is admin on the current server.
* Return the display name for the given [user].
* If setting 'Use_Real_Name' is true then the real name will be given, otherwise the username
* without the '@' is yielded.
*/
fun
isAdmin
():
Boolean
{
return
user
()
?.
roles
?.
find
{
it
.
equals
(
"admin"
,
ignoreCase
=
true
)
}
!=
null
fun
displayName
(
user
:
SimpleUser
)
=
getCurrentServerInteractor
.
get
()
?.
let
{
if
(
settingsRepository
.
get
(
it
).
useRealName
())
{
user
.
name
}
else
{
user
.
username
}
}.
orEmpty
()
private
fun
serverUrl
():
String
{
return
getCurrentServerInteractor
.
get
()
!!
}
/**
* Whether current [User] is admin on the current server.
*/
fun
isAdmin
():
Boolean
=
user
()
?.
roles
?.
find
{
it
.
equals
(
"admin"
,
true
)
}
!=
null
}
app/src/main/java/chat/rocket/android/main/presentation/MainNavigator.kt
View file @
e329ca22
...
...
@@ -10,6 +10,7 @@ import chat.rocket.android.profile.ui.ProfileFragment
import
chat.rocket.android.server.ui.changeServerIntent
import
chat.rocket.android.settings.ui.SettingsFragment
import
chat.rocket.android.util.extensions.addFragment
import
chat.rocket.android.webview.adminpanel.ui.AdminPanelWebViewFragment
class
MainNavigator
(
internal
val
activity
:
MainActivity
)
{
...
...
@@ -37,6 +38,12 @@ class MainNavigator(internal val activity: MainActivity) {
}
}
fun
toAdminPanel
(
webPageUrl
:
String
,
userToken
:
String
)
{
activity
.
addFragment
(
"AdminPanelWebViewFragment"
,
R
.
id
.
fragment_container
)
{
AdminPanelWebViewFragment
.
newInstance
(
webPageUrl
,
userToken
)
}
}
fun
toChatRoom
(
chatRoomId
:
String
,
chatRoomName
:
String
,
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
e329ca22
...
...
@@ -20,6 +20,7 @@ import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.presentation.CheckServerPresenter
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.adminPanelUrl
import
chat.rocket.android.util.extensions.registerPushToken
import
chat.rocket.android.util.extensions.serverLogoUrl
import
chat.rocket.android.util.retryIO
...
...
@@ -28,14 +29,12 @@ import chat.rocket.common.RocketChatException
import
chat.rocket.common.model.UserStatus
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.RocketChatClient
import
chat.rocket.core.internal.realtime.setDefaultStatus
import
chat.rocket.core.internal.rest.logout
import
chat.rocket.core.internal.rest.me
import
chat.rocket.core.internal.rest.unregisterPushToken
import
chat.rocket.core.model.Myself
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.channels.Channel
import
kotlinx.coroutines.experimental.launch
import
kotlinx.coroutines.experimental.withContext
import
timber.log.Timber
import
javax.inject.Inject
...
...
@@ -63,7 +62,6 @@ class MainPresenter @Inject constructor(
private
val
dbManager
=
dbManagerFactory
.
create
(
currentServer
)
private
val
client
:
RocketChatClient
=
factory
.
create
(
currentServer
)
private
var
settings
:
PublicSettings
=
getSettingsInteractor
.
get
(
serverInteractor
.
get
()
!!
)
private
val
userDataChannel
=
Channel
<
Myself
>()
fun
toChatList
(
chatRoomId
:
String
?
=
null
)
=
navigator
.
toChatList
(
chatRoomId
)
...
...
@@ -72,6 +70,10 @@ class MainPresenter @Inject constructor(
fun
toSettings
()
=
navigator
.
toSettings
()
fun
toAdminPanel
()
=
tokenRepository
.
get
(
currentServer
)
?.
let
{
navigator
.
toAdminPanel
(
currentServer
.
adminPanelUrl
(),
it
.
authToken
)
}
fun
toCreateChannel
()
=
navigator
.
toCreateChannel
()
fun
loadServerAccounts
()
{
...
...
app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt
View file @
e329ca22
...
...
@@ -5,10 +5,9 @@ import android.app.Activity
import
android.app.AlertDialog
import
android.app.ProgressDialog
import
android.os.Bundle
import
android.view.Gravity
import
android.view.MenuItem
import
androidx.annotation.IdRes
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.view.GravityCompat
import
androidx.drawerlayout.widget.DrawerLayout
import
androidx.fragment.app.Fragment
import
androidx.recyclerview.widget.LinearLayoutManager
...
...
@@ -19,6 +18,7 @@ import chat.rocket.android.main.adapter.Selector
import
chat.rocket.android.main.presentation.MainPresenter
import
chat.rocket.android.main.presentation.MainView
import
chat.rocket.android.main.uimodel.NavHeaderUiModel
import
chat.rocket.android.server.domain.PermissionsInteractor
import
chat.rocket.android.server.domain.model.Account
import
chat.rocket.android.server.ui.INTENT_CHAT_ROOM_ID
import
chat.rocket.android.util.extensions.fadeIn
...
...
@@ -51,6 +51,8 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
lateinit
var
fragmentDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Fragment
>
@Inject
lateinit
var
presenter
:
MainPresenter
@Inject
lateinit
var
permissions
:
PermissionsInteractor
private
var
isFragmentAdded
:
Boolean
=
false
private
var
expanded
=
false
private
val
headerLayout
by
lazy
{
view_navigation
.
getHeaderView
(
0
)
}
...
...
@@ -166,9 +168,9 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
}
headerLayout
.
image_avatar
.
setOnClickListener
{
view_navigation
.
menu
.
findItem
(
R
.
id
.
action_profile
).
isChecked
=
true
view_navigation
.
menu
.
findItem
(
R
.
id
.
menu_
action_profile
).
isChecked
=
true
presenter
.
toUserProfile
()
drawer_layout
.
closeDrawer
(
Gravity
.
START
)
drawer_layout
.
closeDrawer
(
Gravity
Compat
.
START
)
}
}
...
...
@@ -218,37 +220,20 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
}
fun
setupNavigationView
()
{
view_navigation
.
setNavigationItemSelectedListener
{
menuItem
->
menuItem
.
isChecked
=
true
with
(
view_navigation
.
menu
)
{
clear
()
setupMenu
(
this
)
}
view_navigation
.
setNavigationItemSelectedListener
{
it
.
isChecked
=
true
closeDrawer
()
onNavDrawerItemSelected
(
menuItem
)
onNavDrawerItemSelected
(
it
)
true
}
toolbar
.
setNavigationIcon
(
R
.
drawable
.
ic_menu_white_24dp
)
toolbar
.
setNavigationOnClickListener
{
openDrawer
()
}
}
private
fun
onNavDrawerItemSelected
(
menuItem
:
MenuItem
)
{
when
(
menuItem
.
itemId
)
{
R
.
id
.
action_chat_rooms
->
{
presenter
.
toChatList
()
}
R
.
id
.
action_profile
->
{
presenter
.
toUserProfile
()
}
R
.
id
.
action_channel
->
{
presenter
.
toCreateChannel
()
}
R
.
id
.
action_settings
->
{
presenter
.
toSettings
()
}
R
.
id
.
action_logout
->
{
presenter
.
logout
()
}
}
toolbar
.
setNavigationOnClickListener
{
openDrawer
()
}
}
fun
setAvatar
(
avatarUrl
:
String
)
{
...
...
@@ -257,9 +242,9 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
fun
getDrawerLayout
():
DrawerLayout
=
drawer_layout
fun
openDrawer
()
=
drawer_layout
.
openDrawer
(
Gravity
.
START
)
fun
openDrawer
()
=
drawer_layout
.
openDrawer
(
Gravity
Compat
.
START
)
fun
closeDrawer
()
=
drawer_layout
.
closeDrawer
(
Gravity
.
START
)
fun
closeDrawer
()
=
drawer_layout
.
closeDrawer
(
Gravity
Compat
.
START
)
fun
setCheckedNavDrawerItem
(
@IdRes
item
:
Int
)
=
view_navigation
.
setCheckedItem
(
item
)
...
...
app/src/main/java/chat/rocket/android/main/ui/Menu.kt
0 → 100644
View file @
e329ca22
package
chat.rocket.android.main.ui
import
android.view.Menu
import
android.view.MenuItem
import
chat.rocket.android.R
internal
fun
MainActivity
.
setupMenu
(
menu
:
Menu
)
{
with
(
menu
)
{
add
(
R
.
id
.
menu_section_one
,
R
.
id
.
menu_action_chats
,
Menu
.
NONE
,
R
.
string
.
title_chats
).
setIcon
(
R
.
drawable
.
ic_chat_bubble_black_24dp
)
.
isChecked
=
true
add
(
R
.
id
.
menu_section_one
,
R
.
id
.
menu_action_create_channel
,
Menu
.
NONE
,
R
.
string
.
action_create_channel
).
setIcon
(
R
.
drawable
.
ic_create_black_24dp
)
add
(
R
.
id
.
menu_section_two
,
R
.
id
.
menu_action_profile
,
Menu
.
NONE
,
R
.
string
.
title_profile
).
setIcon
(
R
.
drawable
.
ic_person_black_24dp
)
add
(
R
.
id
.
menu_section_two
,
R
.
id
.
menu_action_settings
,
Menu
.
NONE
,
R
.
string
.
title_settings
).
setIcon
(
R
.
drawable
.
ic_settings_black_24dp
)
if
(
permissions
.
canSeeTheAdminPanel
())
{
add
(
R
.
id
.
menu_section_two
,
R
.
id
.
menu_action_admin_panel
,
Menu
.
NONE
,
R
.
string
.
title_admin_panel
).
setIcon
(
R
.
drawable
.
ic_settings_black_24dp
)
}
add
(
R
.
id
.
menu_section_three
,
R
.
id
.
menu_action_logout
,
Menu
.
NONE
,
R
.
string
.
action_logout
).
setIcon
(
R
.
drawable
.
ic_logout_black_24dp
)
setGroupCheckable
(
R
.
id
.
menu_section_one
,
true
,
true
)
setGroupCheckable
(
R
.
id
.
menu_section_two
,
true
,
true
)
setGroupCheckable
(
R
.
id
.
menu_section_three
,
true
,
true
)
}
}
internal
fun
MainActivity
.
onNavDrawerItemSelected
(
menuItem
:
MenuItem
)
{
when
(
menuItem
.
itemId
)
{
R
.
id
.
menu_action_chats
->
presenter
.
toChatList
()
R
.
id
.
menu_action_create_channel
->
presenter
.
toCreateChannel
()
R
.
id
.
menu_action_profile
->
presenter
.
toUserProfile
()
R
.
id
.
menu_action_settings
->
presenter
.
toSettings
()
R
.
id
.
menu_action_admin_panel
->
presenter
.
toAdminPanel
()
R
.
id
.
menu_action_logout
->
presenter
.
logout
()
}
}
app/src/main/java/chat/rocket/android/server/domain/PermissionsInteractor.kt
View file @
e329ca22
package
chat.rocket.android.server.domain
import
chat.rocket.android.helper.UserHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.core.model.Permission
import
javax.inject.Inject
// Creating rooms
const
val
CREATE_PUBLIC_CHANNELS
=
"create-c"
const
val
CREATE_DIRECT_MESSAGES
=
"create-d"
const
val
CREATE_PRIVATE_CHANNELS
=
"create-p"
private
const
val
CREATE_PUBLIC_CHANNELS
=
"create-c"
private
const
val
CREATE_DIRECT_MESSAGES
=
"create-d"
private
const
val
CREATE_PRIVATE_CHANNELS
=
"create-p"
// Messages
const
val
DELETE_MESSAGE
=
"delete-message"
const
val
FORCE_DELETE_MESSAGE
=
"force-delete-message"
const
val
EDIT_MESSAGE
=
"edit-message"
const
val
PIN_MESSAGE
=
"pin-message"
const
val
POST_READONLY
=
"post-readonly"
private
const
val
DELETE_MESSAGE
=
"delete-message"
private
const
val
FORCE_DELETE_MESSAGE
=
"force-delete-message"
private
const
val
EDIT_MESSAGE
=
"edit-message"
private
const
val
PIN_MESSAGE
=
"pin-message"
private
const
val
POST_READONLY
=
"post-readonly"
private
const
val
VIEW_STATISTICS
=
"view-statistics"
private
const
val
VIEW_ROOM_ADMINISTRATION
=
"view-room-administration"
private
const
val
VIEW_USER_ADMINISTRATION
=
"view-user-administration"
private
const
val
VIEW_PRIVILEGED_SETTING
=
"view-privileged-setting"
class
PermissionsInteractor
@Inject
constructor
(
private
val
settingsRepository
:
SettingsRepository
,
...
...
@@ -23,14 +26,8 @@ class PermissionsInteractor @Inject constructor(
private
val
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
private
val
userHelper
:
UserHelper
)
{
private
fun
publicSettings
():
PublicSettings
?
=
settingsRepository
.
get
(
currentServerUrl
()
!!
)
fun
saveAll
(
permissions
:
List
<
Permission
>)
{
val
url
=
currentServerUrl
()
!!
permissions
.
forEach
{
permissionsRepository
.
save
(
url
,
it
)
}
}
/**
* Check whether the user is allowed to delete a message.
*/
...
...
@@ -71,6 +68,28 @@ class PermissionsInteractor @Inject constructor(
}
==
true
||
userHelper
.
isAdmin
()
}
fun
canSeeTheAdminPanel
():
Boolean
{
currentServerUrl
()
?.
let
{
serverUrl
->
val
viewStatistics
=
permissionsRepository
.
get
(
serverUrl
,
VIEW_STATISTICS
)
val
viewRoomAdministration
=
permissionsRepository
.
get
(
serverUrl
,
VIEW_ROOM_ADMINISTRATION
)
val
viewUserAdministration
=
permissionsRepository
.
get
(
serverUrl
,
VIEW_USER_ADMINISTRATION
)
val
viewPrivilegedSetting
=
permissionsRepository
.
get
(
serverUrl
,
VIEW_PRIVILEGED_SETTING
)
userHelper
.
user
()
?.
roles
?.
let
{
userRolesList
->
return
viewStatistics
?.
roles
?.
any
{
userRolesList
.
contains
(
it
)
}
==
true
||
viewRoomAdministration
?.
roles
?.
any
{
userRolesList
.
contains
(
it
)
}
==
true
||
viewUserAdministration
?.
roles
?.
any
{
userRolesList
.
contains
(
it
)
}
==
true
||
viewPrivilegedSetting
?.
roles
?.
any
{
userRolesList
.
contains
(
it
)
}
==
true
}
}
return
false
}
private
fun
currentServerUrl
():
String
?
{
return
getCurrentServerInteractor
.
get
()
}
...
...
app/src/main/java/chat/rocket/android/server/domain/PermissionsRepository.kt
View file @
e329ca22
...
...
@@ -5,20 +5,20 @@ import chat.rocket.core.model.Permission
interface
PermissionsRepository
{
/**
* Store [permission] locally.
* Store
s
[permission] locally.
*
* @param url The server url
from where we're interest
to store the permission.
* @param url The server url to store the permission.
* @param permission The permission to store.
*/
fun
save
(
url
:
String
,
permission
:
Permission
)
/**
* Get permission given by the [permissionId] and for the server [url].
* Get
s
permission given by the [permissionId] and for the server [url].
*
* @param url The server url
from where we're interested on getting the permissions
.
* @param permissionId the
id
of the permission to get.
* @param url The server url
to get the permissions from
.
* @param permissionId the
ID
of the permission to get.
*
* @return The
interested
[Permission] or null if not found.
* @return The [Permission] or null if not found.
*/
fun
get
(
url
:
String
,
permissionId
:
String
):
Permission
?
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/settings/ui/SettingsFragment.kt
View file @
e329ca22
...
...
@@ -19,9 +19,6 @@ import kotlinx.android.synthetic.main.fragment_settings.*
import
kotlin.reflect.KClass
class
SettingsFragment
:
Fragment
(),
SettingsView
,
AdapterView
.
OnItemClickListener
{
companion
object
{
fun
newInstance
()
=
SettingsFragment
()
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
...
...
@@ -69,4 +66,8 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
startActivity
(
Intent
(
activity
,
classType
.
java
))
activity
?.
overridePendingTransition
(
R
.
anim
.
open_enter
,
R
.
anim
.
open_exit
)
}
companion
object
{
fun
newInstance
()
=
SettingsFragment
()
}
}
app/src/main/java/chat/rocket/android/util/extensions/String.kt
View file @
e329ca22
...
...
@@ -51,6 +51,8 @@ fun String.termsOfServiceUrl() = "${removeTrailingSlash()}/terms-of-service"
fun
String
.
privacyPolicyUrl
()
=
"${removeTrailingSlash()}/privacy-policy"
fun
String
.
adminPanelUrl
()
=
"${removeTrailingSlash()}/admin/info?layout=embedded"
fun
String
.
isValidUrl
():
Boolean
=
Patterns
.
WEB_URL
.
matcher
(
this
).
matches
()
fun
String
.
parseColor
():
Int
{
...
...
app/src/main/java/chat/rocket/android/webview/adminpanel/ui/AdminPanelWebViewFragment.kt
0 → 100644
View file @
e329ca22
package
chat.rocket.android.webview.adminpanel.ui
import
android.annotation.SuppressLint
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.webkit.WebView
import
android.webkit.WebViewClient
import
androidx.appcompat.app.AppCompatActivity
import
androidx.fragment.app.Fragment
import
chat.rocket.android.R
import
chat.rocket.android.util.extensions.inflate
import
kotlinx.android.synthetic.main.fragment_admin_panel_web_view.*
private
const
val
BUNDLE_WEB_PAGE_URL
=
"web_page_url"
private
const
val
BUNDLE_USER_TOKEN
=
"user_token"
class
AdminPanelWebViewFragment
:
Fragment
()
{
private
lateinit
var
webPageUrl
:
String
private
lateinit
var
userToken
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
val
bundle
=
arguments
if
(
bundle
!=
null
)
{
webPageUrl
=
bundle
.
getString
(
BUNDLE_WEB_PAGE_URL
)
userToken
=
bundle
.
getString
(
BUNDLE_USER_TOKEN
)
}
else
{
requireNotNull
(
bundle
)
{
"no arguments supplied when the fragment was instantiated"
}
}
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
savedInstanceState
:
Bundle
?
):
View
?
=
container
?.
inflate
(
R
.
layout
.
fragment_admin_panel_web_view
)
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
setupToolbar
()
setupWebView
()
}
private
fun
setupToolbar
()
{
(
activity
as
AppCompatActivity
?)
?.
supportActionBar
?.
title
=
getString
(
R
.
string
.
title_admin_panel
)
}
@SuppressLint
(
"SetJavaScriptEnabled"
)
private
fun
setupWebView
()
{
with
(
web_view
.
settings
)
{
javaScriptEnabled
=
true
domStorageEnabled
=
true
}
web_view
.
webViewClient
=
object
:
WebViewClient
()
{
override
fun
onPageFinished
(
view
:
WebView
,
url
:
String
)
{
super
.
onPageFinished
(
view
,
url
)
view_loading
.
hide
()
web_view
.
evaluateJavascript
(
"Meteor.loginWithToken('$userToken', function() { })"
)
{}
}
}
web_view
.
loadUrl
(
webPageUrl
)
}
companion
object
{
fun
newInstance
(
webPageUrl
:
String
,
userToken
:
String
)
=
AdminPanelWebViewFragment
().
apply
{
arguments
=
Bundle
(
2
).
apply
{
putString
(
BUNDLE_WEB_PAGE_URL
,
webPageUrl
)
putString
(
BUNDLE_USER_TOKEN
,
userToken
)
}
}
}
}
\ No newline at end of file
app/src/main/res/drawable/ic_
exit_to_app
_black_24dp.xml
→
app/src/main/res/drawable/ic_
logout
_black_24dp.xml
View file @
e329ca22
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewport
Height
=
"24.0"
android:viewport
Width
=
"24.0"
>
android:viewport
Width
=
"24.0"
android:viewport
Height
=
"24.0"
>
<path
android:fillColor=
"#FF000000"
...
...
app/src/main/res/layout/activity_main.xml
View file @
e329ca22
...
...
@@ -33,8 +33,7 @@
android:id=
"@+id/view_navigation"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
app:headerLayout=
"@layout/nav_header"
app:menu=
"@menu/navigation"
/>
app:headerLayout=
"@layout/nav_header"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/accounts_list"
...
...
app/src/main/res/layout/fragment_admin_panel_web_view.xml
0 → 100644
View file @
e329ca22
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".webview.adminpanel.ui.AdminPanelWebViewFragment"
>
<WebView
android:id=
"@+id/web_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/view_loading"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:indicatorColor=
"@color/colorBlack"
app:indicatorName=
"BallPulseIndicator"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/menu/navigation.xml
deleted
100644 → 0
View file @
960de03e
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<group
android:id=
"@+id/menu_section_1"
android:checkableBehavior=
"single"
>
<item
android:id=
"@+id/action_chat_rooms"
android:checked=
"true"
android:icon=
"@drawable/ic_chat_bubble_black_24dp"
android:title=
"@string/title_chats"
/>
<item
android:id=
"@+id/action_channel"
android:icon=
"@drawable/ic_create_black_24dp"
android:title=
"@string/action_create_channel"
/>
</group>
<group
android:id=
"@+id/menu_section_2"
android:checkableBehavior=
"single"
>
<item
android:id=
"@+id/action_profile"
android:icon=
"@drawable/ic_person_black_24dp"
android:title=
"@string/title_profile"
/>
<item
android:id=
"@+id/action_settings"
android:icon=
"@drawable/ic_settings_black_24dp"
android:title=
"@string/title_settings"
/>
</group>
<group
android:id=
"@+id/menu_section_3"
android:checkableBehavior=
"single"
>
<item
android:id=
"@+id/action_logout"
android:icon=
"@drawable/ic_exit_to_app_black_24dp"
android:title=
"@string/action_logout"
/>
</group>
</menu>
\ No newline at end of file
app/src/main/res/values-de/strings.xml
View file @
e329ca22
...
...
@@ -11,6 +11,7 @@
<string
name=
"title_profile"
>
Profil
</string>
<string
name=
"title_members"
>
Benutzer (%d)
</string>
<string
name=
"title_settings"
>
Einstellungen
</string>
<string
name=
"title_admin_panel"
>
Admin panel
</string>
<!-- TODO Add translation -->
<string
name=
"title_password"
>
Ändere Passwort
</string>
<string
name=
"title_update_profile"
>
Update Profil
</string>
<string
name=
"title_about"
>
Über
</string>
...
...
app/src/main/res/values-es/strings.xml
View file @
e329ca22
...
...
@@ -11,6 +11,7 @@
<string
name=
"title_profile"
>
Perfil
</string>
<string
name=
"title_members"
>
Miembros (%d)
</string>
<string
name=
"title_settings"
>
Configuraciones
</string>
<string
name=
"title_admin_panel"
>
Admin panel
</string>
<!-- TODO Add translation -->
<string
name=
"title_password"
>
Cambia la contraseña
</string>
<string
name=
"title_update_profile"
>
Actualización del perfil
</string>
<string
name=
"title_about"
>
Acerca de
</string>
...
...
app/src/main/res/values-fr/strings.xml
View file @
e329ca22
...
...
@@ -12,6 +12,7 @@
<string
name=
"title_profile"
>
Profil
</string>
<string
name=
"title_members"
>
Membres (%d)
</string>
<string
name=
"title_settings"
>
Paramètres
</string>
<string
name=
"title_admin_panel"
>
Admin panel
</string>
<!-- TODO Add translation -->
<string
name=
"title_password"
>
Changer le mot de passe
</string>
<string
name=
"title_update_profile"
>
Update profile
</string>
<string
name=
"title_about"
>
Sur
</string>
...
...
app/src/main/res/values-hi-rIN/strings.xml
View file @
e329ca22
...
...
@@ -12,6 +12,7 @@
<string
name=
"title_profile"
>
प्रोफाइल
</string>
<string
name=
"title_members"
>
सदस्य (%d)
</string>
<string
name=
"title_settings"
>
सेटिंग्स
</string>
<string
name=
"title_admin_panel"
>
Admin panel
</string>
<!-- TODO Add translation -->
<string
name=
"title_password"
>
पासवर्ड बदलें
</string>
<string
name=
"title_update_profile"
>
प्रोफ़ाइल अपडेट करें
</string>
<string
name=
"title_about"
>
परिचय
</string>
...
...
app/src/main/res/values-pt-rBR/strings.xml
View file @
e329ca22
...
...
@@ -12,6 +12,7 @@
<string
name=
"title_profile"
>
Perfil
</string>
<string
name=
"title_members"
>
Membros (%d)
</string>
<string
name=
"title_settings"
>
Configurações
</string>
<string
name=
"title_admin_panel"
>
Painel administrativo
</string>
<string
name=
"title_password"
>
Alterar senha
</string>
<string
name=
"title_update_profile"
>
Editar perfil
</string>
<string
name=
"title_about"
>
Sobre
</string>
...
...
app/src/main/res/values-ru/strings.xml
View file @
e329ca22
...
...
@@ -12,6 +12,7 @@
<string
name=
"title_profile"
>
Профиль
</string>
<string
name=
"title_members"
>
Пользователи (%d)
</string>
<string
name=
"title_settings"
>
Настройки
</string>
<string
name=
"title_admin_panel"
>
Admin panel
</string>
<!-- TODO Add translation -->
<string
name=
"title_password"
>
Изменить пароль
</string>
<string
name=
"title_update_profile"
>
Обновить профиль
</string>
<string
name=
"title_about"
>
О программе
</string>
...
...
app/src/main/res/values/ids.xml
0 → 100644
View file @
e329ca22
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item
name=
"menu_section_one"
type=
"id"
/>
<item
name=
"menu_section_two"
type=
"id"
/>
<item
name=
"menu_section_three"
type=
"id"
/>
<item
name=
"menu_action_chats"
type=
"id"
/>
<item
name=
"menu_action_create_channel"
type=
"id"
/>
<item
name=
"menu_action_profile"
type=
"id"
/>
<item
name=
"menu_action_settings"
type=
"id"
/>
<item
name=
"menu_action_admin_panel"
type=
"id"
/>
<item
name=
"menu_action_logout"
type=
"id"
/>
</resources>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
e329ca22
...
...
@@ -13,6 +13,7 @@
<string
name=
"title_profile"
>
Profile
</string>
<string
name=
"title_members"
>
Members (%d)
</string>
<string
name=
"title_settings"
>
Settings
</string>
<string
name=
"title_admin_panel"
>
Admin panel
</string>
<string
name=
"title_password"
>
Change Password
</string>
<string
name=
"title_update_profile"
>
Update profile
</string>
<string
name=
"title_about"
>
About
</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