mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge remote-tracking branch 'refs/remotes/commons-app/master'
This commit is contained in:
commit
dbf5f06b67
9 changed files with 44 additions and 33 deletions
|
|
@ -11,6 +11,7 @@ import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.util.LruCache;
|
||||||
|
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
import com.facebook.stetho.Stetho;
|
import com.facebook.stetho.Stetho;
|
||||||
|
|
@ -84,6 +85,7 @@ public class CommonsApplication extends Application {
|
||||||
private static CommonsApplication instance = null;
|
private static CommonsApplication instance = null;
|
||||||
private AbstractHttpClient httpClient = null;
|
private AbstractHttpClient httpClient = null;
|
||||||
private MWApi api = null;
|
private MWApi api = null;
|
||||||
|
LruCache<String, String> thumbnailUrlCache = new LruCache<>(1024);
|
||||||
private CacheController cacheData = null;
|
private CacheController cacheData = null;
|
||||||
private DBOpenHelper dbOpenHelper = null;
|
private DBOpenHelper dbOpenHelper = null;
|
||||||
private NearbyPlaces nearbyPlaces = null;
|
private NearbyPlaces nearbyPlaces = null;
|
||||||
|
|
@ -139,6 +141,10 @@ public class CommonsApplication extends Application {
|
||||||
return cacheData;
|
return cacheData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LruCache<String, String> getThumbnailUrlCache() {
|
||||||
|
return thumbnailUrlCache;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized DBOpenHelper getDBOpenHelper() {
|
public synchronized DBOpenHelper getDBOpenHelper() {
|
||||||
if (dbOpenHelper == null) {
|
if (dbOpenHelper == null) {
|
||||||
dbOpenHelper = new DBOpenHelper(this);
|
dbOpenHelper = new DBOpenHelper(this);
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@ package fr.free.nrw.commons;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.util.LruCache;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
import com.facebook.drawee.view.SimpleDraweeView;
|
||||||
|
|
||||||
public class MediaWikiImageView extends SimpleDraweeView {
|
public class MediaWikiImageView extends SimpleDraweeView {
|
||||||
private ThumbnailFetchTask currentThumbnailTask;
|
private ThumbnailFetchTask currentThumbnailTask;
|
||||||
LruCache<String, String> thumbnailUrlCache = new LruCache<>(1024);
|
|
||||||
|
|
||||||
public MediaWikiImageView(Context context) {
|
public MediaWikiImageView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
|
|
@ -29,14 +27,13 @@ public class MediaWikiImageView extends SimpleDraweeView {
|
||||||
currentThumbnailTask.cancel(true);
|
currentThumbnailTask.cancel(true);
|
||||||
}
|
}
|
||||||
if(media == null) {
|
if(media == null) {
|
||||||
setImageURI((String) null);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thumbnailUrlCache.get(media.getFilename()) != null) {
|
if (CommonsApplication.getInstance().getThumbnailUrlCache().get(media.getFilename()) != null) {
|
||||||
setImageUrl(thumbnailUrlCache.get(media.getFilename()));
|
setImageUrl(CommonsApplication.getInstance().getThumbnailUrlCache().get(media.getFilename()));
|
||||||
} else {
|
} else {
|
||||||
setImageURI((String) null);
|
setImageUrl(null);
|
||||||
currentThumbnailTask = new ThumbnailFetchTask(media);
|
currentThumbnailTask = new ThumbnailFetchTask(media);
|
||||||
currentThumbnailTask.execute(media.getFilename());
|
currentThumbnailTask.execute(media.getFilename());
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +61,7 @@ public class MediaWikiImageView extends SimpleDraweeView {
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
thumbnailUrlCache.put(media.getFilename(), result);
|
CommonsApplication.getInstance().getThumbnailUrlCache().put(media.getFilename(), result);
|
||||||
setImageUrl(result);
|
setImageUrl(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
@ -50,10 +48,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
return mf;
|
return mf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageView image;
|
private MediaWikiImageView image;
|
||||||
//private EditText title;
|
|
||||||
private ProgressBar loadingProgress;
|
|
||||||
private ImageView loadingFailed;
|
|
||||||
private MediaDetailSpacer spacer;
|
private MediaDetailSpacer spacer;
|
||||||
private int initialListTop = 0;
|
private int initialListTop = 0;
|
||||||
|
|
||||||
|
|
@ -105,9 +100,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
|
|
||||||
final View view = inflater.inflate(R.layout.fragment_media_detail, container, false);
|
final View view = inflater.inflate(R.layout.fragment_media_detail, container, false);
|
||||||
|
|
||||||
image = (ImageView) view.findViewById(R.id.mediaDetailImage);
|
image = (MediaWikiImageView) view.findViewById(R.id.mediaDetailImage);
|
||||||
loadingProgress = (ProgressBar) view.findViewById(R.id.mediaDetailImageLoading);
|
|
||||||
loadingFailed = (ImageView) view.findViewById(R.id.mediaDetailImageFailed);
|
|
||||||
scrollView = (ScrollView) view.findViewById(R.id.mediaDetailScrollView);
|
scrollView = (ScrollView) view.findViewById(R.id.mediaDetailScrollView);
|
||||||
|
|
||||||
// Detail consists of a list view with main pane in header view, plus category list.
|
// Detail consists of a list view with main pane in header view, plus category list.
|
||||||
|
|
@ -178,8 +171,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
|
|
||||||
private void displayMediaDetails(final Media media) {
|
private void displayMediaDetails(final Media media) {
|
||||||
//Always load image from Internet to allow viewing the desc, license, and cats
|
//Always load image from Internet to allow viewing the desc, license, and cats
|
||||||
MediaWikiImageView mwImage = (MediaWikiImageView) image;
|
image.setMedia(media);
|
||||||
mwImage.setMedia(media);
|
|
||||||
|
|
||||||
// FIXME: For transparent images
|
// FIXME: For transparent images
|
||||||
// FIXME: keep the spinner going while we load data
|
// FIXME: keep the spinner going while we load data
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF808080"
|
||||||
|
android:pathData="M11,15h2v2h-2zM11,7h2v6h-2zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
|
||||||
|
</vector>
|
||||||
9
app/src/main/res/drawable/ic_image_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_image_black_24dp.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="48dp"
|
||||||
|
android:height="48dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF808080"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
|
||||||
|
</vector>
|
||||||
|
|
@ -25,7 +25,9 @@
|
||||||
android:id="@+id/backgroundImage"
|
android:id="@+id/backgroundImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:actualImageScaleType="centerCrop" />
|
app:actualImageScaleType="centerCrop"
|
||||||
|
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||||
|
app:failureImage="@drawable/ic_error_outline_black_24dp" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/single_upload_fragment_container"
|
android:id="@+id/single_upload_fragment_container"
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/mainBackground"
|
android:background="?attr/mainBackground"
|
||||||
>
|
>
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/mediaDetailImageLoading"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:visibility="visible"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/mediaDetailImageFailed"
|
android:id="@+id/mediaDetailImageFailed"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -28,7 +20,9 @@
|
||||||
android:id="@+id/mediaDetailImage"
|
android:id="@+id/mediaDetailImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="fitCenter"
|
app:actualImageScaleType="fitCenter"
|
||||||
|
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||||
|
app:failureImage="@drawable/ic_image_black_24dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:custom="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -22,8 +22,9 @@
|
||||||
android:id="@+id/contributionImage"
|
android:id="@+id/contributionImage"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="240dp"
|
android:layout_height="240dp"
|
||||||
android:scaleType="centerCrop"
|
app:actualImageScaleType="centerCrop"
|
||||||
custom:isThumbnail="true"
|
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||||
|
app:failureImage="@drawable/ic_image_black_24dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="192dp"
|
android:layout_height="192dp"
|
||||||
app:actualImageScaleType="centerCrop"
|
app:actualImageScaleType="centerCrop"
|
||||||
/>
|
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||||
|
app:failureImage="@drawable/ic_error_outline_black_24dp" />
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/uploadOverlay"
|
android:id="@+id/uploadOverlay"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue