mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Unkown problem occurs at map load when I try to use MainActivity again.
This commit is contained in:
parent
bf739485ea
commit
3dc084415b
6 changed files with 22 additions and 47 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;
|
||||||
|
|
@ -73,8 +73,6 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
public boolean isContributionsFragmentVisible = true; // False means nearby fragment is visible
|
public boolean isContributionsFragmentVisible = true; // False means nearby fragment is visible
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
|
|
||||||
private boolean onOrientationChanged = false;
|
|
||||||
|
|
||||||
private MenuItem notificationsMenuItem;
|
private MenuItem notificationsMenuItem;
|
||||||
private TextView notificationCount;
|
private TextView notificationCount;
|
||||||
|
|
||||||
|
|
@ -86,16 +84,6 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
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?
|
||||||
|
|
||||||
|
|
||||||
if (savedInstanceState != null ) {
|
|
||||||
onOrientationChanged = true; // Will be used in nearby fragment to determine significant update of map
|
|
||||||
|
|
||||||
//If nearby map was visible, call on Tab Selected to call all nearby operations
|
|
||||||
/*if (savedInstanceState.getInt("viewPagerCurrentItem") == 1) {
|
|
||||||
((NearbyFragment)contributionsActivityPagerAdapter.getItem(1)).onTabSelected(onOrientationChanged);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -268,7 +256,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 +340,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 +381,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 +408,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);
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
Log.d("denemeTest","NearbyTestLayersFragment create view");
|
||||||
view = inflater.inflate(R.layout.fragment_simple, container, false);
|
view = inflater.inflate(R.layout.fragment_simple, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
|
|
@ -268,6 +269,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMapFragment(Bundle savedInstanceState) {
|
public void setMapFragment(Bundle savedInstanceState) {
|
||||||
|
Log.d("denemeTest","this:"+this+", setMapFragment");
|
||||||
// Mapbox access token is configured here. This needs to be called either in your application
|
// Mapbox access token is configured here. This needs to be called either in your application
|
||||||
// object or in the same activity which contains the mapview.
|
// object or in the same activity which contains the mapview.
|
||||||
Mapbox.getInstance(getActivity(), getString(R.string.mapbox_commons_app_token));
|
Mapbox.getInstance(getActivity(), getString(R.string.mapbox_commons_app_token));
|
||||||
|
|
@ -467,7 +469,7 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
PermissionUtils.checkPermissionsAndPerformAction(getActivity(),
|
PermissionUtils.checkPermissionsAndPerformAction(getActivity(),
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||||
runnable,
|
runnable,
|
||||||
() -> ((NearbyTestFragmentLayersActivity) getActivity()).viewPager.setCurrentItem(CONTRIBUTIONS_TAB_POSITION),
|
() -> ((MainActivity) getActivity()).viewPager.setCurrentItem(CONTRIBUTIONS_TAB_POSITION),
|
||||||
R.string.location_permission_title,
|
R.string.location_permission_title,
|
||||||
R.string.location_permission_rationale_nearby);
|
R.string.location_permission_rationale_nearby);
|
||||||
}
|
}
|
||||||
|
|
@ -483,20 +485,6 @@ public class NearbyTestLayersFragment extends CommonsDaggerSupportFragment imple
|
||||||
@Override
|
@Override
|
||||||
public void animateFABs() {
|
public void animateFABs() {
|
||||||
if (fabPlus.isShown()){
|
if (fabPlus.isShown()){
|
||||||
/*if (isFabOpen) {
|
|
||||||
fabPlus.startAnimation(rotate_backward);
|
|
||||||
fabCamera.startAnimation(fab_close);
|
|
||||||
fabGallery.startAnimation(fab_close);
|
|
||||||
fabCamera.hide();
|
|
||||||
fabGallery.hide();
|
|
||||||
} else {
|
|
||||||
fabPlus.startAnimation(rotate_forward);
|
|
||||||
fabCamera.startAnimation(fab_open);
|
|
||||||
fabGallery.startAnimation(fab_open);
|
|
||||||
fabCamera.show();
|
|
||||||
fabGallery.show();
|
|
||||||
}
|
|
||||||
this.isFabOpen=!isFabOpen;*/
|
|
||||||
if (isFabOpen) {
|
if (isFabOpen) {
|
||||||
closeFABs(isFabOpen);
|
closeFABs(isFabOpen);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ public abstract class NavigationBaseActivity extends BaseActivity
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_nearby_test_fragment_layers:
|
case R.id.action_nearby_test_fragment_layers:
|
||||||
drawerLayout.closeDrawer(navigationView);
|
drawerLayout.closeDrawer(navigationView);
|
||||||
startActivityWithFlags(this, NearbyTestFragmentLayersActivity.class, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT,
|
startActivityWithFlags(this, MainActivity.class, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT,
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_feedback:
|
case R.id.action_feedback:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue