mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Take toolbar back
This commit is contained in:
parent
8c9c37abcb
commit
c1403c1e22
5 changed files with 22 additions and 24 deletions
|
|
@ -452,7 +452,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startMainActivity() {
|
public void startMainActivity() {
|
||||||
NavigationBaseActivity.startActivityWithFlags(this, NearbyTestFragmentLayersActivity.class, Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
NavigationBaseActivity.startActivityWithFlags(this, MainActivity.class, Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
||||||
import fr.free.nrw.commons.nearby.NearbyController;
|
import fr.free.nrw.commons.nearby.NearbyController;
|
||||||
import fr.free.nrw.commons.nearby.NearbyNotificationCardView;
|
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.nearby.Place;
|
||||||
import fr.free.nrw.commons.settings.Prefs;
|
import fr.free.nrw.commons.settings.Prefs;
|
||||||
import fr.free.nrw.commons.upload.UploadService;
|
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
|
operations on first time fragment attached to an activity. Then they will be retained
|
||||||
until fragment life time ends.
|
until fragment life time ends.
|
||||||
*/
|
*/
|
||||||
if (((NearbyTestFragmentLayersActivity)getActivity()).isAuthCookieAcquired && !isFragmentAttachedBefore) {
|
if (((MainActivity)getActivity()).isAuthCookieAcquired && !isFragmentAttachedBefore) {
|
||||||
onAuthCookieAcquired(((NearbyTestFragmentLayersActivity)getActivity()).uploadServiceIntent);
|
onAuthCookieAcquired(((MainActivity)getActivity()).uploadServiceIntent);
|
||||||
isFragmentAttachedBefore = true;
|
isFragmentAttachedBefore = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +270,7 @@ public class ContributionsFragment
|
||||||
*/
|
*/
|
||||||
public void showContributionsListFragment() {
|
public void showContributionsListFragment() {
|
||||||
// show tabs on contribution list is visible
|
// show tabs on contribution list is visible
|
||||||
((NearbyTestFragmentLayersActivity) getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
// show nearby card view on contributions list is visible
|
// show nearby card view on contributions list is visible
|
||||||
if (nearbyNotificationCardView != null) {
|
if (nearbyNotificationCardView != null) {
|
||||||
if (store.getBoolean("displayNearbyCardView", true)) {
|
if (store.getBoolean("displayNearbyCardView", true)) {
|
||||||
|
|
@ -292,7 +291,7 @@ public class ContributionsFragment
|
||||||
*/
|
*/
|
||||||
public void showMediaDetailPagerFragment() {
|
public void showMediaDetailPagerFragment() {
|
||||||
// hide tabs on media detail view is visible
|
// hide tabs on media detail view is visible
|
||||||
((NearbyTestFragmentLayersActivity)getActivity()).hideTabs();
|
((MainActivity)getActivity()).hideTabs();
|
||||||
// hide nearby card view on media detail is visible
|
// hide nearby card view on media detail is visible
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
nearbyNotificationCardView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|
@ -302,7 +301,7 @@ public class ContributionsFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackStackChanged() {
|
public void onBackStackChanged() {
|
||||||
((NearbyTestFragmentLayersActivity)getActivity()).initBackButton();
|
((MainActivity)getActivity()).initBackButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -352,7 +351,7 @@ public class ContributionsFragment
|
||||||
private void setUploadCount() {
|
private void setUploadCount() {
|
||||||
|
|
||||||
compositeDisposable.add(okHttpJsonApiClient
|
compositeDisposable.add(okHttpJsonApiClient
|
||||||
.getUploadCount(((NearbyTestFragmentLayersActivity)getActivity()).sessionManager.getCurrentAccount().name)
|
.getUploadCount(((MainActivity)getActivity()).sessionManager.getCurrentAccount().name)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::displayUploadCount,
|
.subscribe(this::displayUploadCount,
|
||||||
|
|
@ -366,7 +365,7 @@ public class ContributionsFragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
((NearbyTestFragmentLayersActivity)getActivity()).setNumOfUploads(uploadCount);
|
((MainActivity)getActivity()).setNumOfUploads(uploadCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +420,7 @@ public class ContributionsFragment
|
||||||
onLocationPermissionGranted();
|
onLocationPermissionGranted();
|
||||||
} else if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)
|
} else if (shouldShowRequestPermissionRationale(Manifest.permission.ACCESS_FINE_LOCATION)
|
||||||
&& store.getBoolean("displayLocationPermissionForCardView", true)
|
&& 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;
|
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
|
||||||
showNearbyCardPermissionRationale();
|
showNearbyCardPermissionRationale();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
||||||
import fr.free.nrw.commons.auth.SessionManager;
|
import fr.free.nrw.commons.auth.SessionManager;
|
||||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||||
import fr.free.nrw.commons.nearby.NearbyNotificationCardView;
|
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.Notification;
|
||||||
import fr.free.nrw.commons.notification.NotificationActivity;
|
import fr.free.nrw.commons.notification.NotificationActivity;
|
||||||
import fr.free.nrw.commons.notification.NotificationController;
|
import fr.free.nrw.commons.notification.NotificationController;
|
||||||
|
|
@ -82,7 +82,6 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_contributions);
|
setContentView(R.layout.activity_contributions);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
requestAuthToken();
|
requestAuthToken();
|
||||||
initDrawer();
|
initDrawer();
|
||||||
setTitle(getString(R.string.navigation_item_home)); // Should I create a new string variable with another name instead?
|
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;
|
isContributionsFragmentVisible = false;
|
||||||
updateMenuItem();
|
updateMenuItem();
|
||||||
// Do all permission and GPS related tasks on tab selected, not on create
|
// 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;
|
break;
|
||||||
default:
|
default:
|
||||||
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();
|
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();
|
||||||
|
|
@ -268,7 +267,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
}
|
}
|
||||||
} else if (getSupportFragmentManager().findFragmentByTag(nearbyFragmentTag) != null && !isContributionsFragmentVisible) {
|
} else if (getSupportFragmentManager().findFragmentByTag(nearbyFragmentTag) != null && !isContributionsFragmentVisible) {
|
||||||
// Means that nearby fragment is visible (not contributions fragment)
|
// Means that nearby fragment is visible (not contributions fragment)
|
||||||
NearbyParentFragment nearbyFragment = (NearbyParentFragment) contributionsActivityPagerAdapter.getItem(1);
|
NearbyTestLayersFragment nearbyFragment = (NearbyTestLayersFragment) contributionsActivityPagerAdapter.getItem(1);
|
||||||
|
|
||||||
if(nearbyFragment.isBottomSheetExpanded()) {
|
if(nearbyFragment.isBottomSheetExpanded()) {
|
||||||
// Back should first hide the bottom sheet if it is expanded
|
// Back should first hide the bottom sheet if it is expanded
|
||||||
|
|
@ -352,7 +351,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
return true;
|
return true;
|
||||||
case R.id.list_sheet:
|
case R.id.list_sheet:
|
||||||
if (contributionsActivityPagerAdapter.getItem(1) != null) {
|
if (contributionsActivityPagerAdapter.getItem(1) != null) {
|
||||||
((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).listOptionMenuItemClicked();
|
((NearbyTestLayersFragment)contributionsActivityPagerAdapter.getItem(1)).listOptionMenuItemClicked();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|
@ -393,12 +392,12 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
NearbyParentFragment retainedNearbyFragment = getNearbyFragment(1);
|
NearbyTestLayersFragment retainedNearbyFragment = getNearbyFragment(1);
|
||||||
if (retainedNearbyFragment != null) {
|
if (retainedNearbyFragment != null) {
|
||||||
return retainedNearbyFragment;
|
return retainedNearbyFragment;
|
||||||
} else {
|
} else {
|
||||||
// If we reach here, retainedNearbyFragment is null
|
// If we reach here, retainedNearbyFragment is null
|
||||||
return new NearbyParentFragment();
|
return new NearbyTestLayersFragment();
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -420,9 +419,9 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
* @param position index of tabs, in our case 0 or 1
|
* @param position index of tabs, in our case 0 or 1
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private NearbyParentFragment getNearbyFragment(int position) {
|
private NearbyTestLayersFragment getNearbyFragment(int position) {
|
||||||
String tag = makeFragmentName(R.id.pager, position);
|
String tag = makeFragmentName(R.id.pager, position);
|
||||||
return (NearbyParentFragment)fragmentManager.findFragmentByTag(tag);
|
return (NearbyTestLayersFragment)fragmentManager.findFragmentByTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
|
||||||
protected void onAttachedToWindow() {
|
protected void onAttachedToWindow() {
|
||||||
super.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 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);
|
this.setVisibility(VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
this.setVisibility(GONE);
|
this.setVisibility(GONE);
|
||||||
|
|
@ -84,7 +84,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
|
||||||
|
|
||||||
private void setActionListeners(Place place) {
|
private void setActionListeners(Place place) {
|
||||||
this.setOnClickListener(view -> {
|
this.setOnClickListener(view -> {
|
||||||
NearbyTestFragmentLayersActivity m = (NearbyTestFragmentLayersActivity) getContext();
|
MainActivity m = (MainActivity) getContext();
|
||||||
|
|
||||||
// Change to nearby tab
|
// Change to nearby tab
|
||||||
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);
|
m.viewPager.setCurrentItem(NEARBY_TAB_POSITION);
|
||||||
|
|
@ -97,7 +97,7 @@ public class NearbyNotificationCardView extends SwipableCardView {
|
||||||
@Override public boolean onSwipe(View view) {
|
@Override public boolean onSwipe(View view) {
|
||||||
view.setVisibility(GONE);
|
view.setVisibility(GONE);
|
||||||
// Save shared preference for nearby card view accordingly
|
// Save shared preference for nearby card view accordingly
|
||||||
((NearbyTestFragmentLayersActivity) getContext()).defaultKvStore.putBoolean("displayNearbyCardView", false);
|
((MainActivity) getContext()).defaultKvStore.putBoolean("displayNearbyCardView", false);
|
||||||
ViewUtil.showLongToast(getContext(),
|
ViewUtil.showLongToast(getContext(),
|
||||||
getResources().getString(R.string.nearby_notification_dismiss_message));
|
getResources().getString(R.string.nearby_notification_dismiss_message));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static fr.free.nrw.commons.location.LocationServiceManager.LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
|
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 {
|
public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment implements NearbyParentFragmentContract.View {
|
||||||
|
|
@ -170,7 +170,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
FragmentTransaction transaction;
|
FragmentTransaction transaction;
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
|
public NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
|
||||||
SupportMapFragment mapFragment;
|
SupportMapFragment mapFragment;
|
||||||
boolean isDarkTheme;
|
boolean isDarkTheme;
|
||||||
boolean isFabOpen;
|
boolean isFabOpen;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue