Skip to content

Commit

Permalink
Merge pull request #395 from fga-gpp-mds/feature/339
Browse files Browse the repository at this point in the history
Feature/339
  • Loading branch information
luis-gustavo authored Jun 10, 2018
2 parents 3d0ddad + fd2a9dc commit c05e5ed
Show file tree
Hide file tree
Showing 38 changed files with 112 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class FeedFragment : Fragment(), FeedDisplayLogic {
val likeListFragment = LikeListFragment().getInstance()
val fragmentManager = activity.fragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.frame_layout, likeListFragment, "like")
fragmentTransaction.replace(R.id.main_frame_layout, likeListFragment, "like")
fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
}
Expand All @@ -104,7 +104,7 @@ class FeedFragment : Fragment(), FeedDisplayLogic {
val commentsFragment = CommentsFragment().getInstance()
val fragmentManager = activity.fragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.frame_layout, commentsFragment, "comments")
fragmentTransaction.replace(R.id.main_frame_layout, commentsFragment, "comments")
fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
}
Expand Down
72 changes: 42 additions & 30 deletions project/app/src/main/java/com/nexte/nexte/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,70 +1,60 @@
package com.nexte.nexte


import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.nexte.nexte.LoginScene.*
import com.nexte.nexte.ShowProfileScene.ShowProfileFragment
import android.support.design.widget.BottomNavigationView
import android.support.v4.app.Fragment
import android.widget.Button
import com.nexte.nexte.FeedScene.FeedFragment
import com.nexte.nexte.RankingScene.RankingFragment
import kotlinx.android.synthetic.main.activity_main.*
import android.support.design.internal.BottomNavigationItemView
import android.support.design.internal.BottomNavigationMenuView
import android.util.Log

class MainActivity : AppCompatActivity() {

private var bottomNavView: BottomNavigationView?= null
private var loginButton: Button?= null
private val feedFragment = FeedFragment().getInstance()
private val challengeFragment = ChallengeTabsFragment().getInstance()
private val rankingFragment = RankingFragment().getInstance()
private val showProfileFragment = ShowProfileFragment().getInstance(UserSingleton.loggedUser.name)

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
bottomNavView =this.findViewById(R.id.bottom_nav_view)
loginButton = this.findViewById(R.id.loginButton)

bottomNavView?.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
bottomNavView?.setOnNavigationItemReselectedListener(mOnNavigationItemReselectedListener)
bottomNavView?.selectedItemId = R.id.feed
val feedFragment = FeedFragment().getInstance()
openFragment(feedFragment, "feed")
val intent = Intent(this, LoginView::class.java)
startActivity(intent)

bottom_navigation?.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
bottom_navigation?.selectedItemId = R.id.feedNavigation
disableShiftMode(bottom_navigation)

val intent = Intent(this, LoginView::class.java)
startActivity(intent)
}

private val mOnNavigationItemReselectedListener = BottomNavigationView.OnNavigationItemReselectedListener { item ->
when(item.itemId) {
R.id.login -> {
/* Do Nothing*/
}
}
}
private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->

when (item.itemId) {
R.id.feed -> {
val feedFragment = FeedFragment().getInstance()
R.id.feedNavigation -> {
openFragment(feedFragment, "feed")
return@OnNavigationItemSelectedListener true
}

R.id.challenge -> {
val challengeFragment = ChallengeTabsFragment().getInstance()
R.id.challengeNavigation -> {
openFragment(challengeFragment, "challenge")
return@OnNavigationItemSelectedListener true
}

R.id.ranking -> {
val rankingFragment = RankingFragment().getInstance()
R.id.rankingNavigation -> {
openFragment(rankingFragment, "ranking")
return@OnNavigationItemSelectedListener true
}

R.id.profile -> {
val showProfileFragment = ShowProfileFragment().getInstance(UserSingleton.loggedUser.name)
R.id.profileNavigation -> {
openFragment(showProfileFragment, "profile")
return@OnNavigationItemSelectedListener true

Expand All @@ -76,8 +66,30 @@ class MainActivity : AppCompatActivity() {

private fun openFragment(fragment: Fragment, tag: String) {
val transaction = supportFragmentManager.beginTransaction()
transaction.replace(R.id.frame_layout,fragment, tag)
transaction.addToBackStack(null)
transaction.replace(R.id.main_frame_layout, fragment, tag)
transaction.disallowAddToBackStack()
transaction.commit()
}

@SuppressLint("RestrictedApi")
private fun disableShiftMode(view: BottomNavigationView) {
val menuView = view.getChildAt(0) as BottomNavigationMenuView
try {
val shiftingMode = menuView.javaClass.getDeclaredField("mShiftingMode")
shiftingMode.isAccessible = true
shiftingMode.setBoolean(menuView, false)
shiftingMode.isAccessible = false
for (i in 0 until menuView.childCount) {
val item = menuView.getChildAt(i) as BottomNavigationItemView

item.setShiftingMode(false)
item.setChecked(item.itemData.isChecked)
}
} catch (e: NoSuchFieldException) {
Log.e("BNVHelper", "Unable to get shift mode field", e)
} catch (e: IllegalAccessException) {
Log.e("BNVHelper", "Unable to change value of shift mode", e)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.nexte.nexte.UserSingleton
import kotlinx.android.synthetic.main.row_ranking.view.*
import android.support.v7.widget.DividerItemDecoration
import com.nexte.nexte.Entities.Challenge.ChallengeManager
import com.nexte.nexte.Entities.User.User
import com.nexte.nexte.Entities.User.UserManager

/**
Expand Down Expand Up @@ -87,7 +86,7 @@ class RankingFragment : Fragment(), RankingDisplayLogic {

private fun goToShowProfileView(name: String?) {
val fragment = ShowProfileFragment().getInstance(name)
fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment).addToBackStack(null).commit()
fragmentManager.beginTransaction().replace(R.id.main_frame_layout, fragment).addToBackStack(null).commit()
}


Expand All @@ -106,7 +105,9 @@ class RankingFragment : Fragment(), RankingDisplayLogic {

view?.position?.text = String.format("%d", UserSingleton.loggedUser.rankingPosition)
view?.name?.text = UserSingleton.loggedUser.name
view?.picture_img_view?.setImageResource(UserSingleton.loggedUser.profilePicture!!.toInt())
UserSingleton.loggedUser.profilePicture?.let {
view?.picture_img_view?.setImageResource(it.toInt())
}
view?.playerCategory?.text = UserSingleton.loggedUser.category?.name
view?.rowRankingLayout?.background = ColorDrawable(Color.GRAY)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ShowProfileFragment : Fragment(), ShowProfileDisplayLogic {
val editProfileFragment = EditProfileFragment().getInstance()
val fragmentManager = activity.fragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
fragmentTransaction.replace(R.id.frame_layout, editProfileFragment, "editProfile")
fragmentTransaction.replace(R.id.main_frame_layout, editProfileFragment, "editProfile")
fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
}
Expand Down
Binary file not shown.
Binary file removed project/app/src/main/res/drawable-hdpi/ic_feed.png
Binary file not shown.
Binary file removed project/app/src/main/res/drawable-hdpi/ic_ranking.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added project/app/src/main/res/drawable-hdpi/icon_feed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed project/app/src/main/res/drawable-mdpi/ic_challenge.png
Binary file not shown.
Binary file removed project/app/src/main/res/drawable-mdpi/ic_feed.png
Binary file not shown.
Binary file removed project/app/src/main/res/drawable-mdpi/ic_ranking.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added project/app/src/main/res/drawable-mdpi/icon_feed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed project/app/src/main/res/drawable-xhdpi/ic_feed.png
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed project/app/src/main/res/drawable-xxhdpi/ic_feed.png
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions project/app/src/main/res/drawable/bottom_navigation_colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item
android:state_checked="true"
android:color="@color/iconTintSelected" />
<item
android:state_checked="false"
android:color="@color/iconTint" />

</selector>
58 changes: 17 additions & 41 deletions project/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.nexte.nexte.MainActivity"
android:background="#2E2E2E">


<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="148dp"
android:layout_marginStart="148dp"
android:layout_marginTop="16dp"
android:visibility="invisible"
android:text="LOGIN"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_nav_view"
android:layout_width="match_parent"
android:layout_height="58dp"
android:layout_marginBottom="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_navigation" />

<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_above="@+id/bottom_nav_view"
android:layout_marginBottom="0dp"
android:id="@+id/main_frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
app:layout_constraintBottom_toTopOf="@+id/bottom_nav_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
android:layout_above="@id/bottom_navigation"/>

</FrameLayout>
<android.support.design.widget.BottomNavigationView
style="@style/NexteBottomNavigation"
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/bottomNavigationBackground"
app:itemIconTint="@drawable/bottom_navigation_colors"
app:itemTextColor="@color/iconTint"
app:menu="@menu/bottom_navigation"/>

</android.support.constraint.ConstraintLayout>
</RelativeLayout>
48 changes: 17 additions & 31 deletions project/app/src/main/res/menu/bottom_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,24 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/feed"
android:enabled="true"
android:icon="@drawable/ic_feed"
android:iconTint="@color/iconTint"
android:title="Feed"
app:showAsAction="ifRoom" />
<item
android:id="@+id/feedNavigation"
android:icon="@drawable/icon_feed"
android:title="@string/feedNavigation"/>

<item
android:id="@+id/challenge"
android:enabled="true"
android:tint="#fff"
android:icon="@drawable/ic_challenge"
android:iconTint="@color/iconTint"
android:title="Challenge"
app:showAsAction="ifRoom" />
<item
android:id="@+id/challengeNavigation"
android:icon="@drawable/icon_challenge"
android:title="@string/challengeNavigation"/>

<item
android:id="@+id/ranking"
android:enabled="true"
android:tint="#fff"
android:icon="@drawable/ic_ranking"
android:iconTint="@color/iconTint"
android:title="Ranking"
app:showAsAction="ifRoom" />
<item
android:id="@+id/profile"
android:enabled="true"
android:tint="#fff"
android:icon="@drawable/ic_ranking"
android:title="Profile"
android:iconTint="@color/iconTint"
app:showAsAction="ifRoom" />
<item
android:id="@+id/rankingNavigation"
android:icon="@drawable/icon_ranking"
android:title="@string/rankingNavigation"/>

<item
android:id="@+id/profileNavigation"
android:icon="@drawable/icon_profile"
android:title="@string/profileNavigation"/>

</menu>
5 changes: 3 additions & 2 deletions project/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<color name="green">#50e3c2</color>
<color name="hint_color_pattern">#535151</color>
<color name="lightGrey">#595959</color>
<color name="bottomBackground">#1d1d1d</color>
<color name="iconTint">#9d9d9d</color>
<color name="iconTint">#9D9D9D</color>
<color name="iconTintSelected">#FE8A2D</color>
<color name="bottomNavigationBackground">#1D1D1D</color>
<color name="darker_gray">#aaa</color>
</resources>
7 changes: 7 additions & 0 deletions project/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@
<string name="challenge">Challenge</string>
<string name="feed">Feed</string>
<string name="rankingMenu">Ranking</string>

<!-- Navigation Bottom -->
<string name="feedNavigation">Feed</string>
<string name="rankingNavigation">Ranking</string>
<string name="profileNavigation">Perfil</string>
<string name="challengeNavigation">Desafio</string>

</resources>
8 changes: 8 additions & 0 deletions project/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="NexteBottomNavigation">
<item name="itemIconTint">@drawable/bottom_navigation_colors</item>
<item name="android:textSize">20sp</item>
<item name="android:itemTextAppearance">@font/roboto_thin</item>
<item name="android:textAllCaps"/>
</style>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
Expand Down

0 comments on commit c05e5ed

Please sign in to comment.