Take toolbar back

This commit is contained in:
neslihanturan 2019-09-13 22:51:55 +03:00
parent 8c9c37abcb
commit c1403c1e22
5 changed files with 22 additions and 24 deletions

View file

@ -452,7 +452,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
}
public void startMainActivity() {
NavigationBaseActivity.startActivityWithFlags(this, NearbyTestFragmentLayersActivity.class, Intent.FLAG_ACTIVITY_SINGLE_TOP);
NavigationBaseActivity.startActivityWithFlags(this, MainActivity.class, Intent.FLAG_ACTIVITY_SINGLE_TOP);
finish();
}

View file

@ -45,7 +45,6 @@ import fr.free.nrw.commons.mwapi.MediaWikiApi;
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
import fr.free.nrw.commons.nearby.NearbyController;
import fr.free.nrw.commons.nearby.NearbyNotificationCardView;
import fr.free.nrw.commons.nearby.NearbyTestFragmentLayersActivity;
import fr.free.nrw.commons.nearby.Place;
import fr.free.nrw.commons.settings.Prefs;
import fr.free.nrw.commons.upload.UploadService;
@ -258,8 +257,8 @@ public class ContributionsFragment
operations on first time fragment attached to an activity. Then they will be retained
until fragment life time ends.
*/
if (((NearbyTestFragmentLayersActivity)getActivity()).isAuthCookieAcquired && !isFragmentAttachedBefore) {
onAuthCookieAcquired(((NearbyTestFragmentLayersActivity)getActivity()).uploadServiceIntent);
if (((MainActivity)getActivity()).isAuthCookieAcquired && !isFragmentAttachedBefore) {
onAuthCookieAcquired(((MainActivity)getActivity()).uploadServiceIntent);
isFragmentAttachedBefore = true;
}
@ -271,7 +270,7 @@ public class ContributionsFragment
*/
public void showContributionsListFragment() {
// show tabs on contribution list is visible
((NearbyTestFragmentLayersActivity) getActivity()).showTabs();
((MainActivity) getActivity()).showTabs();
// show nearby card view on contributions list is visible
if (nearbyNotificationCardView != null) {
if (store.getBoolean("displayNearbyCardView", true)) {
@ -292,7 +291,7 @@ public class ContributionsFragment
*/
public void showMediaDetailPagerFragment() {
// hide tabs on media detail view is visible
((NearbyTestFragmentLayersActivity)getActivity()).hideTabs();
((MainActivity)getActivity()).hideTabs();
// hide nearby card view on media detail is visible
nearbyNotificationCardView.setVisibility(View.GONE);
@ -302,7 +301,7 @@ public class ContributionsFragment
@Override
public void onBackStackChanged() {
((NearbyTestFragmentLayersActivity)getActivity()).initBackButton();
((MainActivity)getActivity()).initBackButton();
}
/**
@ -352,7 +351,7 @@ public class ContributionsFragment
private void setUploadCount() {
compositeDisposable.add(okHttpJsonApiClient
.getUploadCount(((NearbyTestFragmentLayersActivity)getActivity()).sessionManager.getCurrentAccount().name)
.getUploadCount(((MainActivity)getActivity()).sessionManager.getCurrentAccount().name)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::displayUploadCount,
@ -366,7 +365,7 @@ public class ContributionsFragment
return;
}
((NearbyTestFragmentLayersActivity)getActivity()).setNumOfUploads(uploadCount);
((MainActivity)getActivity()).setNumOfUploads(uploadCount);
}
@ -421,7 +420,7 @@ public class ContributionsFragment
onLocationPermissionGranted();
} else if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)
&& store.getBoolean("displayLocationPermissionForCardView", true)
&& (((NearbyTestFragmentLayersActivity) getActivity()).viewPager.getCurrentItem() == CONTRIBUTIONS_TAB_POSITION)) {
&& (((MainActivity) getActivity()).viewPager.getCurrentItem() == CONTRIBUTIONS_TAB_POSITION)) {
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
showNearbyCardPermissionRationale();
}

View file

@ -33,7 +33,7 @@ import fr.free.nrw.commons.auth.AuthenticatedActivity;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.nearby.NearbyNotificationCardView;
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
import fr.free.nrw.commons.nearby.NearbyTestLayersFragment;
import fr.free.nrw.commons.notification.Notification;
import fr.free.nrw.commons.notification.NotificationActivity;
import fr.free.nrw.commons.notification.NotificationController;
@ -82,7 +82,6 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contributions);
ButterKnife.bind(this);
requestAuthToken();
initDrawer();
setTitle(getString(R.string.navigation_item_home)); // Should I create a new string variable with another name instead?
@ -187,7 +186,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
isContributionsFragmentVisible = false;
updateMenuItem();
// Do all permission and GPS related tasks on tab selected, not on create
((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).nearbyParentFragmentPresenter.onTabSelected();
((NearbyTestLayersFragment)contributionsActivityPagerAdapter.getItem(1)).nearbyParentFragmentPresenter.onTabSelected();
break;
default:
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();
@ -268,7 +267,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
}
} else if (getSupportFragmentManager().findFragmentByTag(nearbyFragmentTag) != null && !isContributionsFragmentVisible) {
// Means that nearby fragment is visible (not contributions fragment)
NearbyParentFragment nearbyFragment = (NearbyParentFragment) contributionsActivityPagerAdapter.getItem(1);
NearbyTestLayersFragment nearbyFragment = (NearbyTestLayersFragment) contributionsActivityPagerAdapter.getItem(1);
if(nearbyFragment.isBottomSheetExpanded()) {
// Back should first hide the bottom sheet if it is expanded
@ -352,7 +351,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
return true;
case R.id.list_sheet:
if (contributionsActivityPagerAdapter.getItem(1) != null) {
((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).listOptionMenuItemClicked();
((NearbyTestLayersFragment)contributionsActivityPagerAdapter.getItem(1)).listOptionMenuItemClicked();
}
return true;
default:
@ -393,12 +392,12 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
}
case 1:
NearbyParentFragment retainedNearbyFragment = getNearbyFragment(1);
NearbyTestLayersFragment retainedNearbyFragment = getNearbyFragment(1);
if (retainedNearbyFragment != null) {
return retainedNearbyFragment;
} else {
// If we reach here, retainedNearbyFragment is null
return new NearbyParentFragment();
return new NearbyTestLayersFragment();
}
default:
return null;
@ -420,9 +419,9 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
* @param position index of tabs, in our case 0 or 1
* @return
*/
private NearbyParentFragment getNearbyFragment(int position) {
private NearbyTestLayersFragment getNearbyFragment(int position) {
String tag = makeFragmentName(R.id.pager, position);
return (NearbyParentFragment)fragmentManager.findFragmentByTag(tag);
return (NearbyTestLayersFragment)fragmentManager.findFragmentByTag(tag);
}
/**

View file

@ -74,7 +74,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
protected void onAttachedToWindow() {
super.onAttachedToWindow();
// If you don't setVisibility after getting layout params, then you will se an empty space in place of nearby NotificationCardView
if (((NearbyTestFragmentLayersActivity)getContext()).defaultKvStore.getBoolean("displayNearbyCardView", true) && this.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
if (((MainActivity)getContext()).defaultKvStore.getBoolean("displayNearbyCardView", true) && this.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
this.setVisibility(VISIBLE);
} else {
this.setVisibility(GONE);
@ -84,7 +84,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
private void setActionListeners(Place place) {
this.setOnClickListener(view -> {
NearbyTestFragmentLayersActivity m = (NearbyTestFragmentLayersActivity) getContext();
MainActivity m = (MainActivity) getContext();
// Change to nearby tab
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);
@ -97,7 +97,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
@Override public boolean onSwipe(View view) {
view.setVisibility(GONE);
// Save shared preference for nearby card view accordingly
((NearbyTestFragmentLayersActivity) getContext()).defaultKvStore.putBoolean("displayNearbyCardView", false);
((MainActivity) getContext()).defaultKvStore.putBoolean("displayNearbyCardView", false);
ViewUtil.showLongToast(getContext(),
getResources().getString(R.string.nearby_notification_dismiss_message));
return true;

View file

@ -63,7 +63,7 @@ import io.reactivex.schedulers.Schedulers;
import timber.log.Timber;
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
import static fr.free.nrw.commons.nearby.NearbyTestFragmentLayersActivity.CONTRIBUTIONS_TAB_POSITION;
import static fr.free.nrw.commons.contributions.MainActivity.CONTRIBUTIONS_TAB_POSITION;
public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment implements NearbyParentFragmentContract.View {
@ -170,7 +170,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
FragmentTransaction transaction;
View view;
NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
public NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
SupportMapFragment mapFragment;
boolean isDarkTheme;
boolean isFabOpen;