mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Never show file extension in display title of images
This commit is contained in:
parent
625339cb51
commit
bee70b58ab
4 changed files with 17 additions and 21 deletions
|
|
@ -7,6 +7,8 @@ import org.wikimedia.commons.contributions.Contribution;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Media implements Parcelable {
|
public class Media implements Parcelable {
|
||||||
|
|
||||||
|
|
@ -23,6 +25,19 @@ public class Media implements Parcelable {
|
||||||
protected Media() {
|
protected Media() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Pattern displayTitlePattern = Pattern.compile("(.*)(\\.\\w+)", Pattern.CASE_INSENSITIVE);
|
||||||
|
public String getDisplayTitle() {
|
||||||
|
// FIXME: Gross hack bercause my regex skills suck maybe or I am too lazy who knows
|
||||||
|
String title = filename.replaceFirst("^File:", "");
|
||||||
|
Matcher matcher = displayTitlePattern.matcher(title);
|
||||||
|
if(matcher.matches()) {
|
||||||
|
return matcher.group(1);
|
||||||
|
} else {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescriptionUrl() {
|
public String getDescriptionUrl() {
|
||||||
// HACK! Geez
|
// HACK! Geez
|
||||||
return CommonsApplication.HOME_URL + "File:" + Utils.urlEncode(getFilename().replace("File:", "").replace(" ", "_"));
|
return CommonsApplication.HOME_URL + "File:" + Utils.urlEncode(getFilename().replace("File:", "").replace(" ", "_"));
|
||||||
|
|
@ -64,11 +79,6 @@ public class Media implements Parcelable {
|
||||||
return Utils.makeThumbUrl(imageUrl, filename, width);
|
return Utils.makeThumbUrl(imageUrl, filename, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayTitle() {
|
|
||||||
return Utils.displayTitleFromTitle(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected Uri localUri;
|
protected Uri localUri;
|
||||||
protected String imageUrl;
|
protected String imageUrl;
|
||||||
protected String filename;
|
protected String filename;
|
||||||
|
|
|
||||||
|
|
@ -78,17 +78,6 @@ public class Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Pattern displayTitlePattern = Pattern.compile("\\w+:(.*)(\\.\\w+)", Pattern.CASE_INSENSITIVE);
|
|
||||||
public static String displayTitleFromTitle(String title) {
|
|
||||||
// FIXME: This does not work for pages without an extension!
|
|
||||||
Matcher matcher = displayTitlePattern.matcher(title);
|
|
||||||
if(matcher.matches()) {
|
|
||||||
return matcher.group(1);
|
|
||||||
} else {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final URLCodec urlCodec = new URLCodec();
|
private static final URLCodec urlCodec = new URLCodec();
|
||||||
|
|
||||||
public static String urlEncode(String url) {
|
public static String urlEncode(String url) {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||||
import org.wikimedia.commons.R;
|
import org.wikimedia.commons.R;
|
||||||
import org.wikimedia.commons.ShareActivity;
|
import org.wikimedia.commons.ShareActivity;
|
||||||
import org.wikimedia.commons.UploadService;
|
import org.wikimedia.commons.UploadService;
|
||||||
import org.wikimedia.commons.Utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -119,7 +118,7 @@ public class ContributionsListFragment extends SherlockFragment {
|
||||||
views.imageView.setBackgroundDrawable(null);
|
views.imageView.setBackgroundDrawable(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
views.titleView.setText(Utils.displayTitleFromTitle(contribution.getFilename()));
|
views.titleView.setText(contribution.getDisplayTitle());
|
||||||
|
|
||||||
views.seqNumView.setText(String.valueOf(cursor.getPosition() + 1));
|
views.seqNumView.setText(String.valueOf(cursor.getPosition() + 1));
|
||||||
views.seqNumView.setVisibility(View.VISIBLE);
|
views.seqNumView.setVisibility(View.VISIBLE);
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,9 @@ import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
import com.nostra13.universalimageloader.core.assist.FailReason;
|
||||||
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
|
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
|
||||||
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||||
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
|
|
||||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
||||||
import org.wikimedia.commons.Media;
|
import org.wikimedia.commons.Media;
|
||||||
import org.wikimedia.commons.R;
|
import org.wikimedia.commons.R;
|
||||||
import org.wikimedia.commons.Utils;
|
|
||||||
|
|
||||||
public class MediaDetailFragment extends SherlockFragment {
|
public class MediaDetailFragment extends SherlockFragment {
|
||||||
|
|
||||||
|
|
@ -83,7 +81,7 @@ public class MediaDetailFragment extends SherlockFragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
title.setText(Utils.displayTitleFromTitle(media.getFilename()));
|
title.setText(media.getDisplayTitle());
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue