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
Enable support toolbar for ProfileActivity and added a couple of unit… #5188
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,10 @@ private void initWLMCampaign() { | |
|
||
@Override | ||
public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) { | ||
|
||
// Removing contributions menu items for ProfileActivity | ||
if(getActivity() instanceof ProfileActivity){ return;} | ||
|
||
inflater.inflate(R.menu.contribution_activity_notification_menu, menu); | ||
|
||
MenuItem notificationsMenuItem = menu.findItem(R.id.notifications); | ||
|
@@ -339,23 +343,23 @@ private void showFragment(Fragment fragment, String tag, Fragment otherFragment) | |
if (fragment.isAdded() && otherFragment != null) { | ||
transaction.hide(otherFragment); | ||
transaction.show(fragment); | ||
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG); | ||
transaction.addToBackStack(tag); | ||
transaction.commit(); | ||
getChildFragmentManager().executePendingTransactions(); | ||
} else if (fragment.isAdded() && otherFragment == null) { | ||
transaction.show(fragment); | ||
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG); | ||
transaction.addToBackStack(tag); | ||
transaction.commit(); | ||
getChildFragmentManager().executePendingTransactions(); | ||
}else if (!fragment.isAdded() && otherFragment != null ) { | ||
transaction.hide(otherFragment); | ||
transaction.add(R.id.root_frame, fragment, tag); | ||
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG); | ||
transaction.addToBackStack(tag); | ||
transaction.commit(); | ||
getChildFragmentManager().executePendingTransactions(); | ||
} else if (!fragment.isAdded()) { | ||
transaction.replace(R.id.root_frame, fragment, tag); | ||
transaction.addToBackStack(CONTRIBUTION_LIST_FRAGMENT_TAG); | ||
transaction.addToBackStack(tag); | ||
transaction.commit(); | ||
getChildFragmentManager().executePendingTransactions(); | ||
} | ||
|
@@ -641,7 +645,7 @@ public void viewPagerNotifyDataSetChanged() { | |
@Override | ||
public void showDetail(int position, boolean isWikipediaButtonDisplayed) { | ||
if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) { | ||
mediaDetailPagerFragment = new MediaDetailPagerFragment(); | ||
mediaDetailPagerFragment = new MediaDetailPagerFragment(false,true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space after , |
||
if(isUserProfile) { | ||
((ProfileActivity)getActivity()).setScroll(false); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.widget.Toolbar; | ||
import androidx.core.content.FileProvider; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
|
@@ -50,6 +51,9 @@ public class ProfileActivity extends BaseActivity { | |
@BindView(R.id.tab_layout) | ||
public TabLayout tabLayout; | ||
|
||
@BindView(R.id.toolbar) | ||
Toolbar toolbar; | ||
|
||
@Inject | ||
SessionManager sessionManager; | ||
|
||
|
@@ -83,9 +87,14 @@ protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_profile); | ||
ButterKnife.bind(this); | ||
setTitle(sessionManager.getUserName()); | ||
|
||
setSupportActionBar(toolbar); | ||
toolbar.setNavigationOnClickListener(view -> { | ||
onSupportNavigateUp(); | ||
}); | ||
|
||
userName = getIntent().getStringExtra(KEY_USERNAME); | ||
setTitle(userName); | ||
shouldShowContributions = getIntent().getBooleanExtra(KEY_SHOULD_SHOW_CONTRIBUTIONS, false); | ||
|
||
supportFragmentManager = getSupportFragmentManager(); | ||
|
@@ -140,14 +149,13 @@ private void setTabs() { | |
fragmentList.add(leaderboardFragment); | ||
titleList.add(getResources().getString(R.string.leaderboard_tab_title).toUpperCase()); | ||
|
||
if (shouldShowContributions) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the past, why was this |
||
contributionsFragment = new ContributionsFragment(); | ||
Bundle contributionsListBundle = new Bundle(); | ||
contributionsListBundle.putString(KEY_USERNAME, userName); | ||
contributionsFragment.setArguments(contributionsListBundle); | ||
fragmentList.add(contributionsFragment); | ||
titleList.add(getString(R.string.contributions_fragment).toUpperCase()); | ||
} | ||
contributionsFragment = new ContributionsFragment(); | ||
Bundle contributionsListBundle = new Bundle(); | ||
contributionsListBundle.putString(KEY_USERNAME, userName); | ||
contributionsFragment.setArguments(contributionsListBundle); | ||
fragmentList.add(contributionsFragment); | ||
titleList.add(getString(R.string.contributions_fragment).toUpperCase()); | ||
|
||
viewPagerAdapter.setTabData(fragmentList, titleList); | ||
viewPagerAdapter.notifyDataSetChanged(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ class MediaDetailPagerFragmentUnitTests { | |
|
||
val activity = Robolectric.buildActivity(SearchActivity::class.java).create().get() | ||
|
||
fragment = MediaDetailPagerFragment() | ||
fragment = MediaDetailPagerFragment(false,true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem |
||
fragment = MediaDetailPagerFragment(false, false) | ||
fragment = MediaDetailPagerFragment(false, false, 0) | ||
fragmentManager = activity.supportFragmentManager | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after if