Commit 8c8aa192 authored by aniket's avatar aniket

adds layout for creating new channel

parent c097f168
...@@ -50,9 +50,9 @@ ...@@ -50,9 +50,9 @@
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" /> android:windowSoftInputMode="adjustResize|stateAlwaysHidden" />
<activity <activity
android:name=".create_channel.ui.CreateNewChannelActivity" android:name=".createChannel.ui.CreateNewChannelActivity"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden" /> android:windowSoftInputMode="stateAlwaysHidden" />
<activity <activity
android:name=".chatroom.ui.PinnedMessagesActivity" android:name=".chatroom.ui.PinnedMessagesActivity"
......
...@@ -13,7 +13,7 @@ import android.view.* ...@@ -13,7 +13,7 @@ import android.view.*
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter import chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
import chat.rocket.android.chatrooms.presentation.ChatRoomsView import chat.rocket.android.chatrooms.presentation.ChatRoomsView
import chat.rocket.android.create_channel.ui.CreateNewChannelActivity import chat.rocket.android.createChannel.ui.CreateNewChannelActivity
import chat.rocket.android.server.domain.GetCurrentServerInteractor import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.SettingsRepository import chat.rocket.android.server.domain.SettingsRepository
import chat.rocket.android.util.extensions.* import chat.rocket.android.util.extensions.*
......
package chat.rocket.android.create_channel.di package chat.rocket.android.createChannel.di
import android.arch.lifecycle.LifecycleOwner import android.arch.lifecycle.LifecycleOwner
import chat.rocket.android.core.lifecycle.CancelStrategy import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.create_channel.ui.CreateNewChannelActivity import chat.rocket.android.createChannel.ui.CreateNewChannelActivity
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import kotlinx.coroutines.experimental.Job import kotlinx.coroutines.experimental.Job
...@@ -19,4 +19,7 @@ class CreateNewChannelModule { ...@@ -19,4 +19,7 @@ class CreateNewChannelModule {
return CancelStrategy(owner, jobs) return CancelStrategy(owner, jobs)
} }
} }
\ No newline at end of file
package chat.rocket.android.create_channel.di package chat.rocket.android.createChannel.di
import chat.rocket.android.create_channel.ui.CreateNewChannelActivity import chat.rocket.android.createChannel.ui.CreateNewChannelActivity
import dagger.Module
import dagger.android.ContributesAndroidInjector import dagger.android.ContributesAndroidInjector
@Module
abstract class CreateNewChannelProvider { abstract class CreateNewChannelProvider {
@ContributesAndroidInjector(modules = [CreateNewChannelModule::class]) @ContributesAndroidInjector(modules = [CreateNewChannelModule::class])
abstract fun provideNewChannelActivity(): CreateNewChannelActivity abstract fun provideNewChannelActivity(): CreateNewChannelActivity
......
package chat.rocket.android.createChannel.presentation
import javax.inject.Inject
class CreateNewChannelPresenter @Inject constructor() {
}
\ No newline at end of file
package chat.rocket.android.create_channel.presentation package chat.rocket.android.createChannel.presentation
interface CreateNewChannelView { interface CreateNewChannelView {
//TODO add functions to be implemented //TODO add functions to be implemented
......
package chat.rocket.android.createChannel.ui
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.MenuItem
import chat.rocket.android.R
import chat.rocket.android.createChannel.presentation.CreateNewChannelPresenter
import chat.rocket.android.createChannel.presentation.CreateNewChannelView
import com.jakewharton.rxbinding2.widget.RxTextView
import dagger.android.AndroidInjection
import kotlinx.android.synthetic.main.activity_create_new_channel.*
import javax.inject.Inject
class CreateNewChannelActivity : AppCompatActivity(), CreateNewChannelView {
@Inject
lateinit var presenter: CreateNewChannelPresenter
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
when (item?.itemId) {
R.id.home -> {
finish()
return true
}
}
return super.onOptionsItemSelected(item)
}
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_create_new_channel)
setUpToolBar()
setUpOnClickListeners()
}
private fun setUpToolBar() {
setSupportActionBar(toolbar)
supportActionBar?.title = getString(R.string.title_create_new_channel)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
RxTextView.textChanges(channel_name_edit_text).subscribe { text ->
create_channel_action_text.isEnabled = text != ""
if (text != "")
create_channel_action_text.alpha = 1.0f
else
create_channel_action_text.alpha = 0.5f
}
}
private fun setUpOnClickListeners(){
public_channel.setOnClickListener{
channel_type.text = getString(R.string.public_channel_type)
channel_description.text = getString(R.string.private_channel_type_description)
placeholder.setImageDrawable(getDrawable(R.drawable.ic_hashtag_black))
(getDrawable(R.drawable.button_border) as GradientDrawable).setColor(resources.getColor(R.color.colorLightTheme))
(getDrawable(R.drawable.button_solid) as GradientDrawable).setColor(resources.getColor(R.color.red))
private_channel.background = getDrawable(R.drawable.button_border)
public_channel.background = getDrawable(R.drawable.button_solid)
private_channel.setTextColor(resources.getColor(R.color.red))
public_channel.setTextColor(resources.getColor(R.color.colorLightTheme))
}
private_channel.setOnClickListener{
channel_type.text = getString(R.string.private_channel_type)
channel_description.text = getString(R.string.public_channel_description)
placeholder.setImageDrawable(getDrawable(R.drawable.ic_room_lock))
(getDrawable(R.drawable.button_border) as GradientDrawable).setColor(resources.getColor(R.color.red))
(getDrawable(R.drawable.button_solid) as GradientDrawable).setColor(resources.getColor(R.color.colorLightTheme))
private_channel.background = getDrawable(R.drawable.button_border)
public_channel.background = getDrawable(R.drawable.button_solid)
private_channel.setTextColor(resources.getColor(R.color.colorLightTheme))
public_channel.setTextColor(resources.getColor(R.color.red))
}
}
}
\ 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.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
...@@ -12,6 +12,8 @@ import chat.rocket.android.chatroom.ui.ChatRoomActivity ...@@ -12,6 +12,8 @@ import chat.rocket.android.chatroom.ui.ChatRoomActivity
import chat.rocket.android.chatroom.ui.PinnedMessagesActivity import chat.rocket.android.chatroom.ui.PinnedMessagesActivity
import chat.rocket.android.chatrooms.di.ChatRoomsFragmentProvider import chat.rocket.android.chatrooms.di.ChatRoomsFragmentProvider
import chat.rocket.android.chatrooms.di.ChatRoomsModule import chat.rocket.android.chatrooms.di.ChatRoomsModule
import chat.rocket.android.createChannel.di.CreateNewChannelProvider
import chat.rocket.android.createChannel.ui.CreateNewChannelActivity
import chat.rocket.android.dagger.scope.PerActivity import chat.rocket.android.dagger.scope.PerActivity
import chat.rocket.android.main.di.MainActivityProvider import chat.rocket.android.main.di.MainActivityProvider
import chat.rocket.android.main.di.MainModule import chat.rocket.android.main.di.MainModule
...@@ -55,4 +57,9 @@ abstract class ActivityBuilder { ...@@ -55,4 +57,9 @@ abstract class ActivityBuilder {
@PerActivity @PerActivity
@ContributesAndroidInjector(modules = [PasswordFragmentProvider::class]) @ContributesAndroidInjector(modules = [PasswordFragmentProvider::class])
abstract fun bindPasswordActivity(): PasswordActivity abstract fun bindPasswordActivity(): PasswordActivity
@PerActivity
@ContributesAndroidInjector(modules = [CreateNewChannelProvider::class])
abstract fun bindCreateNewChannelActivity(): CreateNewChannelActivity
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="56dp"
android:theme="@style/ToolbarTheme"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="8dp"> android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_create_new_channel"
android:textColor="@color/colorLightTheme"
android:textSize="20sp"
/>
<TextView
android:id="@+id/create_channel_action_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.5"
android:textColor="@color/colorLightTheme"
android:background="?selectableItemBackground"
android:enabled="false"
android:gravity="end"
android:text="@string/create_new_channel_action"
android:textSize="16sp" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
<android.support.constraint.ConstraintLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">
<android.support.constraint.Guideline <android.support.constraint.Guideline
android:id="@+id/button_top_guideline" android:id="@+id/button_top_guideline"
...@@ -69,29 +115,32 @@ ...@@ -69,29 +115,32 @@
app:layout_constraintTop_toBottomOf="@id/channel_description" /> app:layout_constraintTop_toBottomOf="@id/channel_description" />
<ImageView <ImageView
android:id="@+id/placeholder"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:src="@drawable/ic_hashtag_black" android:src="@drawable/ic_hashtag_black"
app:layout_constraintBottom_toBottomOf="@id/channel_name_text_input_layout" app:layout_constraintBottom_toBottomOf="@id/channel_name_text_input_layout"
app:layout_constraintEnd_toStartOf="@id/channel_name_text_input_layout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/channel_name_text_input_layout" /> app:layout_constraintTop_toTopOf="@id/channel_name_text_input_layout" />
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:id="@+id/channel_name_text_input_layout" android:id="@+id/channel_name_text_input_layout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/separator"
android:focusable="true" android:focusable="true"
android:hint="@string/new_channel_edit_text_hint"> android:hint="@string/new_channel_edit_text_hint"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/placeholder"
app:layout_constraintTop_toBottomOf="@id/separator">
<android.support.design.widget.TextInputEditText <android.support.design.widget.TextInputEditText
android:id="@+id/channel_name_edit_text" android:id="@+id/channel_name_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
/>
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
\ No newline at end of file
...@@ -52,6 +52,6 @@ ...@@ -52,6 +52,6 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:src="@drawable/ic_add_24dp" android:src="@drawable/ic_add_24dp"
android:backgroundTint="@color/black" app:backgroundTint="@color/black"
/> />
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
<string name="private_channel_type_description"></string> <string name="private_channel_type_description"></string>
<string name="public_channel_description"></string> <string name="public_channel_description"></string>
<string name="new_channel_edit_text_hint">Channel Name</string> <string name="new_channel_edit_text_hint">Channel Name</string>
<string name="create_new_channel_action">CREATE</string>
<!-- System messages --> <!-- System messages -->
<string name="message_room_name_changed">Room name changed to: %1$s by %2$s</string> <string name="message_room_name_changed">Room name changed to: %1$s by %2$s</string>
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
</style> </style>
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:background">@color/colorPrimary</item>
</style>
<style name="AuthenticationTheme" parent="Theme.AppCompat.NoActionBar"> <style name="AuthenticationTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:statusBarColor">@color/colorPrimaryDark</item> <item name="android:statusBarColor">@color/colorPrimaryDark</item>
<item name="android:windowBackground">@color/colorPrimary</item> <item name="android:windowBackground">@color/colorPrimary</item>
......
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