mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix category links in media detail (#3957)
This commit is contained in:
parent
5b526c6c27
commit
174db88ae8
2 changed files with 9 additions and 4 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
package fr.free.nrw.commons.category;
|
package fr.free.nrw.commons.category;
|
||||||
|
|
||||||
|
import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_PREFIX;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
@ -26,6 +28,7 @@ import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.wikipedia.page.PageTitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This activity displays details of a particular category
|
* This activity displays details of a particular category
|
||||||
|
|
@ -179,7 +182,8 @@ public class CategoryDetailsActivity extends BaseActivity
|
||||||
// Handle item selection
|
// Handle item selection
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_browser_current_category:
|
case R.id.menu_browser_current_category:
|
||||||
Utils.handleWebUrl(this, Uri.parse(Utils.getPageTitle(categoryName).getCanonicalUri()));
|
PageTitle title = Utils.getPageTitle(CATEGORY_PREFIX + categoryName);
|
||||||
|
Utils.handleWebUrl(this, Uri.parse(title.getCanonicalUri()));
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package fr.free.nrw.commons.media;
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_NEEDING_CATEGORIES;
|
import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_NEEDING_CATEGORIES;
|
||||||
import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_PREFIX;
|
|
||||||
import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_UNCATEGORISED;
|
import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_UNCATEGORISED;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
|
@ -295,6 +294,9 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
new OnGlobalLayoutListener() {
|
new OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
|
if (getContext() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
scrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
scrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
imageLandscape.setVisibility(VISIBLE);
|
imageLandscape.setVisibility(VISIBLE);
|
||||||
|
|
@ -836,9 +838,8 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
if(!getString(R.string.detail_panel_cats_none).equals(catName)) {
|
if(!getString(R.string.detail_panel_cats_none).equals(catName)) {
|
||||||
textView.setOnClickListener(view -> {
|
textView.setOnClickListener(view -> {
|
||||||
// Open Category Details page
|
// Open Category Details page
|
||||||
String selectedCategoryTitle = CATEGORY_PREFIX + catName;
|
|
||||||
Intent intent = new Intent(getContext(), CategoryDetailsActivity.class);
|
Intent intent = new Intent(getContext(), CategoryDetailsActivity.class);
|
||||||
intent.putExtra("categoryName", selectedCategoryTitle);
|
intent.putExtra("categoryName", catName);
|
||||||
getContext().startActivity(intent);
|
getContext().startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue