Commit c097f168 authored by aniket's avatar aniket

adds basic code for creating new channel

parent c1871a62
......@@ -53,7 +53,6 @@ dependencies {
implementation libraries.kotlin
implementation libraries.coroutines
implementation libraries.coroutinesAndroid
implementation libraries.appCompat
implementation libraries.recyclerview
implementation libraries.design
......
......@@ -37,23 +37,27 @@
<activity
android:name=".main.ui.MainActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity
android:name=".webview.WebViewActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity
android:name=".chatroom.ui.ChatRoomActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity
android:name=".create_channel.ui.CreateNewChannelActivity"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity
android:name=".chatroom.ui.PinnedMessagesActivity"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:theme="@style/AppTheme" />
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity
android:name=".settings.password.ui.PasswordActivity"
......
package chat.rocket.android.chatrooms.ui
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.support.v4.app.Fragment
......@@ -12,6 +13,7 @@ import android.view.*
import chat.rocket.android.R
import chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
import chat.rocket.android.chatrooms.presentation.ChatRoomsView
import chat.rocket.android.create_channel.ui.CreateNewChannelActivity
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.SettingsRepository
import chat.rocket.android.util.extensions.*
......@@ -28,9 +30,12 @@ import kotlinx.coroutines.experimental.launch
import javax.inject.Inject
class ChatRoomsFragment : Fragment(), ChatRoomsView {
@Inject lateinit var presenter: ChatRoomsPresenter
@Inject lateinit var serverInteractor: GetCurrentServerInteractor
@Inject lateinit var settingsRepository: SettingsRepository
@Inject
lateinit var presenter: ChatRoomsPresenter
@Inject
lateinit var serverInteractor: GetCurrentServerInteractor
@Inject
lateinit var settingsRepository: SettingsRepository
private var searchView: SearchView? = null
private val handler = Handler()
......@@ -59,6 +64,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
setupToolbar()
setupRecyclerView()
setUpFAB()
presenter.loadChatRooms()
}
......@@ -156,6 +162,13 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
}
}
private fun setUpFAB() {
create_new_channel_fab.setOnClickListener {
val intent = Intent(activity, CreateNewChannelActivity::class.java)
startActivity(intent)
}
}
private fun queryChatRoomsByName(name: String?): Boolean {
presenter.chatRoomsByName(name ?: "")
return true
......
package chat.rocket.android.create_channel.di
import android.arch.lifecycle.LifecycleOwner
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.create_channel.ui.CreateNewChannelActivity
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.experimental.Job
@Module
class CreateNewChannelModule {
@Provides
fun provideLifecycleOwner(activity: CreateNewChannelActivity): LifecycleOwner {
return activity
}
@Provides
fun provideCancelStrategy(owner: LifecycleOwner, jobs: Job): CancelStrategy {
return CancelStrategy(owner, jobs)
}
}
\ No newline at end of file
package chat.rocket.android.create_channel.di
import chat.rocket.android.create_channel.ui.CreateNewChannelActivity
import dagger.android.ContributesAndroidInjector
abstract class CreateNewChannelProvider {
@ContributesAndroidInjector(modules = [CreateNewChannelModule::class])
abstract fun provideNewChannelActivity(): CreateNewChannelActivity
}
\ No newline at end of file
package chat.rocket.android.create_channel.presentation
/**
* Created by aniket on 9/3/18.
*/
class CreateNewChannelPresenter {
}
\ No newline at end of file
package chat.rocket.android.create_channel.presentation
interface CreateNewChannelView {
//TODO add functions to be implemented
}
\ No newline at end of file
package chat.rocket.android.create_channel.ui
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import chat.rocket.android.R
import chat.rocket.android.create_channel.presentation.CreateNewChannelPresenter
import chat.rocket.android.create_channel.presentation.CreateNewChannelView
import dagger.android.AndroidInjection
import javax.inject.Inject
class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.home -> {
finish()
return true
}
}
return super.onOptionsItemSelected(item)
}
@Inject
var presenter: CreateNewChannelPresenter = CreateNewChannelPresenter()
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_create_new_channel)
setUpToolBar()
}
private fun setUpToolBar() {
supportActionBar?.title = getString(R.string.title_create_new_channel)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
}
\ No newline at end of file
......@@ -7,16 +7,10 @@ import android.support.v7.app.AppCompatActivity
import android.view.Gravity
import android.view.MenuItem
import chat.rocket.android.R
import chat.rocket.android.chatrooms.ui.ChatRoomsFragment
import chat.rocket.android.profile.ui.ProfileFragment
import chat.rocket.android.settings.ui.SettingsFragment
import chat.rocket.android.util.extensions.addFragment
import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.main.presentation.MainPresenter
import chat.rocket.android.main.presentation.MainView
import chat.rocket.android.util.extensions.showToast
import dagger.android.AndroidInjection
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
......@@ -34,7 +28,6 @@ class MainActivity : AppCompatActivity(), MainView, HasSupportFragmentInjector {
AndroidInjection.inject(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
presenter.connect()
setupToolbar()
setupNavigationView()
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="#0000"
android:startColor="#0000" />
<stroke
android:width="1dp"
android:color="@color/red" />
<corners
android:bottomRightRadius="5dp"
android:topRightRadius="5dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/red" />
<corners
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp" />
</shape>
\ No newline at end of file
......@@ -5,7 +5,7 @@
android:viewportHeight="24.0">
<path
android:fillColor="#FF2F343D"
android:fillColor="@color/colorLightTheme"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">
<android.support.constraint.Guideline
android:id="@+id/button_top_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.03" />
<android.support.constraint.Guideline
android:id="@+id/button_bottom_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.09" />
<Button
android:id="@+id/public_channel"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@drawable/button_solid"
android:text="@string/public_channel_type"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@id/button_bottom_guideline"
app:layout_constraintEnd_toStartOf="@+id/private_channel"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/button_top_guideline" />
<Button
android:id="@+id/private_channel"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:background="@drawable/button_border"
android:text="@string/private_channel_type"
android:textColor="@color/red"
app:layout_constraintBottom_toBottomOf="@id/button_bottom_guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/public_channel"
app:layout_constraintTop_toTopOf="@id/button_top_guideline" />
<TextView
android:id="@+id/channel_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/private_channel_type"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/public_channel" />
<TextView
android:id="@+id/channel_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/private_channel_type_description"
android:textColor="@color/black"
app:layout_constraintTop_toBottomOf="@id/channel_type" />
<View
android:id="@+id/separator"
android:layout_width="0dp"
android:layout_height="0.1dp"
android:layout_marginTop="4dp"
android:background="@color/colorDividerMessageComposer"
app:layout_constraintTop_toBottomOf="@id/channel_description" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="6dp"
android:src="@drawable/ic_hashtag_black"
app:layout_constraintBottom_toBottomOf="@id/channel_name_text_input_layout"
app:layout_constraintTop_toTopOf="@id/channel_name_text_input_layout" />
<android.support.design.widget.TextInputLayout
android:id="@+id/channel_name_text_input_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/separator"
android:focusable="true"
android:hint="@string/new_channel_edit_text_hint">
<android.support.design.widget.TextInputEditText
android:id="@+id/channel_name_edit_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.design.widget.TextInputLayout>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -44,4 +44,14 @@
tools:visibility="visible"
tools:text="connected"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/create_new_channel_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/ic_add_24dp"
android:backgroundTint="@color/black"
/>
</RelativeLayout>
\ No newline at end of file
......@@ -12,6 +12,7 @@
<string name="title_settings">Settings</string>
<string name="title_password">Change Password</string>
<string name="title_update_profile">Update profile</string>
<string name="title_create_new_channel">Create New Channel</string>
<!-- Actions -->
<string name="action_connect">Connect</string>
......@@ -66,6 +67,11 @@
<string name="msg_utc_offset">UTC offset</string>
<string name="msg_new_password">Enter New Password</string>
<string name="msg_confirm_password">Confirm New Password</string>
<string name="private_channel_type">Private</string>
<string name="public_channel_type">Public</string>
<string name="private_channel_type_description"></string>
<string name="public_channel_description"></string>
<string name="new_channel_edit_text_hint">Channel Name</string>
<!-- System messages -->
<string name="message_room_name_changed">Room name changed to: %1$s by %2$s</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment