mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-03 16:23:54 +01:00
Merge branch 'main' into issue5502
This commit is contained in:
commit
7b917afa82
70 changed files with 1250 additions and 1373 deletions
1
CREDITS
1
CREDITS
|
|
@ -53,7 +53,6 @@ their contribution to the product.
|
||||||
* Butterknife
|
* Butterknife
|
||||||
* GSON
|
* GSON
|
||||||
* Timber
|
* Timber
|
||||||
* MapBox
|
|
||||||
|
|
||||||
3rd party open source apps from which significant code has been reused:
|
3rd party open source apps from which significant code has been reused:
|
||||||
* Android Wikipedia app https://github.com/wikimedia/apps-android-wikipedia
|
* Android Wikipedia app https://github.com/wikimedia/apps-android-wikipedia
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.LocationPicker;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
|
import fr.free.nrw.commons.Media;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for starting the activity
|
* Helper class for starting the activity
|
||||||
|
|
@ -52,6 +53,17 @@ public final class LocationPicker {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets and puts media in intent
|
||||||
|
* @param media Media
|
||||||
|
* @return LocationPicker.IntentBuilder
|
||||||
|
*/
|
||||||
|
public LocationPicker.IntentBuilder media(
|
||||||
|
final Media media) {
|
||||||
|
intent.putExtra(LocationPickerConstants.MEDIA, media);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets and sets the activity
|
* Gets and sets the activity
|
||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@ import androidx.core.content.ContextCompat;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||||
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
import fr.free.nrw.commons.coordinates.CoordinateEditHelper;
|
||||||
import fr.free.nrw.commons.filepicker.Constants;
|
import fr.free.nrw.commons.filepicker.Constants;
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
import fr.free.nrw.commons.location.LocationPermissionsHelper;
|
import fr.free.nrw.commons.location.LocationPermissionsHelper;
|
||||||
|
|
@ -41,6 +43,9 @@ import fr.free.nrw.commons.location.LocationPermissionsHelper.LocationPermission
|
||||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
import fr.free.nrw.commons.utils.SystemThemeUtils;
|
import fr.free.nrw.commons.utils.SystemThemeUtils;
|
||||||
|
import fr.free.nrw.commons.utils.ViewUtilWrapper;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
@ -52,13 +57,22 @@ import org.osmdroid.views.overlay.Marker;
|
||||||
import org.osmdroid.views.overlay.Overlay;
|
import org.osmdroid.views.overlay.Overlay;
|
||||||
import org.osmdroid.views.overlay.ScaleDiskOverlay;
|
import org.osmdroid.views.overlay.ScaleDiskOverlay;
|
||||||
import org.osmdroid.views.overlay.TilesOverlay;
|
import org.osmdroid.views.overlay.TilesOverlay;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps to pick location and return the result with an intent
|
* Helps to pick location and return the result with an intent
|
||||||
*/
|
*/
|
||||||
public class LocationPickerActivity extends BaseActivity implements
|
public class LocationPickerActivity extends BaseActivity implements
|
||||||
LocationPermissionCallback {
|
LocationPermissionCallback {
|
||||||
|
/**
|
||||||
|
* coordinateEditHelper: helps to edit coordinates
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
CoordinateEditHelper coordinateEditHelper;
|
||||||
|
/**
|
||||||
|
* media : Media object
|
||||||
|
*/
|
||||||
|
private Media media;
|
||||||
/**
|
/**
|
||||||
* cameraPosition : position of picker
|
* cameraPosition : position of picker
|
||||||
*/
|
*/
|
||||||
|
|
@ -125,6 +139,13 @@ public class LocationPickerActivity extends BaseActivity implements
|
||||||
@Inject
|
@Inject
|
||||||
LocationServiceManager locationManager;
|
LocationServiceManager locationManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants
|
||||||
|
*/
|
||||||
|
private static final String CAMERA_POS = "cameraPosition";
|
||||||
|
private static final String ACTIVITY = "activity";
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||||
|
|
@ -145,8 +166,12 @@ public class LocationPickerActivity extends BaseActivity implements
|
||||||
cameraPosition = getIntent()
|
cameraPosition = getIntent()
|
||||||
.getParcelableExtra(LocationPickerConstants.MAP_CAMERA_POSITION);
|
.getParcelableExtra(LocationPickerConstants.MAP_CAMERA_POSITION);
|
||||||
activity = getIntent().getStringExtra(LocationPickerConstants.ACTIVITY_KEY);
|
activity = getIntent().getStringExtra(LocationPickerConstants.ACTIVITY_KEY);
|
||||||
|
media = getIntent().getParcelableExtra(LocationPickerConstants.MEDIA);
|
||||||
|
}else{
|
||||||
|
cameraPosition = savedInstanceState.getParcelable(CAMERA_POS);
|
||||||
|
activity = savedInstanceState.getString(ACTIVITY);
|
||||||
|
media = savedInstanceState.getParcelable("sMedia");
|
||||||
}
|
}
|
||||||
|
|
||||||
bindViews();
|
bindViews();
|
||||||
addBackButtonListener();
|
addBackButtonListener();
|
||||||
addPlaceSelectedButton();
|
addPlaceSelectedButton();
|
||||||
|
|
@ -220,7 +245,10 @@ public class LocationPickerActivity extends BaseActivity implements
|
||||||
*/
|
*/
|
||||||
private void addBackButtonListener() {
|
private void addBackButtonListener() {
|
||||||
final ImageView backButton = findViewById(R.id.maplibre_place_picker_toolbar_back_button);
|
final ImageView backButton = findViewById(R.id.maplibre_place_picker_toolbar_back_button);
|
||||||
backButton.setOnClickListener(view -> finish());
|
backButton.setOnClickListener(v -> {
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -311,14 +339,42 @@ public class LocationPickerActivity extends BaseActivity implements
|
||||||
+ mapView.getMapCenter().getLongitude());
|
+ mapView.getMapCenter().getLongitude());
|
||||||
applicationKvStore.putString(LAST_ZOOM, mapView.getZoomLevel() + "");
|
applicationKvStore.putString(LAST_ZOOM, mapView.getZoomLevel() + "");
|
||||||
}
|
}
|
||||||
final Intent returningIntent = new Intent();
|
|
||||||
returningIntent.putExtra(LocationPickerConstants.MAP_CAMERA_POSITION,
|
if (media == null) {
|
||||||
new CameraPosition(new LatLng(mapView.getMapCenter().getLatitude(),
|
final Intent returningIntent = new Intent();
|
||||||
mapView.getMapCenter().getLongitude()), 14f, 0, 0));
|
returningIntent.putExtra(LocationPickerConstants.MAP_CAMERA_POSITION,
|
||||||
setResult(AppCompatActivity.RESULT_OK, returningIntent);
|
new CameraPosition(new LatLng(mapView.getMapCenter().getLatitude(),
|
||||||
|
mapView.getMapCenter().getLongitude()), 14f, 0, 0));
|
||||||
|
setResult(AppCompatActivity.RESULT_OK, returningIntent);
|
||||||
|
} else {
|
||||||
|
updateCoordinates(String.valueOf(mapView.getMapCenter().getLatitude()),
|
||||||
|
String.valueOf(mapView.getMapCenter().getLongitude()),
|
||||||
|
String.valueOf(0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetched coordinates are replaced with existing coordinates by a POST API call.
|
||||||
|
* @param Latitude to be added
|
||||||
|
* @param Longitude to be added
|
||||||
|
* @param Accuracy to be added
|
||||||
|
*/
|
||||||
|
public void updateCoordinates(final String Latitude, final String Longitude,
|
||||||
|
final String Accuracy) {
|
||||||
|
if (media == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
compositeDisposable.add(coordinateEditHelper.makeCoordinatesEdit(getApplicationContext(),media,
|
||||||
|
Latitude, Longitude, Accuracy)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(s -> {
|
||||||
|
Timber.d("Coordinates are added.");
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Center the camera on the last saved location
|
* Center the camera on the last saved location
|
||||||
*/
|
*/
|
||||||
|
|
@ -458,4 +514,22 @@ public class LocationPickerActivity extends BaseActivity implements
|
||||||
mapView.getOverlays().add(startMarker);
|
mapView.getOverlays().add(startMarker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the state of the activity
|
||||||
|
* @param outState Bundle
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull final Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
if(cameraPosition!=null){
|
||||||
|
outState.putParcelable(CAMERA_POS, cameraPosition);
|
||||||
|
}
|
||||||
|
if(activity!=null){
|
||||||
|
outState.putString(ACTIVITY, activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(media!=null){
|
||||||
|
outState.putParcelable("sMedia", media);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ public final class LocationPickerConstants {
|
||||||
public static final String MAP_CAMERA_POSITION
|
public static final String MAP_CAMERA_POSITION
|
||||||
= "location.picker.cameraPosition";
|
= "location.picker.cameraPosition";
|
||||||
|
|
||||||
|
public static final String MEDIA
|
||||||
|
= "location.picker.media";
|
||||||
|
|
||||||
|
|
||||||
private LocationPickerConstants() {
|
private LocationPickerConstants() {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,15 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
|
||||||
|
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.explore.ParentViewPager;
|
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.R;
|
|
||||||
import fr.free.nrw.commons.contributions.ContributionController;
|
import fr.free.nrw.commons.contributions.ContributionController;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
|
@ -29,12 +21,7 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
private FragmentManager supportFragmentManager;
|
private FragmentManager supportFragmentManager;
|
||||||
private BookmarksPagerAdapter adapter;
|
private BookmarksPagerAdapter adapter;
|
||||||
@BindView(R.id.viewPagerBookmarks)
|
FragmentBookmarksBinding binding;
|
||||||
ParentViewPager viewPager;
|
|
||||||
@BindView(R.id.tab_layout)
|
|
||||||
TabLayout tabLayout;
|
|
||||||
@BindView(R.id.fragmentContainer)
|
|
||||||
FrameLayout fragmentContainer;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ContributionController controller;
|
ContributionController controller;
|
||||||
|
|
@ -54,7 +41,9 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScroll(boolean canScroll) {
|
public void setScroll(boolean canScroll) {
|
||||||
viewPager.setCanScroll(canScroll);
|
if (binding!=null) {
|
||||||
|
binding.viewPagerBookmarks.setCanScroll(canScroll);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -68,8 +57,7 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
@Nullable final ViewGroup container,
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreateView(inflater, container, savedInstanceState);
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_bookmarks, container, false);
|
binding = FragmentBookmarksBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
|
|
||||||
// Activity can call methods in the fragment by acquiring a
|
// Activity can call methods in the fragment by acquiring a
|
||||||
// reference to the Fragment from FragmentManager, using findFragmentById()
|
// reference to the Fragment from FragmentManager, using findFragmentById()
|
||||||
|
|
@ -77,14 +65,14 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
adapter = new BookmarksPagerAdapter(supportFragmentManager, getContext(),
|
adapter = new BookmarksPagerAdapter(supportFragmentManager, getContext(),
|
||||||
applicationKvStore.getBoolean("login_skipped"));
|
applicationKvStore.getBoolean("login_skipped"));
|
||||||
viewPager.setAdapter(adapter);
|
binding.viewPagerBookmarks.setAdapter(adapter);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPagerBookmarks);
|
||||||
|
|
||||||
((MainActivity) getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
|
||||||
setupTabLayout();
|
setupTabLayout();
|
||||||
return view;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,15 +80,15 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
* visibility of tabLayout to gone.
|
* visibility of tabLayout to gone.
|
||||||
*/
|
*/
|
||||||
public void setupTabLayout() {
|
public void setupTabLayout() {
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
if (adapter.getCount() == 1) {
|
if (adapter.getCount() == 1) {
|
||||||
tabLayout.setVisibility(View.GONE);
|
binding.tabLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (((BookmarkListRootFragment) (adapter.getItem(tabLayout.getSelectedTabPosition())))
|
if (((BookmarkListRootFragment) (adapter.getItem(binding.tabLayout.getSelectedTabPosition())))
|
||||||
.backPressed()) {
|
.backPressed()) {
|
||||||
// The event is handled internally by the adapter , no further action required.
|
// The event is handled internally by the adapter , no further action required.
|
||||||
return;
|
return;
|
||||||
|
|
@ -108,4 +96,10 @@ public class BookmarkFragment extends CommonsDaggerSupportFragment {
|
||||||
// Event is not handled by the adapter ( performed back action ) change action bar.
|
// Event is not handled by the adapter ( performed back action ) change action bar.
|
||||||
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsFragment;
|
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsFragment;
|
||||||
|
|
@ -22,6 +20,7 @@ import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment;
|
||||||
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
||||||
import fr.free.nrw.commons.category.GridViewAdapter;
|
import fr.free.nrw.commons.category.GridViewAdapter;
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentFeaturedRootBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
||||||
import fr.free.nrw.commons.navtab.NavTab;
|
import fr.free.nrw.commons.navtab.NavTab;
|
||||||
|
|
@ -39,8 +38,7 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
public Fragment listFragment;
|
public Fragment listFragment;
|
||||||
private BookmarksPagerAdapter bookmarksPagerAdapter;
|
private BookmarksPagerAdapter bookmarksPagerAdapter;
|
||||||
|
|
||||||
@BindView(R.id.explore_container)
|
FragmentFeaturedRootBinding binding;
|
||||||
FrameLayout container;
|
|
||||||
|
|
||||||
public BookmarkListRootFragment() {
|
public BookmarkListRootFragment() {
|
||||||
//empty constructor necessary otherwise crashes on recreate
|
//empty constructor necessary otherwise crashes on recreate
|
||||||
|
|
@ -70,9 +68,8 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
@Nullable final ViewGroup container,
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
binding = FragmentFeaturedRootBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, view);
|
return binding.getRoot();
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -241,8 +238,8 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Log.d("deneme8", "on media clicked");
|
Log.d("deneme8", "on media clicked");
|
||||||
container.setVisibility(View.VISIBLE);
|
binding.exploreContainer.setVisibility(View.VISIBLE);
|
||||||
((BookmarkFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
|
((BookmarkFragment) getParentFragment()).binding.tabLayout.setVisibility(View.GONE);
|
||||||
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
||||||
((BookmarkFragment) getParentFragment()).setScroll(false);
|
((BookmarkFragment) getParentFragment()).setScroll(false);
|
||||||
setFragment(mediaDetails, listFragment);
|
setFragment(mediaDetails, listFragment);
|
||||||
|
|
@ -253,4 +250,10 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
||||||
public void onBackStackChanged() {
|
public void onBackStackChanged() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import dagger.android.support.DaggerFragment;
|
import dagger.android.support.DaggerFragment;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksItemsBinding;
|
||||||
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem;
|
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
@ -26,17 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
*/
|
*/
|
||||||
public class BookmarkItemsFragment extends DaggerFragment {
|
public class BookmarkItemsFragment extends DaggerFragment {
|
||||||
|
|
||||||
@BindView(R.id.status_message)
|
private FragmentBookmarksItemsBinding binding;
|
||||||
TextView statusTextView;
|
|
||||||
|
|
||||||
@BindView(R.id.loading_images_progress_bar)
|
|
||||||
ProgressBar progressBar;
|
|
||||||
|
|
||||||
@BindView(R.id.list_view)
|
|
||||||
RecyclerView recyclerView;
|
|
||||||
|
|
||||||
@BindView(R.id.parent_layout)
|
|
||||||
RelativeLayout parentLayout;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BookmarkItemsController controller;
|
BookmarkItemsController controller;
|
||||||
|
|
@ -51,16 +40,13 @@ public class BookmarkItemsFragment extends DaggerFragment {
|
||||||
final ViewGroup container,
|
final ViewGroup container,
|
||||||
final Bundle savedInstanceState
|
final Bundle savedInstanceState
|
||||||
) {
|
) {
|
||||||
final View v = inflater.inflate(R.layout.fragment_bookmarks_items, container, false);
|
binding = FragmentBookmarksItemsBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, v);
|
return binding.getRoot();
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(final @NotNull View view, @Nullable final Bundle savedInstanceState) {
|
public void onViewCreated(final @NotNull View view, @Nullable final Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
||||||
initList(requireContext());
|
initList(requireContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,13 +63,19 @@ public class BookmarkItemsFragment extends DaggerFragment {
|
||||||
private void initList(final Context context) {
|
private void initList(final Context context) {
|
||||||
final List<DepictedItem> depictItems = controller.loadFavoritesItems();
|
final List<DepictedItem> depictItems = controller.loadFavoritesItems();
|
||||||
final BookmarkItemsAdapter adapter = new BookmarkItemsAdapter(depictItems, context);
|
final BookmarkItemsAdapter adapter = new BookmarkItemsAdapter(depictItems, context);
|
||||||
recyclerView.setAdapter(adapter);
|
binding.listView.setAdapter(adapter);
|
||||||
progressBar.setVisibility(View.GONE);
|
binding.loadingImagesProgressBar.setVisibility(View.GONE);
|
||||||
if (depictItems.isEmpty()) {
|
if (depictItems.isEmpty()) {
|
||||||
statusTextView.setText(R.string.bookmark_empty);
|
binding.statusMessage.setText(R.string.bookmark_empty);
|
||||||
statusTextView.setVisibility(View.VISIBLE);
|
binding.statusMessage.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
statusTextView.setVisibility(View.GONE);
|
binding.statusMessage.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import butterknife.ButterKnife;
|
||||||
import dagger.android.support.DaggerFragment;
|
import dagger.android.support.DaggerFragment;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.contributions.ContributionController;
|
import fr.free.nrw.commons.contributions.ContributionController;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksLocationsBinding;
|
||||||
import fr.free.nrw.commons.nearby.Place;
|
import fr.free.nrw.commons.nearby.Place;
|
||||||
import fr.free.nrw.commons.nearby.fragments.CommonPlaceClickActions;
|
import fr.free.nrw.commons.nearby.fragments.CommonPlaceClickActions;
|
||||||
import fr.free.nrw.commons.nearby.fragments.PlaceAdapter;
|
import fr.free.nrw.commons.nearby.fragments.PlaceAdapter;
|
||||||
|
|
@ -31,10 +32,7 @@ import kotlin.Unit;
|
||||||
|
|
||||||
public class BookmarkLocationsFragment extends DaggerFragment {
|
public class BookmarkLocationsFragment extends DaggerFragment {
|
||||||
|
|
||||||
@BindView(R.id.statusMessage) TextView statusTextView;
|
public FragmentBookmarksLocationsBinding binding;
|
||||||
@BindView(R.id.loadingImagesProgressBar) ProgressBar progressBar;
|
|
||||||
@BindView(R.id.listView) RecyclerView recyclerView;
|
|
||||||
@BindView(R.id.parentLayout) RelativeLayout parentLayout;
|
|
||||||
|
|
||||||
@Inject BookmarkLocationsController controller;
|
@Inject BookmarkLocationsController controller;
|
||||||
@Inject ContributionController contributionController;
|
@Inject ContributionController contributionController;
|
||||||
|
|
@ -75,16 +73,15 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
||||||
ViewGroup container,
|
ViewGroup container,
|
||||||
Bundle savedInstanceState
|
Bundle savedInstanceState
|
||||||
) {
|
) {
|
||||||
View v = inflater.inflate(R.layout.fragment_bookmarks_locations, container, false);
|
binding = FragmentBookmarksLocationsBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, v);
|
return binding.getRoot();
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
binding.loadingImagesProgressBar.setVisibility(View.VISIBLE);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
binding.listView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
adapter = new PlaceAdapter(bookmarkLocationDao,
|
adapter = new PlaceAdapter(bookmarkLocationDao,
|
||||||
place -> Unit.INSTANCE,
|
place -> Unit.INSTANCE,
|
||||||
(place, isBookmarked) -> {
|
(place, isBookmarked) -> {
|
||||||
|
|
@ -94,7 +91,7 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
||||||
commonPlaceClickActions,
|
commonPlaceClickActions,
|
||||||
inAppCameraLocationPermissionLauncher
|
inAppCameraLocationPermissionLauncher
|
||||||
);
|
);
|
||||||
recyclerView.setAdapter(adapter);
|
binding.listView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -109,12 +106,12 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
||||||
private void initList() {
|
private void initList() {
|
||||||
List<Place> places = controller.loadFavoritesLocations();
|
List<Place> places = controller.loadFavoritesLocations();
|
||||||
adapter.setItems(places);
|
adapter.setItems(places);
|
||||||
progressBar.setVisibility(View.GONE);
|
binding.loadingImagesProgressBar.setVisibility(View.GONE);
|
||||||
if (places.size() <= 0) {
|
if (places.size() <= 0) {
|
||||||
statusTextView.setText(R.string.bookmark_empty);
|
binding.statusMessage.setText(R.string.bookmark_empty);
|
||||||
statusTextView.setVisibility(View.VISIBLE);
|
binding.statusMessage.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
statusTextView.setVisibility(View.GONE);
|
binding.statusMessage.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,4 +119,10 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
contributionController.handleActivityResult(getActivity(), requestCode, resultCode, data);
|
contributionController.handleActivityResult(getActivity(), requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,15 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.GridView;
|
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import dagger.android.support.DaggerFragment;
|
import dagger.android.support.DaggerFragment;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.bookmarks.BookmarkListRootFragment;
|
import fr.free.nrw.commons.bookmarks.BookmarkListRootFragment;
|
||||||
import fr.free.nrw.commons.category.GridViewAdapter;
|
import fr.free.nrw.commons.category.GridViewAdapter;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksPicturesBinding;
|
||||||
import fr.free.nrw.commons.utils.NetworkUtils;
|
import fr.free.nrw.commons.utils.NetworkUtils;
|
||||||
import fr.free.nrw.commons.utils.ViewUtil;
|
import fr.free.nrw.commons.utils.ViewUtil;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
|
@ -37,11 +32,7 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
private GridViewAdapter gridAdapter;
|
private GridViewAdapter gridAdapter;
|
||||||
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||||
|
|
||||||
@BindView(R.id.statusMessage) TextView statusTextView;
|
private FragmentBookmarksPicturesBinding binding;
|
||||||
@BindView(R.id.loadingImagesProgressBar) ProgressBar progressBar;
|
|
||||||
@BindView(R.id.bookmarkedPicturesList) GridView gridView;
|
|
||||||
@BindView(R.id.parentLayout) RelativeLayout parentLayout;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BookmarkPicturesController controller;
|
BookmarkPicturesController controller;
|
||||||
|
|
||||||
|
|
@ -59,15 +50,14 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
ViewGroup container,
|
ViewGroup container,
|
||||||
Bundle savedInstanceState
|
Bundle savedInstanceState
|
||||||
) {
|
) {
|
||||||
View v = inflater.inflate(R.layout.fragment_bookmarks_pictures, container, false);
|
binding = FragmentBookmarksPicturesBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, v);
|
return binding.getRoot();
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
gridView.setOnItemClickListener((AdapterView.OnItemClickListener) getParentFragment());
|
binding.bookmarkedPicturesList.setOnItemClickListener((AdapterView.OnItemClickListener) getParentFragment());
|
||||||
initList();
|
initList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,13 +71,14 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
compositeDisposable.clear();
|
compositeDisposable.clear();
|
||||||
|
binding = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (controller.needRefreshBookmarkedPictures()) {
|
if (controller.needRefreshBookmarkedPictures()) {
|
||||||
gridView.setVisibility(GONE);
|
binding.bookmarkedPicturesList.setVisibility(GONE);
|
||||||
if (gridAdapter != null) {
|
if (gridAdapter != null) {
|
||||||
gridAdapter.clear();
|
gridAdapter.clear();
|
||||||
((BookmarkListRootFragment)getParentFragment()).viewPagerNotifyDataSetChanged();
|
((BookmarkListRootFragment)getParentFragment()).viewPagerNotifyDataSetChanged();
|
||||||
|
|
@ -107,8 +98,8 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar.setVisibility(VISIBLE);
|
binding.loadingImagesProgressBar.setVisibility(VISIBLE);
|
||||||
statusTextView.setVisibility(GONE);
|
binding.statusMessage.setVisibility(GONE);
|
||||||
|
|
||||||
compositeDisposable.add(controller.loadBookmarkedPictures()
|
compositeDisposable.add(controller.loadBookmarkedPictures()
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|
@ -120,12 +111,12 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
* Handles the UI updates for no internet scenario
|
* Handles the UI updates for no internet scenario
|
||||||
*/
|
*/
|
||||||
private void handleNoInternet() {
|
private void handleNoInternet() {
|
||||||
progressBar.setVisibility(GONE);
|
binding.loadingImagesProgressBar.setVisibility(GONE);
|
||||||
if (gridAdapter == null || gridAdapter.isEmpty()) {
|
if (gridAdapter == null || gridAdapter.isEmpty()) {
|
||||||
statusTextView.setVisibility(VISIBLE);
|
binding.statusMessage.setVisibility(VISIBLE);
|
||||||
statusTextView.setText(getString(R.string.no_internet));
|
binding.statusMessage.setText(getString(R.string.no_internet));
|
||||||
} else {
|
} else {
|
||||||
ViewUtil.showShortSnackbar(parentLayout, R.string.no_internet);
|
ViewUtil.showShortSnackbar(binding.parentLayout, R.string.no_internet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +127,7 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
private void handleError(Throwable throwable) {
|
private void handleError(Throwable throwable) {
|
||||||
Timber.e(throwable, "Error occurred while loading images inside a category");
|
Timber.e(throwable, "Error occurred while loading images inside a category");
|
||||||
try{
|
try{
|
||||||
ViewUtil.showShortSnackbar(parentLayout, R.string.error_loading_images);
|
ViewUtil.showShortSnackbar(binding.getRoot(), R.string.error_loading_images);
|
||||||
initErrorView();
|
initErrorView();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
@ -147,12 +138,12 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
* Handles the UI updates for a error scenario
|
* Handles the UI updates for a error scenario
|
||||||
*/
|
*/
|
||||||
private void initErrorView() {
|
private void initErrorView() {
|
||||||
progressBar.setVisibility(GONE);
|
binding.loadingImagesProgressBar.setVisibility(GONE);
|
||||||
if (gridAdapter == null || gridAdapter.isEmpty()) {
|
if (gridAdapter == null || gridAdapter.isEmpty()) {
|
||||||
statusTextView.setVisibility(VISIBLE);
|
binding.statusMessage.setVisibility(VISIBLE);
|
||||||
statusTextView.setText(getString(R.string.no_images_found));
|
binding.statusMessage.setText(getString(R.string.no_images_found));
|
||||||
} else {
|
} else {
|
||||||
statusTextView.setVisibility(GONE);
|
binding.statusMessage.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,12 +151,12 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
* Handles the UI updates when there is no bookmarks
|
* Handles the UI updates when there is no bookmarks
|
||||||
*/
|
*/
|
||||||
private void initEmptyBookmarkListView() {
|
private void initEmptyBookmarkListView() {
|
||||||
progressBar.setVisibility(GONE);
|
binding.loadingImagesProgressBar.setVisibility(GONE);
|
||||||
if (gridAdapter == null || gridAdapter.isEmpty()) {
|
if (gridAdapter == null || gridAdapter.isEmpty()) {
|
||||||
statusTextView.setVisibility(VISIBLE);
|
binding.statusMessage.setVisibility(VISIBLE);
|
||||||
statusTextView.setText(getString(R.string.bookmark_empty));
|
binding.statusMessage.setText(getString(R.string.bookmark_empty));
|
||||||
} else {
|
} else {
|
||||||
statusTextView.setVisibility(GONE);
|
binding.statusMessage.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,18 +179,18 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
setAdapter(collection);
|
setAdapter(collection);
|
||||||
} else {
|
} else {
|
||||||
if (gridAdapter.containsAll(collection)) {
|
if (gridAdapter.containsAll(collection)) {
|
||||||
progressBar.setVisibility(GONE);
|
binding.loadingImagesProgressBar.setVisibility(GONE);
|
||||||
statusTextView.setVisibility(GONE);
|
binding.statusMessage.setVisibility(GONE);
|
||||||
gridView.setVisibility(VISIBLE);
|
binding.bookmarkedPicturesList.setVisibility(VISIBLE);
|
||||||
gridView.setAdapter(gridAdapter);
|
binding.bookmarkedPicturesList.setAdapter(gridAdapter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gridAdapter.addItems(collection);
|
gridAdapter.addItems(collection);
|
||||||
((BookmarkListRootFragment) getParentFragment()).viewPagerNotifyDataSetChanged();
|
((BookmarkListRootFragment) getParentFragment()).viewPagerNotifyDataSetChanged();
|
||||||
}
|
}
|
||||||
progressBar.setVisibility(GONE);
|
binding.loadingImagesProgressBar.setVisibility(GONE);
|
||||||
statusTextView.setVisibility(GONE);
|
binding.statusMessage.setVisibility(GONE);
|
||||||
gridView.setVisibility(VISIBLE);
|
binding.bookmarkedPicturesList.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -212,7 +203,7 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
R.layout.layout_category_images,
|
R.layout.layout_category_images,
|
||||||
mediaList
|
mediaList
|
||||||
);
|
);
|
||||||
gridView.setAdapter(gridAdapter);
|
binding.bookmarkedPicturesList.setAdapter(gridAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -221,6 +212,7 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
||||||
* @return GridView Adapter
|
* @return GridView Adapter
|
||||||
*/
|
*/
|
||||||
public ListAdapter getAdapter() {
|
public ListAdapter getAdapter() {
|
||||||
return gridView.getAdapter();
|
return binding.bookmarkedPicturesList.getAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,12 @@ import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter;
|
import fr.free.nrw.commons.ViewPagerAdapter;
|
||||||
|
import fr.free.nrw.commons.databinding.ActivityCategoryDetailsBinding;
|
||||||
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment;
|
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment;
|
||||||
import fr.free.nrw.commons.explore.categories.parent.ParentCategoriesFragment;
|
import fr.free.nrw.commons.explore.categories.parent.ParentCategoriesFragment;
|
||||||
import fr.free.nrw.commons.explore.categories.sub.SubCategoriesFragment;
|
import fr.free.nrw.commons.explore.categories.sub.SubCategoriesFragment;
|
||||||
|
|
@ -45,23 +44,23 @@ public class CategoryDetailsActivity extends BaseActivity
|
||||||
private CategoriesMediaFragment categoriesMediaFragment;
|
private CategoriesMediaFragment categoriesMediaFragment;
|
||||||
private MediaDetailPagerFragment mediaDetails;
|
private MediaDetailPagerFragment mediaDetails;
|
||||||
private String categoryName;
|
private String categoryName;
|
||||||
@BindView(R.id.mediaContainer) FrameLayout mediaContainer;
|
|
||||||
@BindView(R.id.tab_layout) TabLayout tabLayout;
|
|
||||||
@BindView(R.id.viewPager) ViewPager viewPager;
|
|
||||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
|
||||||
ViewPagerAdapter viewPagerAdapter;
|
ViewPagerAdapter viewPagerAdapter;
|
||||||
|
|
||||||
|
private ActivityCategoryDetailsBinding binding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_category_details);
|
|
||||||
ButterKnife.bind(this);
|
binding = ActivityCategoryDetailsBinding.inflate(getLayoutInflater());
|
||||||
|
final View view = binding.getRoot();
|
||||||
|
setContentView(view);
|
||||||
supportFragmentManager = getSupportFragmentManager();
|
supportFragmentManager = getSupportFragmentManager();
|
||||||
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(viewPagerAdapter);
|
binding.viewPager.setAdapter(viewPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(2);
|
binding.viewPager.setOffscreenPageLimit(2);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(binding.toolbarBinding.toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
setTabs();
|
setTabs();
|
||||||
setPageTitle();
|
setPageTitle();
|
||||||
|
|
@ -110,9 +109,9 @@ public class CategoryDetailsActivity extends BaseActivity
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int position) {
|
public void onMediaClicked(int position) {
|
||||||
tabLayout.setVisibility(View.GONE);
|
binding.tabLayout.setVisibility(View.GONE);
|
||||||
viewPager.setVisibility(View.GONE);
|
binding.viewPager.setVisibility(View.GONE);
|
||||||
mediaContainer.setVisibility(View.VISIBLE);
|
binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||||
if (mediaDetails == null || !mediaDetails.isVisible()) {
|
if (mediaDetails == null || !mediaDetails.isVisible()) {
|
||||||
// set isFeaturedImage true for featured images, to include author field on media detail
|
// set isFeaturedImage true for featured images, to include author field on media detail
|
||||||
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
||||||
|
|
@ -216,9 +215,9 @@ public class CategoryDetailsActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (supportFragmentManager.getBackStackEntryCount() == 1){
|
if (supportFragmentManager.getBackStackEntryCount() == 1){
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
binding.viewPager.setVisibility(View.VISIBLE);
|
||||||
mediaContainer.setVisibility(View.GONE);
|
binding.mediaContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,12 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AlertDialog.Builder;
|
import androidx.appcompat.app.AlertDialog.Builder;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
import com.facebook.drawee.view.SimpleDraweeView;
|
||||||
import com.facebook.imagepipeline.request.ImageRequest;
|
import com.facebook.imagepipeline.request.ImageRequest;
|
||||||
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.contributions.ContributionsListAdapter.Callback;
|
import fr.free.nrw.commons.contributions.ContributionsListAdapter.Callback;
|
||||||
|
import fr.free.nrw.commons.databinding.LayoutContributionBinding;
|
||||||
import fr.free.nrw.commons.media.MediaClient;
|
import fr.free.nrw.commons.media.MediaClient;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
@ -29,29 +27,8 @@ import java.io.File;
|
||||||
public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private final Callback callback;
|
private final Callback callback;
|
||||||
@BindView(R.id.contributionImage)
|
|
||||||
SimpleDraweeView imageView;
|
|
||||||
@BindView(R.id.contributionTitle)
|
|
||||||
TextView titleView;
|
|
||||||
@BindView(R.id.authorView)
|
|
||||||
TextView authorView;
|
|
||||||
@BindView(R.id.contributionState)
|
|
||||||
TextView stateView;
|
|
||||||
@BindView(R.id.contributionSequenceNumber)
|
|
||||||
TextView seqNumView;
|
|
||||||
@BindView(R.id.contributionProgress)
|
|
||||||
ProgressBar progressView;
|
|
||||||
@BindView(R.id.image_options)
|
|
||||||
RelativeLayout imageOptions;
|
|
||||||
@BindView(R.id.wikipediaButton)
|
|
||||||
ImageButton addToWikipediaButton;
|
|
||||||
@BindView(R.id.retryButton)
|
|
||||||
ImageButton retryButton;
|
|
||||||
@BindView(R.id.cancelButton)
|
|
||||||
ImageButton cancelButton;
|
|
||||||
@BindView(R.id.pauseResumeButton)
|
|
||||||
ImageButton pauseResumeButton;
|
|
||||||
|
|
||||||
|
LayoutContributionBinding binding;
|
||||||
|
|
||||||
private int position;
|
private int position;
|
||||||
private Contribution contribution;
|
private Contribution contribution;
|
||||||
|
|
@ -67,9 +44,16 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.mediaClient = mediaClient;
|
this.mediaClient = mediaClient;
|
||||||
ButterKnife.bind(this, parent);
|
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|
||||||
|
binding = LayoutContributionBinding.bind(parent);
|
||||||
|
|
||||||
|
binding.retryButton.setOnClickListener(v -> retryUpload());
|
||||||
|
binding.cancelButton.setOnClickListener(v -> deleteUpload());
|
||||||
|
binding.contributionImage.setOnClickListener(v -> imageClicked());
|
||||||
|
binding.wikipediaButton.setOnClickListener(v -> wikipediaButtonClicked());
|
||||||
|
binding.pauseResumeButton.setOnClickListener(v -> onPauseResumeButtonClicked());
|
||||||
|
|
||||||
/* Set a dialog indicating that the upload is being paused. This is needed because pausing
|
/* Set a dialog indicating that the upload is being paused. This is needed because pausing
|
||||||
an upload might take a dozen seconds. */
|
an upload might take a dozen seconds. */
|
||||||
AlertDialog.Builder builder = new Builder(parent.getContext());
|
AlertDialog.Builder builder = new Builder(parent.getContext());
|
||||||
|
|
@ -87,14 +71,17 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
this.contribution = contribution;
|
this.contribution = contribution;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
titleView.setText(contribution.getMedia().getMostRelevantCaption());
|
binding.contributionTitle.setText(contribution.getMedia().getMostRelevantCaption());
|
||||||
authorView.setText(contribution.getMedia().getAuthor());
|
binding.authorView.setText(contribution.getMedia().getAuthor());
|
||||||
|
|
||||||
//Removes flicker of loading image.
|
//Removes flicker of loading image.
|
||||||
imageView.getHierarchy().setFadeDuration(0);
|
binding.contributionImage.getHierarchy().setFadeDuration(0);
|
||||||
|
|
||||||
imageView.getHierarchy().setPlaceholderImage(R.drawable.image_placeholder);
|
binding.contributionImage.getHierarchy().setPlaceholderImage(R.drawable.image_placeholder);
|
||||||
imageView.getHierarchy().setFailureImage(R.drawable.image_placeholder);
|
binding.contributionImage.getHierarchy().setFailureImage(R.drawable.image_placeholder);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final String imageSource = chooseImageSource(contribution.getMedia().getThumbUrl(),
|
final String imageSource = chooseImageSource(contribution.getMedia().getThumbUrl(),
|
||||||
contribution.getLocalUri());
|
contribution.getLocalUri());
|
||||||
|
|
@ -109,67 +96,67 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imageRequest != null){
|
if(imageRequest != null){
|
||||||
imageView.setImageRequest(imageRequest);
|
binding.contributionImage.setImageRequest(imageRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
seqNumView.setText(String.valueOf(position + 1));
|
binding.contributionSequenceNumber.setText(String.valueOf(position + 1));
|
||||||
seqNumView.setVisibility(View.VISIBLE);
|
binding.contributionSequenceNumber.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
addToWikipediaButton.setVisibility(View.GONE);
|
binding.wikipediaButton.setVisibility(View.GONE);
|
||||||
switch (contribution.getState()) {
|
switch (contribution.getState()) {
|
||||||
case Contribution.STATE_COMPLETED:
|
case Contribution.STATE_COMPLETED:
|
||||||
stateView.setVisibility(View.GONE);
|
binding.contributionState.setVisibility(View.GONE);
|
||||||
progressView.setVisibility(View.GONE);
|
binding.contributionProgress.setVisibility(View.GONE);
|
||||||
imageOptions.setVisibility(View.GONE);
|
binding.imageOptions.setVisibility(View.GONE);
|
||||||
stateView.setText("");
|
binding.contributionState.setText("");
|
||||||
checkIfMediaExistsOnWikipediaPage(contribution);
|
checkIfMediaExistsOnWikipediaPage(contribution);
|
||||||
break;
|
break;
|
||||||
case Contribution.STATE_QUEUED:
|
case Contribution.STATE_QUEUED:
|
||||||
case Contribution.STATE_QUEUED_LIMITED_CONNECTION_MODE:
|
case Contribution.STATE_QUEUED_LIMITED_CONNECTION_MODE:
|
||||||
progressView.setVisibility(View.GONE);
|
binding.contributionProgress.setVisibility(View.GONE);
|
||||||
stateView.setVisibility(View.VISIBLE);
|
binding.contributionState.setVisibility(View.VISIBLE);
|
||||||
stateView.setText(R.string.contribution_state_queued);
|
binding.contributionState.setText(R.string.contribution_state_queued);
|
||||||
imageOptions.setVisibility(View.GONE);
|
binding.imageOptions.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case Contribution.STATE_IN_PROGRESS:
|
case Contribution.STATE_IN_PROGRESS:
|
||||||
stateView.setVisibility(View.GONE);
|
binding.contributionState.setVisibility(View.GONE);
|
||||||
progressView.setVisibility(View.VISIBLE);
|
binding.contributionProgress.setVisibility(View.VISIBLE);
|
||||||
addToWikipediaButton.setVisibility(View.GONE);
|
binding.wikipediaButton.setVisibility(View.GONE);
|
||||||
pauseResumeButton.setVisibility(View.VISIBLE);
|
binding.pauseResumeButton.setVisibility(View.VISIBLE);
|
||||||
cancelButton.setVisibility(View.GONE);
|
binding.cancelButton.setVisibility(View.GONE);
|
||||||
retryButton.setVisibility(View.GONE);
|
binding.retryButton.setVisibility(View.GONE);
|
||||||
imageOptions.setVisibility(View.VISIBLE);
|
binding.imageOptions.setVisibility(View.VISIBLE);
|
||||||
final long total = contribution.getDataLength();
|
final long total = contribution.getDataLength();
|
||||||
final long transferred = contribution.getTransferred();
|
final long transferred = contribution.getTransferred();
|
||||||
if (transferred == 0 || transferred >= total) {
|
if (transferred == 0 || transferred >= total) {
|
||||||
progressView.setIndeterminate(true);
|
binding.contributionProgress.setIndeterminate(true);
|
||||||
} else {
|
} else {
|
||||||
progressView.setIndeterminate(false);
|
binding.contributionProgress.setIndeterminate(false);
|
||||||
progressView.setProgress((int) (((double) transferred / (double) total) * 100));
|
binding.contributionProgress.setProgress((int) (((double) transferred / (double) total) * 100));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Contribution.STATE_PAUSED:
|
case Contribution.STATE_PAUSED:
|
||||||
progressView.setVisibility(View.GONE);
|
binding.contributionProgress.setVisibility(View.GONE);
|
||||||
stateView.setVisibility(View.VISIBLE);
|
binding.contributionState.setVisibility(View.VISIBLE);
|
||||||
stateView.setText(R.string.paused);
|
binding.contributionState.setText(R.string.paused);
|
||||||
cancelButton.setVisibility(View.VISIBLE);
|
binding.cancelButton.setVisibility(View.VISIBLE);
|
||||||
retryButton.setVisibility(View.GONE);
|
binding.retryButton.setVisibility(View.GONE);
|
||||||
pauseResumeButton.setVisibility(View.VISIBLE);
|
binding.pauseResumeButton.setVisibility(View.VISIBLE);
|
||||||
imageOptions.setVisibility(View.VISIBLE);
|
binding.imageOptions.setVisibility(View.VISIBLE);
|
||||||
setResume();
|
setResume();
|
||||||
if(pausingPopUp.isShowing()){
|
if(pausingPopUp.isShowing()){
|
||||||
pausingPopUp.hide();
|
pausingPopUp.hide();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Contribution.STATE_FAILED:
|
case Contribution.STATE_FAILED:
|
||||||
stateView.setVisibility(View.VISIBLE);
|
binding.contributionState.setVisibility(View.VISIBLE);
|
||||||
stateView.setText(R.string.contribution_state_failed);
|
binding.contributionState.setText(R.string.contribution_state_failed);
|
||||||
progressView.setVisibility(View.GONE);
|
binding.contributionProgress.setVisibility(View.GONE);
|
||||||
cancelButton.setVisibility(View.VISIBLE);
|
binding.cancelButton.setVisibility(View.VISIBLE);
|
||||||
retryButton.setVisibility(View.VISIBLE);
|
binding.retryButton.setVisibility(View.VISIBLE);
|
||||||
pauseResumeButton.setVisibility(View.GONE);
|
binding.pauseResumeButton.setVisibility(View.GONE);
|
||||||
imageOptions.setVisibility(View.VISIBLE);
|
binding.imageOptions.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -203,11 +190,11 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
*/
|
*/
|
||||||
private void displayWikipediaButton(Boolean mediaExists) {
|
private void displayWikipediaButton(Boolean mediaExists) {
|
||||||
if (!mediaExists) {
|
if (!mediaExists) {
|
||||||
addToWikipediaButton.setVisibility(View.VISIBLE);
|
binding.wikipediaButton.setVisibility(View.VISIBLE);
|
||||||
isWikipediaButtonDisplayed = true;
|
isWikipediaButtonDisplayed = true;
|
||||||
cancelButton.setVisibility(View.GONE);
|
binding.cancelButton.setVisibility(View.GONE);
|
||||||
retryButton.setVisibility(View.GONE);
|
binding.retryButton.setVisibility(View.GONE);
|
||||||
imageOptions.setVisibility(View.VISIBLE);
|
binding.imageOptions.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +216,6 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
/**
|
/**
|
||||||
* Retry upload when it is failed
|
* Retry upload when it is failed
|
||||||
*/
|
*/
|
||||||
@OnClick(R.id.retryButton)
|
|
||||||
public void retryUpload() {
|
public void retryUpload() {
|
||||||
callback.retryUpload(contribution);
|
callback.retryUpload(contribution);
|
||||||
}
|
}
|
||||||
|
|
@ -237,17 +223,14 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
/**
|
/**
|
||||||
* Delete a failed upload attempt
|
* Delete a failed upload attempt
|
||||||
*/
|
*/
|
||||||
@OnClick(R.id.cancelButton)
|
|
||||||
public void deleteUpload() {
|
public void deleteUpload() {
|
||||||
callback.deleteUpload(contribution);
|
callback.deleteUpload(contribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.contributionImage)
|
|
||||||
public void imageClicked() {
|
public void imageClicked() {
|
||||||
callback.openMediaDetail(position, isWikipediaButtonDisplayed);
|
callback.openMediaDetail(position, isWikipediaButtonDisplayed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.wikipediaButton)
|
|
||||||
public void wikipediaButtonClicked() {
|
public void wikipediaButtonClicked() {
|
||||||
callback.addImageToWikipedia(contribution);
|
callback.addImageToWikipedia(contribution);
|
||||||
}
|
}
|
||||||
|
|
@ -255,9 +238,8 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
/**
|
/**
|
||||||
* Triggers a callback for pause/resume
|
* Triggers a callback for pause/resume
|
||||||
*/
|
*/
|
||||||
@OnClick(R.id.pauseResumeButton)
|
|
||||||
public void onPauseResumeButtonClicked() {
|
public void onPauseResumeButtonClicked() {
|
||||||
if (pauseResumeButton.getTag().toString().equals("pause")) {
|
if (binding.pauseResumeButton.getTag().toString().equals("pause")) {
|
||||||
pause();
|
pause();
|
||||||
} else {
|
} else {
|
||||||
resume();
|
resume();
|
||||||
|
|
@ -279,16 +261,16 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
||||||
* Update pause/resume button to show pause state
|
* Update pause/resume button to show pause state
|
||||||
*/
|
*/
|
||||||
private void setPaused() {
|
private void setPaused() {
|
||||||
pauseResumeButton.setImageResource(R.drawable.pause_icon);
|
binding.pauseResumeButton.setImageResource(R.drawable.pause_icon);
|
||||||
pauseResumeButton.setTag(parent.getContext().getString(R.string.pause));
|
binding.pauseResumeButton.setTag(parent.getContext().getString(R.string.pause));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update pause/resume button to show resume state
|
* Update pause/resume button to show resume state
|
||||||
*/
|
*/
|
||||||
private void setResume() {
|
private void setResume() {
|
||||||
pauseResumeButton.setImageResource(R.drawable.play_icon);
|
binding.pauseResumeButton.setImageResource(R.drawable.play_icon);
|
||||||
pauseResumeButton.setTag(parent.getContext().getString(R.string.resume));
|
binding.pauseResumeButton.setTag(parent.getContext().getString(R.string.resume));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageRequest getImageRequest() {
|
public ImageRequest getImageRequest() {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import androidx.fragment.app.FragmentTransaction;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.auth.SessionManager;
|
import fr.free.nrw.commons.auth.SessionManager;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentContributionsBinding;
|
||||||
import fr.free.nrw.commons.notification.models.Notification;
|
import fr.free.nrw.commons.notification.models.Notification;
|
||||||
import fr.free.nrw.commons.notification.NotificationController;
|
import fr.free.nrw.commons.notification.NotificationController;
|
||||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||||
|
|
@ -49,8 +50,6 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import androidx.work.WorkManager;
|
import androidx.work.WorkManager;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.campaigns.models.Campaign;
|
import fr.free.nrw.commons.campaigns.models.Campaign;
|
||||||
|
|
@ -106,10 +105,8 @@ public class ContributionsFragment
|
||||||
static final String MEDIA_DETAIL_PAGER_FRAGMENT_TAG = "MediaDetailFragmentTag";
|
static final String MEDIA_DETAIL_PAGER_FRAGMENT_TAG = "MediaDetailFragmentTag";
|
||||||
private static final int MAX_RETRIES = 10;
|
private static final int MAX_RETRIES = 10;
|
||||||
|
|
||||||
@BindView(R.id.card_view_nearby) public NearbyNotificationCardView nearbyNotificationCardView;
|
|
||||||
@BindView(R.id.campaigns_view) CampaignView campaignView;
|
public FragmentContributionsBinding binding;
|
||||||
@BindView(R.id.limited_connection_enabled_layout) LinearLayout limitedConnectionEnabledLayout;
|
|
||||||
@BindView(R.id.limited_connection_description_text_view) TextView limitedConnectionDescriptionTextView;
|
|
||||||
|
|
||||||
@Inject ContributionsPresenter contributionsPresenter;
|
@Inject ContributionsPresenter contributionsPresenter;
|
||||||
|
|
||||||
|
|
@ -147,7 +144,7 @@ public class ContributionsFragment
|
||||||
&& store.getBoolean("displayLocationPermissionForCardView", true)
|
&& store.getBoolean("displayLocationPermissionForCardView", true)
|
||||||
&& !store.getBoolean("doNotAskForLocationPermission", false)
|
&& !store.getBoolean("doNotAskForLocationPermission", false)
|
||||||
&& (((MainActivity) getActivity()).activeFragment == ActiveFragment.CONTRIBUTIONS)) {
|
&& (((MainActivity) getActivity()).activeFragment == ActiveFragment.CONTRIBUTIONS)) {
|
||||||
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
|
binding.cardViewNearby.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
|
||||||
showNearbyCardPermissionRationale();
|
showNearbyCardPermissionRationale();
|
||||||
} else {
|
} else {
|
||||||
displayYouWontSeeNearbyMessage();
|
displayYouWontSeeNearbyMessage();
|
||||||
|
|
@ -179,12 +176,13 @@ public class ContributionsFragment
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_contributions, container, false);
|
|
||||||
ButterKnife.bind(this, view);
|
binding = FragmentContributionsBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
initWLMCampaign();
|
initWLMCampaign();
|
||||||
presenter.onAttachView(this);
|
presenter.onAttachView(this);
|
||||||
contributionsPresenter.onAttachView(this);
|
contributionsPresenter.onAttachView(this);
|
||||||
campaignView.setVisibility(View.GONE);
|
binding.campaignsView.setVisibility(View.GONE);
|
||||||
checkBoxView = View.inflate(getActivity(), R.layout.nearby_permission_dialog, null);
|
checkBoxView = View.inflate(getActivity(), R.layout.nearby_permission_dialog, null);
|
||||||
checkBox = (CheckBox) checkBoxView.findViewById(R.id.never_ask_again);
|
checkBox = (CheckBox) checkBoxView.findViewById(R.id.never_ask_again);
|
||||||
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
|
@ -204,7 +202,7 @@ public class ContributionsFragment
|
||||||
|
|
||||||
initFragments();
|
initFragments();
|
||||||
if(isUserProfile) {
|
if(isUserProfile) {
|
||||||
limitedConnectionEnabledLayout.setVisibility(View.GONE);
|
binding.limitedConnectionEnabledLayout.setVisibility(View.GONE);
|
||||||
}else {
|
}else {
|
||||||
upDateUploadCount();
|
upDateUploadCount();
|
||||||
}
|
}
|
||||||
|
|
@ -221,9 +219,9 @@ public class ContributionsFragment
|
||||||
&& sessionManager.getCurrentAccount() != null && !isUserProfile) {
|
&& sessionManager.getCurrentAccount() != null && !isUserProfile) {
|
||||||
setUploadCount();
|
setUploadCount();
|
||||||
}
|
}
|
||||||
limitedConnectionEnabledLayout.setOnClickListener(toggleDescriptionListener);
|
binding.limitedConnectionEnabledLayout.setOnClickListener(toggleDescriptionListener);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
return view;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -283,22 +281,17 @@ public class ContributionsFragment
|
||||||
.getBoolean(CommonsApplication.IS_LIMITED_CONNECTION_MODE_ENABLED, false);
|
.getBoolean(CommonsApplication.IS_LIMITED_CONNECTION_MODE_ENABLED, false);
|
||||||
|
|
||||||
checkable.setChecked(isEnabled);
|
checkable.setChecked(isEnabled);
|
||||||
if (isEnabled) {
|
if (binding!=null) {
|
||||||
limitedConnectionEnabledLayout.setVisibility(View.VISIBLE);
|
binding.limitedConnectionEnabledLayout.setVisibility(isEnabled ? View.VISIBLE : View.GONE);
|
||||||
} else {
|
|
||||||
limitedConnectionEnabledLayout.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkable.setIcon((isEnabled) ? R.drawable.ic_baseline_cloud_off_24:R.drawable.ic_baseline_cloud_queue_24);
|
checkable.setIcon((isEnabled) ? R.drawable.ic_baseline_cloud_off_24:R.drawable.ic_baseline_cloud_queue_24);
|
||||||
checkable.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
checkable.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
((MainActivity) getActivity()).toggleLimitedConnectionMode();
|
((MainActivity) getActivity()).toggleLimitedConnectionMode();
|
||||||
boolean isEnabled = store.getBoolean(CommonsApplication.IS_LIMITED_CONNECTION_MODE_ENABLED, false);
|
boolean isEnabled = store.getBoolean(CommonsApplication.IS_LIMITED_CONNECTION_MODE_ENABLED, false);
|
||||||
if (isEnabled) {
|
binding.limitedConnectionEnabledLayout.setVisibility(isEnabled ? View.VISIBLE : View.GONE);
|
||||||
limitedConnectionEnabledLayout.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
limitedConnectionEnabledLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
checkable.setIcon((isEnabled) ? R.drawable.ic_baseline_cloud_off_24:R.drawable.ic_baseline_cloud_queue_24);
|
checkable.setIcon((isEnabled) ? R.drawable.ic_baseline_cloud_off_24:R.drawable.ic_baseline_cloud_queue_24);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -326,14 +319,14 @@ public class ContributionsFragment
|
||||||
*/
|
*/
|
||||||
private void showContributionsListFragment() {
|
private void showContributionsListFragment() {
|
||||||
// show nearby card view on contributions list is visible
|
// show nearby card view on contributions list is visible
|
||||||
if (nearbyNotificationCardView != null && !isUserProfile) {
|
if (binding.cardViewNearby != null && !isUserProfile) {
|
||||||
if (store.getBoolean("displayNearbyCardView", true)) {
|
if (store.getBoolean("displayNearbyCardView", true)) {
|
||||||
if (nearbyNotificationCardView.cardViewVisibilityState
|
if (binding.cardViewNearby.cardViewVisibilityState
|
||||||
== NearbyNotificationCardView.CardViewVisibilityState.READY) {
|
== NearbyNotificationCardView.CardViewVisibilityState.READY) {
|
||||||
nearbyNotificationCardView.setVisibility(View.VISIBLE);
|
binding.cardViewNearby.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.cardViewNearby.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
||||||
|
|
@ -346,8 +339,9 @@ public class ContributionsFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupViewForMediaDetails() {
|
private void setupViewForMediaDetails() {
|
||||||
campaignView.setVisibility(View.GONE);
|
if (binding!=null) {
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.campaignsView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -453,7 +447,12 @@ public class ContributionsFragment
|
||||||
super.onResume();
|
super.onResume();
|
||||||
contributionsPresenter.onAttachView(this);
|
contributionsPresenter.onAttachView(this);
|
||||||
locationManager.addLocationListener(this);
|
locationManager.addLocationListener(this);
|
||||||
nearbyNotificationCardView.permissionRequestButton.setOnClickListener(v -> {
|
|
||||||
|
if (binding==null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.cardViewNearby.permissionRequestButton.setOnClickListener(v -> {
|
||||||
showNearbyCardPermissionRationale();
|
showNearbyCardPermissionRationale();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -468,13 +467,13 @@ public class ContributionsFragment
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Timber.e(e);
|
Timber.e(e);
|
||||||
}
|
}
|
||||||
if (nearbyNotificationCardView.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
|
if (binding.cardViewNearby.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
|
||||||
nearbyNotificationCardView.setVisibility(View.VISIBLE);
|
binding.cardViewNearby.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Hide nearby notification card view if related shared preferences is false
|
// Hide nearby notification card view if related shared preferences is false
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.cardViewNearby.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notification Count and Campaigns should not be set, if it is used in User Profile
|
// Notification Count and Campaigns should not be set, if it is used in User Profile
|
||||||
|
|
@ -493,7 +492,7 @@ public class ContributionsFragment
|
||||||
&& store.getBoolean("displayLocationPermissionForCardView", true)
|
&& store.getBoolean("displayLocationPermissionForCardView", true)
|
||||||
&& !store.getBoolean("doNotAskForLocationPermission", false)
|
&& !store.getBoolean("doNotAskForLocationPermission", false)
|
||||||
&& (((MainActivity) getActivity()).activeFragment == ActiveFragment.CONTRIBUTIONS)) {
|
&& (((MainActivity) getActivity()).activeFragment == ActiveFragment.CONTRIBUTIONS)) {
|
||||||
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
|
binding.cardViewNearby.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
|
||||||
showNearbyCardPermissionRationale();
|
showNearbyCardPermissionRationale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -503,7 +502,7 @@ public class ContributionsFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onLocationPermissionGranted() {
|
private void onLocationPermissionGranted() {
|
||||||
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.NO_PERMISSION_NEEDED;
|
binding.cardViewNearby.permissionType = NearbyNotificationCardView.PermissionType.NO_PERMISSION_NEEDED;
|
||||||
locationManager.registerLocationManager();
|
locationManager.registerLocationManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -548,21 +547,21 @@ public class ContributionsFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
if(closestNearbyPlace == null) {
|
if(closestNearbyPlace == null) {
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.cardViewNearby.setVisibility(View.GONE);
|
||||||
}else{
|
}else{
|
||||||
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location);
|
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location);
|
||||||
closestNearbyPlace.setDistance(distance);
|
closestNearbyPlace.setDistance(distance);
|
||||||
direction = (float) computeBearing(curLatLng, closestNearbyPlace.location);
|
direction = (float) computeBearing(curLatLng, closestNearbyPlace.location);
|
||||||
nearbyNotificationCardView.updateContent(closestNearbyPlace);
|
binding.cardViewNearby.updateContent(closestNearbyPlace);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Means that no close nearby place is found
|
// Means that no close nearby place is found
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.cardViewNearby.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent Nearby banner from appearing in Media Details, fixing bug https://github.com/commons-app/apps-android-commons/issues/4731
|
// Prevent Nearby banner from appearing in Media Details, fixing bug https://github.com/commons-app/apps-android-commons/issues/4731
|
||||||
if (mediaDetailPagerFragment != null && !contributionsListFragment.isVisible()) {
|
if (mediaDetailPagerFragment != null && !contributionsListFragment.isVisible()) {
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.cardViewNearby.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -614,12 +613,16 @@ public class ContributionsFragment
|
||||||
*/
|
*/
|
||||||
private void fetchCampaigns() {
|
private void fetchCampaigns() {
|
||||||
if (Utils.isMonumentsEnabled(new Date())) {
|
if (Utils.isMonumentsEnabled(new Date())) {
|
||||||
campaignView.setCampaign(wlmCampaign);
|
if (binding!=null) {
|
||||||
campaignView.setVisibility(View.VISIBLE);
|
binding.campaignsView.setCampaign(wlmCampaign);
|
||||||
|
binding.campaignsView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
} else if (store.getBoolean(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE, true)) {
|
} else if (store.getBoolean(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE, true)) {
|
||||||
presenter.getCampaigns();
|
presenter.getCampaigns();
|
||||||
} else {
|
} else {
|
||||||
campaignView.setVisibility(View.GONE);
|
if (binding!=null) {
|
||||||
|
binding.campaignsView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -629,7 +632,9 @@ public class ContributionsFragment
|
||||||
|
|
||||||
@Override public void showCampaigns(Campaign campaign) {
|
@Override public void showCampaigns(Campaign campaign) {
|
||||||
if (campaign != null && !isUserProfile) {
|
if (campaign != null && !isUserProfile) {
|
||||||
campaignView.setCampaign(campaign);
|
if (binding!=null) {
|
||||||
|
binding.campaignsView.setCampaign(campaign);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -746,11 +751,11 @@ public class ContributionsFragment
|
||||||
public boolean backButtonClicked() {
|
public boolean backButtonClicked() {
|
||||||
if (mediaDetailPagerFragment != null && mediaDetailPagerFragment.isVisible()) {
|
if (mediaDetailPagerFragment != null && mediaDetailPagerFragment.isVisible()) {
|
||||||
if (store.getBoolean("displayNearbyCardView", true) && !isUserProfile) {
|
if (store.getBoolean("displayNearbyCardView", true) && !isUserProfile) {
|
||||||
if (nearbyNotificationCardView.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
|
if (binding.cardViewNearby.cardViewVisibilityState == NearbyNotificationCardView.CardViewVisibilityState.READY) {
|
||||||
nearbyNotificationCardView.setVisibility(View.VISIBLE);
|
binding.cardViewNearby.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nearbyNotificationCardView.setVisibility(View.GONE);
|
binding.cardViewNearby.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
removeFragment(mediaDetailPagerFragment);
|
removeFragment(mediaDetailPagerFragment);
|
||||||
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
showFragment(contributionsListFragment, CONTRIBUTION_LIST_FRAGMENT_TAG, mediaDetailPagerFragment);
|
||||||
|
|
@ -812,7 +817,7 @@ public class ContributionsFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
View view2 = limitedConnectionDescriptionTextView;
|
View view2 = binding.limitedConnectionDescriptionTextView;
|
||||||
if (view2.getVisibility() == View.GONE) {
|
if (view2.getVisibility() == View.GONE) {
|
||||||
view2.setVisibility(View.VISIBLE);
|
view2.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -827,7 +832,7 @@ public class ContributionsFragment
|
||||||
@Override
|
@Override
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
float rotateDegree = Math.round(event.values[0]);
|
float rotateDegree = Math.round(event.values[0]);
|
||||||
nearbyNotificationCardView.rotateCompass(rotateDegree, direction);
|
binding.cardViewNearby.rotateCompass(rotateDegree, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,13 @@ import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import androidx.work.ExistingWorkPolicy;
|
import androidx.work.ExistingWorkPolicy;
|
||||||
import butterknife.BindView;
|
import fr.free.nrw.commons.databinding.MainBinding;
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.WelcomeActivity;
|
import fr.free.nrw.commons.WelcomeActivity;
|
||||||
|
|
@ -63,14 +61,6 @@ public class MainActivity extends BaseActivity
|
||||||
ContributionController controller;
|
ContributionController controller;
|
||||||
@Inject
|
@Inject
|
||||||
ContributionDao contributionDao;
|
ContributionDao contributionDao;
|
||||||
@BindView(R.id.toolbar)
|
|
||||||
Toolbar toolbar;
|
|
||||||
@BindView(R.id.pager)
|
|
||||||
public UnswipableViewPager viewPager;
|
|
||||||
@BindView(R.id.fragmentContainer)
|
|
||||||
public FrameLayout fragmentContainer;
|
|
||||||
@BindView(R.id.fragment_main_nav_tab_layout)
|
|
||||||
NavTabLayout tabLayout;
|
|
||||||
|
|
||||||
private ContributionsFragment contributionsFragment;
|
private ContributionsFragment contributionsFragment;
|
||||||
private NearbyParentFragment nearbyParentFragment;
|
private NearbyParentFragment nearbyParentFragment;
|
||||||
|
|
@ -95,6 +85,11 @@ public class MainActivity extends BaseActivity
|
||||||
|
|
||||||
public Menu menu;
|
public Menu menu;
|
||||||
|
|
||||||
|
public MainBinding binding;
|
||||||
|
|
||||||
|
NavTabLayout tabLayout;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consumers should be simply using this method to use this activity.
|
* Consumers should be simply using this method to use this activity.
|
||||||
*
|
*
|
||||||
|
|
@ -122,11 +117,13 @@ public class MainActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = MainBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
setSupportActionBar(binding.toolbarBinding.toolbar);
|
||||||
|
tabLayout = binding.fragmentMainNavTabLayout;
|
||||||
loadLocale();
|
loadLocale();
|
||||||
setContentView(R.layout.main);
|
|
||||||
ButterKnife.bind(this);
|
binding.toolbarBinding.toolbar.setNavigationOnClickListener(view -> {
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
toolbar.setNavigationOnClickListener(view -> {
|
|
||||||
onSupportNavigateUp();
|
onSupportNavigateUp();
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
|
|
@ -177,11 +174,11 @@ public class MainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedItemId(int id) {
|
public void setSelectedItemId(int id) {
|
||||||
tabLayout.setSelectedItemId(id);
|
binding.fragmentMainNavTabLayout.setSelectedItemId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpPager() {
|
private void setUpPager() {
|
||||||
tabLayout.setOnNavigationItemSelectedListener(navListener = (item) -> {
|
binding.fragmentMainNavTabLayout.setOnNavigationItemSelectedListener(navListener = (item) -> {
|
||||||
if (!item.getTitle().equals(getString(R.string.more))) {
|
if (!item.getTitle().equals(getString(R.string.more))) {
|
||||||
// do not change title for more fragment
|
// do not change title for more fragment
|
||||||
setTitle(item.getTitle());
|
setTitle(item.getTitle());
|
||||||
|
|
@ -196,7 +193,7 @@ public class MainActivity extends BaseActivity
|
||||||
|
|
||||||
private void setUpLoggedOutPager() {
|
private void setUpLoggedOutPager() {
|
||||||
loadFragment(ExploreFragment.newInstance(),false);
|
loadFragment(ExploreFragment.newInstance(),false);
|
||||||
tabLayout.setOnNavigationItemSelectedListener(item -> {
|
binding.fragmentMainNavTabLayout.setOnNavigationItemSelectedListener(item -> {
|
||||||
if (!item.getTitle().equals(getString(R.string.more))) {
|
if (!item.getTitle().equals(getString(R.string.more))) {
|
||||||
// do not change title for more fragment
|
// do not change title for more fragment
|
||||||
setTitle(item.getTitle());
|
setTitle(item.getTitle());
|
||||||
|
|
@ -258,11 +255,11 @@ public class MainActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideTabs() {
|
public void hideTabs() {
|
||||||
tabLayout.setVisibility(View.GONE);
|
binding.fragmentMainNavTabLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTabs() {
|
public void showTabs() {
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.fragmentMainNavTabLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -317,7 +314,7 @@ public class MainActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putInt("viewPagerCurrentItem", viewPager.getCurrentItem());
|
outState.putInt("viewPagerCurrentItem", binding.pager.getCurrentItem());
|
||||||
outState.putString("activeFragment", activeFragment.name());
|
outState.putString("activeFragment", activeFragment.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -472,7 +469,7 @@ public class MainActivity extends BaseActivity
|
||||||
* Public method to show nearby from the reference of this.
|
* Public method to show nearby from the reference of this.
|
||||||
*/
|
*/
|
||||||
public void showNearby() {
|
public void showNearby() {
|
||||||
tabLayout.setSelectedItemId(NavTab.NEARBY.code());
|
binding.fragmentMainNavTabLayout.setSelectedItemId(NavTab.NEARBY.code());
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ActiveFragment {
|
public enum ActiveFragment {
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ class ImageAdapter(
|
||||||
* Bind View holder, load image, selected view, click listeners.
|
* Bind View holder, load image, selected view, click listeners.
|
||||||
*/
|
*/
|
||||||
override fun onBindViewHolder(holder: ImageViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ImageViewHolder, position: Int) {
|
||||||
|
|
||||||
var image=images[position]
|
var image=images[position]
|
||||||
holder.image.setImageDrawable (null)
|
holder.image.setImageDrawable (null)
|
||||||
if (context.contentResolver.getType(image.uri) == null) {
|
if (context.contentResolver.getType(image.uri) == null) {
|
||||||
|
|
@ -174,9 +175,11 @@ class ImageAdapter(
|
||||||
// inside map, so it will fetch the image from the map and load in the holder
|
// inside map, so it will fetch the image from the map and load in the holder
|
||||||
} else {
|
} else {
|
||||||
val actionableImages: List<Image> = ArrayList(actionableImagesMap.values)
|
val actionableImages: List<Image> = ArrayList(actionableImagesMap.values)
|
||||||
image = actionableImages[position]
|
if(actionableImages.size > position) {
|
||||||
Glide.with(holder.image).load(image.uri)
|
image = actionableImages[position]
|
||||||
.thumbnail(0.3f).into(holder.image)
|
Glide.with(holder.image).load(image.uri)
|
||||||
|
.thumbnail(0.3f).into(holder.image)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If switch is turned off, it just fetches the image from all images without any
|
// If switch is turned off, it just fetches the image from all images without any
|
||||||
|
|
@ -364,6 +367,48 @@ class ImageAdapter(
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear selected images and empty the list.
|
||||||
|
*/
|
||||||
|
fun clearSelectedImages(){
|
||||||
|
numberOfSelectedImagesMarkedAsNotForUpload = 0
|
||||||
|
selectedImages.clear()
|
||||||
|
selectedImages = arrayListOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove image from actionable images map.
|
||||||
|
*/
|
||||||
|
fun removeImageFromActionableImageMap(image: Image) {
|
||||||
|
val sharedPreferences: SharedPreferences =
|
||||||
|
context.getSharedPreferences(CUSTOM_SELECTOR_PREFERENCE_KEY, 0)
|
||||||
|
val showAlreadyActionedImages =
|
||||||
|
sharedPreferences.getBoolean(SHOW_ALREADY_ACTIONED_IMAGES_PREFERENCE_KEY, true)
|
||||||
|
|
||||||
|
if(showAlreadyActionedImages) {
|
||||||
|
refresh(allImages, allImages)
|
||||||
|
} else {
|
||||||
|
val iterator = actionableImagesMap.entries.iterator()
|
||||||
|
var index = 0
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
val entry = iterator.next()
|
||||||
|
if (entry.value == image) {
|
||||||
|
imagePositionAsPerIncreasingOrder -= 2
|
||||||
|
iterator.remove()
|
||||||
|
alreadyAddedPositions.removeAt(alreadyAddedPositions.size - 1)
|
||||||
|
notifyItemRemoved(index)
|
||||||
|
notifyItemRangeChanged(index, itemCount )
|
||||||
|
break
|
||||||
|
}
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total number of items in the data set held by the adapter.
|
* Returns the total number of items in the data set held by the adapter.
|
||||||
*
|
*
|
||||||
|
|
@ -511,4 +556,4 @@ class ImageAdapter(
|
||||||
return images[position].date
|
return images[position].date
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,8 +276,10 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
imageSHA1
|
imageSHA1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
imageFragment!!.removeImage(it)
|
||||||
|
|
||||||
|
}
|
||||||
|
imageFragment!!.clearSelectedImages()
|
||||||
// if all images is already marked as not for upload, delete all images from
|
// if all images is already marked as not for upload, delete all images from
|
||||||
// not for upload table
|
// not for upload table
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -290,9 +292,9 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
)
|
)
|
||||||
notForUploadStatusDao.deleteNotForUploadWithImageSHA1(imageSHA1)
|
notForUploadStatusDao.deleteNotForUploadWithImageSHA1(imageSHA1)
|
||||||
}
|
}
|
||||||
|
imageFragment!!.refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
imageFragment!!.refresh()
|
|
||||||
imageFragment!!.dismissMarkUnmarkProgressDialog()
|
imageFragment!!.dismissMarkUnmarkProgressDialog()
|
||||||
|
|
||||||
val bottomLayout: ConstraintLayout = findViewById(R.id.bottom_layout)
|
val bottomLayout: ConstraintLayout = findViewById(R.id.bottom_layout)
|
||||||
|
|
@ -497,4 +499,4 @@ class CustomSelectorActivity : BaseActivity(), FolderClickListener, ImageSelectL
|
||||||
const val FOLDER_NAME: String = "FolderName"
|
const val FOLDER_NAME: String = "FolderName"
|
||||||
const val ITEM_ID: String = "ItemId"
|
const val ITEM_ID: String = "ItemId"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,19 @@ class ImageFragment : CommonsDaggerSupportFragment(), RefreshUIListener, PassDat
|
||||||
imageAdapter.refresh(filteredImages, allImages)
|
imageAdapter.refresh(filteredImages, allImages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the image from the actionable image map
|
||||||
|
*/
|
||||||
|
fun removeImage(image : Image){
|
||||||
|
imageAdapter.removeImageFromActionableImageMap(image)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the selected images
|
||||||
|
*/
|
||||||
|
fun clearSelectedImages() {
|
||||||
|
imageAdapter.clearSelectedImages()
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Passes selected images and other information from Activity to Fragment and connects it with
|
* Passes selected images and other information from Activity to Fragment and connects it with
|
||||||
* the adapter
|
* the adapter
|
||||||
|
|
@ -371,4 +384,4 @@ class ImageFragment : CommonsDaggerSupportFragment(), RefreshUIListener, PassDat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,11 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
|
import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter;
|
import fr.free.nrw.commons.ViewPagerAdapter;
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentExploreBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
|
|
@ -33,10 +32,8 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
private static final String EXPLORE_MAP = "Map";
|
private static final String EXPLORE_MAP = "Map";
|
||||||
private static final String MEDIA_DETAILS_FRAGMENT_TAG = "MediaDetailsFragment";
|
private static final String MEDIA_DETAILS_FRAGMENT_TAG = "MediaDetailsFragment";
|
||||||
|
|
||||||
@BindView(R.id.tab_layout)
|
|
||||||
TabLayout tabLayout;
|
public FragmentExploreBinding binding;
|
||||||
@BindView(R.id.viewPager)
|
|
||||||
ParentViewPager viewPager;
|
|
||||||
ViewPagerAdapter viewPagerAdapter;
|
ViewPagerAdapter viewPagerAdapter;
|
||||||
private ExploreListRootFragment featuredRootFragment;
|
private ExploreListRootFragment featuredRootFragment;
|
||||||
private ExploreListRootFragment mobileRootFragment;
|
private ExploreListRootFragment mobileRootFragment;
|
||||||
|
|
@ -46,7 +43,10 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
public JsonKvStore applicationKvStore;
|
public JsonKvStore applicationKvStore;
|
||||||
|
|
||||||
public void setScroll(boolean canScroll){
|
public void setScroll(boolean canScroll){
|
||||||
viewPager.setCanScroll(canScroll);
|
if (binding != null)
|
||||||
|
{
|
||||||
|
binding.viewPager.setCanScroll(canScroll);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
@ -56,22 +56,17 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_explore, container, false);
|
binding = FragmentExploreBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
|
viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
|
||||||
viewPager.setAdapter(viewPagerAdapter);
|
binding.viewPager.setAdapter(viewPagerAdapter);
|
||||||
viewPager.setId(R.id.viewPager);
|
binding.viewPager.setId(R.id.viewPager);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
||||||
viewPager.addOnPageChangeListener(new OnPageChangeListener() {
|
binding.viewPager.addOnPageChangeListener(new OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset,
|
public void onPageScrolled(int position, float positionOffset,
|
||||||
int positionOffsetPixels) {
|
int positionOffsetPixels) {
|
||||||
|
|
@ -81,9 +76,9 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
if (position == 2) {
|
if (position == 2) {
|
||||||
viewPager.setCanScroll(false);
|
binding.viewPager.setCanScroll(false);
|
||||||
} else {
|
} else {
|
||||||
viewPager.setCanScroll(true);
|
binding.viewPager.setCanScroll(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +89,7 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
});
|
});
|
||||||
setTabs();
|
setTabs();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
return view;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -133,13 +128,13 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
if (tabLayout.getSelectedTabPosition() == 0) {
|
if (binding.tabLayout.getSelectedTabPosition() == 0) {
|
||||||
if (featuredRootFragment.backPressed()) {
|
if (featuredRootFragment.backPressed()) {
|
||||||
((BaseActivity) getActivity()).getSupportActionBar()
|
((BaseActivity) getActivity()).getSupportActionBar()
|
||||||
.setDisplayHomeAsUpEnabled(false);
|
.setDisplayHomeAsUpEnabled(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (tabLayout.getSelectedTabPosition() == 1) { //Mobile root fragment
|
} else if (binding.tabLayout.getSelectedTabPosition() == 1) { //Mobile root fragment
|
||||||
if (mobileRootFragment.backPressed()) {
|
if (mobileRootFragment.backPressed()) {
|
||||||
((BaseActivity) getActivity()).getSupportActionBar()
|
((BaseActivity) getActivity()).getSupportActionBar()
|
||||||
.setDisplayHomeAsUpEnabled(false);
|
.setDisplayHomeAsUpEnabled(false);
|
||||||
|
|
@ -180,6 +175,12 @@ public class ExploreFragment extends CommonsDaggerSupportFragment {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,11 @@ import android.widget.FrameLayout;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentFeaturedRootBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment;
|
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment;
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
||||||
|
|
@ -26,8 +25,7 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
private MediaDetailPagerFragment mediaDetails;
|
private MediaDetailPagerFragment mediaDetails;
|
||||||
private CategoriesMediaFragment listFragment;
|
private CategoriesMediaFragment listFragment;
|
||||||
|
|
||||||
@BindView(R.id.explore_container)
|
private FragmentFeaturedRootBinding binding;
|
||||||
FrameLayout container;
|
|
||||||
|
|
||||||
public ExploreListRootFragment() {
|
public ExploreListRootFragment() {
|
||||||
//empty constructor necessary otherwise crashes on recreate
|
//empty constructor necessary otherwise crashes on recreate
|
||||||
|
|
@ -47,9 +45,9 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
@Nullable final ViewGroup container,
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
|
||||||
ButterKnife.bind(this, view);
|
binding = FragmentFeaturedRootBinding.inflate(inflater, container, false);
|
||||||
return view;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -109,8 +107,12 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int position) {
|
public void onMediaClicked(int position) {
|
||||||
container.setVisibility(View.VISIBLE);
|
if (binding!=null) {
|
||||||
((ExploreFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
|
binding.exploreContainer.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
if (((ExploreFragment) getParentFragment()).binding!=null) {
|
||||||
|
((ExploreFragment) getParentFragment()).binding.tabLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
||||||
((ExploreFragment) getParentFragment()).setScroll(false);
|
((ExploreFragment) getParentFragment()).setScroll(false);
|
||||||
setFragment(mediaDetails, listFragment);
|
setFragment(mediaDetails, listFragment);
|
||||||
|
|
@ -185,16 +187,29 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
||||||
*/
|
*/
|
||||||
public boolean backPressed() {
|
public boolean backPressed() {
|
||||||
if (null != mediaDetails && mediaDetails.isVisible()) {
|
if (null != mediaDetails && mediaDetails.isVisible()) {
|
||||||
((ExploreFragment) getParentFragment()).tabLayout.setVisibility(View.VISIBLE);
|
if (((ExploreFragment) getParentFragment()).binding != null) {
|
||||||
|
((ExploreFragment) getParentFragment()).binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
removeFragment(mediaDetails);
|
removeFragment(mediaDetails);
|
||||||
((ExploreFragment) getParentFragment()).setScroll(true);
|
((ExploreFragment) getParentFragment()).setScroll(true);
|
||||||
setFragment(listFragment, mediaDetails);
|
setFragment(listFragment, mediaDetails);
|
||||||
((MainActivity) getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
((MainActivity) getActivity()).setSelectedItemId(NavTab.CONTRIBUTIONS.code());
|
if (((MainActivity) getActivity()) != null) {
|
||||||
|
((MainActivity) getActivity()).setSelectedItemId(NavTab.CONTRIBUTIONS.code());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (((MainActivity) getActivity()) != null) {
|
||||||
|
((MainActivity) getActivity()).showTabs();
|
||||||
}
|
}
|
||||||
((MainActivity) getActivity()).showTabs();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,11 @@ import android.widget.FrameLayout;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentFeaturedRootBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.explore.map.ExploreMapFragment;
|
import fr.free.nrw.commons.explore.map.ExploreMapFragment;
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
||||||
|
|
@ -26,8 +25,7 @@ public class ExploreMapRootFragment extends CommonsDaggerSupportFragment impleme
|
||||||
private MediaDetailPagerFragment mediaDetails;
|
private MediaDetailPagerFragment mediaDetails;
|
||||||
private ExploreMapFragment mapFragment;
|
private ExploreMapFragment mapFragment;
|
||||||
|
|
||||||
@BindView(R.id.explore_container)
|
private FragmentFeaturedRootBinding binding;
|
||||||
FrameLayout container;
|
|
||||||
|
|
||||||
public ExploreMapRootFragment() {
|
public ExploreMapRootFragment() {
|
||||||
//empty constructor necessary otherwise crashes on recreate
|
//empty constructor necessary otherwise crashes on recreate
|
||||||
|
|
@ -54,9 +52,10 @@ public class ExploreMapRootFragment extends CommonsDaggerSupportFragment impleme
|
||||||
@Nullable final ViewGroup container,
|
@Nullable final ViewGroup container,
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
View view = inflater.inflate(R.layout.fragment_featured_root, container, false);
|
|
||||||
ButterKnife.bind(this, view);
|
binding = FragmentFeaturedRootBinding.inflate(inflater, container, false);
|
||||||
return view;
|
|
||||||
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -116,8 +115,8 @@ public class ExploreMapRootFragment extends CommonsDaggerSupportFragment impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int position) {
|
public void onMediaClicked(int position) {
|
||||||
container.setVisibility(View.VISIBLE);
|
binding.exploreContainer.setVisibility(View.VISIBLE);
|
||||||
((ExploreFragment) getParentFragment()).tabLayout.setVisibility(View.GONE);
|
((ExploreFragment) getParentFragment()).binding.tabLayout.setVisibility(View.GONE);
|
||||||
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
||||||
((ExploreFragment) getParentFragment()).setScroll(false);
|
((ExploreFragment) getParentFragment()).setScroll(false);
|
||||||
setFragment(mediaDetails, mapFragment);
|
setFragment(mediaDetails, mapFragment);
|
||||||
|
|
@ -192,7 +191,7 @@ public class ExploreMapRootFragment extends CommonsDaggerSupportFragment impleme
|
||||||
*/
|
*/
|
||||||
public boolean backPressed() {
|
public boolean backPressed() {
|
||||||
if (null != mediaDetails && mediaDetails.isVisible()) {
|
if (null != mediaDetails && mediaDetails.isVisible()) {
|
||||||
((ExploreFragment) getParentFragment()).tabLayout.setVisibility(View.VISIBLE);
|
((ExploreFragment) getParentFragment()).binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
removeFragment(mediaDetails);
|
removeFragment(mediaDetails);
|
||||||
((ExploreFragment) getParentFragment()).setScroll(true);
|
((ExploreFragment) getParentFragment()).setScroll(true);
|
||||||
setFragment(mapFragment, mediaDetails);
|
setFragment(mapFragment, mediaDetails);
|
||||||
|
|
@ -213,4 +212,11 @@ public class ExploreMapRootFragment extends CommonsDaggerSupportFragment impleme
|
||||||
((MainActivity) getActivity()).showTabs();
|
((MainActivity) getActivity()).showTabs();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,17 @@ package fr.free.nrw.commons.explore;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.SearchView;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
|
||||||
import com.jakewharton.rxbinding2.view.RxView;
|
import com.jakewharton.rxbinding2.view.RxView;
|
||||||
import com.jakewharton.rxbinding2.widget.RxSearchView;
|
import com.jakewharton.rxbinding2.widget.RxSearchView;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter;
|
import fr.free.nrw.commons.ViewPagerAdapter;
|
||||||
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
||||||
|
import fr.free.nrw.commons.databinding.ActivitySearchBinding;
|
||||||
import fr.free.nrw.commons.explore.categories.search.SearchCategoryFragment;
|
import fr.free.nrw.commons.explore.categories.search.SearchCategoryFragment;
|
||||||
import fr.free.nrw.commons.explore.depictions.search.SearchDepictionsFragment;
|
import fr.free.nrw.commons.explore.depictions.search.SearchDepictionsFragment;
|
||||||
import fr.free.nrw.commons.explore.media.SearchMediaFragment;
|
import fr.free.nrw.commons.explore.media.SearchMediaFragment;
|
||||||
|
|
@ -45,13 +39,6 @@ import timber.log.Timber;
|
||||||
public class SearchActivity extends BaseActivity
|
public class SearchActivity extends BaseActivity
|
||||||
implements MediaDetailPagerFragment.MediaDetailProvider, CategoryImagesCallback {
|
implements MediaDetailPagerFragment.MediaDetailProvider, CategoryImagesCallback {
|
||||||
|
|
||||||
@BindView(R.id.toolbar_search) Toolbar toolbar;
|
|
||||||
@BindView(R.id.searchHistoryContainer) FrameLayout searchHistoryContainer;
|
|
||||||
@BindView(R.id.mediaContainer) FrameLayout mediaContainer;
|
|
||||||
@BindView(R.id.searchBox) SearchView searchView;
|
|
||||||
@BindView(R.id.tab_layout) TabLayout tabLayout;
|
|
||||||
@BindView(R.id.viewPager) ViewPager viewPager;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RecentSearchesDao recentSearchesDao;
|
RecentSearchesDao recentSearchesDao;
|
||||||
|
|
||||||
|
|
@ -63,25 +50,28 @@ public class SearchActivity extends BaseActivity
|
||||||
private MediaDetailPagerFragment mediaDetails;
|
private MediaDetailPagerFragment mediaDetails;
|
||||||
ViewPagerAdapter viewPagerAdapter;
|
ViewPagerAdapter viewPagerAdapter;
|
||||||
|
|
||||||
|
private ActivitySearchBinding binding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_search);
|
binding = ActivitySearchBinding.inflate(getLayoutInflater());
|
||||||
ButterKnife.bind(this);
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
setTitle(getString(R.string.title_activity_search));
|
setTitle(getString(R.string.title_activity_search));
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(binding.toolbarSearch);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
toolbar.setNavigationOnClickListener(v->onBackPressed());
|
binding.toolbarSearch.setNavigationOnClickListener(v->onBackPressed());
|
||||||
supportFragmentManager = getSupportFragmentManager();
|
supportFragmentManager = getSupportFragmentManager();
|
||||||
setSearchHistoryFragment();
|
setSearchHistoryFragment();
|
||||||
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(viewPagerAdapter);
|
binding.viewPager.setAdapter(viewPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(2); // Because we want all the fragments to be alive
|
binding.viewPager.setOffscreenPageLimit(2); // Because we want all the fragments to be alive
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
||||||
setTabs();
|
setTabs();
|
||||||
searchView.setQueryHint(getString(R.string.search_commons));
|
binding.searchBox.setQueryHint(getString(R.string.search_commons));
|
||||||
searchView.onActionViewExpanded();
|
binding.searchBox.onActionViewExpanded();
|
||||||
searchView.clearFocus();
|
binding.searchBox.clearFocus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,8 +103,8 @@ public class SearchActivity extends BaseActivity
|
||||||
|
|
||||||
viewPagerAdapter.setTabData(fragmentList, titleList);
|
viewPagerAdapter.setTabData(fragmentList, titleList);
|
||||||
viewPagerAdapter.notifyDataSetChanged();
|
viewPagerAdapter.notifyDataSetChanged();
|
||||||
compositeDisposable.add(RxSearchView.queryTextChanges(searchView)
|
compositeDisposable.add(RxSearchView.queryTextChanges(binding.searchBox)
|
||||||
.takeUntil(RxView.detaches(searchView))
|
.takeUntil(RxView.detaches(binding.searchBox))
|
||||||
.debounce(500, TimeUnit.MILLISECONDS)
|
.debounce(500, TimeUnit.MILLISECONDS)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::handleSearch, Timber::e
|
.subscribe(this::handleSearch, Timber::e
|
||||||
|
|
@ -124,9 +114,9 @@ public class SearchActivity extends BaseActivity
|
||||||
private void handleSearch(final CharSequence query) {
|
private void handleSearch(final CharSequence query) {
|
||||||
if (!TextUtils.isEmpty(query)) {
|
if (!TextUtils.isEmpty(query)) {
|
||||||
saveRecentSearch(query.toString());
|
saveRecentSearch(query.toString());
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
binding.viewPager.setVisibility(View.VISIBLE);
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
searchHistoryContainer.setVisibility(View.GONE);
|
binding.searchHistoryContainer.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (FragmentUtils.isFragmentUIActive(searchDepictionsFragment)) {
|
if (FragmentUtils.isFragmentUIActive(searchDepictionsFragment)) {
|
||||||
searchDepictionsFragment.onQueryUpdated(query.toString());
|
searchDepictionsFragment.onQueryUpdated(query.toString());
|
||||||
|
|
@ -144,10 +134,10 @@ public class SearchActivity extends BaseActivity
|
||||||
else {
|
else {
|
||||||
//Open RecentSearchesFragment
|
//Open RecentSearchesFragment
|
||||||
recentSearchesFragment.updateRecentSearches();
|
recentSearchesFragment.updateRecentSearches();
|
||||||
viewPager.setVisibility(View.GONE);
|
binding.viewPager.setVisibility(View.GONE);
|
||||||
tabLayout.setVisibility(View.GONE);
|
binding.tabLayout.setVisibility(View.GONE);
|
||||||
setSearchHistoryFragment();
|
setSearchHistoryFragment();
|
||||||
searchHistoryContainer.setVisibility(View.VISIBLE);
|
binding.searchHistoryContainer.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,10 +205,10 @@ public class SearchActivity extends BaseActivity
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int index) {
|
public void onMediaClicked(int index) {
|
||||||
ViewUtil.hideKeyboard(this.findViewById(R.id.searchBox));
|
ViewUtil.hideKeyboard(this.findViewById(R.id.searchBox));
|
||||||
tabLayout.setVisibility(View.GONE);
|
binding.tabLayout.setVisibility(View.GONE);
|
||||||
viewPager.setVisibility(View.GONE);
|
binding.viewPager.setVisibility(View.GONE);
|
||||||
mediaContainer.setVisibility(View.VISIBLE);
|
binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||||
searchView.setVisibility(View.GONE);// to remove searchview when mediaDetails fragment open
|
binding.searchBox.setVisibility(View.GONE);// to remove searchview when mediaDetails fragment open
|
||||||
if (mediaDetails == null || !mediaDetails.isVisible()) {
|
if (mediaDetails == null || !mediaDetails.isVisible()) {
|
||||||
// set isFeaturedImage true for featured images, to include author field on media detail
|
// set isFeaturedImage true for featured images, to include author field on media detail
|
||||||
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
mediaDetails = MediaDetailPagerFragment.newInstance(false, true);
|
||||||
|
|
@ -269,12 +259,12 @@ public class SearchActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
|
if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
|
||||||
// back to search so show search toolbar and hide navigation toolbar
|
// back to search so show search toolbar and hide navigation toolbar
|
||||||
searchView.setVisibility(View.VISIBLE);//set the searchview
|
binding.searchBox.setVisibility(View.VISIBLE);//set the searchview
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
binding.viewPager.setVisibility(View.VISIBLE);
|
||||||
mediaContainer.setVisibility(View.GONE);
|
binding.mediaContainer.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
toolbar.setVisibility(View.GONE);
|
binding.toolbarSearch.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
@ -284,15 +274,16 @@ public class SearchActivity extends BaseActivity
|
||||||
* @param query Recent Search Query
|
* @param query Recent Search Query
|
||||||
*/
|
*/
|
||||||
public void updateText(String query) {
|
public void updateText(String query) {
|
||||||
searchView.setQuery(query, true);
|
binding.searchBox.setQuery(query, true);
|
||||||
// Clear focus of searchView now. searchView.clearFocus(); does not seem to work Check the below link for more details.
|
// Clear focus of searchView now. searchView.clearFocus(); does not seem to work Check the below link for more details.
|
||||||
// https://stackoverflow.com/questions/6117967/how-to-remove-focus-without-setting-focus-to-another-control/15481511
|
// https://stackoverflow.com/questions/6117967/how-to-remove-focus-without-setting-focus-to-another-control/15481511
|
||||||
viewPager.requestFocus();
|
binding.viewPager.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void onDestroy() {
|
@Override protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
//Dispose the disposables when the activity is destroyed
|
//Dispose the disposables when the activity is destroyed
|
||||||
compositeDisposable.dispose();
|
compositeDisposable.dispose();
|
||||||
|
binding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
|
|
@ -23,6 +21,7 @@ import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter;
|
import fr.free.nrw.commons.ViewPagerAdapter;
|
||||||
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao;
|
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao;
|
||||||
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
import fr.free.nrw.commons.category.CategoryImagesCallback;
|
||||||
|
import fr.free.nrw.commons.databinding.ActivityWikidataItemDetailsBinding;
|
||||||
import fr.free.nrw.commons.explore.depictions.child.ChildDepictionsFragment;
|
import fr.free.nrw.commons.explore.depictions.child.ChildDepictionsFragment;
|
||||||
import fr.free.nrw.commons.explore.depictions.media.DepictedImagesFragment;
|
import fr.free.nrw.commons.explore.depictions.media.DepictedImagesFragment;
|
||||||
import fr.free.nrw.commons.explore.depictions.parent.ParentDepictionsFragment;
|
import fr.free.nrw.commons.explore.depictions.parent.ParentDepictionsFragment;
|
||||||
|
|
@ -57,14 +56,7 @@ public class WikidataItemDetailsActivity extends BaseActivity implements MediaDe
|
||||||
@Inject
|
@Inject
|
||||||
DepictModel depictModel;
|
DepictModel depictModel;
|
||||||
private String wikidataItemName;
|
private String wikidataItemName;
|
||||||
@BindView(R.id.mediaContainer)
|
private ActivityWikidataItemDetailsBinding binding;
|
||||||
FrameLayout mediaContainer;
|
|
||||||
@BindView(R.id.tab_layout)
|
|
||||||
TabLayout tabLayout;
|
|
||||||
@BindView(R.id.viewPager)
|
|
||||||
ViewPager viewPager;
|
|
||||||
@BindView(R.id.toolbar)
|
|
||||||
Toolbar toolbar;
|
|
||||||
|
|
||||||
ViewPagerAdapter viewPagerAdapter;
|
ViewPagerAdapter viewPagerAdapter;
|
||||||
private DepictedItem wikidataItem;
|
private DepictedItem wikidataItem;
|
||||||
|
|
@ -72,19 +64,20 @@ public class WikidataItemDetailsActivity extends BaseActivity implements MediaDe
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_wikidata_item_details);
|
|
||||||
ButterKnife.bind(this);
|
binding = ActivityWikidataItemDetailsBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
compositeDisposable = new CompositeDisposable();
|
compositeDisposable = new CompositeDisposable();
|
||||||
supportFragmentManager = getSupportFragmentManager();
|
supportFragmentManager = getSupportFragmentManager();
|
||||||
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(viewPagerAdapter);
|
binding.viewPager.setAdapter(viewPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(2);
|
binding.viewPager.setOffscreenPageLimit(2);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
||||||
|
|
||||||
final DepictedItem depictedItem = getIntent().getParcelableExtra(
|
final DepictedItem depictedItem = getIntent().getParcelableExtra(
|
||||||
WikidataConstants.BOOKMARKS_ITEMS);
|
WikidataConstants.BOOKMARKS_ITEMS);
|
||||||
wikidataItem = depictedItem;
|
wikidataItem = depictedItem;
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(binding.toolbarBinding.toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
setTabs();
|
setTabs();
|
||||||
setPageTitle();
|
setPageTitle();
|
||||||
|
|
@ -137,7 +130,7 @@ public class WikidataItemDetailsActivity extends BaseActivity implements MediaDe
|
||||||
fragmentList.add(parentDepictionsFragment);
|
fragmentList.add(parentDepictionsFragment);
|
||||||
titleList.add(getResources().getString(R.string.title_for_parent_classes));
|
titleList.add(getResources().getString(R.string.title_for_parent_classes));
|
||||||
viewPagerAdapter.setTabData(fragmentList, titleList);
|
viewPagerAdapter.setTabData(fragmentList, titleList);
|
||||||
viewPager.setOffscreenPageLimit(2);
|
binding.viewPager.setOffscreenPageLimit(2);
|
||||||
viewPagerAdapter.notifyDataSetChanged();
|
viewPagerAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -148,9 +141,9 @@ public class WikidataItemDetailsActivity extends BaseActivity implements MediaDe
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onMediaClicked(int position) {
|
public void onMediaClicked(int position) {
|
||||||
tabLayout.setVisibility(View.GONE);
|
binding.tabLayout.setVisibility(View.GONE);
|
||||||
viewPager.setVisibility(View.GONE);
|
binding.viewPager.setVisibility(View.GONE);
|
||||||
mediaContainer.setVisibility(View.VISIBLE);
|
binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||||
if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
|
if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
|
||||||
// set isFeaturedImage true for featured images, to include author field on media detail
|
// set isFeaturedImage true for featured images, to include author field on media detail
|
||||||
mediaDetailPagerFragment = MediaDetailPagerFragment.newInstance(false, true);
|
mediaDetailPagerFragment = MediaDetailPagerFragment.newInstance(false, true);
|
||||||
|
|
@ -183,9 +176,9 @@ public class WikidataItemDetailsActivity extends BaseActivity implements MediaDe
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (supportFragmentManager.getBackStackEntryCount() == 1){
|
if (supportFragmentManager.getBackStackEntryCount() == 1){
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
viewPager.setVisibility(View.VISIBLE);
|
binding.viewPager.setVisibility(View.VISIBLE);
|
||||||
mediaContainer.setVisibility(View.GONE);
|
binding.mediaContainer.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.activity.result.ActivityResultCallback;
|
import androidx.activity.result.ActivityResultCallback;
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
|
@ -39,8 +35,6 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
import androidx.appcompat.widget.AppCompatTextView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
@ -50,6 +44,7 @@ import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentExploreMapBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.explore.ExploreMapRootFragment;
|
import fr.free.nrw.commons.explore.ExploreMapRootFragment;
|
||||||
import fr.free.nrw.commons.explore.paging.LiveDataConverter;
|
import fr.free.nrw.commons.explore.paging.LiveDataConverter;
|
||||||
|
|
@ -130,31 +125,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
private ExploreMapPresenter presenter;
|
private ExploreMapPresenter presenter;
|
||||||
|
|
||||||
@BindView(R.id.map_view)
|
public FragmentExploreMapBinding binding;
|
||||||
org.osmdroid.views.MapView mapView;
|
|
||||||
@BindView(R.id.bottom_sheet_details)
|
|
||||||
View bottomSheetDetails;
|
|
||||||
@BindView(R.id.map_progress_bar)
|
|
||||||
ProgressBar progressBar;
|
|
||||||
@BindView(R.id.fab_recenter)
|
|
||||||
FloatingActionButton fabRecenter;
|
|
||||||
@BindView(R.id.search_this_area_button)
|
|
||||||
Button searchThisAreaButton;
|
|
||||||
@BindView(R.id.tv_attribution)
|
|
||||||
AppCompatTextView tvAttribution;
|
|
||||||
|
|
||||||
@BindView(R.id.directionsButton)
|
|
||||||
LinearLayout directionsButton;
|
|
||||||
@BindView(R.id.commonsButton)
|
|
||||||
LinearLayout commonsButton;
|
|
||||||
@BindView(R.id.mediaDetailsButton)
|
|
||||||
LinearLayout mediaDetailsButton;
|
|
||||||
@BindView(R.id.description)
|
|
||||||
TextView description;
|
|
||||||
@BindView(R.id.title)
|
|
||||||
TextView title;
|
|
||||||
@BindView(R.id.category)
|
|
||||||
TextView distance;
|
|
||||||
|
|
||||||
private ActivityResultLauncher<String[]> activityResultLauncher = registerForActivityResult(
|
private ActivityResultLauncher<String[]> activityResultLauncher = registerForActivityResult(
|
||||||
new ActivityResultContracts.RequestMultiplePermissions(),
|
new ActivityResultContracts.RequestMultiplePermissions(),
|
||||||
|
|
@ -200,27 +171,21 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
@NonNull LayoutInflater inflater,
|
@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container,
|
ViewGroup container,
|
||||||
Bundle savedInstanceState
|
Bundle savedInstanceState
|
||||||
) {
|
) {
|
||||||
View v = inflater.inflate(R.layout.fragment_explore_map, container, false);
|
binding = FragmentExploreMapBinding.inflate(getLayoutInflater());
|
||||||
ButterKnife.bind(this, v);
|
return binding.getRoot();
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
setSearchThisAreaButtonVisibility(false);
|
setSearchThisAreaButtonVisibility(false);
|
||||||
tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution)));
|
binding.tvAttribution.setText(Html.fromHtml(getString(R.string.map_attribution)));
|
||||||
initNetworkBroadCastReceiver();
|
initNetworkBroadCastReceiver();
|
||||||
|
|
||||||
if (presenter == null) {
|
if (presenter == null) {
|
||||||
|
|
@ -238,32 +203,32 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
org.osmdroid.config.Configuration.getInstance().load(this.getContext(),
|
org.osmdroid.config.Configuration.getInstance().load(this.getContext(),
|
||||||
PreferenceManager.getDefaultSharedPreferences(this.getContext()));
|
PreferenceManager.getDefaultSharedPreferences(this.getContext()));
|
||||||
|
|
||||||
mapView.setTileSource(TileSourceFactory.WIKIMEDIA);
|
binding.mapView.setTileSource(TileSourceFactory.WIKIMEDIA);
|
||||||
mapView.setTilesScaledToDpi(true);
|
binding.mapView.setTilesScaledToDpi(true);
|
||||||
|
|
||||||
org.osmdroid.config.Configuration.getInstance().getAdditionalHttpRequestProperties().put(
|
org.osmdroid.config.Configuration.getInstance().getAdditionalHttpRequestProperties().put(
|
||||||
"Referer", "http://maps.wikimedia.org/"
|
"Referer", "http://maps.wikimedia.org/"
|
||||||
);
|
);
|
||||||
|
|
||||||
ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(mapView);
|
ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(binding.mapView);
|
||||||
scaleBarOverlay.setScaleBarOffset(15, 25);
|
scaleBarOverlay.setScaleBarOffset(15, 25);
|
||||||
Paint barPaint = new Paint();
|
Paint barPaint = new Paint();
|
||||||
barPaint.setARGB(200, 255, 250, 250);
|
barPaint.setARGB(200, 255, 250, 250);
|
||||||
scaleBarOverlay.setBackgroundPaint(barPaint);
|
scaleBarOverlay.setBackgroundPaint(barPaint);
|
||||||
scaleBarOverlay.enableScaleBar();
|
scaleBarOverlay.enableScaleBar();
|
||||||
mapView.getOverlays().add(scaleBarOverlay);
|
binding.mapView.getOverlays().add(scaleBarOverlay);
|
||||||
mapView.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
binding.mapView.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER);
|
||||||
mapView.setMultiTouchControls(true);
|
binding.mapView.setMultiTouchControls(true);
|
||||||
mapView.getController().setZoom(ZOOM_LEVEL);
|
binding.mapView.getController().setZoom(ZOOM_LEVEL);
|
||||||
performMapReadyActions();
|
performMapReadyActions();
|
||||||
|
|
||||||
mapView.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
|
binding.mapView.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public boolean singleTapConfirmedHelper(GeoPoint p) {
|
public boolean singleTapConfirmedHelper(GeoPoint p) {
|
||||||
if (clickedMarker != null) {
|
if (clickedMarker != null) {
|
||||||
removeMarker(clickedMarker);
|
removeMarker(clickedMarker);
|
||||||
addMarkerToMap(clickedMarker);
|
addMarkerToMap(clickedMarker);
|
||||||
mapView.invalidate();
|
binding.mapView.invalidate();
|
||||||
} else {
|
} else {
|
||||||
Timber.e("CLICKED MARKER IS NULL");
|
Timber.e("CLICKED MARKER IS NULL");
|
||||||
}
|
}
|
||||||
|
|
@ -282,14 +247,14 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
mapView.addMapListener(new MapListener() {
|
binding.mapView.addMapListener(new MapListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onScroll(ScrollEvent event) {
|
public boolean onScroll(ScrollEvent event) {
|
||||||
if (getLastMapFocus() != null) {
|
if (getLastMapFocus() != null) {
|
||||||
Location mylocation = new Location("");
|
Location mylocation = new Location("");
|
||||||
Location dest_location = new Location("");
|
Location dest_location = new Location("");
|
||||||
dest_location.setLatitude(mapView.getMapCenter().getLatitude());
|
dest_location.setLatitude(binding.mapView.getMapCenter().getLatitude());
|
||||||
dest_location.setLongitude(mapView.getMapCenter().getLongitude());
|
dest_location.setLongitude(binding.mapView.getMapCenter().getLongitude());
|
||||||
mylocation.setLatitude(getLastMapFocus().getLatitude());
|
mylocation.setLatitude(getLastMapFocus().getLatitude());
|
||||||
mylocation.setLongitude(getLastMapFocus().getLongitude());
|
mylocation.setLongitude(getLastMapFocus().getLongitude());
|
||||||
Float distance = mylocation.distanceTo(dest_location);//in meters
|
Float distance = mylocation.distanceTo(dest_location);//in meters
|
||||||
|
|
@ -322,7 +287,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mapView.onResume();
|
binding.mapView.onResume();
|
||||||
presenter.attachView(this);
|
presenter.attachView(this);
|
||||||
registerNetworkReceiver();
|
registerNetworkReceiver();
|
||||||
if (isResumed()) {
|
if (isResumed()) {
|
||||||
|
|
@ -351,7 +316,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
private void performMapReadyActions() {
|
private void performMapReadyActions() {
|
||||||
if (isDarkTheme) {
|
if (isDarkTheme) {
|
||||||
mapView.getOverlayManager().getTilesOverlay()
|
binding.mapView.getOverlayManager().getTilesOverlay()
|
||||||
.setColorFilter(TilesOverlay.INVERT_COLORS);
|
.setColorFilter(TilesOverlay.INVERT_COLORS);
|
||||||
}
|
}
|
||||||
if (!applicationKvStore.getBoolean("doNotAskForLocationPermission", false) ||
|
if (!applicationKvStore.getBoolean("doNotAskForLocationPermission", false) ||
|
||||||
|
|
@ -376,16 +341,16 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private void initBottomSheets() {
|
private void initBottomSheets() {
|
||||||
bottomSheetDetailsBehavior = BottomSheetBehavior.from(bottomSheetDetails);
|
bottomSheetDetailsBehavior = BottomSheetBehavior.from(binding.bottomSheetDetailsBinding.getRoot());
|
||||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
||||||
bottomSheetDetails.setVisibility(View.VISIBLE);
|
binding.bottomSheetDetailsBinding.getRoot().setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines how bottom sheets will act on click
|
* Defines how bottom sheets will act on click
|
||||||
*/
|
*/
|
||||||
private void setBottomSheetCallbacks() {
|
private void setBottomSheetCallbacks() {
|
||||||
bottomSheetDetails.setOnClickListener(v -> {
|
binding.bottomSheetDetailsBinding.getRoot().setOnClickListener(v -> {
|
||||||
if (bottomSheetDetailsBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
if (bottomSheetDetailsBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
} else if (bottomSheetDetailsBehavior.getState()
|
} else if (bottomSheetDetailsBehavior.getState()
|
||||||
|
|
@ -496,7 +461,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
if (lastKnownLocation != null) {
|
if (lastKnownLocation != null) {
|
||||||
GeoPoint targetP = new GeoPoint(target.getLatitude(), target.getLongitude());
|
GeoPoint targetP = new GeoPoint(target.getLatitude(), target.getLongitude());
|
||||||
mapCenter = targetP;
|
mapCenter = targetP;
|
||||||
mapView.getController().setCenter(targetP);
|
binding.mapView.getController().setCenter(targetP);
|
||||||
recenterMarkerToPosition(targetP);
|
recenterMarkerToPosition(targetP);
|
||||||
moveCameraToPosition(targetP);
|
moveCameraToPosition(targetP);
|
||||||
} else if (locationManager.isGPSProviderEnabled()
|
} else if (locationManager.isGPSProviderEnabled()
|
||||||
|
|
@ -528,13 +493,13 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
recenterMarkerToPosition(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()));
|
recenterMarkerToPosition(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()));
|
||||||
mapView.getController()
|
binding.mapView.getController()
|
||||||
.animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()));
|
.animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()));
|
||||||
if (lastMapFocus != null) {
|
if (lastMapFocus != null) {
|
||||||
Location mylocation = new Location("");
|
Location mylocation = new Location("");
|
||||||
Location dest_location = new Location("");
|
Location dest_location = new Location("");
|
||||||
dest_location.setLatitude(mapView.getMapCenter().getLatitude());
|
dest_location.setLatitude(binding.mapView.getMapCenter().getLatitude());
|
||||||
dest_location.setLongitude(mapView.getMapCenter().getLongitude());
|
dest_location.setLongitude(binding.mapView.getMapCenter().getLongitude());
|
||||||
mylocation.setLatitude(lastMapFocus.getLatitude());
|
mylocation.setLatitude(lastMapFocus.getLatitude());
|
||||||
mylocation.setLongitude(lastMapFocus.getLongitude());
|
mylocation.setLongitude(lastMapFocus.getLongitude());
|
||||||
Float distance = mylocation.distanceTo(dest_location);//in meters
|
Float distance = mylocation.distanceTo(dest_location);//in meters
|
||||||
|
|
@ -598,60 +563,52 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
* @param place Place of clicked nearby marker
|
* @param place Place of clicked nearby marker
|
||||||
*/
|
*/
|
||||||
private void passInfoToSheet(final Place place) {
|
private void passInfoToSheet(final Place place) {
|
||||||
directionsButton.setOnClickListener(view -> Utils.handleGeoCoordinates(getActivity(),
|
binding.bottomSheetDetailsBinding.directionsButton.setOnClickListener(view -> Utils.handleGeoCoordinates(getActivity(),
|
||||||
place.getLocation()));
|
place.getLocation()));
|
||||||
|
|
||||||
commonsButton.setVisibility(place.hasCommonsLink() ? View.VISIBLE : View.GONE);
|
binding.bottomSheetDetailsBinding.commonsButton.setVisibility(place.hasCommonsLink() ? View.VISIBLE : View.GONE);
|
||||||
commonsButton.setOnClickListener(
|
binding.bottomSheetDetailsBinding.commonsButton.setOnClickListener(
|
||||||
view -> Utils.handleWebUrl(getContext(), place.siteLinks.getCommonsLink()));
|
view -> Utils.handleWebUrl(getContext(), place.siteLinks.getCommonsLink()));
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Media media : mediaList) {
|
for (Media media : mediaList) {
|
||||||
if (media.getFilename().equals(place.name)) {
|
if (media.getFilename().equals(place.name)) {
|
||||||
int finalIndex = index;
|
int finalIndex = index;
|
||||||
mediaDetailsButton.setOnClickListener(view -> {
|
binding.bottomSheetDetailsBinding.mediaDetailsButton.setOnClickListener(view -> {
|
||||||
((ExploreMapRootFragment) getParentFragment()).onMediaClicked(finalIndex);
|
((ExploreMapRootFragment) getParentFragment()).onMediaClicked(finalIndex);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
title.setText(place.name.substring(5, place.name.lastIndexOf(".")));
|
binding.bottomSheetDetailsBinding.title.setText(place.name.substring(5, place.name.lastIndexOf(".")));
|
||||||
distance.setText(place.distance);
|
binding.bottomSheetDetailsBinding.category.setText(place.distance);
|
||||||
// Remove label since it is double information
|
// Remove label since it is double information
|
||||||
String descriptionText = place.getLongDescription()
|
String descriptionText = place.getLongDescription()
|
||||||
.replace(place.getName() + " (", "");
|
.replace(place.getName() + " (", "");
|
||||||
descriptionText = (descriptionText.equals(place.getLongDescription()) ? descriptionText
|
descriptionText = (descriptionText.equals(place.getLongDescription()) ? descriptionText
|
||||||
: descriptionText.replaceFirst(".$", ""));
|
: descriptionText.replaceFirst(".$", ""));
|
||||||
// Set the short description after we remove place name from long description
|
// Set the short description after we remove place name from long description
|
||||||
description.setText(descriptionText);
|
binding.bottomSheetDetailsBinding.description.setText(descriptionText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSearchThisAreaButtonAction() {
|
public void addSearchThisAreaButtonAction() {
|
||||||
searchThisAreaButton.setOnClickListener(presenter.onSearchThisAreaClicked());
|
binding.searchThisAreaButton.setOnClickListener(presenter.onSearchThisAreaClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSearchThisAreaButtonVisibility(boolean isVisible) {
|
public void setSearchThisAreaButtonVisibility(boolean isVisible) {
|
||||||
if (isVisible) {
|
binding.searchThisAreaButton.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
||||||
searchThisAreaButton.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
searchThisAreaButton.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProgressBarVisibility(boolean isVisible) {
|
public void setProgressBarVisibility(boolean isVisible) {
|
||||||
if (isVisible) {
|
binding.mapProgressBar.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDetailsBottomSheetVisible() {
|
public boolean isDetailsBottomSheetVisible() {
|
||||||
if (bottomSheetDetails.getVisibility() == View.VISIBLE) {
|
if (binding.bottomSheetDetailsBinding.getRoot().getVisibility() == View.VISIBLE) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -660,11 +617,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSearchThisAreaButtonVisible() {
|
public boolean isSearchThisAreaButtonVisible() {
|
||||||
if (searchThisAreaButton.getVisibility() == View.VISIBLE) {
|
return binding.bottomSheetDetailsBinding.getRoot().getVisibility() == View.VISIBLE;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -677,12 +630,12 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disableFABRecenter() {
|
public void disableFABRecenter() {
|
||||||
fabRecenter.setEnabled(false);
|
binding.fabRecenter.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enableFABRecenter() {
|
public void enableFABRecenter() {
|
||||||
fabRecenter.setEnabled(true);
|
binding.fabRecenter.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -696,7 +649,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
for (int i = 0; i < nearbyBaseMarkers.size(); i++) {
|
for (int i = 0; i < nearbyBaseMarkers.size(); i++) {
|
||||||
addMarkerToMap(nearbyBaseMarkers.get(i));
|
addMarkerToMap(nearbyBaseMarkers.get(i));
|
||||||
}
|
}
|
||||||
mapView.invalidate();
|
binding.mapView.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -738,7 +691,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
}, getContext());
|
}, getContext());
|
||||||
|
|
||||||
overlay.setFocusItemsOnTap(true);
|
overlay.setFocusItemsOnTap(true);
|
||||||
mapView.getOverlays().add(overlay); // Add the overlay to the map
|
binding.mapView.getOverlays().add(overlay); // Add the overlay to the map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -748,7 +701,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
private void removeMarker(NearbyBaseMarker nearbyBaseMarker) {
|
private void removeMarker(NearbyBaseMarker nearbyBaseMarker) {
|
||||||
Place place = nearbyBaseMarker.getPlace();
|
Place place = nearbyBaseMarker.getPlace();
|
||||||
List<Overlay> overlays = mapView.getOverlays();
|
List<Overlay> overlays = binding.mapView.getOverlays();
|
||||||
ItemizedOverlayWithFocus item;
|
ItemizedOverlayWithFocus item;
|
||||||
|
|
||||||
for (int i = 0; i < overlays.size(); i++) {
|
for (int i = 0; i < overlays.size(); i++) {
|
||||||
|
|
@ -758,8 +711,8 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
if (place.location.getLatitude() == overlayItem.getPoint().getLatitude()
|
if (place.location.getLatitude() == overlayItem.getPoint().getLatitude()
|
||||||
&& place.location.getLongitude() == overlayItem.getPoint().getLongitude()) {
|
&& place.location.getLongitude() == overlayItem.getPoint().getLongitude()) {
|
||||||
mapView.getOverlays().remove(i);
|
binding.mapView.getOverlays().remove(i);
|
||||||
mapView.invalidate();
|
binding.mapView.invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -772,10 +725,10 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void clearAllMarkers() {
|
public void clearAllMarkers() {
|
||||||
mapView.getOverlayManager().clear();
|
binding.mapView.getOverlayManager().clear();
|
||||||
GeoPoint geoPoint = mapCenter;
|
GeoPoint geoPoint = mapCenter;
|
||||||
if (geoPoint != null) {
|
if (geoPoint != null) {
|
||||||
List<Overlay> overlays = mapView.getOverlays();
|
List<Overlay> overlays = binding.mapView.getOverlays();
|
||||||
ScaleDiskOverlay diskOverlay =
|
ScaleDiskOverlay diskOverlay =
|
||||||
new ScaleDiskOverlay(this.getContext(),
|
new ScaleDiskOverlay(this.getContext(),
|
||||||
geoPoint, 2000, GeoConstants.UnitOfMeasure.foot);
|
geoPoint, 2000, GeoConstants.UnitOfMeasure.foot);
|
||||||
|
|
@ -790,9 +743,9 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
diskOverlay.setCirclePaint1(diskPaint);
|
diskOverlay.setCirclePaint1(diskPaint);
|
||||||
diskOverlay.setDisplaySizeMin(900);
|
diskOverlay.setDisplaySizeMin(900);
|
||||||
diskOverlay.setDisplaySizeMax(1700);
|
diskOverlay.setDisplaySizeMax(1700);
|
||||||
mapView.getOverlays().add(diskOverlay);
|
binding.mapView.getOverlays().add(diskOverlay);
|
||||||
org.osmdroid.views.overlay.Marker startMarker = new org.osmdroid.views.overlay.Marker(
|
org.osmdroid.views.overlay.Marker startMarker = new org.osmdroid.views.overlay.Marker(
|
||||||
mapView);
|
binding.mapView);
|
||||||
startMarker.setPosition(geoPoint);
|
startMarker.setPosition(geoPoint);
|
||||||
startMarker.setAnchor(org.osmdroid.views.overlay.Marker.ANCHOR_CENTER,
|
startMarker.setAnchor(org.osmdroid.views.overlay.Marker.ANCHOR_CENTER,
|
||||||
org.osmdroid.views.overlay.Marker.ANCHOR_BOTTOM);
|
org.osmdroid.views.overlay.Marker.ANCHOR_BOTTOM);
|
||||||
|
|
@ -800,22 +753,22 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
ContextCompat.getDrawable(this.getContext(), R.drawable.current_location_marker));
|
ContextCompat.getDrawable(this.getContext(), R.drawable.current_location_marker));
|
||||||
startMarker.setTitle("Your Location");
|
startMarker.setTitle("Your Location");
|
||||||
startMarker.setTextLabelFontSize(24);
|
startMarker.setTextLabelFontSize(24);
|
||||||
mapView.getOverlays().add(startMarker);
|
binding.mapView.getOverlays().add(startMarker);
|
||||||
}
|
}
|
||||||
ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(mapView);
|
ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(binding.mapView);
|
||||||
scaleBarOverlay.setScaleBarOffset(15, 25);
|
scaleBarOverlay.setScaleBarOffset(15, 25);
|
||||||
Paint barPaint = new Paint();
|
Paint barPaint = new Paint();
|
||||||
barPaint.setARGB(200, 255, 250, 250);
|
barPaint.setARGB(200, 255, 250, 250);
|
||||||
scaleBarOverlay.setBackgroundPaint(barPaint);
|
scaleBarOverlay.setBackgroundPaint(barPaint);
|
||||||
scaleBarOverlay.enableScaleBar();
|
scaleBarOverlay.enableScaleBar();
|
||||||
mapView.getOverlays().add(scaleBarOverlay);
|
binding.mapView.getOverlays().add(scaleBarOverlay);
|
||||||
mapView.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
|
binding.mapView.getOverlays().add(new MapEventsOverlay(new MapEventsReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public boolean singleTapConfirmedHelper(GeoPoint p) {
|
public boolean singleTapConfirmedHelper(GeoPoint p) {
|
||||||
if (clickedMarker != null) {
|
if (clickedMarker != null) {
|
||||||
removeMarker(clickedMarker);
|
removeMarker(clickedMarker);
|
||||||
addMarkerToMap(clickedMarker);
|
addMarkerToMap(clickedMarker);
|
||||||
mapView.invalidate();
|
binding.mapView.invalidate();
|
||||||
} else {
|
} else {
|
||||||
Timber.e("CLICKED MARKER IS NULL");
|
Timber.e("CLICKED MARKER IS NULL");
|
||||||
}
|
}
|
||||||
|
|
@ -833,7 +786,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
mapView.setMultiTouchControls(true);
|
binding.mapView.setMultiTouchControls(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -844,13 +797,13 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
private void recenterMarkerToPosition(GeoPoint geoPoint) {
|
private void recenterMarkerToPosition(GeoPoint geoPoint) {
|
||||||
if (geoPoint != null) {
|
if (geoPoint != null) {
|
||||||
mapView.getController().setCenter(geoPoint);
|
binding.mapView.getController().setCenter(geoPoint);
|
||||||
List<Overlay> overlays = mapView.getOverlays();
|
List<Overlay> overlays = binding.mapView.getOverlays();
|
||||||
for (int i = 0; i < overlays.size(); i++) {
|
for (int i = 0; i < overlays.size(); i++) {
|
||||||
if (overlays.get(i) instanceof org.osmdroid.views.overlay.Marker) {
|
if (overlays.get(i) instanceof org.osmdroid.views.overlay.Marker) {
|
||||||
mapView.getOverlays().remove(i);
|
binding.mapView.getOverlays().remove(i);
|
||||||
} else if (overlays.get(i) instanceof ScaleDiskOverlay) {
|
} else if (overlays.get(i) instanceof ScaleDiskOverlay) {
|
||||||
mapView.getOverlays().remove(i);
|
binding.mapView.getOverlays().remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScaleDiskOverlay diskOverlay =
|
ScaleDiskOverlay diskOverlay =
|
||||||
|
|
@ -867,9 +820,9 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
diskOverlay.setCirclePaint1(diskPaint);
|
diskOverlay.setCirclePaint1(diskPaint);
|
||||||
diskOverlay.setDisplaySizeMin(900);
|
diskOverlay.setDisplaySizeMin(900);
|
||||||
diskOverlay.setDisplaySizeMax(1700);
|
diskOverlay.setDisplaySizeMax(1700);
|
||||||
mapView.getOverlays().add(diskOverlay);
|
binding.mapView.getOverlays().add(diskOverlay);
|
||||||
org.osmdroid.views.overlay.Marker startMarker = new org.osmdroid.views.overlay.Marker(
|
org.osmdroid.views.overlay.Marker startMarker = new org.osmdroid.views.overlay.Marker(
|
||||||
mapView);
|
binding.mapView);
|
||||||
startMarker.setPosition(geoPoint);
|
startMarker.setPosition(geoPoint);
|
||||||
startMarker.setAnchor(org.osmdroid.views.overlay.Marker.ANCHOR_CENTER,
|
startMarker.setAnchor(org.osmdroid.views.overlay.Marker.ANCHOR_CENTER,
|
||||||
org.osmdroid.views.overlay.Marker.ANCHOR_BOTTOM);
|
org.osmdroid.views.overlay.Marker.ANCHOR_BOTTOM);
|
||||||
|
|
@ -877,7 +830,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
ContextCompat.getDrawable(this.getContext(), R.drawable.current_location_marker));
|
ContextCompat.getDrawable(this.getContext(), R.drawable.current_location_marker));
|
||||||
startMarker.setTitle("Your Location");
|
startMarker.setTitle("Your Location");
|
||||||
startMarker.setTextLabelFontSize(24);
|
startMarker.setTextLabelFontSize(24);
|
||||||
mapView.getOverlays().add(startMarker);
|
binding.mapView.getOverlays().add(startMarker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -887,7 +840,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
* @param geoPoint The GeoPoint representing the new camera position for the map.
|
* @param geoPoint The GeoPoint representing the new camera position for the map.
|
||||||
*/
|
*/
|
||||||
private void moveCameraToPosition(GeoPoint geoPoint) {
|
private void moveCameraToPosition(GeoPoint geoPoint) {
|
||||||
mapView.getController().animateTo(geoPoint);
|
binding.mapView.getController().animateTo(geoPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -909,13 +862,13 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
|
||||||
@Override
|
@Override
|
||||||
public fr.free.nrw.commons.location.LatLng getMapFocus() {
|
public fr.free.nrw.commons.location.LatLng getMapFocus() {
|
||||||
fr.free.nrw.commons.location.LatLng mapFocusedLatLng = new fr.free.nrw.commons.location.LatLng(
|
fr.free.nrw.commons.location.LatLng mapFocusedLatLng = new fr.free.nrw.commons.location.LatLng(
|
||||||
mapView.getMapCenter().getLatitude(), mapView.getMapCenter().getLongitude(), 100);
|
binding.mapView.getMapCenter().getLatitude(), binding.mapView.getMapCenter().getLongitude(), 100);
|
||||||
return mapFocusedLatLng;
|
return mapFocusedLatLng;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFABRecenterAction(OnClickListener onClickListener) {
|
public void setFABRecenterAction(OnClickListener onClickListener) {
|
||||||
fabRecenter.setOnClickListener(onClickListener);
|
binding.fabRecenter.setOnClickListener(onClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,11 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentSearchHistoryBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.explore.SearchActivity;
|
import fr.free.nrw.commons.explore.SearchActivity;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -29,42 +25,39 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RecentSearchesDao recentSearchesDao;
|
RecentSearchesDao recentSearchesDao;
|
||||||
@BindView(R.id.recent_searches_list)
|
|
||||||
ListView recentSearchesList;
|
|
||||||
List<String> recentSearches;
|
List<String> recentSearches;
|
||||||
ArrayAdapter adapter;
|
ArrayAdapter adapter;
|
||||||
@BindView(R.id.recent_searches_delete_button)
|
|
||||||
ImageView recent_searches_delete_button;
|
private FragmentSearchHistoryBinding binding;
|
||||||
@BindView(R.id.recent_searches_text_view)
|
|
||||||
TextView recent_searches_text_view;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_search_history, container, false);
|
binding = FragmentSearchHistoryBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, rootView);
|
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
|
|
||||||
if (recentSearches.isEmpty()) {
|
if (recentSearches.isEmpty()) {
|
||||||
recent_searches_delete_button.setVisibility(View.GONE);
|
binding.recentSearchesDeleteButton.setVisibility(View.GONE);
|
||||||
recent_searches_text_view.setText(R.string.no_recent_searches);
|
binding.recentSearchesTextView.setText(R.string.no_recent_searches);
|
||||||
}
|
}
|
||||||
|
|
||||||
recent_searches_delete_button.setOnClickListener(v -> {
|
binding.recentSearchesDeleteButton.setOnClickListener(v -> {
|
||||||
showDeleteRecentAlertDialog(requireContext());
|
showDeleteRecentAlertDialog(requireContext());
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter = new ArrayAdapter<>(requireContext(), R.layout.item_recent_searches,
|
adapter = new ArrayAdapter<>(requireContext(), R.layout.item_recent_searches,
|
||||||
recentSearches);
|
recentSearches);
|
||||||
recentSearchesList.setAdapter(adapter);
|
binding.recentSearchesList.setAdapter(adapter);
|
||||||
recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
|
binding.recentSearchesList.setOnItemClickListener((parent, view, position, id) -> (
|
||||||
(SearchActivity) getContext()).updateText(recentSearches.get(position)));
|
(SearchActivity) getContext()).updateText(recentSearches.get(position)));
|
||||||
recentSearchesList.setOnItemLongClickListener((parent, view, position, id) -> {
|
binding.recentSearchesList.setOnItemLongClickListener((parent, view, position, id) -> {
|
||||||
showDeleteAlertDialog(requireContext(), position);
|
showDeleteAlertDialog(requireContext(), position);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
updateRecentSearches();
|
updateRecentSearches();
|
||||||
return rootView;
|
|
||||||
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDeleteRecentAlertDialog(@NonNull final Context context) {
|
private void showDeleteRecentAlertDialog(@NonNull final Context context) {
|
||||||
|
|
@ -80,15 +73,17 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
private void setDeleteRecentPositiveButton(@NonNull final Context context,
|
private void setDeleteRecentPositiveButton(@NonNull final Context context,
|
||||||
final DialogInterface dialog) {
|
final DialogInterface dialog) {
|
||||||
recentSearchesDao.deleteAll();
|
recentSearchesDao.deleteAll();
|
||||||
recent_searches_delete_button.setVisibility(View.GONE);
|
if (binding != null) {
|
||||||
recent_searches_text_view.setText(R.string.no_recent_searches);
|
binding.recentSearchesDeleteButton.setVisibility(View.GONE);
|
||||||
Toast.makeText(getContext(), getString(R.string.search_history_deleted),
|
binding.recentSearchesTextView.setText(R.string.no_recent_searches);
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), getString(R.string.search_history_deleted),
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
Toast.LENGTH_SHORT).show();
|
||||||
adapter = new ArrayAdapter<>(context, R.layout.item_recent_searches,
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
recentSearches);
|
adapter = new ArrayAdapter<>(context, R.layout.item_recent_searches,
|
||||||
recentSearchesList.setAdapter(adapter);
|
recentSearches);
|
||||||
adapter.notifyDataSetChanged();
|
binding.recentSearchesList.setAdapter(adapter);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,8 +103,10 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
recentSearches = recentSearchesDao.recentSearches(10);
|
recentSearches = recentSearchesDao.recentSearches(10);
|
||||||
adapter = new ArrayAdapter<>(context, R.layout.item_recent_searches,
|
adapter = new ArrayAdapter<>(context, R.layout.item_recent_searches,
|
||||||
recentSearches);
|
recentSearches);
|
||||||
recentSearchesList.setAdapter(adapter);
|
if (binding != null){
|
||||||
adapter.notifyDataSetChanged();
|
binding.recentSearchesList.setAdapter(adapter);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,8 +128,19 @@ public class RecentSearchesFragment extends CommonsDaggerSupportFragment {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
if (!recentSearches.isEmpty()) {
|
if (!recentSearches.isEmpty()) {
|
||||||
recent_searches_delete_button.setVisibility(View.VISIBLE);
|
if (binding!= null) {
|
||||||
recent_searches_text_view.setText(R.string.search_recent_header);
|
binding.recentSearchesDeleteButton.setVisibility(View.VISIBLE);
|
||||||
|
binding.recentSearchesTextView.setText(R.string.search_recent_header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
if (binding != null) {
|
||||||
|
binding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
// in the case when MediaDetailPagerFragment is directly started by the CategoryImagesActivity
|
// in the case when MediaDetailPagerFragment is directly started by the CategoryImagesActivity
|
||||||
if (getParentFragment() instanceof ContributionsFragment) {
|
if (getParentFragment() instanceof ContributionsFragment) {
|
||||||
((ContributionsFragment) (getParentFragment()
|
((ContributionsFragment) (getParentFragment()
|
||||||
.getParentFragment())).nearbyNotificationCardView
|
.getParentFragment())).binding.cardViewNearby
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -938,12 +938,14 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startActivityForResult(new LocationPicker.IntentBuilder()
|
|
||||||
|
startActivity(new LocationPicker.IntentBuilder()
|
||||||
.defaultLocation(new CameraPosition.Builder()
|
.defaultLocation(new CameraPosition.Builder()
|
||||||
.target(new LatLng(defaultLatitude, defaultLongitude))
|
.target(new LatLng(defaultLatitude, defaultLongitude))
|
||||||
.zoom(16).build())
|
.zoom(16).build())
|
||||||
.activityKey("MediaActivity")
|
.activityKey("MediaActivity")
|
||||||
.build(getActivity()), REQUEST_CODE);
|
.media(media)
|
||||||
|
.build(getActivity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.description_edit)
|
@OnClick(R.id.description_edit)
|
||||||
|
|
@ -1121,32 +1123,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
@Nullable final Intent data) {
|
@Nullable final Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
|
if (requestCode == REQUEST_CODE_EDIT_DESCRIPTION && resultCode == RESULT_OK) {
|
||||||
|
|
||||||
assert data != null;
|
|
||||||
final CameraPosition cameraPosition = LocationPicker.getCameraPosition(data);
|
|
||||||
|
|
||||||
if (cameraPosition != null) {
|
|
||||||
|
|
||||||
final String latitude = String.valueOf(cameraPosition.target.getLatitude());
|
|
||||||
final String longitude = String.valueOf(cameraPosition.target.getLongitude());
|
|
||||||
final String accuracy = String.valueOf(cameraPosition.target.getAltitude());
|
|
||||||
String currentLatitude = null;
|
|
||||||
String currentLongitude = null;
|
|
||||||
|
|
||||||
if (media.getCoordinates() != null) {
|
|
||||||
currentLatitude = String.valueOf(media.getCoordinates().getLatitude());
|
|
||||||
currentLongitude = String.valueOf(media.getCoordinates().getLongitude());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!latitude.equals(currentLatitude) || !longitude.equals(currentLongitude)) {
|
|
||||||
updateCoordinates(latitude, longitude, accuracy);
|
|
||||||
} else if (media.getCoordinates() == null) {
|
|
||||||
updateCoordinates(latitude, longitude, accuracy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (requestCode == REQUEST_CODE_EDIT_DESCRIPTION && resultCode == RESULT_OK) {
|
|
||||||
final String updatedWikiText = data.getStringExtra(UPDATED_WIKITEXT);
|
final String updatedWikiText = data.getStringExtra(UPDATED_WIKITEXT);
|
||||||
compositeDisposable.add(descriptionEditHelper.addDescription(getContext(), media,
|
compositeDisposable.add(descriptionEditHelper.addDescription(getContext(), media,
|
||||||
updatedWikiText)
|
updatedWikiText)
|
||||||
|
|
@ -1174,11 +1151,6 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
progressBarEditDescription.setVisibility(GONE);
|
progressBarEditDescription.setVisibility(GONE);
|
||||||
editDescription.setVisibility(VISIBLE);
|
editDescription.setVisibility(VISIBLE);
|
||||||
|
|
||||||
} else if (requestCode == REQUEST_CODE && resultCode == RESULT_CANCELED) {
|
|
||||||
viewUtil.showShortToast(getContext(),
|
|
||||||
requireContext()
|
|
||||||
.getString(R.string.coordinates_picking_unsuccessful));
|
|
||||||
|
|
||||||
} else if (requestCode == REQUEST_CODE_EDIT_DESCRIPTION && resultCode == RESULT_CANCELED) {
|
} else if (requestCode == REQUEST_CODE_EDIT_DESCRIPTION && resultCode == RESULT_CANCELED) {
|
||||||
progressBarEditDescription.setVisibility(GONE);
|
progressBarEditDescription.setVisibility(GONE);
|
||||||
editDescription.setVisibility(VISIBLE);
|
editDescription.setVisibility(VISIBLE);
|
||||||
|
|
@ -1196,24 +1168,6 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
media.setCaptions(updatedCaptions);
|
media.setCaptions(updatedCaptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetched coordinates are replaced with existing coordinates by a POST API call.
|
|
||||||
* @param Latitude to be added
|
|
||||||
* @param Longitude to be added
|
|
||||||
* @param Accuracy to be added
|
|
||||||
*/
|
|
||||||
public void updateCoordinates(final String Latitude, final String Longitude,
|
|
||||||
final String Accuracy) {
|
|
||||||
compositeDisposable.add(coordinateEditHelper.makeCoordinatesEdit(getContext(), media,
|
|
||||||
Latitude, Longitude, Accuracy)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(s -> {
|
|
||||||
Timber.d("Coordinates are added.");
|
|
||||||
coordinates.setText(prettyCoordinates(media));
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("StringFormatInvalid")
|
@SuppressLint("StringFormatInvalid")
|
||||||
@OnClick(R.id.nominateDeletion)
|
@OnClick(R.id.nominateDeletion)
|
||||||
public void onDeleteButtonClicked(){
|
public void onDeleteButtonClicked(){
|
||||||
|
|
@ -1598,4 +1552,5 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
SharedPreferences imageBackgroundColorPref = this.getImageBackgroundColorPref();
|
SharedPreferences imageBackgroundColorPref = this.getImageBackgroundColorPref();
|
||||||
return imageBackgroundColorPref.getInt(IMAGE_BACKGROUND_COLOR, DEFAULT_IMAGE_BACKGROUND_COLOR);
|
return imageBackgroundColorPref.getInt(IMAGE_BACKGROUND_COLOR, DEFAULT_IMAGE_BACKGROUND_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
|
||||||
|
|
||||||
// If fragment is associated with ProfileActivity, then hide the tabLayout
|
// If fragment is associated with ProfileActivity, then hide the tabLayout
|
||||||
if (getActivity() instanceof ProfileActivity) {
|
if (getActivity() instanceof ProfileActivity) {
|
||||||
((ProfileActivity)getActivity()).tabLayout.setVisibility(View.GONE);
|
((ProfileActivity)getActivity()).setTabLayoutVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Else if fragment is associated with MainActivity then hide that tab layout
|
// Else if fragment is associated with MainActivity then hide that tab layout
|
||||||
|
|
|
||||||
|
|
@ -1322,7 +1322,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTabItemContributions() {
|
public void setTabItemContributions() {
|
||||||
((MainActivity) getActivity()).viewPager.setCurrentItem(0);
|
((MainActivity) getActivity()).binding.pager.setCurrentItem(0);
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,19 +13,16 @@ import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter;
|
import fr.free.nrw.commons.ViewPagerAdapter;
|
||||||
import fr.free.nrw.commons.auth.SessionManager;
|
import fr.free.nrw.commons.auth.SessionManager;
|
||||||
import fr.free.nrw.commons.contributions.ContributionsFragment;
|
import fr.free.nrw.commons.contributions.ContributionsFragment;
|
||||||
import fr.free.nrw.commons.explore.ParentViewPager;
|
import fr.free.nrw.commons.databinding.ActivityProfileBinding;
|
||||||
import fr.free.nrw.commons.profile.achievements.AchievementsFragment;
|
import fr.free.nrw.commons.profile.achievements.AchievementsFragment;
|
||||||
import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment;
|
import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment;
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
|
|
@ -45,14 +42,7 @@ public class ProfileActivity extends BaseActivity {
|
||||||
|
|
||||||
private FragmentManager supportFragmentManager;
|
private FragmentManager supportFragmentManager;
|
||||||
|
|
||||||
@BindView(R.id.viewPager)
|
public ActivityProfileBinding binding;
|
||||||
ParentViewPager viewPager;
|
|
||||||
|
|
||||||
@BindView(R.id.tab_layout)
|
|
||||||
public TabLayout tabLayout;
|
|
||||||
|
|
||||||
@BindView(R.id.toolbar)
|
|
||||||
Toolbar toolbar;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SessionManager sessionManager;
|
SessionManager sessionManager;
|
||||||
|
|
@ -70,7 +60,7 @@ public class ProfileActivity extends BaseActivity {
|
||||||
ContributionsFragment contributionsFragment;
|
ContributionsFragment contributionsFragment;
|
||||||
|
|
||||||
public void setScroll(boolean canScroll){
|
public void setScroll(boolean canScroll){
|
||||||
viewPager.setCanScroll(canScroll);
|
binding.viewPager.setCanScroll(canScroll);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
|
protected void onRestoreInstanceState(final Bundle savedInstanceState) {
|
||||||
|
|
@ -85,11 +75,13 @@ public class ProfileActivity extends BaseActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_profile);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
binding = ActivityProfileBinding.inflate(getLayoutInflater());
|
||||||
toolbar.setNavigationOnClickListener(view -> {
|
setContentView(binding.getRoot());
|
||||||
|
setSupportActionBar(binding.toolbarBinding.toolbar);
|
||||||
|
|
||||||
|
|
||||||
|
binding.toolbarBinding.toolbar.setNavigationOnClickListener(view -> {
|
||||||
onSupportNavigateUp();
|
onSupportNavigateUp();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -99,8 +91,8 @@ public class ProfileActivity extends BaseActivity {
|
||||||
|
|
||||||
supportFragmentManager = getSupportFragmentManager();
|
supportFragmentManager = getSupportFragmentManager();
|
||||||
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(viewPagerAdapter);
|
binding.viewPager.setAdapter(viewPagerAdapter);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
binding.tabLayout.setupWithViewPager(binding.viewPager);
|
||||||
setTabs();
|
setTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,9 +249,17 @@ public class ProfileActivity extends BaseActivity {
|
||||||
// Checking if MediaDetailPagerFragment is visible, If visible then show ContributionListFragment else close the ProfileActivity
|
// Checking if MediaDetailPagerFragment is visible, If visible then show ContributionListFragment else close the ProfileActivity
|
||||||
if(contributionsFragment != null && contributionsFragment.getMediaDetailPagerFragment() != null && contributionsFragment.getMediaDetailPagerFragment().isVisible()) {
|
if(contributionsFragment != null && contributionsFragment.getMediaDetailPagerFragment() != null && contributionsFragment.getMediaDetailPagerFragment().isVisible()) {
|
||||||
contributionsFragment.backButtonClicked();
|
contributionsFragment.backButtonClicked();
|
||||||
tabLayout.setVisibility(View.VISIBLE);
|
binding.tabLayout.setVisibility(View.VISIBLE);
|
||||||
}else {
|
}else {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* To set the visibility of tab layout
|
||||||
|
* @param isVisible boolean
|
||||||
|
*/
|
||||||
|
public void setTabLayoutVisibility(boolean isVisible) {
|
||||||
|
binding.tabLayout.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,19 +14,14 @@ import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.MergeAdapter;
|
import androidx.recyclerview.widget.MergeAdapter;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.auth.SessionManager;
|
import fr.free.nrw.commons.auth.SessionManager;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentLeaderboardBinding;
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient;
|
||||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||||
|
|
@ -44,20 +39,6 @@ import timber.log.Timber;
|
||||||
*/
|
*/
|
||||||
public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
@BindView(R.id.leaderboard_list)
|
|
||||||
RecyclerView leaderboardListRecyclerView;
|
|
||||||
|
|
||||||
@BindView(R.id.progressBar)
|
|
||||||
ProgressBar progressBar;
|
|
||||||
|
|
||||||
@BindView(R.id.category_spinner)
|
|
||||||
Spinner categorySpinner;
|
|
||||||
|
|
||||||
@BindView(R.id.duration_spinner)
|
|
||||||
Spinner durationSpinner;
|
|
||||||
|
|
||||||
@BindView(R.id.scroll)
|
|
||||||
Button scrollButton;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SessionManager sessionManager;
|
SessionManager sessionManager;
|
||||||
|
|
@ -110,6 +91,8 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
private FragmentLeaderboardBinding binding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
@ -120,19 +103,18 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.fragment_leaderboard, container, false);
|
binding = FragmentLeaderboardBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, rootView);
|
|
||||||
|
|
||||||
hideLayouts();
|
hideLayouts();
|
||||||
|
|
||||||
// Leaderboard currently unimplemented in Beta flavor. Skip all API calls and disable menu
|
// Leaderboard currently unimplemented in Beta flavor. Skip all API calls and disable menu
|
||||||
if(ConfigUtils.isBetaFlavour()) {
|
if(ConfigUtils.isBetaFlavour()) {
|
||||||
progressBar.setVisibility(View.GONE);
|
binding.progressBar.setVisibility(View.GONE);
|
||||||
scrollButton.setVisibility(View.GONE);
|
binding.scroll.setVisibility(View.GONE);
|
||||||
return rootView;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
binding.progressBar.setVisibility(View.VISIBLE);
|
||||||
setSpinners();
|
setSpinners();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -152,11 +134,11 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
setLeaderboard(duration, category, limit, offset);
|
setLeaderboard(duration, category, limit, offset);
|
||||||
|
|
||||||
durationSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
binding.durationSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
|
||||||
duration = durationValues[durationSpinner.getSelectedItemPosition()];
|
duration = durationValues[binding.durationSpinner.getSelectedItemPosition()];
|
||||||
refreshLeaderboard();
|
refreshLeaderboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,10 +147,10 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
categorySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
binding.categorySpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
category = categoryValues[categorySpinner.getSelectedItemPosition()];
|
category = categoryValues[binding.categorySpinner.getSelectedItemPosition()];
|
||||||
refreshLeaderboard();
|
refreshLeaderboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,10 +160,10 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
scrollButton.setOnClickListener(view -> scrollToUserRank());
|
binding.scroll.setOnClickListener(view -> scrollToUserRank());
|
||||||
|
|
||||||
|
|
||||||
return rootView;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -226,9 +208,12 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
if(userRank==0){
|
if(userRank==0){
|
||||||
Toast.makeText(getContext(),R.string.no_achievements_yet,Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(),R.string.no_achievements_yet,Toast.LENGTH_SHORT).show();
|
||||||
}else {
|
}else {
|
||||||
if (Objects.requireNonNull(leaderboardListRecyclerView.getAdapter()).getItemCount()
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Objects.requireNonNull(binding.leaderboardList.getAdapter()).getItemCount()
|
||||||
> userRank + 1) {
|
> userRank + 1) {
|
||||||
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
|
binding.leaderboardList.smoothScrollToPosition(userRank + 1);
|
||||||
} else {
|
} else {
|
||||||
if (viewModel != null) {
|
if (viewModel != null) {
|
||||||
viewModel.refresh(duration, category, userRank + 1, 0);
|
viewModel.refresh(duration, category, userRank + 1, 0);
|
||||||
|
|
@ -247,12 +232,12 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
ArrayAdapter<CharSequence> categoryAdapter = ArrayAdapter.createFromResource(getContext(),
|
ArrayAdapter<CharSequence> categoryAdapter = ArrayAdapter.createFromResource(getContext(),
|
||||||
R.array.leaderboard_categories, android.R.layout.simple_spinner_item);
|
R.array.leaderboard_categories, android.R.layout.simple_spinner_item);
|
||||||
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
categorySpinner.setAdapter(categoryAdapter);
|
binding.categorySpinner.setAdapter(categoryAdapter);
|
||||||
|
|
||||||
ArrayAdapter<CharSequence> durationAdapter = ArrayAdapter.createFromResource(getContext(),
|
ArrayAdapter<CharSequence> durationAdapter = ArrayAdapter.createFromResource(getContext(),
|
||||||
R.array.leaderboard_durations, android.R.layout.simple_spinner_item);
|
R.array.leaderboard_durations, android.R.layout.simple_spinner_item);
|
||||||
durationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
durationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
durationSpinner.setAdapter(durationAdapter);
|
binding.durationSpinner.setAdapter(durationAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -297,8 +282,8 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
UserDetailAdapter userDetailAdapter= new UserDetailAdapter(response);
|
UserDetailAdapter userDetailAdapter= new UserDetailAdapter(response);
|
||||||
MergeAdapter mergeAdapter = new MergeAdapter(userDetailAdapter, leaderboardListAdapter);
|
MergeAdapter mergeAdapter = new MergeAdapter(userDetailAdapter, leaderboardListAdapter);
|
||||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||||
leaderboardListRecyclerView.setLayoutManager(linearLayoutManager);
|
binding.leaderboardList.setLayoutManager(linearLayoutManager);
|
||||||
leaderboardListRecyclerView.setAdapter(mergeAdapter);
|
binding.leaderboardList.setAdapter(mergeAdapter);
|
||||||
viewModel.getListLiveData().observe(getViewLifecycleOwner(), leaderboardListAdapter::submitList);
|
viewModel.getListLiveData().observe(getViewLifecycleOwner(), leaderboardListAdapter::submitList);
|
||||||
viewModel.getProgressLoadStatus().observe(getViewLifecycleOwner(), status -> {
|
viewModel.getProgressLoadStatus().observe(getViewLifecycleOwner(), status -> {
|
||||||
if (Objects.requireNonNull(status).equalsIgnoreCase(LOADING)) {
|
if (Objects.requireNonNull(status).equalsIgnoreCase(LOADING)) {
|
||||||
|
|
@ -306,7 +291,7 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
} else if (status.equalsIgnoreCase(LOADED)) {
|
} else if (status.equalsIgnoreCase(LOADED)) {
|
||||||
hideProgressBar();
|
hideProgressBar();
|
||||||
if (scrollToRank) {
|
if (scrollToRank) {
|
||||||
leaderboardListRecyclerView.smoothScrollToPosition(userRank + 1);
|
binding.leaderboardList.smoothScrollToPosition(userRank + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -316,12 +301,12 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
* to hide progressbar
|
* to hide progressbar
|
||||||
*/
|
*/
|
||||||
private void hideProgressBar() {
|
private void hideProgressBar() {
|
||||||
if (progressBar != null) {
|
if (binding != null) {
|
||||||
progressBar.setVisibility(View.GONE);
|
binding.progressBar.setVisibility(View.GONE);
|
||||||
categorySpinner.setVisibility(View.VISIBLE);
|
binding.categorySpinner.setVisibility(View.VISIBLE);
|
||||||
durationSpinner.setVisibility(View.VISIBLE);
|
binding.durationSpinner.setVisibility(View.VISIBLE);
|
||||||
scrollButton.setVisibility(View.VISIBLE);
|
binding.scroll.setVisibility(View.VISIBLE);
|
||||||
leaderboardListRecyclerView.setVisibility(View.VISIBLE);
|
binding.leaderboardList.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,19 +314,19 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
* to show progressbar
|
* to show progressbar
|
||||||
*/
|
*/
|
||||||
private void showProgressBar() {
|
private void showProgressBar() {
|
||||||
if (progressBar != null) {
|
if (binding != null) {
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
binding.progressBar.setVisibility(View.VISIBLE);
|
||||||
|
binding.scroll.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
scrollButton.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used to hide the layouts while fetching results from api
|
* used to hide the layouts while fetching results from api
|
||||||
*/
|
*/
|
||||||
private void hideLayouts(){
|
private void hideLayouts(){
|
||||||
categorySpinner.setVisibility(View.INVISIBLE);
|
binding.categorySpinner.setVisibility(View.INVISIBLE);
|
||||||
durationSpinner.setVisibility(View.INVISIBLE);
|
binding.durationSpinner.setVisibility(View.INVISIBLE);
|
||||||
leaderboardListRecyclerView.setVisibility(View.INVISIBLE);
|
binding.leaderboardList.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -364,7 +349,15 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
|
||||||
*/
|
*/
|
||||||
private void onError() {
|
private void onError() {
|
||||||
ViewUtil.showLongToast(getActivity(), getResources().getString(R.string.error_occurred));
|
ViewUtil.showLongToast(getActivity(), getResources().getString(R.string.error_occurred));
|
||||||
progressBar.setVisibility(View.GONE);
|
if (binding!=null) {
|
||||||
|
binding.progressBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
compositeDisposable.clear();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,70 +1,69 @@
|
||||||
package fr.free.nrw.commons.settings;
|
package fr.free.nrw.commons.settings;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import android.view.View;
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import butterknife.BindView;
|
import fr.free.nrw.commons.databinding.ActivitySettingsBinding;
|
||||||
import butterknife.ButterKnife;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
import fr.free.nrw.commons.R;
|
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
/**
|
||||||
|
* allows the user to change the settings
|
||||||
/**
|
*/
|
||||||
* allows the user to change the settings
|
public class SettingsActivity extends BaseActivity {
|
||||||
*/
|
|
||||||
public class SettingsActivity extends BaseActivity {
|
private ActivitySettingsBinding binding;
|
||||||
private AppCompatDelegate settingsDelegate;
|
private AppCompatDelegate settingsDelegate;
|
||||||
@BindView(R.id.toolbar)
|
/**
|
||||||
Toolbar toolbar;
|
* to be called when the activity starts
|
||||||
/**
|
* @param savedInstanceState the previously saved state
|
||||||
* to be called when the activity starts
|
*/
|
||||||
* @param savedInstanceState the previously saved state
|
@Override
|
||||||
*/
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@Override
|
super.onCreate(savedInstanceState);
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
binding = ActivitySettingsBinding.inflate(getLayoutInflater());
|
||||||
super.onCreate(savedInstanceState);
|
final View view = binding.getRoot();
|
||||||
setContentView(R.layout.activity_settings);
|
setContentView(view);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
setSupportActionBar(binding.toolbarBinding.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
}
|
||||||
}
|
|
||||||
|
// Get an action bar
|
||||||
// Get an action bar
|
/**
|
||||||
/**
|
* takes care of actions taken after the creation has happened
|
||||||
* takes care of actions taken after the creation has happened
|
* @param savedInstanceState the saved state
|
||||||
* @param savedInstanceState the saved state
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
protected void onPostCreate(Bundle savedInstanceState) {
|
||||||
protected void onPostCreate(Bundle savedInstanceState) {
|
super.onPostCreate(savedInstanceState);
|
||||||
super.onPostCreate(savedInstanceState);
|
if (settingsDelegate == null) {
|
||||||
if (settingsDelegate == null) {
|
settingsDelegate = AppCompatDelegate.create(this, null);
|
||||||
settingsDelegate = AppCompatDelegate.create(this, null);
|
}
|
||||||
}
|
settingsDelegate.onPostCreate(savedInstanceState);
|
||||||
settingsDelegate.onPostCreate(savedInstanceState);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean onSupportNavigateUp() {
|
||||||
public boolean onSupportNavigateUp() {
|
onBackPressed();
|
||||||
onBackPressed();
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Handle action-bar clicks
|
||||||
* Handle action-bar clicks
|
* @param item the selected item
|
||||||
* @param item the selected item
|
* @return true on success, false on failure
|
||||||
* @return true on success, false on failure
|
*/
|
||||||
*/
|
@Override
|
||||||
@Override
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
switch (item.getItemId()) {
|
||||||
switch (item.getItemId()) {
|
case android.R.id.home:
|
||||||
case android.R.id.home:
|
finish();
|
||||||
finish();
|
return true;
|
||||||
return true;
|
default:
|
||||||
default:
|
return super.onOptionsItemSelected(item);
|
||||||
return super.onOptionsItemSelected(item);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,12 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentSimilarImageDialogBinding;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,17 +22,11 @@ import java.io.File;
|
||||||
|
|
||||||
public class SimilarImageDialogFragment extends DialogFragment {
|
public class SimilarImageDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
@BindView(R.id.orginalImage)
|
|
||||||
SimpleDraweeView originalImage;
|
|
||||||
@BindView(R.id.possibleImage)
|
|
||||||
SimpleDraweeView possibleImage;
|
|
||||||
@BindView(R.id.postive_button)
|
|
||||||
Button positiveButton;
|
|
||||||
@BindView(R.id.negative_button)
|
|
||||||
Button negativeButton;
|
|
||||||
Callback callback;//Implemented interface from shareActivity
|
Callback callback;//Implemented interface from shareActivity
|
||||||
Boolean gotResponse = false;
|
Boolean gotResponse = false;
|
||||||
|
|
||||||
|
private FragmentSimilarImageDialogBinding binding;
|
||||||
|
|
||||||
public SimilarImageDialogFragment() {
|
public SimilarImageDialogFragment() {
|
||||||
}
|
}
|
||||||
public interface Callback {
|
public interface Callback {
|
||||||
|
|
@ -51,17 +41,17 @@ public class SimilarImageDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_similar_image_dialog, container, false);
|
binding = FragmentSimilarImageDialogBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this,view);
|
|
||||||
|
|
||||||
originalImage.setHierarchy(GenericDraweeHierarchyBuilder
|
|
||||||
|
binding.orginalImage.setHierarchy(GenericDraweeHierarchyBuilder
|
||||||
.newInstance(getResources())
|
.newInstance(getResources())
|
||||||
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
||||||
R.drawable.ic_image_black_24dp,getContext().getTheme()))
|
R.drawable.ic_image_black_24dp,getContext().getTheme()))
|
||||||
.setFailureImage(VectorDrawableCompat.create(getResources(),
|
.setFailureImage(VectorDrawableCompat.create(getResources(),
|
||||||
R.drawable.ic_error_outline_black_24dp, getContext().getTheme()))
|
R.drawable.ic_error_outline_black_24dp, getContext().getTheme()))
|
||||||
.build());
|
.build());
|
||||||
possibleImage.setHierarchy(GenericDraweeHierarchyBuilder
|
binding.possibleImage.setHierarchy(GenericDraweeHierarchyBuilder
|
||||||
.newInstance(getResources())
|
.newInstance(getResources())
|
||||||
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
||||||
R.drawable.ic_image_black_24dp,getContext().getTheme()))
|
R.drawable.ic_image_black_24dp,getContext().getTheme()))
|
||||||
|
|
@ -69,10 +59,13 @@ public class SimilarImageDialogFragment extends DialogFragment {
|
||||||
R.drawable.ic_error_outline_black_24dp, getContext().getTheme()))
|
R.drawable.ic_error_outline_black_24dp, getContext().getTheme()))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
originalImage.setImageURI(Uri.fromFile(new File(getArguments().getString("originalImagePath"))));
|
binding.orginalImage.setImageURI(Uri.fromFile(new File(getArguments().getString("originalImagePath"))));
|
||||||
possibleImage.setImageURI(Uri.fromFile(new File(getArguments().getString("possibleImagePath"))));
|
binding.possibleImage.setImageURI(Uri.fromFile(new File(getArguments().getString("possibleImagePath"))));
|
||||||
|
|
||||||
return view;
|
binding.postiveButton.setOnClickListener(v -> onPositiveButtonClicked());
|
||||||
|
binding.negativeButton.setOnClickListener(v -> onNegativeButtonClicked());
|
||||||
|
|
||||||
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -96,17 +89,21 @@ public class SimilarImageDialogFragment extends DialogFragment {
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.negative_button)
|
|
||||||
public void onNegativeButtonClicked() {
|
public void onNegativeButtonClicked() {
|
||||||
callback.onNegativeResponse();
|
callback.onNegativeResponse();
|
||||||
gotResponse = true;
|
gotResponse = true;
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.postive_button)
|
|
||||||
public void onPositiveButtonClicked() {
|
public void onPositiveButtonClicked() {
|
||||||
callback.onPositiveResponse();
|
callback.onPositiveResponse();
|
||||||
gotResponse = true;
|
gotResponse = true;
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,16 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
import com.facebook.drawee.view.SimpleDraweeView;
|
||||||
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.databinding.ItemUploadThumbnailBinding;
|
||||||
|
import fr.free.nrw.commons.filepicker.UploadableFile;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.R;
|
|
||||||
import fr.free.nrw.commons.filepicker.UploadableFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The adapter class for image thumbnails to be shown while uploading.
|
* The adapter class for image thumbnails to be shown while uploading.
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,6 +28,8 @@ class ThumbnailsAdapter extends RecyclerView.Adapter<ThumbnailsAdapter.ViewHolde
|
||||||
List<UploadableFile> uploadableFiles;
|
List<UploadableFile> uploadableFiles;
|
||||||
private Callback callback;
|
private Callback callback;
|
||||||
|
|
||||||
|
private ItemUploadThumbnailBinding binding;
|
||||||
|
|
||||||
public ThumbnailsAdapter(Callback callback) {
|
public ThumbnailsAdapter(Callback callback) {
|
||||||
this.uploadableFiles = new ArrayList<>();
|
this.uploadableFiles = new ArrayList<>();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|
@ -51,8 +48,8 @@ class ThumbnailsAdapter extends RecyclerView.Adapter<ThumbnailsAdapter.ViewHolde
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||||
return new ViewHolder(LayoutInflater.from(viewGroup.getContext())
|
binding = ItemUploadThumbnailBinding.inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false);
|
||||||
.inflate(R.layout.item_upload_thumbnail, viewGroup, false));
|
return new ViewHolder(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -67,16 +64,16 @@ class ThumbnailsAdapter extends RecyclerView.Adapter<ThumbnailsAdapter.ViewHolde
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@BindView(R.id.rl_container)
|
|
||||||
RelativeLayout rlContainer;
|
RelativeLayout rlContainer;
|
||||||
@BindView(R.id.iv_thumbnail)
|
|
||||||
SimpleDraweeView background;
|
SimpleDraweeView background;
|
||||||
@BindView(R.id.iv_error)
|
|
||||||
ImageView ivError;
|
ImageView ivError;
|
||||||
|
|
||||||
public ViewHolder(@NonNull View itemView) {
|
public ViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
rlContainer = binding.rlContainer;
|
||||||
|
background = binding.ivThumbnail;
|
||||||
|
ivError = binding.ivError;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -21,28 +21,21 @@ import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.cardview.widget.CardView;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import androidx.work.ExistingWorkPolicy;
|
import androidx.work.ExistingWorkPolicy;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.auth.LoginActivity;
|
import fr.free.nrw.commons.auth.LoginActivity;
|
||||||
import fr.free.nrw.commons.auth.SessionManager;
|
import fr.free.nrw.commons.auth.SessionManager;
|
||||||
import fr.free.nrw.commons.contributions.ContributionController;
|
import fr.free.nrw.commons.contributions.ContributionController;
|
||||||
|
import fr.free.nrw.commons.databinding.ActivityUploadBinding;
|
||||||
import fr.free.nrw.commons.filepicker.Constants.RequestCodes;
|
import fr.free.nrw.commons.filepicker.Constants.RequestCodes;
|
||||||
import fr.free.nrw.commons.filepicker.UploadableFile;
|
import fr.free.nrw.commons.filepicker.UploadableFile;
|
||||||
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
import fr.free.nrw.commons.kvstore.BasicKvStore;
|
||||||
|
|
@ -93,28 +86,6 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
@Inject
|
@Inject
|
||||||
LocationServiceManager locationManager;
|
LocationServiceManager locationManager;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.cv_container_top_card)
|
|
||||||
CardView cvContainerTopCard;
|
|
||||||
|
|
||||||
@BindView(R.id.ll_container_top_card)
|
|
||||||
LinearLayout llContainerTopCard;
|
|
||||||
|
|
||||||
@BindView(R.id.rl_container_title)
|
|
||||||
RelativeLayout rlContainerTitle;
|
|
||||||
|
|
||||||
@BindView(R.id.tv_top_card_title)
|
|
||||||
TextView tvTopCardTitle;
|
|
||||||
|
|
||||||
@BindView(R.id.ib_toggle_top_card)
|
|
||||||
ImageButton ibToggleTopCard;
|
|
||||||
|
|
||||||
@BindView(R.id.rv_thumbnails)
|
|
||||||
RecyclerView rvThumbnails;
|
|
||||||
|
|
||||||
@BindView(R.id.vp_upload)
|
|
||||||
ViewPager vpUpload;
|
|
||||||
|
|
||||||
private boolean isTitleExpanded = true;
|
private boolean isTitleExpanded = true;
|
||||||
|
|
||||||
private CompositeDisposable compositeDisposable;
|
private CompositeDisposable compositeDisposable;
|
||||||
|
|
@ -169,12 +140,15 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
*/
|
*/
|
||||||
private boolean isFragmentsSaved = false;
|
private boolean isFragmentsSaved = false;
|
||||||
|
|
||||||
|
private ActivityUploadBinding binding;
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_upload);
|
binding = ActivityUploadBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If Configuration of device is changed then get the new fragments
|
If Configuration of device is changed then get the new fragments
|
||||||
|
|
@ -190,7 +164,6 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
compositeDisposable = new CompositeDisposable();
|
compositeDisposable = new CompositeDisposable();
|
||||||
init();
|
init();
|
||||||
nearbyPopupAnswers = new HashMap<>();
|
nearbyPopupAnswers = new HashMap<>();
|
||||||
|
|
@ -223,17 +196,17 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initThumbnailsRecyclerView() {
|
private void initThumbnailsRecyclerView() {
|
||||||
rvThumbnails.setLayoutManager(new LinearLayoutManager(this,
|
binding.rvThumbnails.setLayoutManager(new LinearLayoutManager(this,
|
||||||
LinearLayoutManager.HORIZONTAL, false));
|
LinearLayoutManager.HORIZONTAL, false));
|
||||||
thumbnailsAdapter = new ThumbnailsAdapter(() -> currentSelectedPosition);
|
thumbnailsAdapter = new ThumbnailsAdapter(() -> currentSelectedPosition);
|
||||||
rvThumbnails.setAdapter(thumbnailsAdapter);
|
binding.rvThumbnails.setAdapter(thumbnailsAdapter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViewPager() {
|
private void initViewPager() {
|
||||||
uploadImagesAdapter = new UploadImageAdapter(getSupportFragmentManager());
|
uploadImagesAdapter = new UploadImageAdapter(getSupportFragmentManager());
|
||||||
vpUpload.setAdapter(uploadImagesAdapter);
|
binding.vpUpload.setAdapter(uploadImagesAdapter);
|
||||||
vpUpload.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
binding.vpUpload.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset,
|
public void onPageScrolled(int position, float positionOffset,
|
||||||
int positionOffsetPixels) {
|
int positionOffsetPixels) {
|
||||||
|
|
@ -244,10 +217,10 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
currentSelectedPosition = position;
|
currentSelectedPosition = position;
|
||||||
if (position >= uploadableFiles.size()) {
|
if (position >= uploadableFiles.size()) {
|
||||||
cvContainerTopCard.setVisibility(View.GONE);
|
binding.cvContainerTopCard.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
thumbnailsAdapter.notifyDataSetChanged();
|
thumbnailsAdapter.notifyDataSetChanged();
|
||||||
cvContainerTopCard.setVisibility(View.VISIBLE);
|
binding.cvContainerTopCard.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -298,14 +271,14 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
if (hasAllPermissions) {
|
if (hasAllPermissions) {
|
||||||
// All required permissions are granted, so enable UI elements and perform actions
|
// All required permissions are granted, so enable UI elements and perform actions
|
||||||
receiveSharedItems();
|
receiveSharedItems();
|
||||||
cvContainerTopCard.setVisibility(View.VISIBLE);
|
binding.cvContainerTopCard.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
// Permissions are missing
|
// Permissions are missing
|
||||||
cvContainerTopCard.setVisibility(View.INVISIBLE);
|
binding.cvContainerTopCard.setVisibility(View.INVISIBLE);
|
||||||
if(showPermissionsDialog){
|
if(showPermissionsDialog){
|
||||||
checkPermissionsAndPerformAction(this,
|
checkPermissionsAndPerformAction(this,
|
||||||
() -> {
|
() -> {
|
||||||
cvContainerTopCard.setVisibility(View.VISIBLE);
|
binding.cvContainerTopCard.setVisibility(View.VISIBLE);
|
||||||
this.receiveSharedItems();
|
this.receiveSharedItems();
|
||||||
},() -> {
|
},() -> {
|
||||||
this.showPermissionsDialog = true;
|
this.showPermissionsDialog = true;
|
||||||
|
|
@ -379,7 +352,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showHideTopCard(boolean shouldShow) {
|
public void showHideTopCard(boolean shouldShow) {
|
||||||
llContainerTopCard.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
|
binding.llContainerTopCard.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -392,7 +365,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTopCardTitle() {
|
public void updateTopCardTitle() {
|
||||||
tvTopCardTitle.setText(getResources()
|
binding.tvTopCardTitle.setText(getResources()
|
||||||
.getQuantityString(R.plurals.upload_count_title, uploadableFiles.size(), uploadableFiles.size()));
|
.getQuantityString(R.plurals.upload_count_title, uploadableFiles.size(), uploadableFiles.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -475,9 +448,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
> 1) {//If there is only file, no need to show the image thumbnails
|
> 1) {//If there is only file, no need to show the image thumbnails
|
||||||
thumbnailsAdapter.setUploadableFiles(uploadableFiles);
|
thumbnailsAdapter.setUploadableFiles(uploadableFiles);
|
||||||
} else {
|
} else {
|
||||||
llContainerTopCard.setVisibility(View.GONE);
|
binding.llContainerTopCard.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
tvTopCardTitle.setText(getResources()
|
binding.tvTopCardTitle.setText(getResources()
|
||||||
.getQuantityString(R.plurals.upload_count_title, uploadableFiles.size(), uploadableFiles.size()));
|
.getQuantityString(R.plurals.upload_count_title, uploadableFiles.size(), uploadableFiles.size()));
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -568,7 +541,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
public void changeThumbnail(int index, String filepath) {
|
public void changeThumbnail(int index, String filepath) {
|
||||||
uploadableFiles.remove(index);
|
uploadableFiles.remove(index);
|
||||||
uploadableFiles.add(index, new UploadableFile(new File(filepath)));
|
uploadableFiles.add(index, new UploadableFile(new File(filepath)));
|
||||||
rvThumbnails.getAdapter().notifyDataSetChanged();
|
binding.rvThumbnails.getAdapter().notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -642,9 +615,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
@Override
|
@Override
|
||||||
public void onNextButtonClicked(int index) {
|
public void onNextButtonClicked(int index) {
|
||||||
if (index < fragments.size() - 1) {
|
if (index < fragments.size() - 1) {
|
||||||
vpUpload.setCurrentItem(index + 1, false);
|
binding.vpUpload.setCurrentItem(index + 1, false);
|
||||||
fragments.get(index + 1).onBecameVisible();
|
fragments.get(index + 1).onBecameVisible();
|
||||||
((LinearLayoutManager) rvThumbnails.getLayoutManager())
|
((LinearLayoutManager) binding.rvThumbnails.getLayoutManager())
|
||||||
.scrollToPositionWithOffset((index > 0) ? index-1 : 0, 0);
|
.scrollToPositionWithOffset((index > 0) ? index-1 : 0, 0);
|
||||||
} else {
|
} else {
|
||||||
presenter.handleSubmit();
|
presenter.handleSubmit();
|
||||||
|
|
@ -654,9 +627,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
@Override
|
@Override
|
||||||
public void onPreviousButtonClicked(int index) {
|
public void onPreviousButtonClicked(int index) {
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
vpUpload.setCurrentItem(index - 1, true);
|
binding.vpUpload.setCurrentItem(index - 1, true);
|
||||||
fragments.get(index - 1).onBecameVisible();
|
fragments.get(index - 1).onBecameVisible();
|
||||||
((LinearLayoutManager) rvThumbnails.getLayoutManager())
|
((LinearLayoutManager) binding.rvThumbnails.getLayoutManager())
|
||||||
.scrollToPositionWithOffset((index > 3) ? index-2 : 0, 0);
|
.scrollToPositionWithOffset((index > 3) ? index-2 : 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -691,7 +664,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadImagesAdapter.setFragments(fragments);
|
uploadImagesAdapter.setFragments(fragments);
|
||||||
vpUpload.setOffscreenPageLimit(fragments.size());
|
binding.vpUpload.setOffscreenPageLimit(fragments.size());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -719,9 +692,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void highlightNextImageOnCancelledImage(int index, int maxSize) {
|
public void highlightNextImageOnCancelledImage(int index, int maxSize) {
|
||||||
if (vpUpload != null && index < (maxSize)) {
|
if (binding.vpUpload != null && index < (maxSize)) {
|
||||||
vpUpload.setCurrentItem(index + 1, false);
|
binding.vpUpload.setCurrentItem(index + 1, false);
|
||||||
vpUpload.setCurrentItem(index, false);
|
binding.vpUpload.setCurrentItem(index, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -810,9 +783,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
@Override
|
@Override
|
||||||
public void onNextButtonClicked(int index) {
|
public void onNextButtonClicked(int index) {
|
||||||
if (index < fragments.size() - 1) {
|
if (index < fragments.size() - 1) {
|
||||||
vpUpload.setCurrentItem(index + 1, false);
|
binding.vpUpload.setCurrentItem(index + 1, false);
|
||||||
fragments.get(index + 1).onBecameVisible();
|
fragments.get(index + 1).onBecameVisible();
|
||||||
((LinearLayoutManager) rvThumbnails.getLayoutManager())
|
((LinearLayoutManager) binding.rvThumbnails.getLayoutManager())
|
||||||
.scrollToPositionWithOffset((index > 0) ? index-1 : 0, 0);
|
.scrollToPositionWithOffset((index > 0) ? index-1 : 0, 0);
|
||||||
} else {
|
} else {
|
||||||
presenter.handleSubmit();
|
presenter.handleSubmit();
|
||||||
|
|
@ -822,9 +795,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
@Override
|
@Override
|
||||||
public void onPreviousButtonClicked(int index) {
|
public void onPreviousButtonClicked(int index) {
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
vpUpload.setCurrentItem(index - 1, true);
|
binding.vpUpload.setCurrentItem(index - 1, true);
|
||||||
fragments.get(index - 1).onBecameVisible();
|
fragments.get(index - 1).onBecameVisible();
|
||||||
((LinearLayoutManager) rvThumbnails.getLayoutManager())
|
((LinearLayoutManager) binding.rvThumbnails.getLayoutManager())
|
||||||
.scrollToPositionWithOffset((index > 3) ? index-2 : 0, 0);
|
.scrollToPositionWithOffset((index > 3) ? index-2 : 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -866,9 +839,9 @@ public class UploadActivity extends BaseActivity implements UploadContract.View,
|
||||||
|
|
||||||
@OnClick(R.id.rl_container_title)
|
@OnClick(R.id.rl_container_title)
|
||||||
public void onRlContainerTitleClicked() {
|
public void onRlContainerTitleClicked() {
|
||||||
rvThumbnails.setVisibility(isTitleExpanded ? View.GONE : View.VISIBLE);
|
binding.rvThumbnails.setVisibility(isTitleExpanded ? View.GONE : View.VISIBLE);
|
||||||
isTitleExpanded = !isTitleExpanded;
|
isTitleExpanded = !isTitleExpanded;
|
||||||
ibToggleTopCard.setRotation(ibToggleTopCard.getRotation() + 180);
|
binding.ibToggleTopCard.setRotation(binding.ibToggleTopCard.getRotation() + 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
package fr.free.nrw.commons.upload;
|
package fr.free.nrw.commons.upload;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,9 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.databinding.RowItemDescriptionBinding;
|
||||||
import fr.free.nrw.commons.recentlanguages.Language;
|
import fr.free.nrw.commons.recentlanguages.Language;
|
||||||
import fr.free.nrw.commons.recentlanguages.RecentLanguagesAdapter;
|
import fr.free.nrw.commons.recentlanguages.RecentLanguagesAdapter;
|
||||||
import fr.free.nrw.commons.recentlanguages.RecentLanguagesDao;
|
import fr.free.nrw.commons.recentlanguages.RecentLanguagesDao;
|
||||||
|
|
@ -61,6 +60,8 @@ public class UploadMediaDetailAdapter extends
|
||||||
private SelectedVoiceIcon selectedVoiceIcon;
|
private SelectedVoiceIcon selectedVoiceIcon;
|
||||||
private static final int REQUEST_CODE_FOR_VOICE_INPUT = 1213;
|
private static final int REQUEST_CODE_FOR_VOICE_INPUT = 1213;
|
||||||
|
|
||||||
|
private RowItemDescriptionBinding binding;
|
||||||
|
|
||||||
public UploadMediaDetailAdapter(Fragment fragment, String savedLanguageValue,
|
public UploadMediaDetailAdapter(Fragment fragment, String savedLanguageValue,
|
||||||
RecentLanguagesDao recentLanguagesDao) {
|
RecentLanguagesDao recentLanguagesDao) {
|
||||||
uploadMediaDetails = new ArrayList<>();
|
uploadMediaDetails = new ArrayList<>();
|
||||||
|
|
@ -100,8 +101,9 @@ public class UploadMediaDetailAdapter extends
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
return new ViewHolder(LayoutInflater.from(parent.getContext())
|
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||||
.inflate(R.layout.row_item_description, parent, false));
|
binding = RowItemDescriptionBinding.inflate(inflater, parent, false);
|
||||||
|
return new ViewHolder(binding.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -203,44 +205,34 @@ public class UploadMediaDetailAdapter extends
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@Nullable
|
TextView descriptionLanguages ;
|
||||||
@BindView(R.id.description_languages)
|
|
||||||
TextView descriptionLanguages;
|
|
||||||
|
|
||||||
@BindView(R.id.description_item_edit_text)
|
|
||||||
PasteSensitiveTextInputEditText descItemEditText;
|
PasteSensitiveTextInputEditText descItemEditText;
|
||||||
|
|
||||||
@BindView(R.id.description_item_edit_text_input_layout)
|
|
||||||
TextInputLayout descInputLayout;
|
TextInputLayout descInputLayout;
|
||||||
|
|
||||||
@BindView(R.id.caption_item_edit_text)
|
|
||||||
PasteSensitiveTextInputEditText captionItemEditText;
|
PasteSensitiveTextInputEditText captionItemEditText;
|
||||||
|
|
||||||
@BindView(R.id.caption_item_edit_text_input_layout)
|
|
||||||
TextInputLayout captionInputLayout;
|
TextInputLayout captionInputLayout;
|
||||||
|
|
||||||
@BindView(R.id.btn_remove)
|
|
||||||
ImageView removeButton;
|
ImageView removeButton;
|
||||||
|
|
||||||
@BindView(R.id.btn_add)
|
|
||||||
ImageView addButton;
|
ImageView addButton;
|
||||||
|
|
||||||
@BindView(R.id.cl_parent)
|
|
||||||
ConstraintLayout clParent;
|
ConstraintLayout clParent;
|
||||||
|
|
||||||
@BindView(R.id.ll_write_better_caption)
|
|
||||||
LinearLayout betterCaptionLinearLayout;
|
LinearLayout betterCaptionLinearLayout;
|
||||||
|
|
||||||
@BindView(R.id.ll_write_better_description)
|
|
||||||
LinearLayout betterDescriptionLinearLayout;
|
LinearLayout betterDescriptionLinearLayout;
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
AbstractTextWatcher captionListener;
|
AbstractTextWatcher captionListener;
|
||||||
|
|
||||||
AbstractTextWatcher descriptionListener;
|
AbstractTextWatcher descriptionListener;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
|
||||||
Timber.i("descItemEditText:" + descItemEditText);
|
Timber.i("descItemEditText:" + descItemEditText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,6 +240,18 @@ public class UploadMediaDetailAdapter extends
|
||||||
UploadMediaDetail uploadMediaDetail = uploadMediaDetails.get(position);
|
UploadMediaDetail uploadMediaDetail = uploadMediaDetails.get(position);
|
||||||
Timber.d("UploadMediaDetail is " + uploadMediaDetail);
|
Timber.d("UploadMediaDetail is " + uploadMediaDetail);
|
||||||
|
|
||||||
|
descriptionLanguages = binding.descriptionLanguages;
|
||||||
|
descItemEditText = binding.descriptionItemEditText;
|
||||||
|
descInputLayout = binding.descriptionItemEditTextInputLayout;
|
||||||
|
captionItemEditText = binding.captionItemEditText;
|
||||||
|
captionInputLayout = binding.captionItemEditTextInputLayout;
|
||||||
|
removeButton = binding.btnRemove;
|
||||||
|
addButton = binding.btnAdd;
|
||||||
|
clParent = binding.clParent;
|
||||||
|
betterCaptionLinearLayout = binding.llWriteBetterCaption;
|
||||||
|
betterDescriptionLinearLayout = binding.llWriteBetterDescription;
|
||||||
|
|
||||||
|
|
||||||
descriptionLanguages.setFocusable(false);
|
descriptionLanguages.setFocusable(false);
|
||||||
captionItemEditText.addTextChangedListener(new AbstractTextWatcher(
|
captionItemEditText.addTextChangedListener(new AbstractTextWatcher(
|
||||||
value -> {
|
value -> {
|
||||||
|
|
@ -495,7 +499,9 @@ public class UploadMediaDetailAdapter extends
|
||||||
((RecentLanguagesAdapter) adapterView
|
((RecentLanguagesAdapter) adapterView
|
||||||
.getAdapter()).setSelectedLangCode(languageCode);
|
.getAdapter()).setSelectedLangCode(languageCode);
|
||||||
Timber.d("Description language code is: %s", languageCode);
|
Timber.d("Description language code is: %s", languageCode);
|
||||||
descriptionLanguages.setText(languageCode);
|
if (descriptionLanguages!=null) {
|
||||||
|
descriptionLanguages.setText(languageCode);
|
||||||
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -528,12 +534,15 @@ public class UploadMediaDetailAdapter extends
|
||||||
languageHistoryListView.setVisibility(View.VISIBLE);
|
languageHistoryListView.setVisibility(View.VISIBLE);
|
||||||
recentLanguagesTextView.setVisibility(View.VISIBLE);
|
recentLanguagesTextView.setVisibility(View.VISIBLE);
|
||||||
separator.setVisibility(View.VISIBLE);
|
separator.setVisibility(View.VISIBLE);
|
||||||
final RecentLanguagesAdapter recentLanguagesAdapter
|
|
||||||
= new RecentLanguagesAdapter(
|
if (descriptionLanguages!=null) {
|
||||||
descriptionLanguages.getContext(),
|
final RecentLanguagesAdapter recentLanguagesAdapter
|
||||||
recentLanguagesDao.getRecentLanguages(),
|
= new RecentLanguagesAdapter(
|
||||||
selectedLanguages);
|
descriptionLanguages.getContext(),
|
||||||
languageHistoryListView.setAdapter(recentLanguagesAdapter);
|
recentLanguagesDao.getRecentLanguages(),
|
||||||
|
selectedLanguages);
|
||||||
|
languageHistoryListView.setAdapter(recentLanguagesAdapter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,8 +201,9 @@ class CategoriesPresenter @Inject constructor(
|
||||||
* @param wikiText current WikiText from server
|
* @param wikiText current WikiText from server
|
||||||
*/
|
*/
|
||||||
override fun updateCategories(media: Media, wikiText: String) {
|
override fun updateCategories(media: Media, wikiText: String) {
|
||||||
|
//check if view.existingCategories is null
|
||||||
if (repository.selectedCategories.isNotEmpty()
|
if (repository.selectedCategories.isNotEmpty()
|
||||||
|| repository.selectedExistingCategories.size != view.existingCategories.size
|
|| (view.existingCategories != null && repository.selectedExistingCategories.size != view.existingCategories.size)
|
||||||
) {
|
) {
|
||||||
val selectedCategories: MutableList<String> =
|
val selectedCategories: MutableList<String> =
|
||||||
(repository.selectedCategories.map { it.name }.toMutableList()
|
(repository.selectedCategories.map { it.name }.toMutableList()
|
||||||
|
|
|
||||||
|
|
@ -12,28 +12,19 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
|
||||||
import com.jakewharton.rxbinding2.view.RxView;
|
import com.jakewharton.rxbinding2.view.RxView;
|
||||||
import com.jakewharton.rxbinding2.widget.RxTextView;
|
import com.jakewharton.rxbinding2.widget.RxTextView;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.category.CategoryItem;
|
import fr.free.nrw.commons.category.CategoryItem;
|
||||||
import fr.free.nrw.commons.contributions.ContributionsFragment;
|
import fr.free.nrw.commons.contributions.ContributionsFragment;
|
||||||
|
import fr.free.nrw.commons.databinding.UploadCategoriesFragmentBinding;
|
||||||
import fr.free.nrw.commons.media.MediaDetailFragment;
|
import fr.free.nrw.commons.media.MediaDetailFragment;
|
||||||
import fr.free.nrw.commons.ui.PasteSensitiveTextInputEditText;
|
|
||||||
import fr.free.nrw.commons.upload.UploadActivity;
|
import fr.free.nrw.commons.upload.UploadActivity;
|
||||||
import fr.free.nrw.commons.upload.UploadBaseFragment;
|
import fr.free.nrw.commons.upload.UploadBaseFragment;
|
||||||
import fr.free.nrw.commons.utils.DialogUtil;
|
import fr.free.nrw.commons.utils.DialogUtil;
|
||||||
|
|
@ -48,25 +39,6 @@ import timber.log.Timber;
|
||||||
|
|
||||||
public class UploadCategoriesFragment extends UploadBaseFragment implements CategoriesContract.View {
|
public class UploadCategoriesFragment extends UploadBaseFragment implements CategoriesContract.View {
|
||||||
|
|
||||||
@BindView(R.id.tv_title)
|
|
||||||
TextView tvTitle;
|
|
||||||
@BindView(R.id.tv_subtitle)
|
|
||||||
TextView tvSubTitle;
|
|
||||||
@BindView(R.id.til_container_search)
|
|
||||||
TextInputLayout tilContainerEtSearch;
|
|
||||||
@BindView(R.id.et_search)
|
|
||||||
PasteSensitiveTextInputEditText etSearch;
|
|
||||||
@BindView(R.id.pb_categories)
|
|
||||||
ProgressBar pbCategories;
|
|
||||||
@BindView(R.id.rv_categories)
|
|
||||||
RecyclerView rvCategories;
|
|
||||||
@BindView(R.id.tooltip)
|
|
||||||
ImageView tooltip;
|
|
||||||
@BindView(R.id.btn_next)
|
|
||||||
Button btnNext;
|
|
||||||
@BindView(R.id.btn_previous)
|
|
||||||
Button btnPrevious;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CategoriesContract.UserActionListener presenter;
|
CategoriesContract.UserActionListener presenter;
|
||||||
private UploadCategoryAdapter adapter;
|
private UploadCategoryAdapter adapter;
|
||||||
|
|
@ -85,17 +57,19 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
private String wikiText;
|
private String wikiText;
|
||||||
private String nearbyPlaceCategory;
|
private String nearbyPlaceCategory;
|
||||||
|
|
||||||
|
private UploadCategoriesFragmentBinding binding;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.upload_categories_fragment, container, false);
|
binding = UploadCategoriesFragmentBinding.inflate(inflater, container, false);
|
||||||
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
final Bundle bundle = getArguments();
|
final Bundle bundle = getArguments();
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
media = bundle.getParcelable("Existing_Categories");
|
media = bundle.getParcelable("Existing_Categories");
|
||||||
|
|
@ -108,20 +82,23 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (media == null) {
|
if (media == null) {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
tvTitle.setText(getString(R.string.step_count, callback.getIndexInViewFlipper(this) + 1,
|
binding.tvTitle.setText(getString(R.string.step_count, callback.getIndexInViewFlipper(this) + 1,
|
||||||
callback.getTotalNumberOfSteps(), getString(R.string.categories_activity_title)));
|
callback.getTotalNumberOfSteps(), getString(R.string.categories_activity_title)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tvTitle.setText(R.string.edit_categories);
|
binding.tvTitle.setText(R.string.edit_categories);
|
||||||
tvSubTitle.setVisibility(View.GONE);
|
binding.tvSubtitle.setVisibility(View.GONE);
|
||||||
btnNext.setText(R.string.menu_save_categories);
|
binding.btnNext.setText(R.string.menu_save_categories);
|
||||||
btnPrevious.setText(R.string.menu_cancel_upload);
|
binding.btnPrevious.setText(R.string.menu_cancel_upload);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTvSubTitle();
|
setTvSubTitle();
|
||||||
tooltip.setOnClickListener(new OnClickListener() {
|
binding.tooltip.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
DialogUtil.showAlertDialog(getActivity(), getString(R.string.categories_activity_title), getString(R.string.categories_tooltip), getString(android.R.string.ok), null, true);
|
DialogUtil.showAlertDialog(getActivity(), getString(R.string.categories_activity_title), getString(R.string.categories_tooltip), getString(android.R.string.ok), null, true);
|
||||||
|
|
@ -132,14 +109,20 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
} else {
|
} else {
|
||||||
presenter.onAttachViewWithMedia(this, media);
|
presenter.onAttachViewWithMedia(this, media);
|
||||||
}
|
}
|
||||||
|
binding.btnNext.setOnClickListener(v -> onNextButtonClicked());
|
||||||
|
binding.btnPrevious.setOnClickListener(v -> onPreviousButtonClicked());
|
||||||
|
|
||||||
initRecyclerView();
|
initRecyclerView();
|
||||||
addTextChangeListenerToEtSearch();
|
addTextChangeListenerToEtSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTextChangeListenerToEtSearch() {
|
private void addTextChangeListenerToEtSearch() {
|
||||||
subscribe = RxTextView.textChanges(etSearch)
|
if (binding == null) {
|
||||||
.doOnEach(v -> tilContainerEtSearch.setError(null))
|
return;
|
||||||
.takeUntil(RxView.detaches(etSearch))
|
}
|
||||||
|
subscribe = RxTextView.textChanges(binding.etSearch)
|
||||||
|
.doOnEach(v -> binding.tilContainerSearch.setError(null))
|
||||||
|
.takeUntil(RxView.detaches(binding.etSearch))
|
||||||
.debounce(500, TimeUnit.MILLISECONDS)
|
.debounce(500, TimeUnit.MILLISECONDS)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(filter -> searchForCategory(filter.toString()), Timber::e);
|
.subscribe(filter -> searchForCategory(filter.toString()), Timber::e);
|
||||||
|
|
@ -154,7 +137,7 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
if (activity instanceof UploadActivity) {
|
if (activity instanceof UploadActivity) {
|
||||||
final boolean isMultipleFileSelected = ((UploadActivity) activity).getIsMultipleFilesSelected();
|
final boolean isMultipleFileSelected = ((UploadActivity) activity).getIsMultipleFilesSelected();
|
||||||
if (!isMultipleFileSelected) {
|
if (!isMultipleFileSelected) {
|
||||||
tvSubTitle.setVisibility(View.GONE);
|
binding.tvSubtitle.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -168,8 +151,11 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
presenter.onCategoryItemClicked(categoryItem);
|
presenter.onCategoryItemClicked(categoryItem);
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
}, nearbyPlaceCategory);
|
}, nearbyPlaceCategory);
|
||||||
rvCategories.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
||||||
rvCategories.setAdapter(adapter);
|
if (binding!=null) {
|
||||||
|
binding.rvCategories.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
binding.rvCategories.setAdapter(adapter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -181,17 +167,23 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showProgress(boolean shouldShow) {
|
public void showProgress(boolean shouldShow) {
|
||||||
pbCategories.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
|
if (binding != null) {
|
||||||
|
binding.pbCategories.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showError(String error) {
|
public void showError(String error) {
|
||||||
tilContainerEtSearch.setError(error);
|
if (binding != null) {
|
||||||
|
binding.tilContainerSearch.setError(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showError(int stringResourceId) {
|
public void showError(int stringResourceId) {
|
||||||
tilContainerEtSearch.setError(getString(stringResourceId));
|
if (binding != null) {
|
||||||
|
binding.tilContainerSearch.setError(getString(stringResourceId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -203,16 +195,20 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
}
|
}
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
|
||||||
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Nested waiting for search result data to load into the category
|
// Nested waiting for search result data to load into the category
|
||||||
// list and smoothly scroll to the top of the search result list.
|
// list and smoothly scroll to the top of the search result list.
|
||||||
rvCategories.post(new Runnable() {
|
binding.rvCategories.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
rvCategories.smoothScrollToPosition(0);
|
binding.rvCategories.smoothScrollToPosition(0);
|
||||||
rvCategories.post(new Runnable() {
|
binding.rvCategories.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
rvCategories.smoothScrollToPosition(0);
|
binding.rvCategories.smoothScrollToPosition(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -284,7 +280,9 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void dismissProgressDialog() {
|
public void dismissProgressDialog() {
|
||||||
progressDialog.dismiss();
|
if (progressDialog != null) {
|
||||||
|
progressDialog.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -297,7 +295,6 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
mediaDetailFragment.updateCategories();
|
mediaDetailFragment.updateCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btn_next)
|
|
||||||
public void onNextButtonClicked() {
|
public void onNextButtonClicked() {
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
presenter.updateCategories(media, wikiText);
|
presenter.updateCategories(media, wikiText);
|
||||||
|
|
@ -306,7 +303,6 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btn_previous)
|
|
||||||
public void onPreviousButtonClicked() {
|
public void onPreviousButtonClicked() {
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
presenter.clearPreviousSelection();
|
presenter.clearPreviousSelection();
|
||||||
|
|
@ -325,8 +321,11 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
@Override
|
@Override
|
||||||
protected void onBecameVisible() {
|
protected void onBecameVisible() {
|
||||||
super.onBecameVisible();
|
super.onBecameVisible();
|
||||||
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
presenter.selectCategories();
|
presenter.selectCategories();
|
||||||
final Editable text = etSearch.getText();
|
final Editable text = binding.etSearch.getText();
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
presenter.searchForCategories(text.toString());
|
presenter.searchForCategories(text.toString());
|
||||||
}
|
}
|
||||||
|
|
@ -340,9 +339,9 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
etSearch.setOnKeyListener((v, keyCode, event) -> {
|
binding.etSearch.setOnKeyListener((v, keyCode, event) -> {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
etSearch.clearFocus();
|
binding.etSearch.clearFocus();
|
||||||
presenter.clearPreviousSelection();
|
presenter.clearPreviousSelection();
|
||||||
final MediaDetailFragment mediaDetailFragment = (MediaDetailFragment) getParentFragment();
|
final MediaDetailFragment mediaDetailFragment = (MediaDetailFragment) getParentFragment();
|
||||||
assert mediaDetailFragment != null;
|
assert mediaDetailFragment != null;
|
||||||
|
|
@ -374,7 +373,7 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
if (getParentFragment().getParentFragment().getParentFragment()
|
if (getParentFragment().getParentFragment().getParentFragment()
|
||||||
instanceof ContributionsFragment) {
|
instanceof ContributionsFragment) {
|
||||||
((ContributionsFragment) (getParentFragment()
|
((ContributionsFragment) (getParentFragment()
|
||||||
.getParentFragment().getParentFragment())).nearbyNotificationCardView
|
.getParentFragment().getParentFragment())).binding.cardViewNearby
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -392,4 +391,10 @@ public class UploadCategoriesFragment extends UploadBaseFragment implements Cate
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,29 +10,20 @@ import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import com.google.android.material.textfield.TextInputLayout;
|
|
||||||
import com.jakewharton.rxbinding2.view.RxView;
|
import com.jakewharton.rxbinding2.view.RxView;
|
||||||
import com.jakewharton.rxbinding2.widget.RxTextView;
|
import com.jakewharton.rxbinding2.widget.RxTextView;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.contributions.ContributionsFragment;
|
import fr.free.nrw.commons.contributions.ContributionsFragment;
|
||||||
|
import fr.free.nrw.commons.databinding.UploadDepictsFragmentBinding;
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
import fr.free.nrw.commons.media.MediaDetailFragment;
|
import fr.free.nrw.commons.media.MediaDetailFragment;
|
||||||
import fr.free.nrw.commons.nearby.Place;
|
import fr.free.nrw.commons.nearby.Place;
|
||||||
import fr.free.nrw.commons.ui.PasteSensitiveTextInputEditText;
|
|
||||||
import fr.free.nrw.commons.upload.UploadActivity;
|
import fr.free.nrw.commons.upload.UploadActivity;
|
||||||
import fr.free.nrw.commons.upload.UploadBaseFragment;
|
import fr.free.nrw.commons.upload.UploadBaseFragment;
|
||||||
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem;
|
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem;
|
||||||
|
|
@ -53,24 +44,6 @@ import timber.log.Timber;
|
||||||
*/
|
*/
|
||||||
public class DepictsFragment extends UploadBaseFragment implements DepictsContract.View {
|
public class DepictsFragment extends UploadBaseFragment implements DepictsContract.View {
|
||||||
|
|
||||||
@BindView(R.id.depicts_title)
|
|
||||||
TextView depictsTitle;
|
|
||||||
@BindView(R.id.depicts_subtitle)
|
|
||||||
TextView depictsSubTitle;
|
|
||||||
@BindView(R.id.depicts_search_container)
|
|
||||||
TextInputLayout depictsSearchContainer;
|
|
||||||
@BindView(R.id.depicts_search)
|
|
||||||
PasteSensitiveTextInputEditText depictsSearch;
|
|
||||||
@BindView(R.id.depictsSearchInProgress)
|
|
||||||
ProgressBar depictsSearchInProgress;
|
|
||||||
@BindView(R.id.depicts_recycler_view)
|
|
||||||
RecyclerView depictsRecyclerView;
|
|
||||||
@BindView(R.id.tooltip)
|
|
||||||
ImageView tooltip;
|
|
||||||
@BindView(R.id.depicts_next)
|
|
||||||
Button btnNext;
|
|
||||||
@BindView(R.id.depicts_previous)
|
|
||||||
Button btnPrevious;
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default_preferences")
|
@Named("default_preferences")
|
||||||
public
|
public
|
||||||
|
|
@ -88,18 +61,20 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
private int count;
|
private int count;
|
||||||
private Place nearbyPlace;
|
private Place nearbyPlace;
|
||||||
|
|
||||||
|
private UploadDepictsFragmentBinding binding;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public android.view.View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public android.view.View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.upload_depicts_fragment, container, false);
|
binding = UploadDepictsFragmentBinding.inflate(inflater, container, false);
|
||||||
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull android.view.View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull android.view.View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
media = bundle.getParcelable("Existing_Depicts");
|
media = bundle.getParcelable("Existing_Depicts");
|
||||||
|
|
@ -117,18 +92,22 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
*/
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (media == null) {
|
if (media == null) {
|
||||||
depictsTitle.setText(String.format(getString(R.string.step_count), callback.getIndexInViewFlipper(this) + 1,
|
binding.depictsTitle.setText(String.format(getString(R.string.step_count), callback.getIndexInViewFlipper(this) + 1,
|
||||||
callback.getTotalNumberOfSteps(), getString(R.string.depicts_step_title)));
|
callback.getTotalNumberOfSteps(), getString(R.string.depicts_step_title)));
|
||||||
} else {
|
} else {
|
||||||
depictsTitle.setText(R.string.edit_depictions);
|
binding.depictsTitle.setText(R.string.edit_depictions);
|
||||||
depictsSubTitle.setVisibility(View.GONE);
|
binding.depictsSubtitle.setVisibility(View.GONE);
|
||||||
btnNext.setText(R.string.menu_save_categories);
|
binding.depictsNext.setText(R.string.menu_save_categories);
|
||||||
btnPrevious.setText(R.string.menu_cancel_upload);
|
binding.depictsPrevious.setText(R.string.menu_cancel_upload);
|
||||||
}
|
}
|
||||||
|
|
||||||
setDepictsSubTitle();
|
setDepictsSubTitle();
|
||||||
tooltip.setOnClickListener(v -> DialogUtil
|
binding.tooltip.setOnClickListener(v -> DialogUtil
|
||||||
.showAlertDialog(getActivity(), getString(R.string.depicts_step_title),
|
.showAlertDialog(getActivity(), getString(R.string.depicts_step_title),
|
||||||
getString(R.string.depicts_tooltip), getString(android.R.string.ok), null, true));
|
getString(R.string.depicts_tooltip), getString(android.R.string.ok), null, true));
|
||||||
if (media == null) {
|
if (media == null) {
|
||||||
|
|
@ -138,6 +117,9 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
}
|
}
|
||||||
initRecyclerView();
|
initRecyclerView();
|
||||||
addTextChangeListenerToSearchBox();
|
addTextChangeListenerToSearchBox();
|
||||||
|
|
||||||
|
binding.depictsNext.setOnClickListener(v->onNextButtonClicked());
|
||||||
|
binding.depictsPrevious.setOnClickListener(v->onPreviousButtonClicked());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -149,7 +131,7 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
if (activity instanceof UploadActivity) {
|
if (activity instanceof UploadActivity) {
|
||||||
final boolean isMultipleFileSelected = ((UploadActivity) activity).getIsMultipleFilesSelected();
|
final boolean isMultipleFileSelected = ((UploadActivity) activity).getIsMultipleFilesSelected();
|
||||||
if (!isMultipleFileSelected) {
|
if (!isMultipleFileSelected) {
|
||||||
depictsSubTitle.setVisibility(View.GONE);
|
binding.depictsSubtitle.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -169,8 +151,11 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
}, nearbyPlace);
|
}, nearbyPlace);
|
||||||
}
|
}
|
||||||
depictsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
if (binding == null) {
|
||||||
depictsRecyclerView.setAdapter(adapter);
|
return;
|
||||||
|
}
|
||||||
|
binding.depictsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
|
binding.depictsRecyclerView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -221,15 +206,21 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showProgress(boolean shouldShow) {
|
public void showProgress(boolean shouldShow) {
|
||||||
depictsSearchInProgress.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
binding.depictsSearchInProgress.setVisibility(shouldShow ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showError(Boolean value) {
|
public void showError(Boolean value) {
|
||||||
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
depictsSearchContainer.setError(getString(R.string.no_depiction_found));
|
binding.depictsSearchContainer.setError(getString(R.string.no_depiction_found));
|
||||||
} else {
|
} else {
|
||||||
depictsSearchContainer.setErrorEnabled(false);
|
binding.depictsSearchContainer.setErrorEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,16 +240,19 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Nested waiting for search result data to load into the depicted item
|
// Nested waiting for search result data to load into the depicted item
|
||||||
// list and smoothly scroll to the top of the search result list.
|
// list and smoothly scroll to the top of the search result list.
|
||||||
depictsRecyclerView.post(new Runnable() {
|
binding.depictsRecyclerView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
depictsRecyclerView.smoothScrollToPosition(0);
|
binding.depictsRecyclerView.smoothScrollToPosition(0);
|
||||||
depictsRecyclerView.post(new Runnable() {
|
binding.depictsRecyclerView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
depictsRecyclerView.smoothScrollToPosition(0);
|
binding.depictsRecyclerView.smoothScrollToPosition(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +314,6 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
/**
|
/**
|
||||||
* Determines the calling fragment by media nullability and act accordingly
|
* Determines the calling fragment by media nullability and act accordingly
|
||||||
*/
|
*/
|
||||||
@OnClick(R.id.depicts_next)
|
|
||||||
public void onNextButtonClicked() {
|
public void onNextButtonClicked() {
|
||||||
if(media != null){
|
if(media != null){
|
||||||
presenter.updateDepictions(media);
|
presenter.updateDepictions(media);
|
||||||
|
|
@ -332,7 +325,6 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
/**
|
/**
|
||||||
* Determines the calling fragment by media nullability and act accordingly
|
* Determines the calling fragment by media nullability and act accordingly
|
||||||
*/
|
*/
|
||||||
@OnClick(R.id.depicts_previous)
|
|
||||||
public void onPreviousButtonClicked() {
|
public void onPreviousButtonClicked() {
|
||||||
if(media != null){
|
if(media != null){
|
||||||
presenter.clearPreviousSelection();
|
presenter.clearPreviousSelection();
|
||||||
|
|
@ -347,9 +339,9 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
* Text change listener for the edit text view of depicts
|
* Text change listener for the edit text view of depicts
|
||||||
*/
|
*/
|
||||||
private void addTextChangeListenerToSearchBox() {
|
private void addTextChangeListenerToSearchBox() {
|
||||||
subscribe = RxTextView.textChanges(depictsSearch)
|
subscribe = RxTextView.textChanges(binding.depictsSearch)
|
||||||
.doOnEach(v -> depictsSearchContainer.setError(null))
|
.doOnEach(v -> binding.depictsSearchContainer.setError(null))
|
||||||
.takeUntil(RxView.detaches(depictsSearch))
|
.takeUntil(RxView.detaches(binding.depictsSearch))
|
||||||
.debounce(500, TimeUnit.MILLISECONDS)
|
.debounce(500, TimeUnit.MILLISECONDS)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(filter -> searchForDepictions(filter.toString()), Timber::e);
|
.subscribe(filter -> searchForDepictions(filter.toString()), Timber::e);
|
||||||
|
|
@ -374,9 +366,9 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
depictsSearch.setOnKeyListener((v, keyCode, event) -> {
|
binding.depictsSearch.setOnKeyListener((v, keyCode, event) -> {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
depictsSearch.clearFocus();
|
binding.depictsSearch.clearFocus();
|
||||||
presenter.clearPreviousSelection();
|
presenter.clearPreviousSelection();
|
||||||
updateDepicts();
|
updateDepicts();
|
||||||
goBackToPreviousScreen();
|
goBackToPreviousScreen();
|
||||||
|
|
@ -404,7 +396,7 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
if (getParentFragment().getParentFragment().getParentFragment()
|
if (getParentFragment().getParentFragment().getParentFragment()
|
||||||
instanceof ContributionsFragment) {
|
instanceof ContributionsFragment) {
|
||||||
((ContributionsFragment) (getParentFragment()
|
((ContributionsFragment) (getParentFragment()
|
||||||
.getParentFragment().getParentFragment())).nearbyNotificationCardView
|
.getParentFragment().getParentFragment())).binding.cardViewNearby
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -422,4 +414,10 @@ public class DepictsFragment extends UploadBaseFragment implements DepictsContra
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,14 @@ import android.text.style.ClickableSpan;
|
||||||
import android.text.style.URLSpan;
|
import android.text.style.URLSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
@ -21,10 +25,18 @@ import androidx.annotation.Nullable;
|
||||||
import fr.free.nrw.commons.databinding.FragmentMediaLicenseBinding;
|
import fr.free.nrw.commons.databinding.FragmentMediaLicenseBinding;
|
||||||
import fr.free.nrw.commons.upload.UploadActivity;
|
import fr.free.nrw.commons.upload.UploadActivity;
|
||||||
import fr.free.nrw.commons.utils.DialogUtil;
|
import fr.free.nrw.commons.utils.DialogUtil;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentMediaLicenseBinding;
|
||||||
|
import fr.free.nrw.commons.upload.UploadActivity;
|
||||||
import fr.free.nrw.commons.upload.UploadBaseFragment;
|
import fr.free.nrw.commons.upload.UploadBaseFragment;
|
||||||
|
import fr.free.nrw.commons.utils.DialogUtil;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ import static fr.free.nrw.commons.utils.ImageUtils.getErrorMessageForResult;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.speech.RecognizerIntent;
|
import android.speech.RecognizerIntent;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
|
@ -16,25 +18,16 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.AppCompatButton;
|
|
||||||
import androidx.appcompat.widget.AppCompatImageButton;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
import com.github.chrisbanes.photoview.PhotoView;
|
|
||||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||||
import fr.free.nrw.commons.LocationPicker.LocationPicker;
|
import fr.free.nrw.commons.LocationPicker.LocationPicker;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.edit.EditActivity;
|
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentUploadMediaDetailFragmentBinding;
|
||||||
|
import fr.free.nrw.commons.edit.EditActivity;
|
||||||
import fr.free.nrw.commons.filepicker.UploadableFile;
|
import fr.free.nrw.commons.filepicker.UploadableFile;
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||||
import fr.free.nrw.commons.location.LatLng;
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
|
|
@ -60,7 +53,6 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
UploadMediaDetailsContract.View, UploadMediaDetailAdapter.EventListener {
|
UploadMediaDetailsContract.View, UploadMediaDetailAdapter.EventListener {
|
||||||
|
|
@ -85,34 +77,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
public static final String UPLOADABLE_FILE = "uploadable_file";
|
public static final String UPLOADABLE_FILE = "uploadable_file";
|
||||||
|
|
||||||
public static final String UPLOAD_MEDIA_DETAILS = "upload_media_detail_adapter";
|
public static final String UPLOAD_MEDIA_DETAILS = "upload_media_detail_adapter";
|
||||||
@BindView(R.id.tv_title)
|
|
||||||
TextView tvTitle;
|
|
||||||
@BindView(R.id.location_image_view)
|
|
||||||
ImageView locationImageView;
|
|
||||||
@BindView(R.id.location_text_view)
|
|
||||||
TextView locationTextView;
|
|
||||||
@BindView(R.id.ll_location_status)
|
|
||||||
LinearLayout llLocationStatus;
|
|
||||||
@BindView(R.id.ib_expand_collapse)
|
|
||||||
AppCompatImageButton ibExpandCollapse;
|
|
||||||
@BindView(R.id.ll_container_media_detail)
|
|
||||||
LinearLayout llContainerMediaDetail;
|
|
||||||
@BindView(R.id.rv_descriptions)
|
|
||||||
RecyclerView rvDescriptions;
|
|
||||||
@BindView(R.id.backgroundImage)
|
|
||||||
PhotoView photoViewBackgroundImage;
|
|
||||||
@BindView(R.id.btn_next)
|
|
||||||
AppCompatButton btnNext;
|
|
||||||
@BindView(R.id.btn_previous)
|
|
||||||
AppCompatButton btnPrevious;
|
|
||||||
@BindView(R.id.ll_edit_image)
|
|
||||||
LinearLayout llEditImage;
|
|
||||||
@BindView(R.id.tooltip)
|
|
||||||
ImageView tooltip;
|
|
||||||
|
|
||||||
private UploadMediaDetailAdapter uploadMediaDetailAdapter;
|
private UploadMediaDetailAdapter uploadMediaDetailAdapter;
|
||||||
@BindView(R.id.btn_copy_subsequent_media)
|
|
||||||
AppCompatButton btnCopyToSubsequentMedia;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
UploadMediaDetailsContract.UserActionListener presenter;
|
UploadMediaDetailsContract.UserActionListener presenter;
|
||||||
|
|
@ -158,6 +125,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
|
|
||||||
private UploadMediaDetailFragmentCallback callback;
|
private UploadMediaDetailFragmentCallback callback;
|
||||||
|
|
||||||
|
private FragmentUploadMediaDetailFragmentBinding binding;
|
||||||
|
|
||||||
public void setCallback(UploadMediaDetailFragmentCallback callback) {
|
public void setCallback(UploadMediaDetailFragmentCallback callback) {
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
@ -186,14 +155,14 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
return inflater.inflate(R.layout.fragment_upload_media_detail_fragment, container, false);
|
binding = FragmentUploadMediaDetailFragmentBinding.inflate(inflater, container, false);
|
||||||
|
return binding.getRoot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
init();
|
init();
|
||||||
|
|
@ -209,43 +178,54 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
tvTitle.setText(getString(R.string.step_count, callback.getIndexInViewFlipper(this) + 1,
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
binding.tvTitle.setText(getString(R.string.step_count, callback.getIndexInViewFlipper(this) + 1,
|
||||||
callback.getTotalNumberOfSteps(), getString(R.string.media_detail_step_title)));
|
callback.getTotalNumberOfSteps(), getString(R.string.media_detail_step_title)));
|
||||||
tooltip.setOnClickListener(
|
binding.tooltip.setOnClickListener(
|
||||||
v -> showInfoAlert(R.string.media_detail_step_title, R.string.media_details_tooltip));
|
v -> showInfoAlert(R.string.media_detail_step_title, R.string.media_details_tooltip));
|
||||||
initPresenter();
|
initPresenter();
|
||||||
presenter.receiveImage(uploadableFile, place, inAppPictureLocation);
|
presenter.receiveImage(uploadableFile, place, inAppPictureLocation);
|
||||||
initRecyclerView();
|
initRecyclerView();
|
||||||
|
|
||||||
if (callback.getIndexInViewFlipper(this) == 0) {
|
if (callback.getIndexInViewFlipper(this) == 0) {
|
||||||
btnPrevious.setEnabled(false);
|
binding.btnPrevious.setEnabled(false);
|
||||||
btnPrevious.setAlpha(0.5f);
|
binding.btnPrevious.setAlpha(0.5f);
|
||||||
} else {
|
} else {
|
||||||
btnPrevious.setEnabled(true);
|
binding.btnPrevious.setEnabled(true);
|
||||||
btnPrevious.setAlpha(1.0f);
|
binding.btnPrevious.setAlpha(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the image EXIF data contains the location, show the map icon with a green tick
|
// If the image EXIF data contains the location, show the map icon with a green tick
|
||||||
if (inAppPictureLocation != null ||
|
if (inAppPictureLocation != null ||
|
||||||
(uploadableFile != null && uploadableFile.hasLocation())) {
|
(uploadableFile != null && uploadableFile.hasLocation())) {
|
||||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
||||||
locationImageView.setImageDrawable(mapTick);
|
binding.locationImageView.setImageDrawable(mapTick);
|
||||||
locationTextView.setText(R.string.edit_location);
|
binding.locationTextView.setText(R.string.edit_location);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, show the map icon with a red question mark
|
// Otherwise, show the map icon with a red question mark
|
||||||
Drawable mapQuestionMark =
|
Drawable mapQuestionMark =
|
||||||
getResources().getDrawable(R.drawable.ic_map_not_available_20dp);
|
getResources().getDrawable(R.drawable.ic_map_not_available_20dp);
|
||||||
locationImageView.setImageDrawable(mapQuestionMark);
|
binding.locationImageView.setImageDrawable(mapQuestionMark);
|
||||||
locationTextView.setText(R.string.add_location);
|
binding.locationTextView.setText(R.string.add_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If this is the last media, we have nothing to copy, lets not show the button
|
//If this is the last media, we have nothing to copy, lets not show the button
|
||||||
if (callback.getIndexInViewFlipper(this) == callback.getTotalNumberOfSteps() - 4) {
|
if (callback.getIndexInViewFlipper(this) == callback.getTotalNumberOfSteps() - 4) {
|
||||||
btnCopyToSubsequentMedia.setVisibility(View.GONE);
|
binding.btnCopySubsequentMedia.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
btnCopyToSubsequentMedia.setVisibility(View.VISIBLE);
|
binding.btnCopySubsequentMedia.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.btnNext.setOnClickListener(v -> onNextButtonClicked());
|
||||||
|
binding.btnPrevious.setOnClickListener(v -> onPreviousButtonClicked());
|
||||||
|
binding.llEditImage.setOnClickListener(v -> onEditButtonClicked());
|
||||||
|
binding.llContainerTitle.setOnClickListener(v -> onLlContainerTitleClicked());
|
||||||
|
binding.llLocationStatus.setOnClickListener(v -> onIbMapClicked());
|
||||||
|
binding.btnCopySubsequentMedia.setOnClickListener(v -> onButtonCopyTitleDescToSubsequentMedia());
|
||||||
|
|
||||||
|
|
||||||
attachImageViewScaleChangeListener();
|
attachImageViewScaleChangeListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,7 +233,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
* Attaches the scale change listener to the image view
|
* Attaches the scale change listener to the image view
|
||||||
*/
|
*/
|
||||||
private void attachImageViewScaleChangeListener() {
|
private void attachImageViewScaleChangeListener() {
|
||||||
photoViewBackgroundImage.setOnScaleChangeListener(
|
binding.backgroundImage.setOnScaleChangeListener(
|
||||||
(scaleFactor, focusX, focusY) -> {
|
(scaleFactor, focusX, focusY) -> {
|
||||||
//Whenever the uses plays with the image, lets collapse the media detail container
|
//Whenever the uses plays with the image, lets collapse the media detail container
|
||||||
expandCollapseLlMediaDetail(false);
|
expandCollapseLlMediaDetail(false);
|
||||||
|
|
@ -275,8 +255,8 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, ""), recentLanguagesDao);
|
defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, ""), recentLanguagesDao);
|
||||||
uploadMediaDetailAdapter.setCallback(this::showInfoAlert);
|
uploadMediaDetailAdapter.setCallback(this::showInfoAlert);
|
||||||
uploadMediaDetailAdapter.setEventListener(this);
|
uploadMediaDetailAdapter.setEventListener(this);
|
||||||
rvDescriptions.setLayoutManager(new LinearLayoutManager(getContext()));
|
binding.rvDescriptions.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
rvDescriptions.setAdapter(uploadMediaDetailAdapter);
|
binding.rvDescriptions.setAdapter(uploadMediaDetailAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -289,8 +269,11 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
getString(messageStringId), getString(android.R.string.ok), null, true);
|
getString(messageStringId), getString(android.R.string.ok), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btn_next)
|
|
||||||
public void onNextButtonClicked() {
|
public void onNextButtonClicked() {
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean isValidUploads = presenter.verifyImageQuality(callback.getIndexInViewFlipper(this), inAppPictureLocation);
|
boolean isValidUploads = presenter.verifyImageQuality(callback.getIndexInViewFlipper(this), inAppPictureLocation);
|
||||||
if (!isValidUploads) {
|
if (!isValidUploads) {
|
||||||
startActivityWithFlags(
|
startActivityWithFlags(
|
||||||
|
|
@ -299,12 +282,13 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btn_previous)
|
|
||||||
public void onPreviousButtonClicked() {
|
public void onPreviousButtonClicked() {
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
callback.onPreviousButtonClicked(callback.getIndexInViewFlipper(this));
|
callback.onPreviousButtonClicked(callback.getIndexInViewFlipper(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.ll_edit_image)
|
|
||||||
public void onEditButtonClicked() {
|
public void onEditButtonClicked() {
|
||||||
presenter.onEditButtonClicked(callback.getIndexInViewFlipper(this));
|
presenter.onEditButtonClicked(callback.getIndexInViewFlipper(this));
|
||||||
}
|
}
|
||||||
|
|
@ -340,7 +324,10 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onImageProcessed(UploadItem uploadItem, Place place) {
|
public void onImageProcessed(UploadItem uploadItem, Place place) {
|
||||||
photoViewBackgroundImage.setImageURI(uploadItem.getMediaUri());
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
binding.backgroundImage.setImageURI(uploadItem.getMediaUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -353,12 +340,17 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
nearbyPlace = place;
|
nearbyPlace = place;
|
||||||
this.uploadItem = uploadItem;
|
this.uploadItem = uploadItem;
|
||||||
showNearbyFound = true;
|
showNearbyFound = true;
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (callback.getIndexInViewFlipper(this) == 0) {
|
if (callback.getIndexInViewFlipper(this) == 0) {
|
||||||
if (UploadActivity.nearbyPopupAnswers.containsKey(nearbyPlace)) {
|
if (UploadActivity.nearbyPopupAnswers.containsKey(nearbyPlace)) {
|
||||||
final boolean response = UploadActivity.nearbyPopupAnswers.get(nearbyPlace);
|
final boolean response = UploadActivity.nearbyPopupAnswers.get(nearbyPlace);
|
||||||
if (response) {
|
if (response) {
|
||||||
presenter.onUserConfirmedUploadIsOfPlace(nearbyPlace,
|
if (callback != null) {
|
||||||
callback.getIndexInViewFlipper(this));
|
presenter.onUserConfirmedUploadIsOfPlace(nearbyPlace,
|
||||||
|
callback.getIndexInViewFlipper(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showNearbyPlaceFound(nearbyPlace);
|
showNearbyPlaceFound(nearbyPlace);
|
||||||
|
|
@ -394,11 +386,17 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showProgress(boolean shouldShow) {
|
public void showProgress(boolean shouldShow) {
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
callback.showProgress(shouldShow);
|
callback.showProgress(shouldShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onImageValidationSuccess() {
|
public void onImageValidationSuccess() {
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
callback.onNextButtonClicked(callback.getIndexInViewFlipper(this));
|
callback.onNextButtonClicked(callback.getIndexInViewFlipper(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -408,13 +406,18 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
@Override
|
@Override
|
||||||
protected void onBecameVisible() {
|
protected void onBecameVisible() {
|
||||||
super.onBecameVisible();
|
super.onBecameVisible();
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
presenter.fetchTitleAndDescription(callback.getIndexInViewFlipper(this));
|
presenter.fetchTitleAndDescription(callback.getIndexInViewFlipper(this));
|
||||||
if (showNearbyFound) {
|
if (showNearbyFound) {
|
||||||
if (UploadActivity.nearbyPopupAnswers.containsKey(nearbyPlace)) {
|
if (UploadActivity.nearbyPopupAnswers.containsKey(nearbyPlace)) {
|
||||||
final boolean response = UploadActivity.nearbyPopupAnswers.get(nearbyPlace);
|
final boolean response = UploadActivity.nearbyPopupAnswers.get(nearbyPlace);
|
||||||
if (response) {
|
if (response) {
|
||||||
presenter.onUserConfirmedUploadIsOfPlace(nearbyPlace,
|
if (callback != null) {
|
||||||
callback.getIndexInViewFlipper(this));
|
presenter.onUserConfirmedUploadIsOfPlace(nearbyPlace,
|
||||||
|
callback.getIndexInViewFlipper(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showNearbyPlaceFound(nearbyPlace);
|
showNearbyPlaceFound(nearbyPlace);
|
||||||
|
|
@ -615,10 +618,13 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
photoViewBackgroundImage.setImageURI(Uri.fromFile(new File(result)));
|
if (binding != null){
|
||||||
|
binding.backgroundImage.setImageURI(Uri.fromFile(new File(result)));
|
||||||
|
}
|
||||||
editableUploadItem.setContentUri(Uri.fromFile(new File(result)));
|
editableUploadItem.setContentUri(Uri.fromFile(new File(result)));
|
||||||
callback.changeThumbnail(callback.getIndexInViewFlipper(this),
|
if (callback != null) {
|
||||||
result);
|
callback.changeThumbnail(callback.getIndexInViewFlipper(this), result);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Timber.e(e);
|
Timber.e(e);
|
||||||
}
|
}
|
||||||
|
|
@ -649,8 +655,11 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
|
|
||||||
// Replace the map icon using the one with a green tick
|
// Replace the map icon using the one with a green tick
|
||||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
||||||
locationImageView.setImageDrawable(mapTick);
|
|
||||||
locationTextView.setText(R.string.edit_location);
|
if (binding != null) {
|
||||||
|
binding.locationImageView.setImageDrawable(mapTick);
|
||||||
|
binding.locationTextView.setText(R.string.edit_location);
|
||||||
|
}
|
||||||
|
|
||||||
Toast.makeText(getContext(), "Location Updated", Toast.LENGTH_LONG).show();
|
Toast.makeText(getContext(), "Location Updated", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
|
|
@ -703,6 +712,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteThisPicture() {
|
private void deleteThisPicture() {
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
callback.deletePictureAtIndex(callback.getIndexInViewFlipper(this));
|
callback.deletePictureAtIndex(callback.getIndexInViewFlipper(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -712,7 +724,6 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
presenter.onDetachView();
|
presenter.onDetachView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.ll_container_title)
|
|
||||||
public void onLlContainerTitleClicked() {
|
public void onLlContainerTitleClicked() {
|
||||||
expandCollapseLlMediaDetail(!isExpanded);
|
expandCollapseLlMediaDetail(!isExpanded);
|
||||||
}
|
}
|
||||||
|
|
@ -722,23 +733,32 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
* @param shouldExpand
|
* @param shouldExpand
|
||||||
*/
|
*/
|
||||||
private void expandCollapseLlMediaDetail(boolean shouldExpand){
|
private void expandCollapseLlMediaDetail(boolean shouldExpand){
|
||||||
llContainerMediaDetail.setVisibility(shouldExpand ? View.VISIBLE : View.GONE);
|
if (binding == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
binding.llContainerMediaDetail.setVisibility(shouldExpand ? View.VISIBLE : View.GONE);
|
||||||
isExpanded = !isExpanded;
|
isExpanded = !isExpanded;
|
||||||
ibExpandCollapse.setRotation(ibExpandCollapse.getRotation() + 180);
|
binding.ibExpandCollapse.setRotation(binding.ibExpandCollapse.getRotation() + 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.ll_location_status) public void onIbMapClicked() {
|
public void onIbMapClicked() {
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
presenter.onMapIconClicked(callback.getIndexInViewFlipper(this));
|
presenter.onMapIconClicked(callback.getIndexInViewFlipper(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrimaryCaptionTextChange(boolean isNotEmpty) {
|
public void onPrimaryCaptionTextChange(boolean isNotEmpty) {
|
||||||
btnCopyToSubsequentMedia.setEnabled(isNotEmpty);
|
if (binding == null) {
|
||||||
btnCopyToSubsequentMedia.setClickable(isNotEmpty);
|
return;
|
||||||
btnCopyToSubsequentMedia.setAlpha(isNotEmpty ? 1.0f : 0.5f);
|
}
|
||||||
btnNext.setEnabled(isNotEmpty);
|
binding.btnCopySubsequentMedia.setEnabled(isNotEmpty);
|
||||||
btnNext.setClickable(isNotEmpty);
|
binding.btnCopySubsequentMedia.setClickable(isNotEmpty);
|
||||||
btnNext.setAlpha(isNotEmpty ? 1.0f : 0.5f);
|
binding.btnCopySubsequentMedia.setAlpha(isNotEmpty ? 1.0f : 0.5f);
|
||||||
|
binding.btnNext.setEnabled(isNotEmpty);
|
||||||
|
binding.btnNext.setClickable(isNotEmpty);
|
||||||
|
binding.btnNext.setAlpha(isNotEmpty ? 1.0f : 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -749,7 +769,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
UploadMediaDetail uploadMediaDetail = new UploadMediaDetail();
|
UploadMediaDetail uploadMediaDetail = new UploadMediaDetail();
|
||||||
uploadMediaDetail.setManuallyAdded(true);//This was manually added by the user
|
uploadMediaDetail.setManuallyAdded(true);//This was manually added by the user
|
||||||
uploadMediaDetailAdapter.addDescription(uploadMediaDetail);
|
uploadMediaDetailAdapter.addDescription(uploadMediaDetail);
|
||||||
rvDescriptions.smoothScrollToPosition(uploadMediaDetailAdapter.getItemCount()-1);
|
binding.rvDescriptions.smoothScrollToPosition(uploadMediaDetailAdapter.getItemCount()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface UploadMediaDetailFragmentCallback extends Callback {
|
public interface UploadMediaDetailFragmentCallback extends Callback {
|
||||||
|
|
@ -760,8 +780,10 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OnClick(R.id.btn_copy_subsequent_media)
|
|
||||||
public void onButtonCopyTitleDescToSubsequentMedia(){
|
public void onButtonCopyTitleDescToSubsequentMedia(){
|
||||||
|
if (callback == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
presenter.copyTitleAndDescriptionToSubsequentMedia(callback.getIndexInViewFlipper(this));
|
presenter.copyTitleAndDescriptionToSubsequentMedia(callback.getIndexInViewFlipper(this));
|
||||||
Toast.makeText(getContext(), getResources().getString(R.string.copied_successfully), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getContext(), getResources().getString(R.string.copied_successfully), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
@ -779,5 +801,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
binding = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/mainBackground">
|
android:background="?attr/mainBackground">
|
||||||
|
|
||||||
<include layout="@layout/toolbar"/>
|
<include
|
||||||
|
android:id="@+id/toolbarBinding"
|
||||||
|
layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
|
|
@ -44,4 +46,4 @@
|
||||||
android:layout_below="@id/toolbar_layout" />
|
android:layout_below="@id/toolbar_layout" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
android:id="@+id/toolbarBinding"
|
||||||
layout="@layout/toolbar"
|
layout="@layout/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
@ -45,4 +46,4 @@
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@
|
||||||
android:id="@+id/toolbarLayout"
|
android:id="@+id/toolbarLayout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="?attr/actionBarSize">
|
android:layout_height="?attr/actionBarSize">
|
||||||
<include layout="@layout/toolbar" />
|
<include
|
||||||
|
android:id="@+id/toolbarBinding"
|
||||||
|
layout="@layout/toolbar" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -27,4 +29,4 @@
|
||||||
tools:layout="@xml/preferences"
|
tools:layout="@xml/preferences"
|
||||||
/>
|
/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/mainBackground">
|
android:background="?attr/mainBackground">
|
||||||
|
|
||||||
<include layout="@layout/toolbar"/>
|
<include
|
||||||
|
android:id="@+id/toolbarBinding"
|
||||||
|
layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
|
|
@ -44,4 +46,4 @@
|
||||||
android:layout_below="@id/toolbar_layout" />
|
android:layout_below="@id/toolbar_layout" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
</androidx.drawerlayout.widget.DrawerLayout>
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
app:elevation="@dimen/dimen_6" />
|
app:elevation="@dimen/dimen_6" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/bottom_sheet_details"
|
android:id="@+id/bottom_sheet_details_binding"
|
||||||
layout="@layout/bottom_sheet_details_explore" />
|
layout="@layout/bottom_sheet_details_explore" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
|
@ -78,4 +78,4 @@
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:elevation="@dimen/dimen_6" />
|
app:elevation="@dimen/dimen_6" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/toolbar" />
|
<include
|
||||||
|
android:id="@+id/toolbarBinding"
|
||||||
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@
|
||||||
<string name="login_success">Kirjautuminen onnistui!</string>
|
<string name="login_success">Kirjautuminen onnistui!</string>
|
||||||
<string name="login_failed">Kirjautuminen epäonnistui!</string>
|
<string name="login_failed">Kirjautuminen epäonnistui!</string>
|
||||||
<string name="upload_failed">Tiedostoa ei löytynyt. Yritä toista tiedostoa.</string>
|
<string name="upload_failed">Tiedostoa ei löytynyt. Yritä toista tiedostoa.</string>
|
||||||
|
<string name="unrestricted_battery_mode">Poistetaanko akun optimointi käytöstä?</string>
|
||||||
<string name="authentication_failed">Tunnistautuminen epäonnistui, kirjaudu uudelleen sisään</string>
|
<string name="authentication_failed">Tunnistautuminen epäonnistui, kirjaudu uudelleen sisään</string>
|
||||||
<string name="uploading_started">Tallentaminen aloitettiin!</string>
|
<string name="uploading_started">Tallentaminen aloitettiin!</string>
|
||||||
<string name="uploading_queued">Lataus jonossa (rajoitettu yhteystila käytössä)</string>
|
<string name="uploading_queued">Lataus jonossa (rajoitettu yhteystila käytössä)</string>
|
||||||
|
|
@ -314,7 +315,7 @@
|
||||||
<string name="search_tab_title_categories">Luokat</string>
|
<string name="search_tab_title_categories">Luokat</string>
|
||||||
<string name="search_tab_title_depictions">Kohteet</string>
|
<string name="search_tab_title_depictions">Kohteet</string>
|
||||||
<string name="explore_tab_title_featured">Suositeltu</string>
|
<string name="explore_tab_title_featured">Suositeltu</string>
|
||||||
<string name="explore_tab_title_mobile">Tallennettu mobiilin kautta</string>
|
<string name="explore_tab_title_mobile">Tallennettu mobiililaitteella</string>
|
||||||
<string name="explore_tab_title_map">Kartta</string>
|
<string name="explore_tab_title_map">Kartta</string>
|
||||||
<string name="successful_wikidata_edit">Kuva lisätty Wikidata-kohteeseen %1$s!</string>
|
<string name="successful_wikidata_edit">Kuva lisätty Wikidata-kohteeseen %1$s!</string>
|
||||||
<string name="wikidata_edit_failure">Vastaavaa Wikidata-kohdetta ei voitu päivittää!</string>
|
<string name="wikidata_edit_failure">Vastaavaa Wikidata-kohdetta ei voitu päivittää!</string>
|
||||||
|
|
@ -651,11 +652,16 @@
|
||||||
<string name="mark_as_not_for_upload">Merkitse ei-tallennettavaksi</string>
|
<string name="mark_as_not_for_upload">Merkitse ei-tallennettavaksi</string>
|
||||||
<string name="this_image_is_already_uploaded">Tämä kuva on jo tallennettu</string>
|
<string name="this_image_is_already_uploaded">Tämä kuva on jo tallennettu</string>
|
||||||
<string name="image_selected">Kuva valittu</string>
|
<string name="image_selected">Kuva valittu</string>
|
||||||
|
<string name="menu_view_report">Ilmoita</string>
|
||||||
|
<string name="menu_view_set_white_background">Aseta valkoinen tausta</string>
|
||||||
|
<string name="menu_view_set_black_background">Aseta musta tausta</string>
|
||||||
<string name="report_user">Ilmianna käyttäjä</string>
|
<string name="report_user">Ilmianna käyttäjä</string>
|
||||||
|
<string name="report_content">Ilmianna sisältö</string>
|
||||||
<string name="request_user_block">Pyydä tämän käyttäjän estämistä</string>
|
<string name="request_user_block">Pyydä tämän käyttäjän estämistä</string>
|
||||||
<string name="welcome_to_full_screen_mode_text">Tervetuloa koko näytön valintatilaan</string>
|
<string name="welcome_to_full_screen_mode_text">Tervetuloa koko näytön valintatilaan</string>
|
||||||
<string name="full_screen_mode_zoom_info">Käytä kahta sormea lähentääksesi ja loitontaaksesi.</string>
|
<string name="full_screen_mode_zoom_info">Käytä kahta sormea lähentääksesi ja loitontaaksesi.</string>
|
||||||
<string name="full_screen_mode_features_info">Pyyhkäise nopeasti ja pitkään suorittaaksesi nämä toiminnot: \n- Vasen/Oikea: Siirry edelliseen/seuraavaan \n- Ylös: Valitse\n- Alas: Merkitse ei-tallennettavaksi.</string>
|
<string name="full_screen_mode_features_info">Pyyhkäise nopeasti ja pitkään suorittaaksesi nämä toiminnot: \n- Vasen/Oikea: Siirry edelliseen/seuraavaan \n- Ylös: Valitse\n- Alas: Merkitse ei-tallennettavaksi.</string>
|
||||||
|
<string name="see_your_achievements">Näytä omat saavutukset</string>
|
||||||
<string name="edit_image">Muokkaa kuvaa</string>
|
<string name="edit_image">Muokkaa kuvaa</string>
|
||||||
<string name="edit_location">Muokkaa sijaintia</string>
|
<string name="edit_location">Muokkaa sijaintia</string>
|
||||||
<string name="send_thanks_to_author">Kiitä tekijää</string>
|
<string name="send_thanks_to_author">Kiitä tekijää</string>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- Authors:
|
<!-- Authors:
|
||||||
* Maksat
|
* Maksat
|
||||||
|
* Элдин беги
|
||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
<string name="crash_dialog_title">Кыйроо</string>
|
<string name="crash_dialog_title">Кыйроо</string>
|
||||||
<string name="crash_dialog_text">Уупс. Бир нерсе туура эмес болду!</string>
|
<string name="crash_dialog_text">Ай ботом, бир нерсе туура эмес болду!</string>
|
||||||
<string name="crash_dialog_comment_prompt">Сиздин иш аракетиңиз тууралуу бизге электрондук кат жөнөтүңүз. Бул кийнки каталарды оңдоого жарам берет!</string>
|
<string name="crash_dialog_comment_prompt">Сиздин иш аракетиңиз тууралуу бизге электрондук кат жөнөтүңүз. Бул кийнки каталарды оңдоого жардам берет!</string>
|
||||||
<string name="crash_dialog_ok_toast">Ыракмат!</string>
|
<string name="crash_dialog_ok_toast">Ыракмат!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,7 @@
|
||||||
<string name="share_app_title">Toepassing delen</string>
|
<string name="share_app_title">Toepassing delen</string>
|
||||||
<string name="rotate">Draaien</string>
|
<string name="rotate">Draaien</string>
|
||||||
<string name="error_fetching_nearby_places">Fout bij het ophalen van plaatsen in de buurt.</string>
|
<string name="error_fetching_nearby_places">Fout bij het ophalen van plaatsen in de buurt.</string>
|
||||||
|
<string name="no_pictures_in_this_area">Geen foto\'s in dit gebied.</string>
|
||||||
<string name="no_nearby_places_around">Geen plaatsen in de buurt</string>
|
<string name="no_nearby_places_around">Geen plaatsen in de buurt</string>
|
||||||
<string name="error_fetching_nearby_monuments">Fout bij het ophalen van monumenten.</string>
|
<string name="error_fetching_nearby_monuments">Fout bij het ophalen van monumenten.</string>
|
||||||
<string name="no_recent_searches">Geen recente zoekopdrachten</string>
|
<string name="no_recent_searches">Geen recente zoekopdrachten</string>
|
||||||
|
|
@ -759,7 +760,13 @@
|
||||||
<string name="storage_permissions_denied">Opslagtoestemming geweigerd</string>
|
<string name="storage_permissions_denied">Opslagtoestemming geweigerd</string>
|
||||||
<string name="unable_to_share_upload_item">Kan dit item niet delen</string>
|
<string name="unable_to_share_upload_item">Kan dit item niet delen</string>
|
||||||
<string name="permissions_are_required_for_functionality">Voor deze functionaliteit zijn toestemmingen vereist</string>
|
<string name="permissions_are_required_for_functionality">Voor deze functionaliteit zijn toestemmingen vereist</string>
|
||||||
|
<string name="learn_how_to_write_a_useful_description">Leer hoe u een nuttige beschrijving schrijft</string>
|
||||||
|
<string name="learn_how_to_write_a_useful_caption">Leer hoe u een nuttig bijschrift schrijft</string>
|
||||||
|
<string name="see_your_achievements">Bekijk uw prestaties</string>
|
||||||
<string name="edit_image">Afbeelding Bewerken</string>
|
<string name="edit_image">Afbeelding Bewerken</string>
|
||||||
|
<string name="edit_location">Locatie bewerken</string>
|
||||||
|
<string name="send_thanks_to_author">Auteur bedanken</string>
|
||||||
|
<string name="error_sending_thanks">Fout bij het bedanken van de auteur.</string>
|
||||||
<plurals name="custom_picker_images_selected_title_appendix">
|
<plurals name="custom_picker_images_selected_title_appendix">
|
||||||
<item quantity="one">%d afbeelding geselecteerd</item>
|
<item quantity="one">%d afbeelding geselecteerd</item>
|
||||||
<item quantity="other">%d afbeeldingen geselecteerd</item>
|
<item quantity="other">%d afbeeldingen geselecteerd</item>
|
||||||
|
|
|
||||||
|
|
@ -700,6 +700,7 @@
|
||||||
<string name="custom_selector_info_text2">W przeciwieństwie do zdjęcia po lewej, zdjęcie po prawej ma logo Commons wskazujące, że zostało już przesłane.\n Dotknij i przytrzymaj, aby wyświetlić podgląd obrazu.</string>
|
<string name="custom_selector_info_text2">W przeciwieństwie do zdjęcia po lewej, zdjęcie po prawej ma logo Commons wskazujące, że zostało już przesłane.\n Dotknij i przytrzymaj, aby wyświetlić podgląd obrazu.</string>
|
||||||
<string name="welcome_custom_selector_ok">Niesamowite</string>
|
<string name="welcome_custom_selector_ok">Niesamowite</string>
|
||||||
<string name="custom_selector_already_uploaded_image_text">Tez plik został już przesłany do Commons.</string>
|
<string name="custom_selector_already_uploaded_image_text">Tez plik został już przesłany do Commons.</string>
|
||||||
|
<string name="custom_selector_dismiss_limit_warning_button_text">Odrzuć</string>
|
||||||
<string name="custom_selector_button_limit_text">Maks.: %1$d</string>
|
<string name="custom_selector_button_limit_text">Maks.: %1$d</string>
|
||||||
<string name="custom_selector_limit_error_desc">Błąd: przekroczono limit przesyłania</string>
|
<string name="custom_selector_limit_error_desc">Błąd: przekroczono limit przesyłania</string>
|
||||||
<string name="wlm_upload_info">Ten obraz zostanie zgłoszony do konkursu Wiki Loves Monuments</string>
|
<string name="wlm_upload_info">Ten obraz zostanie zgłoszony do konkursu Wiki Loves Monuments</string>
|
||||||
|
|
@ -762,4 +763,8 @@
|
||||||
<string name="set_up_avatar_toast_string">Aby skonfigurować swojego awatara rankingu, dotknij \'Ustaw jako awatar\' w menu z trzema kropkami dowolnego obrazu.</string>
|
<string name="set_up_avatar_toast_string">Aby skonfigurować swojego awatara rankingu, dotknij \'Ustaw jako awatar\' w menu z trzema kropkami dowolnego obrazu.</string>
|
||||||
<string name="similar_coordinate_description_auto_set">Współrzędne nie są dokładnymi współrzędnymi, ale osoba, która przesłała to zdjęcie, uważa, że są wystarczająco blisko.</string>
|
<string name="similar_coordinate_description_auto_set">Współrzędne nie są dokładnymi współrzędnymi, ale osoba, która przesłała to zdjęcie, uważa, że są wystarczająco blisko.</string>
|
||||||
<string name="unable_to_share_upload_item">Nie można udostępnić tego elementu</string>
|
<string name="unable_to_share_upload_item">Nie można udostępnić tego elementu</string>
|
||||||
|
<string name="edit_image">Edytuj obraz</string>
|
||||||
|
<string name="edit_location">Edytuj lokalizację</string>
|
||||||
|
<string name="send_thanks_to_author">Dziękuję autorowi</string>
|
||||||
|
<string name="error_sending_thanks">Błąd wysyłania podziękowań do autora.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@
|
||||||
<string name="caption_edit_helper_edit_message_else">Govvateavstta lasiheapmi ii lihkostuvvan.</string>
|
<string name="caption_edit_helper_edit_message_else">Govvateavstta lasiheapmi ii lihkostuvvan.</string>
|
||||||
<string name="description_activity_title">Rievdat govvádusaid ja govvateavsttaid</string>
|
<string name="description_activity_title">Rievdat govvádusaid ja govvateavsttaid</string>
|
||||||
<string name="nearby_search_hint">Šaldi, musea, hotealla jna.</string>
|
<string name="nearby_search_hint">Šaldi, musea, hotealla jna.</string>
|
||||||
|
<string name="add_picture_to_wikipedia_article_title">Lasit gova Wikipediai</string>
|
||||||
<string name="resume">joatkke</string>
|
<string name="resume">joatkke</string>
|
||||||
<string name="leaderboard_column_user">Geavaheaddji</string>
|
<string name="leaderboard_column_user">Geavaheaddji</string>
|
||||||
<string name="cancelling_upload">Fiilla vurkema gaskkalduhttomin…</string>
|
<string name="cancelling_upload">Fiilla vurkema gaskkalduhttomin…</string>
|
||||||
|
|
|
||||||
9
app/src/main/res/values-yue-hant/error.xml
Normal file
9
app/src/main/res/values-yue-hant/error.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Authors:
|
||||||
|
* Winston Sung
|
||||||
|
-->
|
||||||
|
<resources>
|
||||||
|
<string name="crash_dialog_title">同享壞咗</string>
|
||||||
|
<string name="crash_dialog_text">哎呀。出咗錯!</string>
|
||||||
|
<string name="crash_dialog_ok_toast">多謝你!</string>
|
||||||
|
</resources>
|
||||||
|
|
@ -17,6 +17,7 @@ import fr.free.nrw.commons.location.LocationServiceManager
|
||||||
class TestCommonsApplication : Application() {
|
class TestCommonsApplication : Application() {
|
||||||
private var mockApplicationComponent: CommonsApplicationComponent? = null
|
private var mockApplicationComponent: CommonsApplicationComponent? = null
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
if (mockApplicationComponent == null) {
|
if (mockApplicationComponent == null) {
|
||||||
mockApplicationComponent = DaggerCommonsApplicationComponent.builder()
|
mockApplicationComponent = DaggerCommonsApplicationComponent.builder()
|
||||||
|
|
@ -64,4 +65,4 @@ class MockCommonsApplicationModule(appContext: Context) : CommonsApplicationModu
|
||||||
override fun provideDBOpenHelper(context: Context): DBOpenHelper = mockDbOpenHelper
|
override fun provideDBOpenHelper(context: Context): DBOpenHelper = mockDbOpenHelper
|
||||||
|
|
||||||
override fun provideLruCache(): LruCache<String, String> = lruCache
|
override fun provideLruCache(): LruCache<String, String> = lruCache
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment
|
import fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesFragment
|
||||||
import fr.free.nrw.commons.contributions.MainActivity
|
import fr.free.nrw.commons.contributions.MainActivity
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksBinding
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentFeaturedRootBinding
|
||||||
import fr.free.nrw.commons.explore.ParentViewPager
|
import fr.free.nrw.commons.explore.ParentViewPager
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
@ -81,6 +83,8 @@ class BookmarkListRootFragmentUnitTest {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var adapter: BookmarksPagerAdapter
|
private lateinit var adapter: BookmarksPagerAdapter
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentFeaturedRootBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
|
|
@ -95,14 +99,17 @@ class BookmarkListRootFragmentUnitTest {
|
||||||
fragmentTransaction.commitNowAllowingStateLoss()
|
fragmentTransaction.commitNowAllowingStateLoss()
|
||||||
|
|
||||||
bookmarkFragment = BookmarkFragment()
|
bookmarkFragment = BookmarkFragment()
|
||||||
|
bookmarkFragment.binding = FragmentBookmarksBinding.inflate(LayoutInflater.from(activity))
|
||||||
|
|
||||||
|
binding = FragmentFeaturedRootBinding.inflate(LayoutInflater.from(activity))
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "mChildFragmentManager", childFragmentManager)
|
Whitebox.setInternalState(fragment, "mChildFragmentManager", childFragmentManager)
|
||||||
Whitebox.setInternalState(fragment, "mParentFragment", bookmarkFragment)
|
Whitebox.setInternalState(fragment, "mParentFragment", bookmarkFragment)
|
||||||
Whitebox.setInternalState(fragment, "listFragment", listFragment)
|
Whitebox.setInternalState(fragment, "listFragment", listFragment)
|
||||||
Whitebox.setInternalState(fragment, "mediaDetails", mediaDetails)
|
Whitebox.setInternalState(fragment, "mediaDetails", mediaDetails)
|
||||||
Whitebox.setInternalState(fragment, "bookmarksPagerAdapter", bookmarksPagerAdapter)
|
Whitebox.setInternalState(fragment, "bookmarksPagerAdapter", bookmarksPagerAdapter)
|
||||||
Whitebox.setInternalState(bookmarkFragment, "tabLayout", tabLayout)
|
Whitebox.setInternalState(bookmarkFragment.binding, "tabLayout", tabLayout)
|
||||||
Whitebox.setInternalState(bookmarkFragment, "viewPager", viewPager)
|
Whitebox.setInternalState(bookmarkFragment.binding, "viewPagerBookmarks", viewPager)
|
||||||
Whitebox.setInternalState(bookmarkFragment, "adapter", adapter)
|
Whitebox.setInternalState(bookmarkFragment, "adapter", adapter)
|
||||||
|
|
||||||
whenever(childFragmentManager.beginTransaction()).thenReturn(childFragmentTransaction)
|
whenever(childFragmentManager.beginTransaction()).thenReturn(childFragmentTransaction)
|
||||||
|
|
@ -322,4 +329,4 @@ class BookmarkListRootFragmentUnitTest {
|
||||||
Assert.assertEquals(fragment.backPressed(), false)
|
Assert.assertEquals(fragment.backPressed(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.category.CategoryItem
|
import fr.free.nrw.commons.category.CategoryItem
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksItemsBinding
|
||||||
import fr.free.nrw.commons.profile.ProfileActivity
|
import fr.free.nrw.commons.profile.ProfileActivity
|
||||||
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
@ -25,6 +26,7 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
import org.powermock.reflect.Whitebox
|
||||||
import org.robolectric.Robolectric
|
import org.robolectric.Robolectric
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
|
@ -45,8 +47,7 @@ class BookmarkItemsFragmentUnitTest {
|
||||||
private lateinit var recyclerView: RecyclerView
|
private lateinit var recyclerView: RecyclerView
|
||||||
private lateinit var layoutInflater: LayoutInflater
|
private lateinit var layoutInflater: LayoutInflater
|
||||||
|
|
||||||
@Mock
|
private lateinit var binding: FragmentBookmarksItemsBinding
|
||||||
private lateinit var parentLayout: RelativeLayout
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var savedInstanceState: Bundle
|
private lateinit var savedInstanceState: Bundle
|
||||||
|
|
@ -89,17 +90,16 @@ class BookmarkItemsFragmentUnitTest {
|
||||||
layoutInflater = LayoutInflater.from(activity)
|
layoutInflater = LayoutInflater.from(activity)
|
||||||
view = layoutInflater
|
view = layoutInflater
|
||||||
.inflate(R.layout.fragment_bookmarks_items, null) as View
|
.inflate(R.layout.fragment_bookmarks_items, null) as View
|
||||||
|
binding = FragmentBookmarksItemsBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
statusTextView = view.findViewById(R.id.status_message)
|
statusTextView = view.findViewById(R.id.status_message)
|
||||||
progressBar = view.findViewById(R.id.loading_images_progress_bar)
|
progressBar = view.findViewById(R.id.loading_images_progress_bar)
|
||||||
recyclerView = view.findViewById(R.id.list_view)
|
recyclerView = view.findViewById(R.id.list_view)
|
||||||
|
|
||||||
fragment.statusTextView = statusTextView
|
|
||||||
fragment.progressBar = progressBar
|
|
||||||
fragment.recyclerView = recyclerView
|
|
||||||
fragment.parentLayout = parentLayout
|
|
||||||
fragment.controller = controller
|
fragment.controller = controller
|
||||||
|
|
||||||
|
Whitebox.setInternalState(fragment, "binding", binding)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -132,4 +132,4 @@ class BookmarkItemsFragmentUnitTest {
|
||||||
fun checkFragmentNotNull() {
|
fun checkFragmentNotNull() {
|
||||||
Assert.assertNotNull(fragment)
|
Assert.assertNotNull(fragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.contributions.ContributionController
|
import fr.free.nrw.commons.contributions.ContributionController
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksLocationsBinding
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore
|
import fr.free.nrw.commons.kvstore.JsonKvStore
|
||||||
import fr.free.nrw.commons.nearby.Place
|
import fr.free.nrw.commons.nearby.Place
|
||||||
import fr.free.nrw.commons.nearby.fragments.CommonPlaceClickActions
|
import fr.free.nrw.commons.nearby.fragments.CommonPlaceClickActions
|
||||||
|
|
@ -52,9 +53,6 @@ class BookmarkLocationFragmentUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var store: JsonKvStore
|
lateinit var store: JsonKvStore
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var parentLayout: RelativeLayout
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var savedInstanceState: Bundle
|
private lateinit var savedInstanceState: Bundle
|
||||||
|
|
||||||
|
|
@ -70,6 +68,8 @@ class BookmarkLocationFragmentUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var adapter: PlaceAdapter
|
private lateinit var adapter: PlaceAdapter
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentBookmarksLocationsBinding
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Mock bookmark list.
|
* Get Mock bookmark list.
|
||||||
*/
|
*/
|
||||||
|
|
@ -109,20 +109,18 @@ class BookmarkLocationFragmentUnitTests {
|
||||||
layoutInflater = LayoutInflater.from(activity)
|
layoutInflater = LayoutInflater.from(activity)
|
||||||
view = layoutInflater
|
view = layoutInflater
|
||||||
.inflate(R.layout.fragment_bookmarks_locations, null) as View
|
.inflate(R.layout.fragment_bookmarks_locations, null) as View
|
||||||
|
binding = FragmentBookmarksLocationsBinding.bind(view)
|
||||||
|
|
||||||
statusTextView = view.findViewById(R.id.statusMessage)
|
statusTextView = view.findViewById(R.id.statusMessage)
|
||||||
progressBar = view.findViewById(R.id.loadingImagesProgressBar)
|
progressBar = view.findViewById(R.id.loadingImagesProgressBar)
|
||||||
recyclerView = view.findViewById(R.id.listView)
|
recyclerView = view.findViewById(R.id.listView)
|
||||||
commonPlaceClickActions = CommonPlaceClickActions(store,activity,contributionController)
|
commonPlaceClickActions = CommonPlaceClickActions(store,activity,contributionController)
|
||||||
|
|
||||||
fragment.statusTextView = statusTextView
|
|
||||||
fragment.progressBar = progressBar
|
|
||||||
fragment.recyclerView = recyclerView
|
|
||||||
fragment.parentLayout = parentLayout
|
|
||||||
fragment.bookmarkLocationDao = bookmarkLocationDao
|
fragment.bookmarkLocationDao = bookmarkLocationDao
|
||||||
fragment.controller = controller
|
fragment.controller = controller
|
||||||
fragment.commonPlaceClickActions = commonPlaceClickActions
|
fragment.commonPlaceClickActions = commonPlaceClickActions
|
||||||
Whitebox.setInternalState(fragment, "adapter", adapter)
|
Whitebox.setInternalState(fragment, "adapter", adapter)
|
||||||
|
Whitebox.setInternalState(fragment, "binding", binding)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,4 +171,4 @@ class BookmarkLocationFragmentUnitTests {
|
||||||
fun testOnResume() {
|
fun testOnResume() {
|
||||||
fragment.onResume()
|
fragment.onResume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@ import androidx.test.core.app.ApplicationProvider
|
||||||
import com.nhaarman.mockitokotlin2.any
|
import com.nhaarman.mockitokotlin2.any
|
||||||
import com.nhaarman.mockitokotlin2.times
|
import com.nhaarman.mockitokotlin2.times
|
||||||
import com.nhaarman.mockitokotlin2.verify
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.Media
|
import fr.free.nrw.commons.Media
|
||||||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||||
import fr.free.nrw.commons.R
|
import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.category.GridViewAdapter
|
import fr.free.nrw.commons.category.GridViewAdapter
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentBookmarksPicturesBinding
|
||||||
import fr.free.nrw.commons.media.MediaClient
|
import fr.free.nrw.commons.media.MediaClient
|
||||||
import fr.free.nrw.commons.profile.ProfileActivity
|
import fr.free.nrw.commons.profile.ProfileActivity
|
||||||
import media
|
import media
|
||||||
|
|
@ -49,9 +51,9 @@ class BookmarkPicturesFragmentUnitTests {
|
||||||
|
|
||||||
private lateinit var fragment: BookmarkPicturesFragment
|
private lateinit var fragment: BookmarkPicturesFragment
|
||||||
|
|
||||||
private lateinit var context: Context
|
private lateinit var binding: FragmentBookmarksPicturesBinding
|
||||||
|
|
||||||
private lateinit var view: View
|
private lateinit var context: Context
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
lateinit var statusTextView: TextView
|
lateinit var statusTextView: TextView
|
||||||
|
|
@ -97,13 +99,7 @@ class BookmarkPicturesFragmentUnitTests {
|
||||||
fragmentTransaction.add(fragment, null)
|
fragmentTransaction.add(fragment, null)
|
||||||
fragmentTransaction.commit()
|
fragmentTransaction.commit()
|
||||||
|
|
||||||
view = LayoutInflater.from(activity)
|
binding = FragmentBookmarksPicturesBinding.inflate(LayoutInflater.from(activity))
|
||||||
.inflate(R.layout.fragment_bookmarks_pictures, null) as View
|
|
||||||
|
|
||||||
fragment.statusTextView = statusTextView
|
|
||||||
fragment.progressBar = progressBar
|
|
||||||
fragment.gridView = gridView
|
|
||||||
fragment.parentLayout = parentLayout
|
|
||||||
|
|
||||||
val bookmarkDao = BookmarkPicturesDao { client }
|
val bookmarkDao = BookmarkPicturesDao { client }
|
||||||
|
|
||||||
|
|
@ -116,6 +112,12 @@ class BookmarkPicturesFragmentUnitTests {
|
||||||
0,
|
0,
|
||||||
listOf(media())
|
listOf(media())
|
||||||
))
|
))
|
||||||
|
Whitebox.setInternalState(fragment, "binding", binding)
|
||||||
|
|
||||||
|
Whitebox.setInternalState(binding, "statusMessage", statusTextView)
|
||||||
|
Whitebox.setInternalState(binding, "loadingImagesProgressBar", progressBar)
|
||||||
|
Whitebox.setInternalState(binding, "bookmarkedPicturesList", gridView)
|
||||||
|
Whitebox.setInternalState(binding, "parentLayout", parentLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -127,7 +129,7 @@ class BookmarkPicturesFragmentUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnViewCreated() {
|
fun testOnViewCreated() {
|
||||||
fragment.onViewCreated(view, savedInstanceState)
|
fragment.onViewCreated(binding.root, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -216,4 +218,4 @@ class BookmarkPicturesFragmentUnitTests {
|
||||||
method.isAccessible = true
|
method.isAccessible = true
|
||||||
method.invoke(fragment)
|
method.invoke(fragment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import fr.free.nrw.commons.Media
|
||||||
import fr.free.nrw.commons.R
|
import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
import fr.free.nrw.commons.TestUtility.setFinalStatic
|
||||||
|
import fr.free.nrw.commons.databinding.LayoutContributionBinding
|
||||||
import fr.free.nrw.commons.media.MediaClient
|
import fr.free.nrw.commons.media.MediaClient
|
||||||
import fr.free.nrw.commons.profile.ProfileActivity
|
import fr.free.nrw.commons.profile.ProfileActivity
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
|
@ -46,17 +47,6 @@ class ContributionViewHolderUnitTests {
|
||||||
private lateinit var contributionViewHolder: ContributionViewHolder
|
private lateinit var contributionViewHolder: ContributionViewHolder
|
||||||
private lateinit var activity: ProfileActivity
|
private lateinit var activity: ProfileActivity
|
||||||
private lateinit var parent: View
|
private lateinit var parent: View
|
||||||
private lateinit var pauseResumeButton: ImageButton
|
|
||||||
private lateinit var addToWikipediaButton: ImageButton
|
|
||||||
private lateinit var cancelButton: ImageButton
|
|
||||||
private lateinit var retryButton: ImageButton
|
|
||||||
private lateinit var imageOptions: RelativeLayout
|
|
||||||
private lateinit var imageView: SimpleDraweeView
|
|
||||||
private lateinit var titleView: TextView
|
|
||||||
private lateinit var authorView: TextView
|
|
||||||
private lateinit var stateView: TextView
|
|
||||||
private lateinit var seqNumView: TextView
|
|
||||||
private lateinit var progressView: ProgressBar
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var callback: ContributionsListAdapter.Callback
|
private lateinit var callback: ContributionsListAdapter.Callback
|
||||||
|
|
@ -76,6 +66,8 @@ class ContributionViewHolderUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var media: Media
|
private lateinit var media: Media
|
||||||
|
|
||||||
|
private lateinit var bindind : LayoutContributionBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
|
|
@ -85,42 +77,10 @@ class ContributionViewHolderUnitTests {
|
||||||
parent = LayoutInflater.from(activity).inflate(R.layout.layout_contribution, null)
|
parent = LayoutInflater.from(activity).inflate(R.layout.layout_contribution, null)
|
||||||
contributionViewHolder = ContributionViewHolder(parent, callback, mediaClient)
|
contributionViewHolder = ContributionViewHolder(parent, callback, mediaClient)
|
||||||
|
|
||||||
pauseResumeButton = parent.findViewById(R.id.pauseResumeButton)
|
bindind = LayoutContributionBinding.bind(parent)
|
||||||
Whitebox.setInternalState(contributionViewHolder, "pauseResumeButton", pauseResumeButton)
|
|
||||||
|
|
||||||
addToWikipediaButton = parent.findViewById(R.id.wikipediaButton)
|
Whitebox.setInternalState(contributionViewHolder, "binding", bindind)
|
||||||
Whitebox.setInternalState(
|
|
||||||
contributionViewHolder,
|
|
||||||
"addToWikipediaButton",
|
|
||||||
addToWikipediaButton
|
|
||||||
)
|
|
||||||
|
|
||||||
cancelButton = parent.findViewById(R.id.cancelButton)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "cancelButton", cancelButton)
|
|
||||||
|
|
||||||
retryButton = parent.findViewById(R.id.retryButton)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "retryButton", retryButton)
|
|
||||||
|
|
||||||
imageOptions = parent.findViewById(R.id.image_options)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "imageOptions", imageOptions)
|
|
||||||
|
|
||||||
imageView = parent.findViewById(R.id.contributionImage)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "imageView", imageView)
|
|
||||||
|
|
||||||
titleView = parent.findViewById(R.id.contributionTitle)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "titleView", titleView)
|
|
||||||
|
|
||||||
authorView = parent.findViewById(R.id.authorView)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "authorView", authorView)
|
|
||||||
|
|
||||||
stateView = parent.findViewById(R.id.contributionState)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "stateView", stateView)
|
|
||||||
|
|
||||||
seqNumView = parent.findViewById(R.id.contributionSequenceNumber)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "seqNumView", seqNumView)
|
|
||||||
|
|
||||||
progressView = parent.findViewById(R.id.contributionProgress)
|
|
||||||
Whitebox.setInternalState(contributionViewHolder, "progressView", progressView)
|
|
||||||
setFinalStatic(
|
setFinalStatic(
|
||||||
ContributionViewHolder::class.java.getDeclaredField("compositeDisposable"),
|
ContributionViewHolder::class.java.getDeclaredField("compositeDisposable"),
|
||||||
compositeDisposable)
|
compositeDisposable)
|
||||||
|
|
@ -185,7 +145,7 @@ class ContributionViewHolderUnitTests {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnPauseResumeButtonClickedCaseFalse() {
|
fun testOnPauseResumeButtonClickedCaseFalse() {
|
||||||
pauseResumeButton.tag = ""
|
bindind.pauseResumeButton.tag = ""
|
||||||
contributionViewHolder.onPauseResumeButtonClicked()
|
contributionViewHolder.onPauseResumeButtonClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,4 +316,4 @@ class ContributionViewHolderUnitTests {
|
||||||
contributionViewHolder.init(0, contribution)
|
contributionViewHolder.init(0, contribution)
|
||||||
Assert.assertNotNull(contributionViewHolder.imageRequest)
|
Assert.assertNotNull(contributionViewHolder.imageRequest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.campaigns.CampaignView
|
import fr.free.nrw.commons.campaigns.CampaignView
|
||||||
import fr.free.nrw.commons.campaigns.models.Campaign
|
import fr.free.nrw.commons.campaigns.models.Campaign
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentContributionsBinding
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore
|
import fr.free.nrw.commons.kvstore.JsonKvStore
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
||||||
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
|
||||||
|
|
@ -120,21 +121,10 @@ class ContributionsFragmentUnitTests {
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "contributionsListFragment", contributionsListFragment)
|
Whitebox.setInternalState(fragment, "contributionsListFragment", contributionsListFragment)
|
||||||
Whitebox.setInternalState(fragment, "store", store)
|
Whitebox.setInternalState(fragment, "store", store)
|
||||||
Whitebox.setInternalState(
|
|
||||||
fragment,
|
|
||||||
"limitedConnectionEnabledLayout",
|
|
||||||
limitedConnectionEnabledLayout
|
|
||||||
)
|
|
||||||
Whitebox.setInternalState(fragment, "notificationCount", notificationCount)
|
Whitebox.setInternalState(fragment, "notificationCount", notificationCount)
|
||||||
Whitebox.setInternalState(fragment, "notificationController", notificationController)
|
Whitebox.setInternalState(fragment, "notificationController", notificationController)
|
||||||
Whitebox.setInternalState(fragment, "compositeDisposable", compositeDisposable)
|
Whitebox.setInternalState(fragment, "compositeDisposable", compositeDisposable)
|
||||||
Whitebox.setInternalState(fragment, "okHttpJsonApiClient", okHttpJsonApiClient)
|
Whitebox.setInternalState(fragment, "okHttpJsonApiClient", okHttpJsonApiClient)
|
||||||
Whitebox.setInternalState(
|
|
||||||
fragment,
|
|
||||||
"nearbyNotificationCardView",
|
|
||||||
nearbyNotificationCardView
|
|
||||||
)
|
|
||||||
Whitebox.setInternalState(fragment, "campaignView", campaignView)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -360,4 +350,4 @@ class ContributionsFragmentUnitTests {
|
||||||
fragment.showDetail(0, false)
|
fragment.showDetail(0, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -481,4 +481,4 @@ class MainActivityUnitTests {
|
||||||
.putBoolean("last_opened_nearby",false)
|
.putBoolean("last_opened_nearby",false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.contributions.MainActivity
|
import fr.free.nrw.commons.contributions.MainActivity
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
import org.junit.Ignore
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
|
@ -69,8 +70,6 @@ class ExploreFragmentUnitTest {
|
||||||
view = fragment.onCreateView(layoutInflater, null, null) as View
|
view = fragment.onCreateView(layoutInflater, null, null) as View
|
||||||
viewPager = view.findViewById(R.id.viewPager)
|
viewPager = view.findViewById(R.id.viewPager)
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "viewPager", viewPager)
|
|
||||||
Whitebox.setInternalState(fragment, "tabLayout", tabLayout)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -102,7 +101,7 @@ class ExploreFragmentUnitTest {
|
||||||
Assert.assertEquals(fragment.onBackPressed(), true)
|
Assert.assertEquals(fragment.onBackPressed(), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @Ignore("TODO fix this test")
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnBackPressedCaseTrueSelectedTabNonZero() {
|
fun testOnBackPressedCaseTrueSelectedTabNonZero() {
|
||||||
Whitebox.setInternalState(fragment, "mobileRootFragment", exploreRootFragment)
|
Whitebox.setInternalState(fragment, "mobileRootFragment", exploreRootFragment)
|
||||||
|
|
@ -152,4 +151,4 @@ class ExploreFragmentUnitTest {
|
||||||
verify(inflater).inflate(R.menu.menu_search, menu)
|
verify(inflater).inflate(R.menu.menu_search, menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,9 @@ package fr.free.nrw.commons.explore
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.widget.FrameLayout
|
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import com.google.android.material.tabs.TabLayout
|
|
||||||
import com.nhaarman.mockitokotlin2.any
|
import com.nhaarman.mockitokotlin2.any
|
||||||
import com.nhaarman.mockitokotlin2.times
|
import com.nhaarman.mockitokotlin2.times
|
||||||
import fr.free.nrw.commons.Media
|
import fr.free.nrw.commons.Media
|
||||||
|
|
@ -16,6 +13,7 @@ import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.contributions.MainActivity
|
import fr.free.nrw.commons.contributions.MainActivity
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentFeaturedRootBinding
|
||||||
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment
|
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
@ -42,11 +40,11 @@ class ExploreListRootFragmentUnitTest {
|
||||||
private lateinit var fragment: ExploreListRootFragment
|
private lateinit var fragment: ExploreListRootFragment
|
||||||
private lateinit var fragmentManager: FragmentManager
|
private lateinit var fragmentManager: FragmentManager
|
||||||
private lateinit var context: Context
|
private lateinit var context: Context
|
||||||
private lateinit var view: View
|
|
||||||
private lateinit var layoutInflater: LayoutInflater
|
|
||||||
private lateinit var activity: MainActivity
|
private lateinit var activity: MainActivity
|
||||||
private lateinit var exploreFragment: ExploreFragment
|
private lateinit var exploreFragment: ExploreFragment
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentFeaturedRootBinding
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mediaDetails: MediaDetailPagerFragment
|
private lateinit var mediaDetails: MediaDetailPagerFragment
|
||||||
|
|
||||||
|
|
@ -59,15 +57,6 @@ class ExploreListRootFragmentUnitTest {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var childFragmentTransaction: FragmentTransaction
|
private lateinit var childFragmentTransaction: FragmentTransaction
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var container: FrameLayout
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var tabLayout: TabLayout
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var viewPager: ParentViewPager
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var media: Media
|
private lateinit var media: Media
|
||||||
|
|
||||||
|
|
@ -87,16 +76,13 @@ class ExploreListRootFragmentUnitTest {
|
||||||
|
|
||||||
exploreFragment = ExploreFragment()
|
exploreFragment = ExploreFragment()
|
||||||
|
|
||||||
layoutInflater = LayoutInflater.from(activity)
|
binding = FragmentFeaturedRootBinding.inflate(LayoutInflater.from(activity))
|
||||||
view = fragment.onCreateView(layoutInflater, null, null) as View
|
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "mChildFragmentManager", childFragmentManager)
|
Whitebox.setInternalState(fragment, "mChildFragmentManager", childFragmentManager)
|
||||||
Whitebox.setInternalState(fragment, "mParentFragment", exploreFragment)
|
Whitebox.setInternalState(fragment, "mParentFragment", exploreFragment)
|
||||||
Whitebox.setInternalState(fragment, "mediaDetails", mediaDetails)
|
Whitebox.setInternalState(fragment, "mediaDetails", mediaDetails)
|
||||||
Whitebox.setInternalState(fragment, "listFragment", listFragment)
|
Whitebox.setInternalState(fragment, "listFragment", listFragment)
|
||||||
Whitebox.setInternalState(fragment, "container", container)
|
|
||||||
Whitebox.setInternalState(exploreFragment, "tabLayout", tabLayout)
|
|
||||||
Whitebox.setInternalState(exploreFragment, "viewPager", viewPager)
|
|
||||||
|
|
||||||
`when`(childFragmentManager.beginTransaction()).thenReturn(childFragmentTransaction)
|
`when`(childFragmentManager.beginTransaction()).thenReturn(childFragmentTransaction)
|
||||||
`when`(childFragmentTransaction.hide(any())).thenReturn(childFragmentTransaction)
|
`when`(childFragmentTransaction.hide(any())).thenReturn(childFragmentTransaction)
|
||||||
|
|
@ -116,7 +102,7 @@ class ExploreListRootFragmentUnitTest {
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnViewCreated() {
|
fun testOnViewCreated() {
|
||||||
fragment.onViewCreated(view, null)
|
fragment.onViewCreated(binding.root, null)
|
||||||
verify(childFragmentManager).beginTransaction()
|
verify(childFragmentManager).beginTransaction()
|
||||||
verify(childFragmentTransaction).hide(mediaDetails)
|
verify(childFragmentTransaction).hide(mediaDetails)
|
||||||
verify(childFragmentTransaction).add(R.id.explore_container, listFragment)
|
verify(childFragmentTransaction).add(R.id.explore_container, listFragment)
|
||||||
|
|
@ -179,8 +165,6 @@ class ExploreListRootFragmentUnitTest {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnMediaClicked() {
|
fun testOnMediaClicked() {
|
||||||
fragment.onMediaClicked(0)
|
fragment.onMediaClicked(0)
|
||||||
verify(container).visibility = View.VISIBLE
|
|
||||||
verify(tabLayout).visibility = View.GONE
|
|
||||||
verify(childFragmentManager).beginTransaction()
|
verify(childFragmentManager).beginTransaction()
|
||||||
verify(childFragmentTransaction).hide(listFragment)
|
verify(childFragmentTransaction).hide(listFragment)
|
||||||
verify(childFragmentTransaction).addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
verify(childFragmentTransaction).addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
||||||
|
|
@ -235,8 +219,6 @@ class ExploreListRootFragmentUnitTest {
|
||||||
verify(childFragmentTransaction).remove(mediaDetails)
|
verify(childFragmentTransaction).remove(mediaDetails)
|
||||||
verify(childFragmentTransaction, times(2)).commit()
|
verify(childFragmentTransaction, times(2)).commit()
|
||||||
verify(childFragmentManager, times(2)).executePendingTransactions()
|
verify(childFragmentManager, times(2)).executePendingTransactions()
|
||||||
verify(container).visibility = View.VISIBLE
|
|
||||||
verify(tabLayout).visibility = View.GONE
|
|
||||||
verify(childFragmentTransaction).hide(listFragment)
|
verify(childFragmentTransaction).hide(listFragment)
|
||||||
verify(childFragmentTransaction).addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
verify(childFragmentTransaction).addToBackStack("CONTRIBUTION_LIST_FRAGMENT_TAG")
|
||||||
}
|
}
|
||||||
|
|
@ -268,4 +250,4 @@ class ExploreListRootFragmentUnitTest {
|
||||||
Assert.assertEquals(fragment.backPressed(), false)
|
Assert.assertEquals(fragment.backPressed(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||||
import fr.free.nrw.commons.R
|
import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
|
import fr.free.nrw.commons.databinding.ActivityWikidataItemDetailsBinding
|
||||||
import fr.free.nrw.commons.explore.depictions.media.DepictedImagesFragment
|
import fr.free.nrw.commons.explore.depictions.media.DepictedImagesFragment
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment
|
||||||
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
import fr.free.nrw.commons.upload.structure.depictions.DepictedItem
|
||||||
|
|
@ -36,7 +37,6 @@ import org.robolectric.fakes.RoboMenuItem
|
||||||
class WikidataItemDetailsActivityUnitTests {
|
class WikidataItemDetailsActivityUnitTests {
|
||||||
|
|
||||||
private lateinit var activity: WikidataItemDetailsActivity
|
private lateinit var activity: WikidataItemDetailsActivity
|
||||||
private lateinit var parent: View
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mediaDetailPagerFragment: MediaDetailPagerFragment
|
private lateinit var mediaDetailPagerFragment: MediaDetailPagerFragment
|
||||||
|
|
@ -53,14 +53,6 @@ class WikidataItemDetailsActivityUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var wikidataItem: DepictedItem
|
private lateinit var wikidataItem: DepictedItem
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var mediaContainer: FrameLayout
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var tabLayout: TabLayout
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var viewPager: ViewPager
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
|
|
@ -83,17 +75,6 @@ class WikidataItemDetailsActivityUnitTests {
|
||||||
)
|
)
|
||||||
Whitebox.setInternalState(activity, "supportFragmentManager", supportFragmentManager)
|
Whitebox.setInternalState(activity, "supportFragmentManager", supportFragmentManager)
|
||||||
|
|
||||||
parent =
|
|
||||||
LayoutInflater.from(activity).inflate(R.layout.activity_wikidata_item_details, null)
|
|
||||||
|
|
||||||
mediaContainer = parent.findViewById(R.id.mediaContainer)
|
|
||||||
Whitebox.setInternalState(activity, "mediaContainer", mediaContainer)
|
|
||||||
|
|
||||||
tabLayout = parent.findViewById(R.id.tab_layout)
|
|
||||||
Whitebox.setInternalState(activity, "tabLayout", tabLayout)
|
|
||||||
|
|
||||||
viewPager = parent.findViewById(R.id.viewPager)
|
|
||||||
Whitebox.setInternalState(activity, "viewPager", viewPager)
|
|
||||||
|
|
||||||
Whitebox.setInternalState(activity, "wikidataItem", wikidataItem)
|
Whitebox.setInternalState(activity, "wikidataItem", wikidataItem)
|
||||||
|
|
||||||
|
|
@ -189,4 +170,4 @@ class WikidataItemDetailsActivityUnitTests {
|
||||||
activity.onMediaClicked(0)
|
activity.onMediaClicked(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,20 +38,11 @@ class RecentSearchesFragmentUnitTest {
|
||||||
private lateinit var fragment: RecentSearchesFragment
|
private lateinit var fragment: RecentSearchesFragment
|
||||||
private lateinit var fragmentManager: FragmentManager
|
private lateinit var fragmentManager: FragmentManager
|
||||||
private lateinit var context: Context
|
private lateinit var context: Context
|
||||||
private lateinit var view: View
|
|
||||||
private lateinit var layoutInflater: LayoutInflater
|
private lateinit var layoutInflater: LayoutInflater
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var recentSearchesDao: RecentSearchesDao
|
private lateinit var recentSearchesDao: RecentSearchesDao
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var imageView: ImageView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var textView: TextView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var listView: ListView
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var adapter: ArrayAdapter<*>
|
private lateinit var adapter: ArrayAdapter<*>
|
||||||
|
|
@ -77,14 +68,9 @@ class RecentSearchesFragmentUnitTest {
|
||||||
fragmentTransaction.commitNowAllowingStateLoss()
|
fragmentTransaction.commitNowAllowingStateLoss()
|
||||||
|
|
||||||
layoutInflater = LayoutInflater.from(activity)
|
layoutInflater = LayoutInflater.from(activity)
|
||||||
view = LayoutInflater.from(activity)
|
|
||||||
.inflate(R.layout.fragment_leaderboard, null) as View
|
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "recentSearchesDao", recentSearchesDao)
|
Whitebox.setInternalState(fragment, "recentSearchesDao", recentSearchesDao)
|
||||||
Whitebox.setInternalState(fragment, "recent_searches_delete_button", imageView)
|
|
||||||
Whitebox.setInternalState(fragment, "recent_searches_text_view", textView)
|
|
||||||
Whitebox.setInternalState(fragment, "adapter", adapter)
|
Whitebox.setInternalState(fragment, "adapter", adapter)
|
||||||
Whitebox.setInternalState(fragment, "recentSearchesList", listView)
|
|
||||||
Whitebox.setInternalState(fragment, "recentSearches", listOf("string"))
|
Whitebox.setInternalState(fragment, "recentSearches", listOf("string"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,4 +141,4 @@ class RecentSearchesFragmentUnitTest {
|
||||||
method.invoke(fragment, context, dialog, 0)
|
method.invoke(fragment, context, dialog, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.nhaarman.mockitokotlin2.verify
|
||||||
import fr.free.nrw.commons.Media
|
import fr.free.nrw.commons.Media
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.ViewPagerAdapter
|
import fr.free.nrw.commons.ViewPagerAdapter
|
||||||
|
import fr.free.nrw.commons.databinding.ActivitySearchBinding
|
||||||
import fr.free.nrw.commons.explore.SearchActivity
|
import fr.free.nrw.commons.explore.SearchActivity
|
||||||
import fr.free.nrw.commons.explore.categories.search.SearchCategoryFragment
|
import fr.free.nrw.commons.explore.categories.search.SearchCategoryFragment
|
||||||
import fr.free.nrw.commons.explore.depictions.search.SearchDepictionsFragment
|
import fr.free.nrw.commons.explore.depictions.search.SearchDepictionsFragment
|
||||||
|
|
@ -45,15 +46,6 @@ class SearchActivityUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var activity: SearchActivity
|
private lateinit var activity: SearchActivity
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var searchView: SearchView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var viewPager: ViewPager
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var context: Context
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var compositeDisposable: CompositeDisposable
|
private lateinit var compositeDisposable: CompositeDisposable
|
||||||
|
|
||||||
|
|
@ -81,6 +73,8 @@ class SearchActivityUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var searchCategoryFragment: SearchCategoryFragment
|
private lateinit var searchCategoryFragment: SearchCategoryFragment
|
||||||
|
|
||||||
|
private lateinit var context: Context
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.openMocks(this)
|
MockitoAnnotations.openMocks(this)
|
||||||
|
|
@ -102,17 +96,6 @@ class SearchActivityUnitTests {
|
||||||
verify(viewPagerAdapter).notifyDataSetChanged()
|
verify(viewPagerAdapter).notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Throws(Exception::class)
|
|
||||||
fun testUpdateText() {
|
|
||||||
val query = "test"
|
|
||||||
Whitebox.setInternalState(activity, "searchView", searchView)
|
|
||||||
Whitebox.setInternalState(activity, "viewPager", viewPager)
|
|
||||||
activity.updateText(query)
|
|
||||||
verify(searchView).setQuery(query, true)
|
|
||||||
verify(viewPager).requestFocus()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnBackPressed() {
|
fun testOnBackPressed() {
|
||||||
|
|
@ -238,4 +221,4 @@ class SearchActivityUnitTests {
|
||||||
verify(searchCategoryFragment).onQueryUpdated(query)
|
verify(searchCategoryFragment).onQueryUpdated(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
import fr.free.nrw.commons.auth.SessionManager
|
import fr.free.nrw.commons.auth.SessionManager
|
||||||
|
import fr.free.nrw.commons.databinding.FragmentLeaderboardBinding
|
||||||
import fr.free.nrw.commons.profile.ProfileActivity
|
import fr.free.nrw.commons.profile.ProfileActivity
|
||||||
import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment
|
import fr.free.nrw.commons.profile.leaderboard.LeaderboardFragment
|
||||||
import fr.free.nrw.commons.profile.leaderboard.LeaderboardListAdapter
|
import fr.free.nrw.commons.profile.leaderboard.LeaderboardListAdapter
|
||||||
|
|
@ -47,21 +48,12 @@ class LeaderboardFragmentUnitTests {
|
||||||
private lateinit var fragment: LeaderboardFragment
|
private lateinit var fragment: LeaderboardFragment
|
||||||
private lateinit var fragmentManager: FragmentManager
|
private lateinit var fragmentManager: FragmentManager
|
||||||
private lateinit var context: Context
|
private lateinit var context: Context
|
||||||
private lateinit var view: View
|
|
||||||
private lateinit var layoutInflater: LayoutInflater
|
private lateinit var layoutInflater: LayoutInflater
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var progressBar: ProgressBar
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var spinner: Spinner
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var viewModel: LeaderboardListViewModel
|
private lateinit var viewModel: LeaderboardListViewModel
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var recyclerView: RecyclerView
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var adapter: LeaderboardListAdapter
|
private lateinit var adapter: LeaderboardListAdapter
|
||||||
|
|
||||||
|
|
@ -71,12 +63,11 @@ class LeaderboardFragmentUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var account: Account
|
private lateinit var account: Account
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var button: Button
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var parentView: ViewGroup
|
private lateinit var parentView: ViewGroup
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentLeaderboardBinding
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
|
|
@ -92,15 +83,9 @@ class LeaderboardFragmentUnitTests {
|
||||||
fragmentTransaction.commitNowAllowingStateLoss()
|
fragmentTransaction.commitNowAllowingStateLoss()
|
||||||
|
|
||||||
layoutInflater = LayoutInflater.from(activity)
|
layoutInflater = LayoutInflater.from(activity)
|
||||||
view = LayoutInflater.from(activity)
|
binding = FragmentLeaderboardBinding.inflate(layoutInflater)
|
||||||
.inflate(R.layout.fragment_leaderboard, null) as View
|
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "progressBar", progressBar)
|
|
||||||
Whitebox.setInternalState(fragment, "categorySpinner", spinner)
|
|
||||||
Whitebox.setInternalState(fragment, "durationSpinner", spinner)
|
|
||||||
Whitebox.setInternalState(fragment, "viewModel", viewModel)
|
Whitebox.setInternalState(fragment, "viewModel", viewModel)
|
||||||
Whitebox.setInternalState(fragment, "scrollButton", button)
|
|
||||||
Whitebox.setInternalState(fragment, "leaderboardListRecyclerView", recyclerView)
|
|
||||||
Whitebox.setInternalState(fragment, "mView", parentView)
|
Whitebox.setInternalState(fragment, "mView", parentView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +125,6 @@ class LeaderboardFragmentUnitTests {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testScrollToUserRankCaseNonZeroTrue() {
|
fun testScrollToUserRankCaseNonZeroTrue() {
|
||||||
Whitebox.setInternalState(fragment, "userRank", 1)
|
Whitebox.setInternalState(fragment, "userRank", 1)
|
||||||
`when`(recyclerView.adapter).thenReturn(adapter)
|
|
||||||
`when`(adapter.itemCount).thenReturn(3)
|
`when`(adapter.itemCount).thenReturn(3)
|
||||||
val method: Method = LeaderboardFragment::class.java.getDeclaredMethod(
|
val method: Method = LeaderboardFragment::class.java.getDeclaredMethod(
|
||||||
"scrollToUserRank"
|
"scrollToUserRank"
|
||||||
|
|
@ -153,7 +137,6 @@ class LeaderboardFragmentUnitTests {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testScrollToUserRankCaseNonZeroFalse() {
|
fun testScrollToUserRankCaseNonZeroFalse() {
|
||||||
Whitebox.setInternalState(fragment, "userRank", 1)
|
Whitebox.setInternalState(fragment, "userRank", 1)
|
||||||
`when`(recyclerView.adapter).thenReturn(adapter)
|
|
||||||
`when`(adapter.itemCount).thenReturn(1)
|
`when`(adapter.itemCount).thenReturn(1)
|
||||||
val method: Method = LeaderboardFragment::class.java.getDeclaredMethod(
|
val method: Method = LeaderboardFragment::class.java.getDeclaredMethod(
|
||||||
"scrollToUserRank"
|
"scrollToUserRank"
|
||||||
|
|
@ -245,4 +228,4 @@ class LeaderboardFragmentUnitTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.locationpicker
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
|
@ -20,10 +21,14 @@ import com.nhaarman.mockitokotlin2.times
|
||||||
import com.nhaarman.mockitokotlin2.verify
|
import com.nhaarman.mockitokotlin2.verify
|
||||||
import com.nhaarman.mockitokotlin2.whenever
|
import com.nhaarman.mockitokotlin2.whenever
|
||||||
import fr.free.nrw.commons.LocationPicker.LocationPickerActivity
|
import fr.free.nrw.commons.LocationPicker.LocationPickerActivity
|
||||||
|
import fr.free.nrw.commons.Media
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
|
import fr.free.nrw.commons.coordinates.CoordinateEditHelper
|
||||||
import fr.free.nrw.commons.kvstore.JsonKvStore
|
import fr.free.nrw.commons.kvstore.JsonKvStore
|
||||||
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION
|
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION
|
||||||
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_ZOOM
|
import fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_ZOOM
|
||||||
|
import io.reactivex.android.plugins.RxAndroidPlugins
|
||||||
|
import io.reactivex.schedulers.Schedulers
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
|
@ -93,6 +98,7 @@ class LocationPickerActivityUnitTests {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
context = RuntimeEnvironment.getApplication().applicationContext
|
context = RuntimeEnvironment.getApplication().applicationContext
|
||||||
activity = Robolectric.buildActivity(LocationPickerActivity::class.java).get()
|
activity = Robolectric.buildActivity(LocationPickerActivity::class.java).get()
|
||||||
|
RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() }
|
||||||
|
|
||||||
Whitebox.setInternalState(activity, "mapView", mapView)
|
Whitebox.setInternalState(activity, "mapView", mapView)
|
||||||
Whitebox.setInternalState(activity, "applicationKvStore", applicationKvStore)
|
Whitebox.setInternalState(activity, "applicationKvStore", applicationKvStore)
|
||||||
|
|
@ -165,4 +171,5 @@ class LocationPickerActivityUnitTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ class ProfileActivityTest {
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
fun testToolbarNotNull() {
|
fun testToolbarNotNull() {
|
||||||
val toolbar = activity.findViewById<Toolbar>(R.id.toolbar)
|
val toolbar = activity.binding.toolbarBinding.toolbar
|
||||||
Assert.assertNotNull(toolbar)
|
Assert.assertNotNull(toolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,4 +120,4 @@ class ProfileActivityTest {
|
||||||
Assert.assertEquals(1, menu.size())
|
Assert.assertEquals(1, menu.size())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||||
import fr.free.nrw.commons.R
|
import fr.free.nrw.commons.R
|
||||||
import fr.free.nrw.commons.TestCommonsApplication
|
import fr.free.nrw.commons.TestCommonsApplication
|
||||||
import fr.free.nrw.commons.createTestClient
|
import fr.free.nrw.commons.createTestClient
|
||||||
|
import fr.free.nrw.commons.databinding.UploadCategoriesFragmentBinding
|
||||||
import fr.free.nrw.commons.ui.PasteSensitiveTextInputEditText
|
import fr.free.nrw.commons.ui.PasteSensitiveTextInputEditText
|
||||||
import fr.free.nrw.commons.upload.UploadActivity
|
import fr.free.nrw.commons.upload.UploadActivity
|
||||||
import fr.free.nrw.commons.upload.UploadBaseFragment
|
import fr.free.nrw.commons.upload.UploadBaseFragment
|
||||||
|
|
@ -51,41 +52,10 @@ class UploadCategoriesFragmentUnitTests {
|
||||||
private lateinit var context: Context
|
private lateinit var context: Context
|
||||||
private lateinit var fragmentManager: FragmentManager
|
private lateinit var fragmentManager: FragmentManager
|
||||||
private lateinit var layoutInflater: LayoutInflater
|
private lateinit var layoutInflater: LayoutInflater
|
||||||
private lateinit var view: View
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var subscribe: Disposable
|
private lateinit var subscribe: Disposable
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var pbCategories: ProgressBar
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var progressDialog: ProgressDialog
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var tilContainerEtSearch: TextInputLayout
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var etSearch: PasteSensitiveTextInputEditText
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var rvCategories: RecyclerView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var tvTitle: TextView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var tvSubTitle: TextView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var tooltip: ImageView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var editable: Editable
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var button: Button
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var adapter: UploadCategoryAdapter
|
private lateinit var adapter: UploadCategoryAdapter
|
||||||
|
|
||||||
|
|
@ -98,6 +68,8 @@ class UploadCategoriesFragmentUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var media: Media
|
private lateinit var media: Media
|
||||||
|
|
||||||
|
private lateinit var binding : UploadCategoriesFragmentBinding
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
|
|
@ -110,22 +82,13 @@ class UploadCategoriesFragmentUnitTests {
|
||||||
val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction()
|
val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction()
|
||||||
fragmentTransaction.add(fragment, null)
|
fragmentTransaction.add(fragment, null)
|
||||||
fragmentTransaction.commit()
|
fragmentTransaction.commit()
|
||||||
|
|
||||||
layoutInflater = LayoutInflater.from(activity)
|
layoutInflater = LayoutInflater.from(activity)
|
||||||
view = LayoutInflater.from(activity)
|
binding = UploadCategoriesFragmentBinding.inflate(layoutInflater)
|
||||||
.inflate(R.layout.upload_categories_fragment, null) as View
|
|
||||||
Whitebox.setInternalState(fragment, "subscribe", subscribe)
|
Whitebox.setInternalState(fragment, "subscribe", subscribe)
|
||||||
Whitebox.setInternalState(fragment, "pbCategories", pbCategories)
|
|
||||||
Whitebox.setInternalState(fragment, "tilContainerEtSearch", tilContainerEtSearch)
|
|
||||||
Whitebox.setInternalState(fragment, "adapter", adapter)
|
Whitebox.setInternalState(fragment, "adapter", adapter)
|
||||||
Whitebox.setInternalState(fragment, "presenter", presenter)
|
Whitebox.setInternalState(fragment, "presenter", presenter)
|
||||||
Whitebox.setInternalState(fragment, "etSearch", etSearch)
|
|
||||||
Whitebox.setInternalState(fragment, "rvCategories", rvCategories)
|
|
||||||
Whitebox.setInternalState(fragment, "tvTitle", tvTitle)
|
|
||||||
Whitebox.setInternalState(fragment, "tooltip", tooltip)
|
|
||||||
Whitebox.setInternalState(fragment, "tvSubTitle", tvSubTitle)
|
|
||||||
Whitebox.setInternalState(fragment, "btnNext", button)
|
|
||||||
Whitebox.setInternalState(fragment, "btnPrevious", button)
|
|
||||||
Whitebox.setInternalState(fragment, "progressDialog", progressDialog)
|
|
||||||
Whitebox.setInternalState(fragment, "wikiText", "[[Category:Test]]")
|
Whitebox.setInternalState(fragment, "wikiText", "[[Category:Test]]")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,7 +218,6 @@ class UploadCategoriesFragmentUnitTests {
|
||||||
fun testShowProgressDialog() {
|
fun testShowProgressDialog() {
|
||||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.showProgressDialog()
|
fragment.showProgressDialog()
|
||||||
verify(progressDialog, times(0)).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -263,7 +225,6 @@ class UploadCategoriesFragmentUnitTests {
|
||||||
fun testDismissProgressDialog() {
|
fun testDismissProgressDialog() {
|
||||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
fragment.dismissProgressDialog()
|
fragment.dismissProgressDialog()
|
||||||
verify(progressDialog, times(1)).dismiss()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -300,7 +261,6 @@ class UploadCategoriesFragmentUnitTests {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun testOnBecameVisible() {
|
fun testOnBecameVisible() {
|
||||||
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
Shadows.shadowOf(Looper.getMainLooper()).idle()
|
||||||
`when`(etSearch.text).thenReturn(editable)
|
|
||||||
val method: Method = UploadCategoriesFragment::class.java.getDeclaredMethod(
|
val method: Method = UploadCategoriesFragment::class.java.getDeclaredMethod(
|
||||||
"onBecameVisible"
|
"onBecameVisible"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,6 @@ import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.ProgressBar
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
@ -53,27 +49,6 @@ class DepictsFragmentUnitTests {
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var savedInstanceState: Bundle
|
private lateinit var savedInstanceState: Bundle
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var textView: TextView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var imageView: ImageView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var recyclerView: RecyclerView
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var textInputEditText: PasteSensitiveTextInputEditText
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var progressBar: ProgressBar
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var button: Button
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var textInputLayout: TextInputLayout
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var callback: UploadBaseFragment.Callback
|
private lateinit var callback: UploadBaseFragment.Callback
|
||||||
|
|
||||||
|
|
@ -110,16 +85,8 @@ class DepictsFragmentUnitTests {
|
||||||
view = LayoutInflater.from(activity)
|
view = LayoutInflater.from(activity)
|
||||||
.inflate(R.layout.upload_depicts_fragment, null) as View
|
.inflate(R.layout.upload_depicts_fragment, null) as View
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "depictsTitle", textView)
|
|
||||||
Whitebox.setInternalState(fragment, "callback", callback)
|
Whitebox.setInternalState(fragment, "callback", callback)
|
||||||
Whitebox.setInternalState(fragment, "tooltip", imageView)
|
|
||||||
Whitebox.setInternalState(fragment, "btnNext", button)
|
|
||||||
Whitebox.setInternalState(fragment, "btnPrevious", button)
|
|
||||||
Whitebox.setInternalState(fragment, "depictsSubTitle", textView)
|
|
||||||
Whitebox.setInternalState(fragment, "depictsRecyclerView", recyclerView)
|
|
||||||
Whitebox.setInternalState(fragment, "depictsSearch", textInputEditText)
|
|
||||||
Whitebox.setInternalState(fragment, "depictsSearchContainer", textInputLayout)
|
|
||||||
Whitebox.setInternalState(fragment, "depictsSearchInProgress", progressBar)
|
|
||||||
Whitebox.setInternalState(fragment, "subscribe", disposable)
|
Whitebox.setInternalState(fragment, "subscribe", disposable)
|
||||||
Whitebox.setInternalState(fragment, "adapter", adapter)
|
Whitebox.setInternalState(fragment, "adapter", adapter)
|
||||||
}
|
}
|
||||||
|
|
@ -309,4 +276,4 @@ class DepictsFragmentUnitTests {
|
||||||
Whitebox.setInternalState(fragment, "progressDialog", progressDialog)
|
Whitebox.setInternalState(fragment, "progressDialog", progressDialog)
|
||||||
fragment.dismissProgressDialog()
|
fragment.dismissProgressDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,20 +142,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
llContainerMediaDetail = view.findViewById(R.id.ll_container_media_detail)
|
llContainerMediaDetail = view.findViewById(R.id.ll_container_media_detail)
|
||||||
ibExpandCollapse = view.findViewById(R.id.ib_expand_collapse)
|
ibExpandCollapse = view.findViewById(R.id.ib_expand_collapse)
|
||||||
|
|
||||||
Whitebox.setInternalState(fragment, "tvTitle", tvTitle)
|
|
||||||
Whitebox.setInternalState(fragment, "tooltip", tooltip)
|
|
||||||
Whitebox.setInternalState(fragment, "callback", callback)
|
|
||||||
Whitebox.setInternalState(fragment, "rvDescriptions", rvDescriptions)
|
|
||||||
Whitebox.setInternalState(fragment, "btnPrevious", btnPrevious)
|
|
||||||
Whitebox.setInternalState(fragment, "btnNext", btnNext)
|
|
||||||
Whitebox.setInternalState(fragment, "btnCopyToSubsequentMedia", btnCopyToSubsequentMedia)
|
|
||||||
Whitebox.setInternalState(fragment, "photoViewBackgroundImage", photoViewBackgroundImage)
|
|
||||||
Whitebox.setInternalState(fragment, "uploadMediaDetailAdapter", uploadMediaDetailAdapter)
|
Whitebox.setInternalState(fragment, "uploadMediaDetailAdapter", uploadMediaDetailAdapter)
|
||||||
Whitebox.setInternalState(fragment, "llLocationStatus", locationStatusLl)
|
|
||||||
Whitebox.setInternalState(fragment, "locationImageView", locationImageView)
|
|
||||||
Whitebox.setInternalState(fragment, "locationTextView", locationTextView)
|
|
||||||
Whitebox.setInternalState(fragment, "llContainerMediaDetail", llContainerMediaDetail)
|
|
||||||
Whitebox.setInternalState(fragment, "ibExpandCollapse", ibExpandCollapse)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -388,6 +375,7 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
val cameraPosition = Mockito.mock(CameraPosition::class.java)
|
val cameraPosition = Mockito.mock(CameraPosition::class.java)
|
||||||
val latLng = Mockito.mock(LatLng::class.java)
|
val latLng = Mockito.mock(LatLng::class.java)
|
||||||
|
|
||||||
|
Whitebox.setInternalState(fragment, "callback", callback)
|
||||||
Whitebox.setInternalState(cameraPosition, "target", latLng)
|
Whitebox.setInternalState(cameraPosition, "target", latLng)
|
||||||
Whitebox.setInternalState(fragment, "editableUploadItem", uploadItem)
|
Whitebox.setInternalState(fragment, "editableUploadItem", uploadItem)
|
||||||
Whitebox.setInternalState(fragment,"isMissingLocationDialog",true)
|
Whitebox.setInternalState(fragment,"isMissingLocationDialog",true)
|
||||||
|
|
@ -497,4 +485,4 @@ class UploadMediaDetailFragmentUnitTest {
|
||||||
Assert.assertEquals(shadowIntent.intentClass, LocationPickerActivity::class.java)
|
Assert.assertEquals(shadowIntent.intentClass, LocationPickerActivity::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue