mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Delete categoryImagesActivity (#3878)
* deleted categoryImagesActivity test & activity * deleted categoryImagesActivity reference in ActivityBuilderModule * deleted categoryImages from manifest * deleted categoryImages import from ActivityBuilderModule * deleted categoryImagesActivity
This commit is contained in:
parent
593ccdb16a
commit
91a5aa1abe
4 changed files with 0 additions and 226 deletions
|
|
@ -1,19 +0,0 @@
|
||||||
package fr.free.nrw.commons
|
|
||||||
|
|
||||||
import androidx.test.rule.ActivityTestRule
|
|
||||||
import androidx.test.runner.AndroidJUnit4
|
|
||||||
import fr.free.nrw.commons.category.CategoryImagesActivity
|
|
||||||
import org.junit.Rule
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
|
||||||
class CategoryImagesActivityTest {
|
|
||||||
@get:Rule
|
|
||||||
var activityRule = ActivityTestRule(CategoryImagesActivity::class.java)
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun orientationChange() {
|
|
||||||
UITestHelper.changeOrientation(activityRule)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -108,12 +108,6 @@
|
||||||
<activity android:name=".quiz.QuizResultActivity"
|
<activity android:name=".quiz.QuizResultActivity"
|
||||||
android:label="@string/result"/>
|
android:label="@string/result"/>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".category.CategoryImagesActivity"
|
|
||||||
android:label="@string/title_activity_featured_images"
|
|
||||||
android:parentActivityName=".contributions.MainActivity"
|
|
||||||
android:configChanges="orientation|screenSize|keyboard"/>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".category.CategoryDetailsActivity"
|
android:name=".category.CategoryDetailsActivity"
|
||||||
android:label="@string/title_activity_featured_images"
|
android:label="@string/title_activity_featured_images"
|
||||||
|
|
|
||||||
|
|
@ -1,197 +0,0 @@
|
||||||
package fr.free.nrw.commons.category;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import fr.free.nrw.commons.Media;
|
|
||||||
import fr.free.nrw.commons.R;
|
|
||||||
import fr.free.nrw.commons.explore.SearchActivity;
|
|
||||||
import fr.free.nrw.commons.explore.categories.media.CategoriesMediaFragment;
|
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
|
||||||
import fr.free.nrw.commons.utils.ActivityUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This activity displays pictures of a particular category
|
|
||||||
* Its generic and simply takes the name of category name in its start intent to load all images in
|
|
||||||
* a particular category. This activity is currently being used to display a list of featured images,
|
|
||||||
* which is nothing but another category on wikimedia commons.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class CategoryImagesActivity
|
|
||||||
extends BaseActivity
|
|
||||||
implements FragmentManager.OnBackStackChangedListener,
|
|
||||||
MediaDetailPagerFragment.MediaDetailProvider,
|
|
||||||
AdapterView.OnItemClickListener, CategoryImagesCallback {
|
|
||||||
|
|
||||||
|
|
||||||
private FragmentManager supportFragmentManager;
|
|
||||||
private CategoriesMediaFragment categoriesMediaFragment;
|
|
||||||
private MediaDetailPagerFragment mediaDetails;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called on backPressed of anyFragment in the activity.
|
|
||||||
* We are changing the icon here from back to hamburger icon.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.onBackPressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_category_images);
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
// Activity can call methods in the fragment by acquiring a
|
|
||||||
// reference to the Fragment from FragmentManager, using findFragmentById()
|
|
||||||
supportFragmentManager = getSupportFragmentManager();
|
|
||||||
setCategoryImagesFragment();
|
|
||||||
supportFragmentManager.addOnBackStackChangedListener(this);
|
|
||||||
setPageTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the categoryName from the intent and initializes the fragment for showing images of that category
|
|
||||||
*/
|
|
||||||
private void setCategoryImagesFragment() {
|
|
||||||
categoriesMediaFragment = new CategoriesMediaFragment();
|
|
||||||
String categoryName = getIntent().getStringExtra("categoryName");
|
|
||||||
if (getIntent() != null && categoryName != null) {
|
|
||||||
Bundle arguments = new Bundle();
|
|
||||||
arguments.putString("categoryName", categoryName);
|
|
||||||
categoriesMediaFragment.setArguments(arguments);
|
|
||||||
FragmentTransaction transaction = supportFragmentManager.beginTransaction();
|
|
||||||
transaction
|
|
||||||
.add(R.id.fragmentContainer, categoriesMediaFragment)
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the passed title from the intents and displays it as the page title
|
|
||||||
*/
|
|
||||||
private void setPageTitle() {
|
|
||||||
if (getIntent() != null && getIntent().getStringExtra("title") != null) {
|
|
||||||
setTitle(getIntent().getStringExtra("title"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBackStackChanged() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called onClick of media inside category details (CategoryImageListFragment).
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
if (mediaDetails == null || !mediaDetails.isVisible()) {
|
|
||||||
// set isFeaturedImage true for featured images, to include author field on media detail
|
|
||||||
mediaDetails = new MediaDetailPagerFragment(false, true);
|
|
||||||
FragmentManager supportFragmentManager = getSupportFragmentManager();
|
|
||||||
supportFragmentManager
|
|
||||||
.beginTransaction()
|
|
||||||
.hide(supportFragmentManager.getFragments().get(supportFragmentManager.getBackStackEntryCount()))
|
|
||||||
.add(R.id.fragmentContainer, mediaDetails)
|
|
||||||
.addToBackStack(null)
|
|
||||||
.commit();
|
|
||||||
// Reason for using hide, add instead of replace is to maintain scroll position after
|
|
||||||
// coming back to the search activity. See https://github.com/commons-app/apps-android-commons/issues/1631
|
|
||||||
// https://stackoverflow.com/questions/11353075/how-can-i-maintain-fragment-state-when-added-to-the-back-stack/19022550#19022550 supportFragmentManager.executePendingTransactions();
|
|
||||||
}
|
|
||||||
mediaDetails.showImage(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Consumers should be simply using this method to use this activity.
|
|
||||||
* @param context A Context of the application package implementing this class.
|
|
||||||
* @param title Page title
|
|
||||||
* @param categoryName Name of the category for displaying its images
|
|
||||||
*/
|
|
||||||
public static void startYourself(Context context, String title, String categoryName) {
|
|
||||||
Intent intent = new Intent(context, CategoryImagesActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
||||||
intent.putExtra("title", title);
|
|
||||||
intent.putExtra("categoryName", categoryName);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called mediaDetailPagerFragment. It returns the Media Object at that Index
|
|
||||||
* @param i It is the index of which media object is to be returned which is same as
|
|
||||||
* current index of viewPager.
|
|
||||||
* @return Media Object
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Media getMediaAtPosition(int i) {
|
|
||||||
return categoriesMediaFragment.getMediaAtPosition(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called on success of API call for featured Images.
|
|
||||||
* The viewpager will notified that number of items have changed.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void viewPagerNotifyDataSetChanged() {
|
|
||||||
if (mediaDetails!=null){
|
|
||||||
mediaDetails.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called on from getCount of MediaDetailPagerFragment
|
|
||||||
* The viewpager will contain same number of media items as that of media elements in adapter.
|
|
||||||
* @return Total Media count in the adapter
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getTotalMediaCount() {
|
|
||||||
return categoriesMediaFragment.getTotalMediaCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getContributionStateAt(int position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method inflates the menu in the toolbar
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate(R.menu.menu_search, menu);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method handles the logic on ItemSelect in toolbar menu
|
|
||||||
* Currently only 1 choice is available to open search page of the app
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
|
|
||||||
// Handle item selection
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_search:
|
|
||||||
ActivityUtils.startActivityWithFlags(this, SearchActivity.class);
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMediaClicked(int position) {
|
|
||||||
// this class is unused and will be deleted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -7,7 +7,6 @@ import fr.free.nrw.commons.WelcomeActivity;
|
||||||
import fr.free.nrw.commons.auth.LoginActivity;
|
import fr.free.nrw.commons.auth.LoginActivity;
|
||||||
import fr.free.nrw.commons.auth.SignupActivity;
|
import fr.free.nrw.commons.auth.SignupActivity;
|
||||||
import fr.free.nrw.commons.category.CategoryDetailsActivity;
|
import fr.free.nrw.commons.category.CategoryDetailsActivity;
|
||||||
import fr.free.nrw.commons.category.CategoryImagesActivity;
|
|
||||||
import fr.free.nrw.commons.contributions.MainActivity;
|
import fr.free.nrw.commons.contributions.MainActivity;
|
||||||
import fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity;
|
import fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity;
|
||||||
import fr.free.nrw.commons.explore.SearchActivity;
|
import fr.free.nrw.commons.explore.SearchActivity;
|
||||||
|
|
@ -47,9 +46,6 @@ public abstract class ActivityBuilderModule {
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract NotificationActivity bindNotificationActivity();
|
abstract NotificationActivity bindNotificationActivity();
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
|
||||||
abstract CategoryImagesActivity bindFeaturedImagesActivity();
|
|
||||||
|
|
||||||
@ContributesAndroidInjector
|
@ContributesAndroidInjector
|
||||||
abstract UploadActivity bindUploadActivity();
|
abstract UploadActivity bindUploadActivity();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue