Skip to content

Commit

Permalink
Localize 'camera' folder title.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and greyson-signal committed Oct 28, 2020
1 parent 07952f2 commit dfc4178
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
*/
public class MediaRepository {

private static final String TAG = Log.tag(MediaRepository.class);
private static final String TAG = Log.tag(MediaRepository.class);
private static final String CAMERA = "Camera";

/**
* Retrieves a list of folders that contain media.
Expand Down Expand Up @@ -169,12 +170,12 @@ static void transformMedia(@NonNull Context context,
String bucketId = cursor.getString(cursor.getColumnIndexOrThrow(projection[1]));
String title = cursor.getString(cursor.getColumnIndexOrThrow(projection[2]));
long timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(projection[3]));
FolderData folder = Util.getOrDefault(folders, bucketId, new FolderData(thumbnail, title, bucketId));
FolderData folder = Util.getOrDefault(folders, bucketId, new FolderData(thumbnail, localizeTitle(context, title), bucketId));

folder.incrementCount();
folders.put(bucketId, folder);

if (cameraBucketId == null && "Camera".equals(title)) {
if (cameraBucketId == null && CAMERA.equals(title)) {
cameraBucketId = bucketId;
}

Expand All @@ -188,6 +189,14 @@ static void transformMedia(@NonNull Context context,
return new FolderResult(cameraBucketId, globalThumbnail, thumbnailTimestamp, folders);
}

private @NonNull String localizeTitle(@NonNull Context context, @NonNull String title) {
if (CAMERA.equals(title)) {
return context.getString(R.string.MediaRepository__camera);
} else {
return title;
}
}

@WorkerThread
private @NonNull List<Media> getMediaInBucket(@NonNull Context context, @NonNull String bucketId) {
List<Media> images = getMediaInBucket(context, bucketId, Images.Media.EXTERNAL_CONTENT_URI, true);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@

<!-- MediaRepository -->
<string name="MediaRepository_all_media">All media</string>
<string name="MediaRepository__camera">Camera</string>

<!-- MessageRecord -->
<string name="MessageRecord_unknown">Unknown</string>
Expand Down

0 comments on commit dfc4178

Please sign in to comment.