mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Change the old NearbyFragment by our new NearbyParentFragment for first tests
This commit is contained in:
parent
a77c3c45d4
commit
d0556419f7
4 changed files with 53 additions and 14 deletions
|
|
@ -32,8 +32,8 @@ import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
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.NearbyFragment;
|
|
||||||
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.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;
|
||||||
|
|
@ -188,7 +188,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
|
||||||
((NearbyFragment)contributionsActivityPagerAdapter.getItem(1)).onTabSelected(onOrientationChanged);
|
((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).nearbyParentFragmentPresenter.onTabSelected();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();
|
tabLayout.getTabAt(CONTRIBUTIONS_TAB_POSITION).select();
|
||||||
|
|
@ -269,7 +269,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)
|
||||||
NearbyFragment nearbyFragment = (NearbyFragment) contributionsActivityPagerAdapter.getItem(1);
|
NearbyParentFragment nearbyFragment = (NearbyParentFragment) 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
|
||||||
|
|
@ -353,7 +353,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) {
|
||||||
((NearbyFragment)contributionsActivityPagerAdapter.getItem(1)).listOptionMenuItemClicked();
|
((NearbyParentFragment)contributionsActivityPagerAdapter.getItem(1)).listOptionMenuItemClicked();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|
@ -407,12 +407,12 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
||||||
}
|
}
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
NearbyFragment retainedNearbyFragment = getNearbyFragment(1);
|
NearbyParentFragment 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 NearbyFragment();
|
return new NearbyParentFragment();
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -434,9 +434,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 NearbyFragment getNearbyFragment(int position) {
|
private NearbyParentFragment getNearbyFragment(int position) {
|
||||||
String tag = makeFragmentName(R.id.pager, position);
|
String tag = makeFragmentName(R.id.pager, position);
|
||||||
return (NearbyFragment)fragmentManager.findFragmentByTag(tag);
|
return (NearbyParentFragment)fragmentManager.findFragmentByTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ import fr.free.nrw.commons.explore.images.SearchImageFragment;
|
||||||
import fr.free.nrw.commons.explore.recentsearches.RecentSearchesFragment;
|
import fr.free.nrw.commons.explore.recentsearches.RecentSearchesFragment;
|
||||||
import fr.free.nrw.commons.media.MediaDetailFragment;
|
import fr.free.nrw.commons.media.MediaDetailFragment;
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
||||||
import fr.free.nrw.commons.nearby.NearbyFragment;
|
|
||||||
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
import fr.free.nrw.commons.nearby.NearbyListFragment;
|
||||||
import fr.free.nrw.commons.nearby.NearbyMapFragment;
|
import fr.free.nrw.commons.nearby.NearbyMapFragment;
|
||||||
|
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
|
||||||
import fr.free.nrw.commons.review.ReviewImageFragment;
|
import fr.free.nrw.commons.review.ReviewImageFragment;
|
||||||
import fr.free.nrw.commons.settings.SettingsFragment;
|
import fr.free.nrw.commons.settings.SettingsFragment;
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ public abstract class FragmentBuilderModule {
|
||||||
abstract ContributionsFragment bindContributionsFragment();
|
abstract ContributionsFragment bindContributionsFragment();
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract NearbyFragment bindNearbyFragment();
|
abstract NearbyParentFragment bindNearbyParentFragment();
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract BookmarkPicturesFragment bindBookmarkPictureListFragment();
|
abstract BookmarkPicturesFragment bindBookmarkPictureListFragment();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ public interface NearbyParentFragmentContract {
|
||||||
void checkLocationPermission(LocationServiceManager locationServiceManager);
|
void checkLocationPermission(LocationServiceManager locationServiceManager);
|
||||||
boolean isNetworkConnectionEstablished();
|
boolean isNetworkConnectionEstablished();
|
||||||
void addNetworkBroadcastReceiver();
|
void addNetworkBroadcastReceiver();
|
||||||
|
void listOptionMenuItemClicked();
|
||||||
|
boolean isBottomSheetExpanded();
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UserActions {
|
interface UserActions {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
@ -13,6 +14,7 @@ import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
|
@ -75,7 +77,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
private NearbyListFragment nearbyListFragment;
|
private NearbyListFragment nearbyListFragment;
|
||||||
private static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
|
private static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
|
||||||
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
|
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
|
||||||
private NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
|
public NearbyParentFragmentPresenter nearbyParentFragmentPresenter;
|
||||||
|
|
||||||
// Variables for adding network broadcast receiver.
|
// Variables for adding network broadcast receiver.
|
||||||
private Snackbar snackbar;
|
private Snackbar snackbar;
|
||||||
|
|
@ -84,6 +86,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
private boolean isNetworkErrorOccurred = false;
|
private boolean isNetworkErrorOccurred = false;
|
||||||
public View view;
|
public View view;
|
||||||
|
|
||||||
|
// Variables for bottom sheet behaviour management
|
||||||
|
private BottomSheetBehavior bottomSheetBehavior; // Behavior for list bottom sheet
|
||||||
|
private BottomSheetBehavior bottomSheetBehaviorForDetails; // Behavior for details bottom sheet
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
|
@ -107,6 +113,19 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter(this, nearbyMapFragment);
|
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter(this, nearbyMapFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
wikidataEditListener.setAuthenticationStateListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
wikidataEditListener.setAuthenticationStateListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resume fragments if they exists
|
* Resume fragments if they exists
|
||||||
*/
|
*/
|
||||||
|
|
@ -132,17 +151,17 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChangedSignificantly(LatLng latLng) {
|
public void onLocationChangedSignificantly(LatLng latLng) {
|
||||||
|
Log.d("deneme","location changed significantly");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChangedSlightly(LatLng latLng) {
|
public void onLocationChangedSlightly(LatLng latLng) {
|
||||||
|
Log.d("deneme","location changed significantly");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChangedMedium(LatLng latLng) {
|
public void onLocationChangedMedium(LatLng latLng) {
|
||||||
|
Log.d("deneme","location changed significantly");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -352,4 +371,22 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
getActivity().registerReceiver(broadcastReceiver, intentFilter);
|
getActivity().registerReceiver(broadcastReceiver, intentFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide or expand bottom sheet according to states of all sheets
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void listOptionMenuItemClicked() {
|
||||||
|
if(bottomSheetBehavior.getState()== BottomSheetBehavior.STATE_COLLAPSED || bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_HIDDEN){
|
||||||
|
bottomSheetBehaviorForDetails.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
|
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
|
}else if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED){
|
||||||
|
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBottomSheetExpanded() {
|
||||||
|
return bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue