Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the main screen with new UX/UI using DrawerNavigation #186

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
12 changes: 10 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,17 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".ui.meeting.MeetingActivity"
android:screenOrientation="${orientation}" />
android:name=".ui.main.MainActivity"
android:screenOrientation="${orientation}" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".ui.session.SessionActivity"
android:screenOrientation="${orientation}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import br.org.cesar.discordtime.stickysessions.ui.list.ListSessionsActivity;
import br.org.cesar.discordtime.stickysessions.ui.lobby.LobbyActivity;
import br.org.cesar.discordtime.stickysessions.ui.login.LoginActivity;
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingActivity;
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingFragment;
import br.org.cesar.discordtime.stickysessions.ui.session.SessionActivity;
import io.fabric.sdk.android.Fabric;

Expand Down Expand Up @@ -77,8 +77,8 @@ public void inject(ListSessionsActivity activity) {
mSessionListBuilder.build().inject(activity);
}

public void inject(MeetingActivity activity) {
mMeetingComponentBuilder.build().inject(activity);
public void inject(MeetingFragment fragment) {
mMeetingComponentBuilder.build().inject(fragment);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import br.org.cesar.discordtime.stickysessions.injectors.modules.ServerModule;
import br.org.cesar.discordtime.stickysessions.injectors.modules.SessionModule;
import br.org.cesar.discordtime.stickysessions.injectors.modules.ThreadModule;
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingActivity;
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingFragment;
import dagger.Component;

@Component(modules = {
Expand All @@ -32,5 +32,5 @@
AuthModule.class
})
public interface MeetingComponent {
void inject(MeetingActivity activity);
void inject(MeetingFragment activity);
haldny marked this conversation as resolved.
Show resolved Hide resolved

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inject(MeetingFragment fragment)

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IRouteRepository {
new Route(
ViewNames.LOGIN_ACTIVITY,
IRouter.USER_LOGGED,
ViewNames.MEETING_ACTIVITY,
ViewNames.MAIN_ACTIVITY,
true)
);
put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import br.org.cesar.discordtime.stickysessions.ui.list.ListSessionsActivity;
import br.org.cesar.discordtime.stickysessions.ui.lobby.LobbyActivity;
import br.org.cesar.discordtime.stickysessions.ui.login.LoginActivity;
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingActivity;
import br.org.cesar.discordtime.stickysessions.ui.main.MainActivity;
import br.org.cesar.discordtime.stickysessions.ui.session.SessionActivity;

public class ViewStarter implements IViewStarter {
Expand All @@ -22,9 +22,9 @@ public class ViewStarter implements IViewStarter {
new HashMap<String, Class<? extends Activity>> (){{
put(ViewNames.LOGIN_ACTIVITY, LoginActivity.class);
put(ViewNames.LOBBY_ACTIVITY, LobbyActivity.class);
put(ViewNames.MEETING_ACTIVITY, MeetingActivity.class);
put(ViewNames.SESSION_ACTIVITY, SessionActivity.class);
put(ViewNames.LIST_ACTIVITY, ListSessionsActivity.class);
put(ViewNames.MAIN_ACTIVITY, MainActivity.class);
}};

public void goNext(Context context, String activityName, boolean shouldClearStack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class ViewNames {
public static final String MEETING_ACTIVITY = "meeting_activity";
public static final String SESSION_ACTIVITY = "session_activity";
public static final String LIST_ACTIVITY = "list_activity";
public static final String MAIN_ACTIVITY = "main_activity";

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class LobbyActivity extends AppCompatActivity implements LobbyContract.Vi
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setContentView(R.layout.activity_lobby);

((StickySessionApplication) getApplication()).inject(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class LoginActivity : AppCompatActivity() {

// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
val task = GoogleSignIn.getSignedInAccountFromIntent(data)
try {
val task = GoogleSignIn.getSignedInAccountFromIntent(data)
// Google Sign In was successful, authenticate with Firebase
val account = task.getResult(ApiException::class.java)
firebaseAuthWithGoogle(account!!)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package br.org.cesar.discordtime.stickysessions.ui.main

import android.os.Build
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.TextView
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.GravityCompat
import br.org.cesar.discordtime.stickysessions.R
import br.org.cesar.discordtime.stickysessions.ui.meeting.MeetingFragment
import com.google.android.material.navigation.NavigationView
import com.google.android.material.snackbar.Snackbar

import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main_app_bar.*

class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {

private lateinit var mToolbarTitle: TextView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
configureToolbar()

fab.setOnClickListener { view ->
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
haldny marked this conversation as resolved.
Show resolved Hide resolved
}

supportFragmentManager.beginTransaction()
.replace(R.id.main_container, MeetingFragment()).commit()
}

private fun configureToolbar() {
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

supportActionBar?.apply {
setDisplayShowHomeEnabled(true)
setDisplayHomeAsUpEnabled(true)
}

mToolbarTitle = findViewById(R.id.toolbar_title)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i meant:

mToolbarTitle = findViewById(R.id.toolbar_title).apply {
text = getString(R.string.nav_header_desc)
}

mToolbarTitle.apply {
text = getString(R.string.nav_header_desc)
}

val toggle = ActionBarDrawerToggle(
this, drawer_layout, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close
)

drawer_layout.addDrawerListener(toggle)
toggle.syncState()

nav_view.setNavigationItemSelectedListener(this)
}

override fun onBackPressed() {
if (drawer_layout.isDrawerOpen(GravityCompat.START)) {
drawer_layout.closeDrawer(GravityCompat.START)
} else {
super.onBackPressed()
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.drawer_menu, menu)

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
val icon = menu.findItem(R.id.notification_menu).icon
val drawable = DrawableCompat.wrap(icon)
DrawableCompat.setTint(drawable, ContextCompat.getColor(this, R.color.coral))
menu.findItem(R.id.notification_menu).apply {
setIcon(drawable)
}
}

return true
}

override fun onNavigationItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.nav_meetings -> { showMeetingFragment() }
R.id.nav_about -> { }
R.id.nav_settings -> { }
}

drawer_layout.closeDrawer(GravityCompat.START)
return true
}

private fun showMeetingFragment() {
supportFragmentManager.beginTransaction()
.replace(R.id.main_container, MeetingFragment()).commit()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package br.org.cesar.discordtime.stickysessions.ui.meeting
import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ProgressBar
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import br.org.cesar.discordtime.stickysessions.R
import br.org.cesar.discordtime.stickysessions.app.StickySessionApplication
import br.org.cesar.discordtime.stickysessions.navigation.exception.InvalidViewNameException
Expand All @@ -18,42 +19,38 @@ import br.org.cesar.discordtime.stickysessions.navigation.wrapper.IViewStarter
import br.org.cesar.discordtime.stickysessions.presentation.meeting.MeetingContract
import br.org.cesar.discordtime.stickysessions.presentation.meeting.MeetingItem
import br.org.cesar.discordtime.stickysessions.ui.ViewNames
import kotlinx.android.synthetic.main.activity_meeting.*
import javax.inject.Inject
import kotlinx.android.synthetic.main.activity_meeting.recycler_view_meetings as mRecyclerView

class MeetingActivity : AppCompatActivity(), MeetingContract.View {
class MeetingFragment : Fragment(), MeetingContract.View {

@Inject
lateinit var mPresenter: MeetingContract.Presenter
@Inject
lateinit var mViewStarter: IViewStarter
lateinit var mProgressBar: ProgressBar
lateinit var mAdapter: MeetingItemAdapter
private lateinit var mProgressBar: ProgressBar
private lateinit var mRecyclerView: RecyclerView
private lateinit var mAdapter: MeetingItemAdapter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_meeting)
(application as StickySessionApplication).inject(this)

mProgressBar = findViewById(R.id.progressbar)
configureToolbar()
configureRecycleView()
(activity?.application as StickySessionApplication).inject(this)
}

private fun configureToolbar() {
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val rootView = inflater.inflate(R.layout.fragment_meeting, container, false)

val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
toolbarTitle.setText(R.string.toolbar_title_meetings)
mProgressBar = rootView.findViewById(R.id.progressbar)
configureRecyclerView(rootView)
return rootView
}

@SuppressLint("CheckResult")
private fun configureRecycleView() {
mAdapter = MeetingItemAdapter(this)
private fun configureRecyclerView(rootView: View) {
mAdapter = MeetingItemAdapter(rootView.context)
mRecyclerView = rootView.findViewById(R.id.recycler_view_meetings)
mRecyclerView.apply {
layoutManager = LinearLayoutManager(this@MeetingActivity)
layoutManager = LinearLayoutManager(rootView.context)
adapter = mAdapter
}
mAdapter.clickEvent.subscribe {
Expand Down Expand Up @@ -100,10 +97,10 @@ class MeetingActivity : AppCompatActivity(), MeetingContract.View {

@Throws(InvalidViewNameException::class)
override fun goNext(route: Route, bundle: IBundle) {
mViewStarter.goNext(this, route.to, route.shouldClearStack, bundle)
mViewStarter.goNext(activity, route.to, route.shouldClearStack, bundle)
}

companion object {
const val TAG = "MeetingActivity"
const val TAG = "MeetingFragment"
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/color/drawer_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/coral" android:state_checked="true" />
<item android:color="@color/warm_grey" />
</selector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,2a10,10 0,1 0,10 10A10,10 0,0 0,12 2zM13,17h-2v-6h2zM13,9h-2L11,7h2z"
android:fillColor="#8b8b8b"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_coffee.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M2,21h18v-2H2M20,8h-2V5h2m0,-2H4v10a4,4 0,0 0,4 4h6a4,4 0,0 0,4 -4v-3h2a2,2 0,0 0,2 -2V5a2,2 0,0 0,-2 -2z"
android:fillColor="#ff534b"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_logout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<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="M10.09,15.59L11.5,17l5,-5 -5,-5 -1.41,1.41L12.67,11H3v2h9.67l-2.58,2.59zM19,3H5c-1.11,0 -2,0.9 -2,2v4h2V5h14v14H5v-4H3v4c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_menu_send.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<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="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_menu_share.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<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="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_notification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M18.714,16.952v0.762L5,17.714v-0.762l1.524,-1.524L6.524,10.857a5.326,5.326 0,0 1,3.81 -5.112v-0.221a1.524,1.524 0,0 1,3.048 0v0.221a5.326,5.326 0,0 1,3.81 5.112v4.571l1.524,1.524m-5.333,1.524a1.524,1.524 0,0 1,-3.048 0"
android:fillColor="#8b8b8b"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M19.144,12.936a7.832,7.832 0,0 0,0.06 -0.936,5.918 5.918,0 0,0 -0.072,-0.936l2.024,-1.584a0.5,0.5 0,0 0,0.12 -0.612l-1.92,-3.324a0.488,0.488 0,0 0,-0.588 -0.216l-2.388,0.96a7.03,7.03 0,0 0,-1.62 -0.936l-0.36,-2.544a0.479,0.479 0,0 0,-0.48 -0.408h-3.84a0.467,0.467 0,0 0,-0.468 0.408l-0.36,2.544a7.219,7.219 0,0 0,-1.62 0.936L5.244,5.328a0.475,0.475 0,0 0,-0.588 0.216l-1.92,3.324a0.465,0.465 0,0 0,0.12 0.612l2.028,1.584a5.655,5.655 0,0 0,-0.012 1.872L2.844,14.52a0.5,0.5 0,0 0,-0.12 0.612l1.92,3.324a0.488,0.488 0,0 0,0.588 0.216l2.388,-0.96a7.03,7.03 0,0 0,1.62 0.936l0.36,2.544a0.488,0.488 0,0 0,0.48 0.408h3.84a0.459,0.459 0,0 0,0.468 -0.408l0.36,-2.544a7.219,7.219 0,0 0,1.62 -0.936l2.388,0.96a0.475,0.475 0,0 0,0.588 -0.216l1.92,-3.324a0.465,0.465 0,0 0,-0.12 -0.612l-2,-1.584zM12,15.6a3.6,3.6 0,1 1,3.6 -3.6,3.611 3.611,0 0,1 -3.6,3.6z"
android:fillColor="#8b8b8b"/>
</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/font/roboto.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Roboto"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
7 changes: 7 additions & 0 deletions app/src/main/res/font/roboto_bold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="name=Roboto&amp;weight=700"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>