Merge remote-tracking branch 'refs/remotes/commons-app/master'
|
|
@ -1,9 +1,5 @@
|
||||||
package fr.free.nrw.commons;
|
package fr.free.nrw.commons;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.allOf;
|
|
||||||
import static org.hamcrest.Matchers.anyOf;
|
|
||||||
import static org.hamcrest.Matchers.anything;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.test.espresso.Espresso;
|
import android.support.test.espresso.Espresso;
|
||||||
|
|
@ -15,15 +11,18 @@ import android.support.test.rule.ActivityTestRule;
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
import android.support.test.runner.AndroidJUnit4;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import fr.free.nrw.commons.settings.SettingsActivity;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.settings.SettingsActivity;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.allOf;
|
||||||
|
import static org.hamcrest.Matchers.anything;
|
||||||
|
|
||||||
@LargeTest
|
@LargeTest
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class SettingsActivityTest {
|
public class SettingsActivityTest {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
package="fr.free.nrw.commons">
|
package="fr.free.nrw.commons">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ SELECT
|
||||||
(SAMPLE(COALESCE(?class_label_preferred_language, ?class_label_any_language, "?")) as ?class_label)
|
(SAMPLE(COALESCE(?class_label_preferred_language, ?class_label_any_language, "?")) as ?class_label)
|
||||||
(SAMPLE(COALESCE(?icon0, ?icon1)) as ?icon)
|
(SAMPLE(COALESCE(?icon0, ?icon1)) as ?icon)
|
||||||
(SAMPLE(COALESCE(?emoji0, ?emoji1)) as ?emoji)
|
(SAMPLE(COALESCE(?emoji0, ?emoji1)) as ?emoji)
|
||||||
(SAMPLE(?sitelink) as ?sitelink)
|
?wikipediaArticle
|
||||||
|
?commonsArticle
|
||||||
WHERE {
|
WHERE {
|
||||||
# Around given location...
|
# Around given location...
|
||||||
SERVICE wikibase:around {
|
SERVICE wikibase:around {
|
||||||
|
|
@ -37,7 +38,18 @@ SELECT
|
||||||
OPTIONAL {
|
OPTIONAL {
|
||||||
?sitelink schema:about ?item .
|
?sitelink schema:about ?item .
|
||||||
?sitelink schema:inLanguage "en"
|
?sitelink schema:inLanguage "en"
|
||||||
}
|
}
|
||||||
|
OPTIONAL {
|
||||||
|
?wikipediaArticle schema:about ?item ;
|
||||||
|
schema:isPartOf <https://en.wikipedia.org/> .
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
|
||||||
|
}
|
||||||
|
|
||||||
|
OPTIONAL {
|
||||||
|
?commonsArticle schema:about ?item ;
|
||||||
|
schema:isPartOf <https://commons.wikimedia.org/> .
|
||||||
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GROUP BY ?item
|
GROUP BY ?item ?wikipediaArticle ?commonsArticle
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
package fr.free.nrw.commons;
|
package fr.free.nrw.commons;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||||
|
|
||||||
public class AboutActivity extends BaseActivity {
|
public class AboutActivity extends NavigationBaseActivity {
|
||||||
@BindView(R.id.about_version) TextView versionText;
|
@BindView(R.id.about_version) TextView versionText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -19,5 +20,11 @@ public class AboutActivity extends BaseActivity {
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
versionText.setText(BuildConfig.VERSION_NAME);
|
versionText.setText(BuildConfig.VERSION_NAME);
|
||||||
|
initDrawer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startYourself(Context context) {
|
||||||
|
Intent settingsIntent = new Intent(context, AboutActivity.class);
|
||||||
|
context.startActivity(settingsIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,9 +5,13 @@ import android.accounts.AccountManager;
|
||||||
import android.accounts.AuthenticatorException;
|
import android.accounts.AuthenticatorException;
|
||||||
import android.accounts.OperationCanceledException;
|
import android.accounts.OperationCanceledException;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.util.LruCache;
|
import android.support.v4.util.LruCache;
|
||||||
|
|
||||||
import com.android.volley.RequestQueue;
|
import com.android.volley.RequestQueue;
|
||||||
|
|
@ -20,7 +24,14 @@ import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||||
import com.nostra13.universalimageloader.utils.StorageUtils;
|
import com.nostra13.universalimageloader.utils.StorageUtils;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.caching.CacheController;
|
||||||
|
import fr.free.nrw.commons.category.Category;
|
||||||
|
import fr.free.nrw.commons.contributions.Contribution;
|
||||||
|
import fr.free.nrw.commons.data.DBOpenHelper;
|
||||||
|
import fr.free.nrw.commons.modifications.ModifierSequence;
|
||||||
import fr.free.nrw.commons.auth.AccountUtil;
|
import fr.free.nrw.commons.auth.AccountUtil;
|
||||||
|
import fr.free.nrw.commons.nearby.NearbyPlaces;
|
||||||
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.ReportingInteractionMode;
|
import org.acra.ReportingInteractionMode;
|
||||||
import org.acra.annotation.ReportsCrashes;
|
import org.acra.annotation.ReportsCrashes;
|
||||||
|
|
@ -35,9 +46,10 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
||||||
import org.apache.http.params.BasicHttpParams;
|
import org.apache.http.params.BasicHttpParams;
|
||||||
import org.apache.http.params.CoreProtocolPNames;
|
import org.apache.http.params.CoreProtocolPNames;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import fr.free.nrw.commons.caching.CacheController;
|
import fr.free.nrw.commons.utils.FileUtils;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
// TODO: Use ProGuard to rip out reporting when publishing
|
// TODO: Use ProGuard to rip out reporting when publishing
|
||||||
|
|
@ -51,7 +63,6 @@ import timber.log.Timber;
|
||||||
)
|
)
|
||||||
public class CommonsApplication extends Application {
|
public class CommonsApplication extends Application {
|
||||||
|
|
||||||
private MWApi api;
|
|
||||||
private Account currentAccount = null; // Unlike a savings account...
|
private Account currentAccount = null; // Unlike a savings account...
|
||||||
public static final String API_URL = "https://commons.wikimedia.org/w/api.php";
|
public static final String API_URL = "https://commons.wikimedia.org/w/api.php";
|
||||||
public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/commons";
|
public static final String IMAGE_URL_BASE = "https://upload.wikimedia.org/wikipedia/commons";
|
||||||
|
|
@ -70,13 +81,37 @@ public class CommonsApplication extends Application {
|
||||||
public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com";
|
public static final String FEEDBACK_EMAIL = "commons-app-android@googlegroups.com";
|
||||||
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback";
|
public static final String FEEDBACK_EMAIL_SUBJECT = "Commons Android App (%s) Feedback";
|
||||||
|
|
||||||
public RequestQueue volleyQueue;
|
private static CommonsApplication instance = null;
|
||||||
|
private AbstractHttpClient httpClient = null;
|
||||||
|
private MWApi api = null;
|
||||||
|
private CacheController cacheData = null;
|
||||||
|
private RequestQueue volleyQueue = null;
|
||||||
|
private DBOpenHelper dbOpenHelper = null;
|
||||||
|
private NearbyPlaces nearbyPlaces = null;
|
||||||
|
|
||||||
public CacheController cacheData;
|
/**
|
||||||
|
* This should not be called by ANY application code (other than the magic Android glue)
|
||||||
|
* Use CommonsApplication.getInstance() instead to get the singleton.
|
||||||
|
*/
|
||||||
|
public CommonsApplication() {
|
||||||
|
CommonsApplication.instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
public static CommonsApplication app;
|
public static CommonsApplication getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CommonsApplication();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public static AbstractHttpClient createHttpClient() {
|
public AbstractHttpClient getHttpClient() {
|
||||||
|
if (httpClient == null) {
|
||||||
|
httpClient = newHttpClient();
|
||||||
|
}
|
||||||
|
return httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractHttpClient newHttpClient() {
|
||||||
BasicHttpParams params = new BasicHttpParams();
|
BasicHttpParams params = new BasicHttpParams();
|
||||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||||
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
|
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
|
||||||
|
|
@ -87,14 +122,50 @@ public class CommonsApplication extends Application {
|
||||||
return new DefaultHttpClient(cm, params);
|
return new DefaultHttpClient(cm, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MWApi createMWApi() {
|
public MWApi getMWApi() {
|
||||||
return new MWApi(API_URL, createHttpClient());
|
if (api == null) {
|
||||||
|
api = newMWApi();
|
||||||
|
}
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MWApi newMWApi() {
|
||||||
|
return new MWApi(API_URL, getHttpClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CacheController getCacheData() {
|
||||||
|
if (cacheData == null) {
|
||||||
|
cacheData = new CacheController();
|
||||||
|
}
|
||||||
|
return cacheData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestQueue getVolleyQueue() {
|
||||||
|
if (volleyQueue == null) {
|
||||||
|
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
|
||||||
|
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
|
||||||
|
volleyQueue.start();
|
||||||
|
}
|
||||||
|
return volleyQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized DBOpenHelper getDBOpenHelper() {
|
||||||
|
if (dbOpenHelper == null) {
|
||||||
|
dbOpenHelper = new DBOpenHelper(this);
|
||||||
|
}
|
||||||
|
return dbOpenHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized NearbyPlaces getNearbyPlaces() {
|
||||||
|
if (nearbyPlaces == null) {
|
||||||
|
nearbyPlaces = new NearbyPlaces();
|
||||||
|
}
|
||||||
|
return nearbyPlaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
app = this;
|
|
||||||
|
|
||||||
Timber.plant(new Timber.DebugTree());
|
Timber.plant(new Timber.DebugTree());
|
||||||
|
|
||||||
|
|
@ -105,9 +176,8 @@ public class CommonsApplication extends Application {
|
||||||
}
|
}
|
||||||
// Fire progress callbacks for every 3% of uploaded content
|
// Fire progress callbacks for every 3% of uploaded content
|
||||||
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
|
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
|
||||||
api = createMWApi();
|
|
||||||
|
|
||||||
ImageLoaderConfiguration imageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
ImageLoaderConfiguration imageLoaderConfiguration = new ImageLoaderConfiguration.Builder(this)
|
||||||
.discCache(new TotalSizeLimitedDiscCache(StorageUtils.getCacheDirectory(this), 128 * 1024 * 1024))
|
.discCache(new TotalSizeLimitedDiscCache(StorageUtils.getCacheDirectory(this), 128 * 1024 * 1024))
|
||||||
.build();
|
.build();
|
||||||
ImageLoader.getInstance().init(imageLoaderConfiguration);
|
ImageLoader.getInstance().init(imageLoaderConfiguration);
|
||||||
|
|
@ -136,13 +206,6 @@ public class CommonsApplication extends Application {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//For caching area -> categories
|
|
||||||
cacheData = new CacheController();
|
|
||||||
|
|
||||||
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
|
|
||||||
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
|
|
||||||
volleyQueue.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private com.android.volley.toolbox.ImageLoader imageLoader;
|
private com.android.volley.toolbox.ImageLoader imageLoader;
|
||||||
|
|
@ -150,7 +213,7 @@ public class CommonsApplication extends Application {
|
||||||
|
|
||||||
public com.android.volley.toolbox.ImageLoader getImageLoader() {
|
public com.android.volley.toolbox.ImageLoader getImageLoader() {
|
||||||
if(imageLoader == null) {
|
if(imageLoader == null) {
|
||||||
imageLoader = new com.android.volley.toolbox.ImageLoader(volleyQueue, new com.android.volley.toolbox.ImageLoader.ImageCache() {
|
imageLoader = new com.android.volley.toolbox.ImageLoader(getVolleyQueue(), new com.android.volley.toolbox.ImageLoader.ImageCache() {
|
||||||
@Override
|
@Override
|
||||||
public Bitmap getBitmap(String key) {
|
public Bitmap getBitmap(String key) {
|
||||||
return imageCache.get(key);
|
return imageCache.get(key);
|
||||||
|
|
@ -165,13 +228,9 @@ public class CommonsApplication extends Application {
|
||||||
}
|
}
|
||||||
return imageLoader;
|
return imageLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MWApi getApi() {
|
|
||||||
return api;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Accout|null
|
* @return Account|null
|
||||||
*/
|
*/
|
||||||
public Account getCurrentAccount() {
|
public Account getCurrentAccount() {
|
||||||
if(currentAccount == null) {
|
if(currentAccount == null) {
|
||||||
|
|
@ -192,21 +251,12 @@ public class CommonsApplication extends Application {
|
||||||
return false; // This should never happen
|
return false; // This should never happen
|
||||||
}
|
}
|
||||||
|
|
||||||
accountManager.invalidateAuthToken(AccountUtil.accountType(), api.getAuthCookie());
|
accountManager.invalidateAuthToken(AccountUtil.accountType(), getMWApi().getAuthCookie());
|
||||||
try {
|
try {
|
||||||
String authCookie = accountManager.blockingGetAuthToken(curAccount, "", false);
|
String authCookie = accountManager.blockingGetAuthToken(curAccount, "", false);
|
||||||
api.setAuthCookie(authCookie);
|
getMWApi().setAuthCookie(authCookie);
|
||||||
return true;
|
return true;
|
||||||
} catch (OperationCanceledException e) {
|
} catch (OperationCanceledException | NullPointerException | IOException | AuthenticatorException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} catch (AuthenticatorException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -217,4 +267,47 @@ public class CommonsApplication extends Application {
|
||||||
return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) ||
|
return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) ||
|
||||||
pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
|
pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearApplicationData(Context context) {
|
||||||
|
File cacheDirectory = context.getCacheDir();
|
||||||
|
File applicationDirectory = new File(cacheDirectory.getParent());
|
||||||
|
if (applicationDirectory.exists()) {
|
||||||
|
String[] fileNames = applicationDirectory.list();
|
||||||
|
for (String fileName : fileNames) {
|
||||||
|
if (!fileName.equals("lib")) {
|
||||||
|
FileUtils.deleteFile(new File(applicationDirectory, fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountManager accountManager = AccountManager.get(this);
|
||||||
|
Account[] allAccounts = accountManager.getAccountsByType(AccountUtil.accountType());
|
||||||
|
for (int index = 0; index < allAccounts.length; index++) {
|
||||||
|
accountManager.removeAccount(allAccounts[index], null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: fix preference manager
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(getInstance()).edit().clear().commit();
|
||||||
|
SharedPreferences preferences = context
|
||||||
|
.getSharedPreferences("fr.free.nrw.commons", MODE_PRIVATE);
|
||||||
|
preferences.edit().clear().commit();
|
||||||
|
context.getSharedPreferences("prefs", Context.MODE_PRIVATE).edit().clear().commit();
|
||||||
|
preferences.edit().putBoolean("firstrun", false).apply();
|
||||||
|
updateAllDatabases(context);
|
||||||
|
currentAccount = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all tables and re-creates them.
|
||||||
|
* @param context context
|
||||||
|
*/
|
||||||
|
public void updateAllDatabases(Context context) {
|
||||||
|
DBOpenHelper dbOpenHelper = CommonsApplication.getInstance().getDBOpenHelper();
|
||||||
|
dbOpenHelper.getReadableDatabase().close();
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
||||||
|
|
||||||
|
ModifierSequence.Table.onDelete(db);
|
||||||
|
Category.Table.onDelete(db);
|
||||||
|
Contribution.Table.onDelete(db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.os.Build;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.impl.client.AbstractHttpClient;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
@ -30,10 +31,10 @@ public class EventLog {
|
||||||
boolean allSuccess = true;
|
boolean allSuccess = true;
|
||||||
// Not using the default URL connection, since that seems to have different behavior than the rest of the code
|
// Not using the default URL connection, since that seems to have different behavior than the rest of the code
|
||||||
for(LogBuilder logBuilder: logBuilders) {
|
for(LogBuilder logBuilder: logBuilders) {
|
||||||
HttpURLConnection conn;
|
|
||||||
try {
|
try {
|
||||||
URL url = logBuilder.toUrl();
|
URL url = logBuilder.toUrl();
|
||||||
HttpResponse response = Http.get(url.toString()).use(CommonsApplication.createHttpClient()).asResponse();
|
AbstractHttpClient httpClient = CommonsApplication.getInstance().getHttpClient();
|
||||||
|
HttpResponse response = Http.get(url.toString()).use(httpClient).asResponse();
|
||||||
|
|
||||||
if(response.getStatusLine().getStatusCode() != 204) {
|
if(response.getStatusLine().getStatusCode() != 204) {
|
||||||
allSuccess = false;
|
allSuccess = false;
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ public class Media implements Parcelable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategories(List<String> categories) {
|
public void setCategories(List<String> categories) {
|
||||||
this.categories.removeAll(this.categories);
|
this.categories.clear();
|
||||||
this.categories.addAll(categories);
|
this.categories.addAll(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class MediaDataExtractor {
|
||||||
throw new IllegalStateException("Tried to call MediaDataExtractor.fetch() again.");
|
throw new IllegalStateException("Tried to call MediaDataExtractor.fetch() again.");
|
||||||
}
|
}
|
||||||
|
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
ApiResult result = api.action("query")
|
ApiResult result = api.action("query")
|
||||||
.param("prop", "revisions")
|
.param("prop", "revisions")
|
||||||
.param("titles", filename)
|
.param("titles", filename)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.ImageLoader;
|
import com.android.volley.toolbox.ImageLoader;
|
||||||
|
|
@ -31,7 +30,7 @@ import com.android.volley.toolbox.ImageLoader.ImageListener;
|
||||||
import fr.free.nrw.commons.contributions.Contribution;
|
import fr.free.nrw.commons.contributions.Contribution;
|
||||||
import fr.free.nrw.commons.contributions.ContributionsContentProvider;
|
import fr.free.nrw.commons.contributions.ContributionsContentProvider;
|
||||||
|
|
||||||
public class MediaWikiImageView extends ImageView {
|
public class MediaWikiImageView extends android.support.v7.widget.AppCompatImageView {
|
||||||
|
|
||||||
private Media mMedia;
|
private Media mMedia;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class AccountUtil {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static CommonsApplication app() {
|
private static CommonsApplication app() {
|
||||||
return CommonsApplication.app;
|
return CommonsApplication.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@ import java.io.IOException;
|
||||||
|
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
|
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||||
|
|
||||||
public abstract class AuthenticatedActivity extends BaseActivity {
|
public abstract class AuthenticatedActivity extends NavigationBaseActivity {
|
||||||
|
|
||||||
String accountType;
|
String accountType;
|
||||||
CommonsApplication app;
|
CommonsApplication app;
|
||||||
|
|
@ -131,7 +132,7 @@ public abstract class AuthenticatedActivity extends BaseActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
app = (CommonsApplication)this.getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
if(savedInstanceState != null) {
|
if(savedInstanceState != null) {
|
||||||
authCookie = savedInstanceState.getString("authCookie");
|
authCookie = savedInstanceState.getString("authCookie");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
app = (CommonsApplication) getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
|
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
final LoginActivity that = this;
|
final LoginActivity that = this;
|
||||||
|
|
@ -199,7 +199,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showUserToast( int resId ) {
|
private void showUserToast( int resId ) {
|
||||||
Toast.makeText(getApplicationContext(), resId, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, resId, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showSuccessToastAndDismissDialog() {
|
public void showSuccessToastAndDismissDialog() {
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@ package fr.free.nrw.commons.auth;
|
||||||
import android.accounts.AccountAuthenticatorResponse;
|
import android.accounts.AccountAuthenticatorResponse;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.EventLog;
|
import fr.free.nrw.commons.EventLog;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
class LoginTask extends AsyncTask<String, String, String> {
|
class LoginTask extends AsyncTask<String, String, String> {
|
||||||
|
|
||||||
private LoginActivity loginActivity;
|
private LoginActivity loginActivity;
|
||||||
|
|
@ -26,7 +26,7 @@ class LoginTask extends AsyncTask<String, String, String> {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.twoFactorCode = twoFactorCode;
|
this.twoFactorCode = twoFactorCode;
|
||||||
app = (CommonsApplication) loginActivity.getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -44,9 +44,9 @@ class LoginTask extends AsyncTask<String, String, String> {
|
||||||
protected String doInBackground(String... params) {
|
protected String doInBackground(String... params) {
|
||||||
try {
|
try {
|
||||||
if (twoFactorCode.isEmpty()) {
|
if (twoFactorCode.isEmpty()) {
|
||||||
return app.getApi().login(username, password);
|
return app.getMWApi().login(username, password);
|
||||||
} else {
|
} else {
|
||||||
return app.getApi().login(username, password, twoFactorCode);
|
return app.getMWApi().login(username, password, twoFactorCode);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Do something better!
|
// Do something better!
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
import fr.free.nrw.commons.theme.BaseActivity;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
@ -39,10 +40,14 @@ public class SignupActivity extends BaseActivity {
|
||||||
//Signup success, so clear cookies, notify user, and load LoginActivity again
|
//Signup success, so clear cookies, notify user, and load LoginActivity again
|
||||||
Timber.d("Overriding URL %s", url);
|
Timber.d("Overriding URL %s", url);
|
||||||
|
|
||||||
Toast toast = Toast.makeText(getApplicationContext(), "Account created!", Toast.LENGTH_LONG);
|
Toast toast = Toast.makeText(
|
||||||
|
CommonsApplication.getInstance(),
|
||||||
|
"Account created!",
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
);
|
||||||
toast.show();
|
toast.show();
|
||||||
|
|
||||||
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
|
Intent intent = new Intent(CommonsApplication.getInstance(), LoginActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ public class WikiAccountAuthenticator extends AbstractAccountAuthenticator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAuthCookie(String username, String password) throws IOException {
|
private String getAuthCookie(String username, String password) throws IOException {
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
//TODO add 2fa support here
|
//TODO add 2fa support here
|
||||||
String result = api.login(username, password);
|
String result = api.login(username, password);
|
||||||
if(result.equals("PASS")) {
|
if(result.equals("PASS")) {
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,11 @@ public class Category {
|
||||||
db.execSQL(CREATE_TABLE_STATEMENT);
|
db.execSQL(CREATE_TABLE_STATEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onDelete(SQLiteDatabase db) {
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
|
||||||
public static void onUpdate(SQLiteDatabase db, int from, int to) {
|
public static void onUpdate(SQLiteDatabase db, int from, int to) {
|
||||||
if(from == to) {
|
if(from == to) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import android.database.sqlite.SQLiteQueryBuilder;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.data.DBOpenHelper;
|
import fr.free.nrw.commons.data.DBOpenHelper;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
@ -36,7 +37,7 @@ public class CategoryContentProvider extends ContentProvider {
|
||||||
private DBOpenHelper dbOpenHelper;
|
private DBOpenHelper dbOpenHelper;
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
dbOpenHelper = DBOpenHelper.getInstance(getContext());
|
dbOpenHelper = CommonsApplication.getInstance().getDBOpenHelper();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ public class MethodAUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
|
||||||
protected ArrayList<String> doInBackground(Void... voids) {
|
protected ArrayList<String> doInBackground(Void... voids) {
|
||||||
|
|
||||||
//otherwise if user has typed something in that isn't in cache, search API for matching categories
|
//otherwise if user has typed something in that isn't in cache, search API for matching categories
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
ApiResult result;
|
ApiResult result;
|
||||||
ArrayList<String> categories = new ArrayList<>();
|
ArrayList<String> categories = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
|
||||||
|
|
||||||
//otherwise if user has typed something in that isn't in cache, search API for matching categories
|
//otherwise if user has typed something in that isn't in cache, search API for matching categories
|
||||||
//URL: https://commons.wikimedia.org/w/api.php?action=query&list=allcategories&acprefix=filter&aclimit=25
|
//URL: https://commons.wikimedia.org/w/api.php?action=query&list=allcategories&acprefix=filter&aclimit=25
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
ApiResult result;
|
ApiResult result;
|
||||||
ArrayList<String> categories = new ArrayList<>();
|
ArrayList<String> categories = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class TitleCategories extends AsyncTask<Void, Void, ArrayList<String>> {
|
||||||
@Override
|
@Override
|
||||||
protected ArrayList<String> doInBackground(Void... voids) {
|
protected ArrayList<String> doInBackground(Void... voids) {
|
||||||
|
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
ApiResult result;
|
ApiResult result;
|
||||||
ArrayList<String> items = new ArrayList<>();
|
ArrayList<String> items = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,11 @@ public class Contribution extends Media {
|
||||||
db.execSQL(CREATE_TABLE_STATEMENT);
|
db.execSQL(CREATE_TABLE_STATEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onDelete(SQLiteDatabase db) {
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
|
||||||
public static void onUpdate(SQLiteDatabase db, int from, int to) {
|
public static void onUpdate(SQLiteDatabase db, int from, int to) {
|
||||||
if(from == to) {
|
if(from == to) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,13 @@ import android.widget.AdapterView;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.HandlerService;
|
import fr.free.nrw.commons.HandlerService;
|
||||||
import fr.free.nrw.commons.Media;
|
import fr.free.nrw.commons.Media;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
||||||
|
import fr.free.nrw.commons.hamburger.HamburgerMenuContainer;
|
||||||
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
import fr.free.nrw.commons.media.MediaDetailPagerFragment;
|
||||||
import fr.free.nrw.commons.settings.Prefs;
|
import fr.free.nrw.commons.settings.Prefs;
|
||||||
import fr.free.nrw.commons.upload.UploadService;
|
import fr.free.nrw.commons.upload.UploadService;
|
||||||
|
|
@ -41,7 +43,8 @@ public class ContributionsActivity
|
||||||
AdapterView.OnItemClickListener,
|
AdapterView.OnItemClickListener,
|
||||||
MediaDetailPagerFragment.MediaDetailProvider,
|
MediaDetailPagerFragment.MediaDetailProvider,
|
||||||
FragmentManager.OnBackStackChangedListener,
|
FragmentManager.OnBackStackChangedListener,
|
||||||
ContributionsListFragment.SourceRefresher {
|
ContributionsListFragment.SourceRefresher,
|
||||||
|
HamburgerMenuContainer {
|
||||||
|
|
||||||
private Cursor allContributions;
|
private Cursor allContributions;
|
||||||
private ContributionsListFragment contributionsList;
|
private ContributionsListFragment contributionsList;
|
||||||
|
|
@ -50,6 +53,7 @@ public class ContributionsActivity
|
||||||
private boolean isUploadServiceConnected;
|
private boolean isUploadServiceConnected;
|
||||||
private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<>();
|
private ArrayList<DataSetObserver> observersWaitingForLoad = new ArrayList<>();
|
||||||
private String CONTRIBUTION_SELECTION = "";
|
private String CONTRIBUTION_SELECTION = "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This sorts in the following order:
|
This sorts in the following order:
|
||||||
Currently Uploading
|
Currently Uploading
|
||||||
|
|
@ -105,7 +109,7 @@ public class ContributionsActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onAuthCookieAcquired(String authCookie) {
|
protected void onAuthCookieAcquired(String authCookie) {
|
||||||
// Do a sync everytime we get here!
|
// Do a sync everytime we get here!
|
||||||
ContentResolver.requestSync(((CommonsApplication) getApplicationContext()).getCurrentAccount(), ContributionsContentProvider.AUTHORITY, new Bundle());
|
ContentResolver.requestSync(CommonsApplication.getInstance().getCurrentAccount(), ContributionsContentProvider.AUTHORITY, new Bundle());
|
||||||
Intent uploadServiceIntent = new Intent(this, UploadService.class);
|
Intent uploadServiceIntent = new Intent(this, UploadService.class);
|
||||||
uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE);
|
uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE);
|
||||||
startService(uploadServiceIntent);
|
startService(uploadServiceIntent);
|
||||||
|
|
@ -119,8 +123,8 @@ public class ContributionsActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setTitle(R.string.title_activity_contributions);
|
|
||||||
setContentView(R.layout.activity_contributions);
|
setContentView(R.layout.activity_contributions);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
// Activity can call methods in the fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById()
|
// Activity can call methods in the fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById()
|
||||||
contributionsList = (ContributionsListFragment)getSupportFragmentManager().findFragmentById(R.id.contributionsListFragment);
|
contributionsList = (ContributionsListFragment)getSupportFragmentManager().findFragmentById(R.id.contributionsListFragment);
|
||||||
|
|
@ -136,6 +140,7 @@ public class ContributionsActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
requestAuthToken();
|
requestAuthToken();
|
||||||
|
initDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -214,7 +219,7 @@ public class ContributionsActivity
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||||
SharedPreferences sharedPref =
|
SharedPreferences sharedPref =
|
||||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||||
return new CursorLoader(this, ContributionsContentProvider.BASE_URI,
|
return new CursorLoader(this, ContributionsContentProvider.BASE_URI,
|
||||||
Contribution.Table.ALL_FIELDS, CONTRIBUTION_SELECTION, null,
|
Contribution.Table.ALL_FIELDS, CONTRIBUTION_SELECTION, null,
|
||||||
|
|
@ -320,4 +325,9 @@ public class ContributionsActivity
|
||||||
public void refreshSource() {
|
public void refreshSource() {
|
||||||
getSupportLoaderManager().restartLoader(0, null, this);
|
getSupportLoaderManager().restartLoader(0, null, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void startYourself(Context context) {
|
||||||
|
Intent settingsIntent = new Intent(context, ContributionsActivity.class);
|
||||||
|
context.startActivity(settingsIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import android.database.sqlite.SQLiteQueryBuilder;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.data.DBOpenHelper;
|
import fr.free.nrw.commons.data.DBOpenHelper;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
@ -35,7 +36,7 @@ public class ContributionsContentProvider extends ContentProvider{
|
||||||
private DBOpenHelper dbOpenHelper;
|
private DBOpenHelper dbOpenHelper;
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
dbOpenHelper = DBOpenHelper.getInstance(getContext());
|
dbOpenHelper = CommonsApplication.getInstance().getDBOpenHelper();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class ContributionsListAdapter extends CursorAdapter {
|
||||||
if(views.url == null || !views.url.equals(actualUrl)) {
|
if(views.url == null || !views.url.equals(actualUrl)) {
|
||||||
if(actualUrl.startsWith("http")) {
|
if(actualUrl.startsWith("http")) {
|
||||||
MediaWikiImageView mwImageView = views.imageView;
|
MediaWikiImageView mwImageView = views.imageView;
|
||||||
mwImageView.setMedia(contribution, ((CommonsApplication) activity.getApplicationContext()).getImageLoader());
|
mwImageView.setMedia(contribution, CommonsApplication.getInstance().getImageLoader());
|
||||||
// FIXME: For transparent images
|
// FIXME: For transparent images
|
||||||
} else {
|
} else {
|
||||||
ImageLoader.getInstance().displayImage(actualUrl, views.imageView, contributionDisplayOptions, new SimpleImageLoadingListener() {
|
ImageLoader.getInstance().displayImage(actualUrl, views.imageView, contributionDisplayOptions, new SimpleImageLoadingListener() {
|
||||||
|
|
@ -66,7 +66,7 @@ class ContributionsListAdapter extends CursorAdapter {
|
||||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||||
super.onLoadingFailed(imageUri, view, failReason);
|
super.onLoadingFailed(imageUri, view, failReason);
|
||||||
MediaWikiImageView mwImageView = views.imageView;
|
MediaWikiImageView mwImageView = views.imageView;
|
||||||
mwImageView.setMedia(contribution, ((CommonsApplication) activity.getApplicationContext()).getImageLoader());
|
mwImageView.setMedia(contribution, CommonsApplication.getInstance().getImageLoader());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,46 +126,6 @@ public class ContributionsListFragment extends Fragment {
|
||||||
case R.id.menu_from_camera:
|
case R.id.menu_from_camera:
|
||||||
controller.startCameraCapture();
|
controller.startCameraCapture();
|
||||||
return true;
|
return true;
|
||||||
case R.id.menu_settings:
|
|
||||||
Intent settingsIntent = new Intent(getActivity(), SettingsActivity.class);
|
|
||||||
startActivity(settingsIntent);
|
|
||||||
return true;
|
|
||||||
case R.id.menu_about:
|
|
||||||
Intent aboutIntent = new Intent(getActivity(), AboutActivity.class);
|
|
||||||
startActivity(aboutIntent);
|
|
||||||
return true;
|
|
||||||
case R.id.menu_feedback:
|
|
||||||
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
|
||||||
feedbackIntent.setType("message/rfc822");
|
|
||||||
feedbackIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { CommonsApplication.FEEDBACK_EMAIL });
|
|
||||||
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT, BuildConfig.VERSION_NAME));
|
|
||||||
try {
|
|
||||||
startActivity(feedbackIntent);
|
|
||||||
}
|
|
||||||
catch (ActivityNotFoundException e) {
|
|
||||||
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case R.id.menu_nearby:
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
if (ContextCompat.checkSelfPermission(this.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
//See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
|
|
||||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 2);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
|
||||||
startActivity(nearbyIntent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
|
||||||
startActivity(nearbyIntent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case R.id.menu_refresh:
|
|
||||||
((SourceRefresher)getActivity()).refreshSource();
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
@ -199,12 +159,9 @@ public class ContributionsListFragment extends Fragment {
|
||||||
menu.clear(); // See http://stackoverflow.com/a/8495697/17865
|
menu.clear(); // See http://stackoverflow.com/a/8495697/17865
|
||||||
inflater.inflate(R.menu.fragment_contributions_list, menu);
|
inflater.inflate(R.menu.fragment_contributions_list, menu);
|
||||||
|
|
||||||
CommonsApplication app = (CommonsApplication)getActivity().getApplicationContext();
|
if (!CommonsApplication.getInstance().deviceHasCamera()) {
|
||||||
if (!app.deviceHasCamera()) {
|
|
||||||
menu.findItem(R.id.menu_from_camera).setEnabled(false);
|
menu.findItem(R.id.menu_from_camera).setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.findItem(R.id.menu_refresh).setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ContributionsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||||
public void onPerformSync(Account account, Bundle bundle, String s, ContentProviderClient contentProviderClient, SyncResult syncResult) {
|
public void onPerformSync(Account account, Bundle bundle, String s, ContentProviderClient contentProviderClient, SyncResult syncResult) {
|
||||||
// This code is fraught with possibilities of race conditions, but lalalalala I can't hear you!
|
// This code is fraught with possibilities of race conditions, but lalalalala I can't hear you!
|
||||||
String user = account.name;
|
String user = account.name;
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
SharedPreferences prefs = this.getContext().getSharedPreferences("prefs", Context.MODE_PRIVATE);
|
SharedPreferences prefs = this.getContext().getSharedPreferences("prefs", Context.MODE_PRIVATE);
|
||||||
String lastModified = prefs.getString("lastSyncTimestamp", "");
|
String lastModified = prefs.getString("lastSyncTimestamp", "");
|
||||||
Date curTime = new Date();
|
Date curTime = new Date();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class ContributionsSyncService extends Service {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
synchronized (sSyncAdapterLock) {
|
synchronized (sSyncAdapterLock) {
|
||||||
if (sSyncAdapter == null) {
|
if (sSyncAdapter == null) {
|
||||||
sSyncAdapter = new ContributionsSyncAdapter(getApplicationContext(), true);
|
sSyncAdapter = new ContributionsSyncAdapter(this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,11 @@ public class DBOpenHelper extends SQLiteOpenHelper{
|
||||||
|
|
||||||
private static final String DATABASE_NAME = "commons.db";
|
private static final String DATABASE_NAME = "commons.db";
|
||||||
private static final int DATABASE_VERSION = 6;
|
private static final int DATABASE_VERSION = 6;
|
||||||
private static DBOpenHelper singleton = null;
|
|
||||||
|
|
||||||
public static synchronized DBOpenHelper getInstance(Context context) {
|
/**
|
||||||
if ( singleton == null ) {
|
* Do not use, please call CommonsApplication.getDBOpenHelper()
|
||||||
singleton = new DBOpenHelper(context);
|
*/
|
||||||
}
|
public DBOpenHelper(Context context) {
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DBOpenHelper(Context context) {
|
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package fr.free.nrw.commons.hamburger;
|
||||||
|
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
|
|
||||||
|
public interface HamburgerMenuContainer {
|
||||||
|
void setDrawerListener(ActionBarDrawerToggle listener);
|
||||||
|
void toggleDrawer();
|
||||||
|
boolean isDrawerVisible();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,165 @@
|
||||||
|
package fr.free.nrw.commons.hamburger;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
|
import fr.free.nrw.commons.AboutActivity;
|
||||||
|
import fr.free.nrw.commons.BuildConfig;
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.auth.LoginActivity;
|
||||||
|
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
||||||
|
import fr.free.nrw.commons.nearby.NearbyActivity;
|
||||||
|
import fr.free.nrw.commons.settings.SettingsActivity;
|
||||||
|
|
||||||
|
|
||||||
|
public class NavigationBaseFragment extends Fragment {
|
||||||
|
@BindView(R.id.pictureOfTheDay)
|
||||||
|
ImageView pictureOfTheDay;
|
||||||
|
|
||||||
|
@BindView(R.id.upload_item)
|
||||||
|
LinearLayout uploadItem;
|
||||||
|
|
||||||
|
@BindView(R.id.nearby_item)
|
||||||
|
LinearLayout nearbyItem;
|
||||||
|
|
||||||
|
@BindView(R.id.about_item)
|
||||||
|
LinearLayout aboutItem;
|
||||||
|
|
||||||
|
@BindView(R.id.settings_item)
|
||||||
|
LinearLayout settingsItem;
|
||||||
|
|
||||||
|
@BindView(R.id.feedback_item)
|
||||||
|
LinearLayout feedbackItem;
|
||||||
|
|
||||||
|
@BindView(R.id.logout_item)
|
||||||
|
LinearLayout logoutItem;
|
||||||
|
|
||||||
|
private DrawerLayout drawerLayout;
|
||||||
|
private RelativeLayout drawerPane;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater,
|
||||||
|
ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View hamburgerView = inflater.inflate(R.layout.navigation_drawer_menu, container, false);
|
||||||
|
ButterKnife.bind(this, hamburgerView);
|
||||||
|
showPictureOfTheDay();
|
||||||
|
setupHamburgerMenu();
|
||||||
|
return hamburgerView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPictureOfTheDay() {
|
||||||
|
pictureOfTheDay.setImageDrawable(getResources().getDrawable(R.drawable.commons_logo_large));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupHamburgerMenu() {
|
||||||
|
ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(getActivity(),
|
||||||
|
drawerLayout, R.string.ok, R.string.cancel);
|
||||||
|
if (getActivity() instanceof HamburgerMenuContainer) {
|
||||||
|
((HamburgerMenuContainer) getActivity()).setDrawerListener(drawerToggle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.upload_item)
|
||||||
|
protected void onUploadItemClicked() {
|
||||||
|
closeDrawer();
|
||||||
|
ContributionsActivity.startYourself(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.settings_item)
|
||||||
|
protected void onSettingsItemClicked() {
|
||||||
|
closeDrawer();
|
||||||
|
SettingsActivity.startYourself(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.about_item)
|
||||||
|
protected void onAboutItemClicked() {
|
||||||
|
closeDrawer();
|
||||||
|
AboutActivity.startYourself(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.nearby_item)
|
||||||
|
protected void onNearbyItemClicked() {
|
||||||
|
closeDrawer();
|
||||||
|
NearbyActivity.startYourself(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.feedback_item)
|
||||||
|
protected void onFeedbackItemClicked() {
|
||||||
|
closeDrawer();
|
||||||
|
Intent feedbackIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
feedbackIntent.setType("message/rfc822");
|
||||||
|
feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
|
||||||
|
new String[]{CommonsApplication.FEEDBACK_EMAIL});
|
||||||
|
feedbackIntent.putExtra(Intent.EXTRA_SUBJECT,
|
||||||
|
String.format(CommonsApplication.FEEDBACK_EMAIL_SUBJECT,
|
||||||
|
BuildConfig.VERSION_NAME));
|
||||||
|
try {
|
||||||
|
startActivity(feedbackIntent);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(getActivity(), R.string.no_email_client, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.logout_item)
|
||||||
|
protected void onLogoutItemClicked() {
|
||||||
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
|
||||||
|
alertDialogBuilder.setMessage(R.string.logout_verification)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.yes,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
((CommonsApplication)getActivity().getApplicationContext())
|
||||||
|
.clearApplicationData(getContext());
|
||||||
|
Intent nearbyIntent = new Intent
|
||||||
|
(getActivity(), LoginActivity.class);
|
||||||
|
nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
nearbyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(nearbyIntent);
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alertDialogBuilder.setNegativeButton(R.string.no,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog alert = alertDialogBuilder.create();
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeDrawer() {
|
||||||
|
if (drawerLayout != null) {
|
||||||
|
drawerLayout.closeDrawer(drawerPane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrawerLayout(DrawerLayout drawerLayout, RelativeLayout drawerPane) {
|
||||||
|
this.drawerLayout = drawerLayout;
|
||||||
|
this.drawerPane = drawerPane;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,8 @@ public class LatLng {
|
||||||
public final double longitude;
|
public final double longitude;
|
||||||
|
|
||||||
/** Accepts latitude and longitude.
|
/** Accepts latitude and longitude.
|
||||||
|
* North and South values are cut off at 90°
|
||||||
|
*
|
||||||
* @param latitude double value
|
* @param latitude double value
|
||||||
* @param longitude double value
|
* @param longitude double value
|
||||||
*/
|
*/
|
||||||
|
|
@ -44,14 +46,15 @@ public class LatLng {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rounds the float to 4 digits.
|
* Rounds the float to 4 digits and returns absolute value.
|
||||||
*
|
*
|
||||||
* @param coordinate A coordinate value as string.
|
* @param coordinate A coordinate value as string.
|
||||||
* @return String of the rounded number.
|
* @return String of the rounded number.
|
||||||
*/
|
*/
|
||||||
private String formatCoordinate(double coordinate) {
|
private String formatCoordinate(double coordinate) {
|
||||||
double roundedNumber = Math.round(coordinate * 10000d) / 10000d;
|
double roundedNumber = Math.round(coordinate * 10000d) / 10000d;
|
||||||
return String.valueOf(roundedNumber);
|
double absoluteNumber = Math.abs(roundedNumber);
|
||||||
|
return String.valueOf(absoluteNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,7 +76,7 @@ public class LatLng {
|
||||||
* @return "E" or "W".
|
* @return "E" or "W".
|
||||||
*/
|
*/
|
||||||
private String getEastWest() {
|
private String getEastWest() {
|
||||||
if (this.longitude < 180) {
|
if (this.longitude >= 0 && this.longitude < 180) {
|
||||||
return "E";
|
return "E";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
if(actualUrl.startsWith("http")) {
|
if(actualUrl.startsWith("http")) {
|
||||||
Timber.d("Actual URL starts with http and is: %s", actualUrl);
|
Timber.d("Actual URL starts with http and is: %s", actualUrl);
|
||||||
|
|
||||||
ImageLoader loader = ((CommonsApplication)getActivity().getApplicationContext()).getImageLoader();
|
ImageLoader loader = CommonsApplication.getInstance().getImageLoader();
|
||||||
MediaWikiImageView mwImage = (MediaWikiImageView)image;
|
MediaWikiImageView mwImage = (MediaWikiImageView)image;
|
||||||
mwImage.setLoadingView(loadingProgress); //FIXME: Set this as an attribute
|
mwImage.setLoadingView(loadingProgress); //FIXME: Set this as an attribute
|
||||||
mwImage.setMedia(media, loader);
|
mwImage.setMedia(media, loader);
|
||||||
|
|
@ -235,7 +235,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
coordinates.setText(prettyCoordinates(media));
|
coordinates.setText(prettyCoordinates(media));
|
||||||
uploadedDate.setText(prettyUploadedDate(media));
|
uploadedDate.setText(prettyUploadedDate(media));
|
||||||
|
|
||||||
categoryNames.removeAll(categoryNames);
|
categoryNames.clear();
|
||||||
categoryNames.addAll(media.getCategories());
|
categoryNames.addAll(media.getCategories());
|
||||||
|
|
||||||
categoriesLoaded = true;
|
categoriesLoaded = true;
|
||||||
|
|
@ -280,7 +280,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
desc.setText(prettyDescription(media));
|
desc.setText(prettyDescription(media));
|
||||||
license.setText(prettyLicense(media));
|
license.setText(prettyLicense(media));
|
||||||
|
|
||||||
categoryNames.removeAll(categoryNames);
|
categoryNames.clear();
|
||||||
categoryNames.addAll(media.getCategories());
|
categoryNames.addAll(media.getCategories());
|
||||||
|
|
||||||
categoriesLoaded = true;
|
categoriesLoaded = true;
|
||||||
|
|
@ -403,8 +403,7 @@ public class MediaDetailFragment extends Fragment {
|
||||||
return "Uploaded date not available";
|
return "Uploaded date not available";
|
||||||
}
|
}
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
|
SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
|
||||||
String formattedDate = formatter.format(date);
|
return formatter.format(date);
|
||||||
return formattedDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -413,8 +412,6 @@ public class MediaDetailFragment extends Fragment {
|
||||||
* @return Coordinates as text.
|
* @return Coordinates as text.
|
||||||
*/
|
*/
|
||||||
private String prettyCoordinates(Media media) {
|
private String prettyCoordinates(Media media) {
|
||||||
String coordinates = media.getCoordinates();
|
return media.getCoordinates();
|
||||||
|
|
||||||
return coordinates;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
||||||
if(savedInstanceState != null) {
|
if(savedInstanceState != null) {
|
||||||
editable = savedInstanceState.getBoolean("editable");
|
editable = savedInstanceState.getBoolean("editable");
|
||||||
}
|
}
|
||||||
app = (CommonsApplication)getActivity().getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import android.database.sqlite.SQLiteQueryBuilder;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.data.DBOpenHelper;
|
import fr.free.nrw.commons.data.DBOpenHelper;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
@ -35,7 +36,7 @@ public class ModificationsContentProvider extends ContentProvider{
|
||||||
private DBOpenHelper dbOpenHelper;
|
private DBOpenHelper dbOpenHelper;
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreate() {
|
public boolean onCreate() {
|
||||||
dbOpenHelper = DBOpenHelper.getInstance(getContext());
|
dbOpenHelper = CommonsApplication.getInstance().getDBOpenHelper();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class ModificationsSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
api.setAuthCookie(authCookie);
|
api.setAuthCookie(authCookie);
|
||||||
String editToken;
|
String editToken;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class ModificationsSyncService extends Service {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
synchronized (sSyncAdapterLock) {
|
synchronized (sSyncAdapterLock) {
|
||||||
if (sSyncAdapter == null) {
|
if (sSyncAdapter == null) {
|
||||||
sSyncAdapter = new ModificationsSyncAdapter(getApplicationContext(), true);
|
sSyncAdapter = new ModificationsSyncAdapter(this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,5 +142,10 @@ public class ModifierSequence {
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void onDelete(SQLiteDatabase db) {
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
package fr.free.nrw.commons.nearby;
|
package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -20,23 +17,22 @@ import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
import fr.free.nrw.commons.location.LatLng;
|
|
||||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
|
||||||
import fr.free.nrw.commons.theme.BaseActivity;
|
|
||||||
import fr.free.nrw.commons.utils.UriSerializer;
|
|
||||||
|
|
||||||
import fr.free.nrw.commons.R;
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NearbyActivity extends BaseActivity {
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
|
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||||
|
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||||
|
import fr.free.nrw.commons.utils.UriSerializer;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
public class NearbyActivity extends NavigationBaseActivity {
|
||||||
@BindView(R.id.progressBar)
|
@BindView(R.id.progressBar)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
private boolean isMapViewActive = false;
|
private boolean isMapViewActive = false;
|
||||||
|
|
@ -64,7 +60,7 @@ public class NearbyActivity extends BaseActivity {
|
||||||
curLatLang = locationManager.getLatestLocation();
|
curLatLang = locationManager.getLatestLocation();
|
||||||
nearbyAsyncTask = new NearbyAsyncTask(this);
|
nearbyAsyncTask = new NearbyAsyncTask(this);
|
||||||
nearbyAsyncTask.execute();
|
nearbyAsyncTask.execute();
|
||||||
|
initDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -189,7 +185,7 @@ public class NearbyActivity extends BaseActivity {
|
||||||
@Override
|
@Override
|
||||||
protected List<Place> doInBackground(Void... params) {
|
protected List<Place> doInBackground(Void... params) {
|
||||||
return NearbyController
|
return NearbyController
|
||||||
.loadAttractionsFromLocation(curLatLang, getApplicationContext()
|
.loadAttractionsFromLocation(curLatLang, CommonsApplication.getInstance()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,4 +247,9 @@ public class NearbyActivity extends BaseActivity {
|
||||||
fragmentTransaction.replace(R.id.container, fragment);
|
fragmentTransaction.replace(R.id.container, fragment);
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void startYourself(Context context) {
|
||||||
|
Intent settingsIntent = new Intent(context, NearbyActivity.class);
|
||||||
|
context.startActivity(settingsIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.location.LatLng;
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
@ -37,13 +38,14 @@ public class NearbyController {
|
||||||
if (curLatLng == null) {
|
if (curLatLng == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
NearbyPlaces nearbyPlaces = CommonsApplication.getInstance().getNearbyPlaces();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
List<Place> places = prefs.getBoolean("useWikidata", true)
|
List<Place> places = prefs.getBoolean("useWikidata", true)
|
||||||
? NearbyPlaces.getInstance().getFromWikidataQuery(
|
? nearbyPlaces.getFromWikidataQuery(
|
||||||
context,
|
context,
|
||||||
curLatLng,
|
curLatLng,
|
||||||
Locale.getDefault().getLanguage())
|
Locale.getDefault().getLanguage())
|
||||||
: NearbyPlaces.getInstance().getFromWikiNeedsPictures();
|
: nearbyPlaces.getFromWikiNeedsPictures();
|
||||||
if (curLatLng != null) {
|
if (curLatLng != null) {
|
||||||
Timber.d("Sorting places by distance...");
|
Timber.d("Sorting places by distance...");
|
||||||
final Map<Place, Double> distances = new HashMap<>();
|
final Map<Place, Double> distances = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
|
||||||
import fr.free.nrw.commons.location.LatLng;
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
import fr.free.nrw.commons.ui.widget.OverlayDialog;
|
import fr.free.nrw.commons.ui.widget.OverlayDialog;
|
||||||
import fr.free.nrw.commons.utils.DialogUtil;
|
import fr.free.nrw.commons.utils.DialogUtil;
|
||||||
|
|
@ -25,8 +24,7 @@ public class NearbyInfoDialog extends OverlayDialog {
|
||||||
private final static String ARG_DESC = "placeDesc";
|
private final static String ARG_DESC = "placeDesc";
|
||||||
private final static String ARG_LATITUDE = "latitude";
|
private final static String ARG_LATITUDE = "latitude";
|
||||||
private final static String ARG_LONGITUDE = "longitude";
|
private final static String ARG_LONGITUDE = "longitude";
|
||||||
private final static String ARG_ARTICLE_LINK = "articleLink";
|
private final static String ARG_SITE_LINK = "sitelink";
|
||||||
private final static String ARG_WIKI_DATA_LINK = "wikiDataLink";
|
|
||||||
|
|
||||||
@BindView(R.id.link_preview_title)
|
@BindView(R.id.link_preview_title)
|
||||||
TextView placeTitle;
|
TextView placeTitle;
|
||||||
|
|
@ -58,15 +56,10 @@ public class NearbyInfoDialog extends OverlayDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getArticleLink(Bundle bundle) {
|
private void getArticleLink(Bundle bundle) {
|
||||||
String articleLink = bundle.getString(ARG_ARTICLE_LINK);
|
Sitelinks sitelinks = bundle.getParcelable(ARG_SITE_LINK);
|
||||||
articleLink = articleLink.replace("<", "").replace(">", "");
|
|
||||||
|
|
||||||
if (Utils.isNullOrWhiteSpace(articleLink) || articleLink == "\n") {
|
if (sitelinks.getWikipediaLink() != null) {
|
||||||
articleLink = bundle.getString(ARG_WIKI_DATA_LINK).replace("<", "").replace(">", "");
|
this.articleLink = sitelinks.getWikipediaLink();
|
||||||
}
|
|
||||||
|
|
||||||
if (!Utils.isNullOrWhiteSpace(articleLink) && articleLink != "\n") {
|
|
||||||
this.articleLink = Uri.parse(articleLink);
|
|
||||||
} else {
|
} else {
|
||||||
goToButton.setVisibility(View.GONE);
|
goToButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
@ -79,8 +72,7 @@ public class NearbyInfoDialog extends OverlayDialog {
|
||||||
bundle.putString(ARG_DESC, place.description);
|
bundle.putString(ARG_DESC, place.description);
|
||||||
bundle.putDouble(ARG_LATITUDE, place.location.latitude);
|
bundle.putDouble(ARG_LATITUDE, place.location.latitude);
|
||||||
bundle.putDouble(ARG_LONGITUDE, place.location.longitude);
|
bundle.putDouble(ARG_LONGITUDE, place.location.longitude);
|
||||||
bundle.putString(ARG_ARTICLE_LINK, place.siteLink.toString());
|
bundle.putParcelable(ARG_SITE_LINK, place.siteLinks);
|
||||||
bundle.putString(ARG_WIKI_DATA_LINK, place.wikiDataLink.toString());
|
|
||||||
mDialog.setArguments(bundle);
|
mDialog.setArguments(bundle);
|
||||||
DialogUtil.showSafely(fragmentActivity, mDialog);
|
DialogUtil.showSafely(fragmentActivity, mDialog);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package fr.free.nrw.commons.nearby;
|
package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ListFragment;
|
import android.support.v4.app.ListFragment;
|
||||||
|
|
@ -9,22 +8,19 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnItemClick;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import fr.free.nrw.commons.R;
|
|
||||||
import fr.free.nrw.commons.location.LatLng;
|
|
||||||
import fr.free.nrw.commons.utils.UriDeserializer;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnItemClick;
|
||||||
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.location.LatLng;
|
||||||
|
import fr.free.nrw.commons.utils.UriDeserializer;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class NearbyListFragment extends ListFragment {
|
public class NearbyListFragment extends ListFragment {
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,13 @@ import timber.log.Timber;
|
||||||
public class NearbyPlaces {
|
public class NearbyPlaces {
|
||||||
|
|
||||||
private static final int MIN_RESULTS = 40;
|
private static final int MIN_RESULTS = 40;
|
||||||
private static final double INITIAL_RADIUS = 1.0;
|
private static final double INITIAL_RADIUS = 1.0; // in kilometer
|
||||||
private static final double MAX_RADIUS = 300.0;
|
private static final double MAX_RADIUS = 300.0; // in kilometer
|
||||||
private static final double RADIUS_MULTIPLIER = 1.618;
|
private static final double RADIUS_MULTIPLIER = 1.618;
|
||||||
private static final String WIKIDATA_QUERY_URL = "https://query.wikidata.org/sparql?query=${QUERY}";
|
private static final String WIKIDATA_QUERY_URL = "https://query.wikidata.org/sparql?query=${QUERY}";
|
||||||
private static NearbyPlaces singleton;
|
|
||||||
private double radius = INITIAL_RADIUS;
|
private double radius = INITIAL_RADIUS;
|
||||||
private List<Place> places;
|
private List<Place> places;
|
||||||
|
|
||||||
private NearbyPlaces(){
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Place> getFromWikidataQuery(Context context,
|
List<Place> getFromWikidataQuery(Context context,
|
||||||
LatLng curLatLng,
|
LatLng curLatLng,
|
||||||
String lang) {
|
String lang) {
|
||||||
|
|
@ -69,16 +65,20 @@ public class NearbyPlaces {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
List<Place> places = new ArrayList<>();
|
List<Place> places = new ArrayList<>();
|
||||||
|
|
||||||
String query = FileUtils.readFromFile(context, "queries/nearby_query.txt");
|
String query = FileUtils.readFromFile(context, "queries/nearby_query.rq")
|
||||||
|
.replace("${RADIUS}", String.format(Locale.ROOT, "%.2f", radius))
|
||||||
|
.replace("${LAT}", String.format(Locale.ROOT, "%.4f", cur.latitude))
|
||||||
|
.replace("${LONG}", String.format(Locale.ROOT, "%.4f", cur.longitude))
|
||||||
|
.replace("${LANG}", lang);
|
||||||
|
|
||||||
Timber.d(query);
|
Timber.d("Wikidata query "+ query);
|
||||||
|
|
||||||
|
// format as a URL
|
||||||
|
String url = WIKIDATA_QUERY_URL.replace(
|
||||||
|
"${QUERY}",
|
||||||
|
URLEncoder.encode(query, "utf-8").replace("+", "%20")
|
||||||
|
);
|
||||||
|
|
||||||
query = query.replace("${RADIUS}", "" + radius)
|
|
||||||
.replace("${LAT}", "" + String.format(Locale.ROOT, "%.3f", cur.latitude))
|
|
||||||
.replace("${LONG}", "" + String.format(Locale.ROOT, "%.3f", cur.longitude))
|
|
||||||
.replace("${LANG}", "" + lang);
|
|
||||||
query = URLEncoder.encode(query, "utf-8").replace("+", "%20");
|
|
||||||
String url = WIKIDATA_QUERY_URL.replace("${QUERY}", query);
|
|
||||||
Timber.d(url);
|
Timber.d(url);
|
||||||
URLConnection conn = new URL(url).openConnection();
|
URLConnection conn = new URL(url).openConnection();
|
||||||
conn.setRequestProperty("Accept", "text/tab-separated-values");
|
conn.setRequestProperty("Accept", "text/tab-separated-values");
|
||||||
|
|
@ -97,8 +97,9 @@ public class NearbyPlaces {
|
||||||
String point = fields[0];
|
String point = fields[0];
|
||||||
String name = Utils.stripLocalizedString(fields[2]);
|
String name = Utils.stripLocalizedString(fields[2]);
|
||||||
String type = Utils.stripLocalizedString(fields[4]);
|
String type = Utils.stripLocalizedString(fields[4]);
|
||||||
String sitelink = Utils.stripLocalizedString(fields[7]);
|
String wikipediaSitelink = Utils.stripLocalizedString(fields[7]);
|
||||||
String wikiDataLink = Utils.stripLocalizedString(fields[3]);
|
String commonsSitelink = Utils.stripLocalizedString(fields[8]);
|
||||||
|
String wikiDataLink = Utils.stripLocalizedString(fields[1]);
|
||||||
String icon = fields[5];
|
String icon = fields[5];
|
||||||
|
|
||||||
double latitude = 0;
|
double latitude = 0;
|
||||||
|
|
@ -121,8 +122,11 @@ public class NearbyPlaces {
|
||||||
type, // details
|
type, // details
|
||||||
Uri.parse(icon),
|
Uri.parse(icon),
|
||||||
new LatLng(latitude, longitude),
|
new LatLng(latitude, longitude),
|
||||||
Uri.parse(sitelink),
|
new Sitelinks.Builder()
|
||||||
Uri.parse(wikiDataLink)
|
.setWikipediaLink(wikipediaSitelink)
|
||||||
|
.setCommonsLink(commonsSitelink)
|
||||||
|
.setWikidataLink(wikiDataLink)
|
||||||
|
.build()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|
@ -180,8 +184,7 @@ public class NearbyPlaces {
|
||||||
type, // details
|
type, // details
|
||||||
null,
|
null,
|
||||||
new LatLng(latitude, longitude),
|
new LatLng(latitude, longitude),
|
||||||
null,
|
new Sitelinks.Builder().build()
|
||||||
null
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
|
|
@ -192,17 +195,4 @@ public class NearbyPlaces {
|
||||||
}
|
}
|
||||||
return places;
|
return places;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the singleton instance of this class.
|
|
||||||
* The instance is created upon the first invocation of this method, and then reused.
|
|
||||||
*
|
|
||||||
* @return The singleton instance
|
|
||||||
*/
|
|
||||||
public static synchronized NearbyPlaces getInstance() {
|
|
||||||
if (singleton == null) {
|
|
||||||
singleton = new NearbyPlaces();
|
|
||||||
}
|
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,12 @@ public class NearbyViewHolder implements ViewHolder<Place> {
|
||||||
public void bindModel(Context context, Place place) {
|
public void bindModel(Context context, Place place) {
|
||||||
// Populate the data into the template view using the data object
|
// Populate the data into the template view using the data object
|
||||||
tvName.setText(place.name);
|
tvName.setText(place.name);
|
||||||
tvDesc.setText(place.description);
|
String description = place.description;
|
||||||
|
if ( description == null || description.isEmpty() || description.equals("?")) {
|
||||||
|
description = "No Description Found";
|
||||||
|
}
|
||||||
|
tvDesc.setText(description);
|
||||||
distance.setText(place.distance);
|
distance.setText(place.distance);
|
||||||
|
|
||||||
icon.setImageResource(ResourceUtils.getDescriptionIcon(place.description));
|
icon.setImageResource(ResourceUtils.getDescriptionIcon(place.description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,17 @@ public class Place {
|
||||||
public Bitmap image;
|
public Bitmap image;
|
||||||
public Bitmap secondaryImage;
|
public Bitmap secondaryImage;
|
||||||
public String distance;
|
public String distance;
|
||||||
public Uri siteLink;
|
public Sitelinks siteLinks;
|
||||||
public Uri wikiDataLink;
|
|
||||||
|
|
||||||
|
|
||||||
public Place(String name, String description, String longDescription,
|
public Place(String name, String description, String longDescription,
|
||||||
Uri secondaryImageUrl, LatLng location, Uri siteLink, Uri wikiDataLink) {
|
Uri secondaryImageUrl, LatLng location, Sitelinks siteLinks) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.longDescription = longDescription;
|
this.longDescription = longDescription;
|
||||||
this.secondaryImageUrl = secondaryImageUrl;
|
this.secondaryImageUrl = secondaryImageUrl;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.siteLink = siteLink;
|
this.siteLinks = siteLinks;
|
||||||
this.wikiDataLink = wikiDataLink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDistance(String distance) {
|
public void setDistance(String distance) {
|
||||||
|
|
|
||||||
106
app/src/main/java/fr/free/nrw/commons/nearby/Sitelinks.java
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.Utils;
|
||||||
|
|
||||||
|
public class Sitelinks implements Parcelable {
|
||||||
|
private final String wikipediaLink;
|
||||||
|
private final String commonsLink;
|
||||||
|
private final String wikidataLink;
|
||||||
|
|
||||||
|
|
||||||
|
protected Sitelinks(Parcel in) {
|
||||||
|
wikipediaLink = in.readString();
|
||||||
|
commonsLink = in.readString();
|
||||||
|
wikidataLink = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(wikipediaLink);
|
||||||
|
dest.writeString(commonsLink);
|
||||||
|
dest.writeString(wikidataLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<Sitelinks> CREATOR = new Creator<Sitelinks>() {
|
||||||
|
@Override
|
||||||
|
public Sitelinks createFromParcel(Parcel in) {
|
||||||
|
return new Sitelinks(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sitelinks[] newArray(int size) {
|
||||||
|
return new Sitelinks[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Uri getWikipediaLink() {
|
||||||
|
return sanitiseString(wikipediaLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Uri getCommonsLink() {
|
||||||
|
return sanitiseString(commonsLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Uri getWikidataLink() {
|
||||||
|
return sanitiseString(wikidataLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Uri sanitiseString(String stringUrl) {
|
||||||
|
stringUrl = stringUrl
|
||||||
|
.replaceAll("<", "")
|
||||||
|
.replaceAll(">", "")
|
||||||
|
.replaceAll("\n", "");
|
||||||
|
if (!Utils.isNullOrWhiteSpace(stringUrl) && stringUrl != null) {
|
||||||
|
return Uri.parse(stringUrl);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sitelinks(Sitelinks.Builder builder) {
|
||||||
|
this.wikidataLink = builder.wikidataLink;
|
||||||
|
this.wikipediaLink = builder.wikipediaLink;
|
||||||
|
this.commonsLink = builder.commonsLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String wikidataLink;
|
||||||
|
private String commonsLink;
|
||||||
|
private String wikipediaLink;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sitelinks.Builder setWikipediaLink(String link) {
|
||||||
|
this.wikipediaLink = link;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sitelinks.Builder setWikidataLink(String link) {
|
||||||
|
this.wikidataLink = link;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sitelinks.Builder setCommonsLink(@Nullable String link) {
|
||||||
|
this.commonsLink = link;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sitelinks build() {
|
||||||
|
return new Sitelinks(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
package fr.free.nrw.commons.settings;
|
package fr.free.nrw.commons.settings;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v7.app.AppCompatDelegate;
|
import android.support.v7.app.AppCompatDelegate;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.theme.NavigationBaseActivity;
|
||||||
|
|
||||||
|
public class SettingsActivity extends NavigationBaseActivity {
|
||||||
|
private SettingsFragment settingsFragment;
|
||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity {
|
|
||||||
private AppCompatDelegate settingsDelegate;
|
private AppCompatDelegate settingsDelegate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -20,11 +26,13 @@ public class SettingsActivity extends PreferenceActivity {
|
||||||
setTheme(R.style.LightAppTheme);
|
setTheme(R.style.LightAppTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the fragment as the main content.
|
settingsFragment = (SettingsFragment) getFragmentManager().findFragmentById(R.id.settingsFragment);
|
||||||
getFragmentManager().beginTransaction()
|
|
||||||
.replace(android.R.id.content, new SettingsFragment()).commit();
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_settings);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
initDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an action bar
|
// Get an action bar
|
||||||
|
|
@ -37,7 +45,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||||
settingsDelegate.onPostCreate(savedInstanceState);
|
settingsDelegate.onPostCreate(savedInstanceState);
|
||||||
|
|
||||||
//Get an up button
|
//Get an up button
|
||||||
settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
//settingsDelegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle action-bar clicks
|
//Handle action-bar clicks
|
||||||
|
|
@ -51,4 +59,9 @@ public class SettingsActivity extends PreferenceActivity {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void startYourself(Context context) {
|
||||||
|
Intent settingsIntent = new Intent(context, SettingsActivity.class);
|
||||||
|
context.startActivity(settingsIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ public class SettingsFragment extends PreferenceFragment {
|
||||||
|
|
||||||
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
final EditTextPreference uploadLimit = (EditTextPreference) findPreference("uploads");
|
||||||
final SharedPreferences sharedPref = PreferenceManager
|
final SharedPreferences sharedPref = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
.getDefaultSharedPreferences(CommonsApplication.getInstance());
|
||||||
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
int uploads = sharedPref.getInt(Prefs.UPLOADS_SHOWING, 100);
|
||||||
uploadLimit.setText(uploads + "");
|
uploadLimit.setText(uploads + "");
|
||||||
uploadLimit.setSummary(uploads + "");
|
uploadLimit.setSummary(uploads + "");
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,19 @@ package fr.free.nrw.commons.theme;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Utils;
|
import fr.free.nrw.commons.Utils;
|
||||||
|
import fr.free.nrw.commons.hamburger.NavigationBaseFragment;
|
||||||
|
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||||
|
|
||||||
public class BaseActivity extends AppCompatActivity {
|
public class BaseActivity extends AppCompatActivity {
|
||||||
boolean currentTheme;
|
boolean currentTheme;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
if(Utils.isDarkTheme(this)){
|
if(Utils.isDarkTheme(this)){
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
package fr.free.nrw.commons.theme;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import fr.free.nrw.commons.R;
|
||||||
|
import fr.free.nrw.commons.hamburger.HamburgerMenuContainer;
|
||||||
|
import fr.free.nrw.commons.hamburger.NavigationBaseFragment;
|
||||||
|
import fr.free.nrw.commons.utils.FragmentUtils;
|
||||||
|
|
||||||
|
import static android.support.v4.view.GravityCompat.START;
|
||||||
|
|
||||||
|
public class NavigationBaseActivity extends BaseActivity implements HamburgerMenuContainer {
|
||||||
|
@BindView(R.id.toolbar)
|
||||||
|
Toolbar toolbar;
|
||||||
|
|
||||||
|
@BindView(R.id.drawer_layout)
|
||||||
|
DrawerLayout drawerLayout;
|
||||||
|
|
||||||
|
@BindView(R.id.drawer_pane)
|
||||||
|
RelativeLayout drawerPane;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initDrawer() {
|
||||||
|
initSubviews();
|
||||||
|
NavigationBaseFragment baseFragment = new NavigationBaseFragment();
|
||||||
|
baseFragment.setDrawerLayout(drawerLayout, drawerPane);
|
||||||
|
FragmentUtils.addAndCommitFragmentWithImmediateExecution(getSupportFragmentManager(),
|
||||||
|
R.id.drawer_fragment,
|
||||||
|
baseFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSubviews() {
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this,
|
||||||
|
drawerLayout,
|
||||||
|
toolbar,
|
||||||
|
R.string.navigation_drawer_open,
|
||||||
|
R.string.navigation_drawer_close);
|
||||||
|
drawerLayout.setDrawerListener(toggle);
|
||||||
|
toggle.setDrawerIndicatorEnabled(true);
|
||||||
|
toggle.syncState();
|
||||||
|
setDrawerPaneWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDrawerPaneWidth() {
|
||||||
|
ViewGroup.LayoutParams params = drawerPane.getLayoutParams();
|
||||||
|
// set width to lowerBound of 80% of the screen size
|
||||||
|
params.width = (getResources().getDisplayMetrics().widthPixels * 70) / 100;
|
||||||
|
drawerPane.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDrawerListener(ActionBarDrawerToggle listener) {
|
||||||
|
drawerLayout.setDrawerListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toggleDrawer() {
|
||||||
|
if (drawerLayout.isDrawerVisible(START)) {
|
||||||
|
drawerLayout.closeDrawer(START);
|
||||||
|
} else {
|
||||||
|
drawerLayout.openDrawer(START);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDrawerVisible() {
|
||||||
|
return drawerLayout.isDrawerVisible(START);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -38,7 +38,7 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... voids) {
|
protected Boolean doInBackground(Void... voids) {
|
||||||
MWApi api = CommonsApplication.createMWApi();
|
MWApi api = CommonsApplication.getInstance().getMWApi();
|
||||||
ApiResult result;
|
ApiResult result;
|
||||||
|
|
||||||
// https://commons.wikimedia.org/w/api.php?action=query&list=allimages&format=xml&aisha1=801957214aba50cb63bb6eb1b0effa50188900ba
|
// https://commons.wikimedia.org/w/api.php?action=query&list=allimages&format=xml&aisha1=801957214aba50cb63bb6eb1b0effa50188900ba
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package fr.free.nrw.commons.upload;
|
package fr.free.nrw.commons.upload;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
|
@ -20,6 +21,8 @@ public class FileUtils {
|
||||||
* @param uri The Uri to query.
|
* @param uri The Uri to query.
|
||||||
* @author paulburke
|
* @author paulburke
|
||||||
*/
|
*/
|
||||||
|
// Can be safely suppressed, checks for isKitKat before running isDocumentUri
|
||||||
|
@SuppressLint("NewApi")
|
||||||
public static String getPath(final Context context, final Uri uri) {
|
public static String getPath(final Context context, final Uri uri) {
|
||||||
|
|
||||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
|
|
@ -130,7 +132,11 @@ public class MultipleShareActivity
|
||||||
dialog.setProgress(uploadCount);
|
dialog.setProgress(uploadCount);
|
||||||
if(uploadCount == photosList.size()) {
|
if(uploadCount == photosList.size()) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
Toast startingToast = Toast.makeText(getApplicationContext(), R.string.uploading_started, Toast.LENGTH_LONG);
|
Toast startingToast = Toast.makeText(
|
||||||
|
CommonsApplication.getInstance(),
|
||||||
|
R.string.uploading_started,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
);
|
||||||
startingToast.show();
|
startingToast.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +206,9 @@ public class MultipleShareActivity
|
||||||
uploadController = new UploadController(this);
|
uploadController = new UploadController(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_multiple_uploads);
|
setContentView(R.layout.activity_multiple_uploads);
|
||||||
app = (CommonsApplication)this.getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
initDrawer();
|
||||||
|
|
||||||
if(savedInstanceState != null) {
|
if(savedInstanceState != null) {
|
||||||
photosList = savedInstanceState.getParcelableArrayList("uploadsList");
|
photosList = savedInstanceState.getParcelableArrayList("uploadsList");
|
||||||
|
|
@ -237,7 +245,7 @@ public class MultipleShareActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAuthCookieAcquired(String authCookie) {
|
protected void onAuthCookieAcquired(String authCookie) {
|
||||||
app.getApi().setAuthCookie(authCookie);
|
app.getMWApi().setAuthCookie(authCookie);
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
|
||||||
if(intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
|
if(intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public class MwVolleyApi {
|
||||||
|
|
||||||
private static RequestQueue getQueue(Context context) {
|
private static RequestQueue getQueue(Context context) {
|
||||||
if (REQUEST_QUEUE == null) {
|
if (REQUEST_QUEUE == null) {
|
||||||
REQUEST_QUEUE = Volley.newRequestQueue(context.getApplicationContext());
|
REQUEST_QUEUE = Volley.newRequestQueue(context);
|
||||||
}
|
}
|
||||||
return REQUEST_QUEUE;
|
return REQUEST_QUEUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import fr.free.nrw.commons.CommonsApplication;
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import fr.free.nrw.commons.EventLog;
|
import fr.free.nrw.commons.EventLog;
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
|
|
@ -105,12 +106,16 @@ public class ShareActivity
|
||||||
getFileMetadata(false);
|
getFileMetadata(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Toast startingToast = Toast.makeText(getApplicationContext(), R.string.uploading_started, Toast.LENGTH_LONG);
|
Toast startingToast = Toast.makeText(
|
||||||
|
CommonsApplication.getInstance(),
|
||||||
|
R.string.uploading_started,
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
);
|
||||||
startingToast.show();
|
startingToast.show();
|
||||||
|
|
||||||
if (!cacheFound) {
|
if (!cacheFound) {
|
||||||
//Has to be called after apiCall.request()
|
//Has to be called after apiCall.request()
|
||||||
app.cacheData.cacheCategory();
|
app.getCacheData().cacheCategory();
|
||||||
Timber.d("Cache the categories found");
|
Timber.d("Cache the categories found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,7 +193,7 @@ public class ShareActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAuthCookieAcquired(String authCookie) {
|
protected void onAuthCookieAcquired(String authCookie) {
|
||||||
app.getApi().setAuthCookie(authCookie);
|
app.getMWApi().setAuthCookie(authCookie);
|
||||||
|
|
||||||
shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView");
|
shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView");
|
||||||
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
|
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
|
||||||
|
|
@ -214,8 +219,9 @@ public class ShareActivity
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
uploadController = new UploadController(this);
|
uploadController = new UploadController(this);
|
||||||
setContentView(R.layout.activity_share);
|
setContentView(R.layout.activity_share);
|
||||||
|
ButterKnife.bind(this);
|
||||||
app = (CommonsApplication)this.getApplicationContext();
|
initDrawer();
|
||||||
|
app = CommonsApplication.getInstance();
|
||||||
backgroundImageView = (ImageView)findViewById(R.id.backgroundImage);
|
backgroundImageView = (ImageView)findViewById(R.id.backgroundImage);
|
||||||
|
|
||||||
//Receive intent from ContributionController.java when user selects picture to upload
|
//Receive intent from ContributionController.java when user selects picture to upload
|
||||||
|
|
@ -396,12 +402,12 @@ public class ShareActivity
|
||||||
if (imageObj.imageCoordsExists) {
|
if (imageObj.imageCoordsExists) {
|
||||||
double decLongitude = imageObj.getDecLongitude();
|
double decLongitude = imageObj.getDecLongitude();
|
||||||
double decLatitude = imageObj.getDecLatitude();
|
double decLatitude = imageObj.getDecLatitude();
|
||||||
app.cacheData.setQtPoint(decLongitude, decLatitude);
|
app.getCacheData().setQtPoint(decLongitude, decLatitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwVolleyApi apiCall = new MwVolleyApi(this);
|
MwVolleyApi apiCall = new MwVolleyApi(this);
|
||||||
|
|
||||||
List<String> displayCatList = app.cacheData.findCategory();
|
List<String> displayCatList = app.getCacheData().findCategory();
|
||||||
boolean catListEmpty = displayCatList.isEmpty();
|
boolean catListEmpty = displayCatList.isEmpty();
|
||||||
|
|
||||||
// If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories
|
// If no categories found in cache, call MediaWiki API to match image coords with nearby Commons categories
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public class UploadController {
|
||||||
|
|
||||||
public UploadController(Activity activity) {
|
public UploadController(Activity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
app = (CommonsApplication)activity.getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUploadServiceConnected;
|
private boolean isUploadServiceConnected;
|
||||||
|
|
@ -55,7 +55,7 @@ public class UploadController {
|
||||||
};
|
};
|
||||||
|
|
||||||
public void prepareService() {
|
public void prepareService() {
|
||||||
Intent uploadServiceIntent = new Intent(activity.getApplicationContext(), UploadService.class);
|
Intent uploadServiceIntent = new Intent(activity, UploadService.class);
|
||||||
uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE);
|
uploadServiceIntent.setAction(UploadService.ACTION_START_SERVICE);
|
||||||
activity.startService(uploadServiceIntent);
|
activity.startService(uploadServiceIntent);
|
||||||
activity.bindService(uploadServiceIntent, uploadServiceConnection, Context.BIND_AUTO_CREATE);
|
activity.bindService(uploadServiceIntent, uploadServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
app = (CommonsApplication) this.getApplicationContext();
|
app = CommonsApplication.getInstance();
|
||||||
contributionsProviderClient = this.getContentResolver().acquireContentProviderClient(ContributionsContentProvider.AUTHORITY);
|
contributionsProviderClient = this.getContentResolver().acquireContentProviderClient(ContributionsContentProvider.AUTHORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,7 +176,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadContribution(Contribution contribution) {
|
private void uploadContribution(Contribution contribution) {
|
||||||
MWApi api = app.getApi();
|
MWApi api = app.getMWApi();
|
||||||
|
|
||||||
ApiResult result;
|
ApiResult result;
|
||||||
InputStream file = null;
|
InputStream file = null;
|
||||||
|
|
@ -201,7 +201,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
.setContentText(getResources().getQuantityString(R.plurals.uploads_pending_notification_indicator, toUpload, toUpload))
|
.setContentText(getResources().getQuantityString(R.plurals.uploads_pending_notification_indicator, toUpload, toUpload))
|
||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setProgress(100, 0, true)
|
.setProgress(100, 0, true)
|
||||||
.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(this, ContributionsActivity.class), 0))
|
.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(this, ContributionsActivity.class), 0))
|
||||||
.setTicker(getString(R.string.upload_progress_notification_title_in_progress, contribution.getDisplayTitle()));
|
.setTicker(getString(R.string.upload_progress_notification_title_in_progress, contribution.getDisplayTitle()));
|
||||||
|
|
||||||
this.startForeground(NOTIFICATION_UPLOAD_IN_PROGRESS, curProgressNotification.build());
|
this.startForeground(NOTIFICATION_UPLOAD_IN_PROGRESS, curProgressNotification.build());
|
||||||
|
|
@ -282,7 +282,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
toUpload--;
|
toUpload--;
|
||||||
if(toUpload == 0) {
|
if(toUpload == 0) {
|
||||||
// Sync modifications right after all uplaods are processed
|
// Sync modifications right after all uplaods are processed
|
||||||
ContentResolver.requestSync(((CommonsApplication) getApplicationContext()).getCurrentAccount(), ModificationsContentProvider.AUTHORITY, new Bundle());
|
ContentResolver.requestSync((CommonsApplication.getInstance()).getCurrentAccount(), ModificationsContentProvider.AUTHORITY, new Bundle());
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +304,7 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String findUniqueFilename(String fileName) throws IOException {
|
private String findUniqueFilename(String fileName) throws IOException {
|
||||||
MWApi api = app.getApi();
|
MWApi api = app.getMWApi();
|
||||||
String sequenceFileName;
|
String sequenceFileName;
|
||||||
for ( int sequenceNumber = 1; true; sequenceNumber++ ) {
|
for ( int sequenceNumber = 1; true; sequenceNumber++ ) {
|
||||||
if (sequenceNumber == 1) {
|
if (sequenceNumber == 1) {
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,25 @@ package fr.free.nrw.commons.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
public static String readFromFile(Context context, String fileName) {
|
public static String readFromFile(Context context, String fileName) {
|
||||||
String stringBuilder = "";
|
String stringBuilder = "";
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try {
|
try {
|
||||||
reader = new BufferedReader(
|
reader = new BufferedReader(
|
||||||
new InputStreamReader(context.getAssets().open(fileName), "UTF-8"));
|
new InputStreamReader(context.getAssets().open(fileName)));
|
||||||
String mLine;
|
String mLine;
|
||||||
while ((mLine = reader.readLine()) != null) {
|
while ((mLine = reader.readLine()) != null) {
|
||||||
stringBuilder += mLine + "\n";
|
stringBuilder += mLine + "\n";
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
//log the exception
|
Timber.e("File not found exception", e);
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -30,4 +33,26 @@ public class FileUtils {
|
||||||
}
|
}
|
||||||
return stringBuilder;
|
return stringBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes files.
|
||||||
|
* @param file context
|
||||||
|
*/
|
||||||
|
public static boolean deleteFile(File file) {
|
||||||
|
boolean deletedAll = true;
|
||||||
|
if (file != null) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
String[] children = file.list();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
deletedAll = deleteFile(new File(file, children[i])) && deletedAll;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deletedAll = file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deletedAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package fr.free.nrw.commons.utils;
|
||||||
|
|
||||||
|
import android.support.annotation.IdRes;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
public class FragmentUtils {
|
||||||
|
|
||||||
|
public static boolean addAndCommitFragmentWithImmediateExecution(
|
||||||
|
@NonNull FragmentManager fragmentManager,
|
||||||
|
@IdRes int containerViewId,
|
||||||
|
@NonNull Fragment fragment) {
|
||||||
|
if (fragment.isAdded()) {
|
||||||
|
Timber.w("Could not add fragment. The fragment is already added.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.add(containerViewId, fragment)
|
||||||
|
.commitNow();
|
||||||
|
return true;
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
Timber.e(e, "Could not add & commit fragment. " +
|
||||||
|
"Did you mean to call commitAllowingStateLoss?");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
app/src/main/res/drawable-hdpi/ic_exit_to_app_black_24dp.png
Normal file
|
After Width: | Height: | Size: 251 B |
BIN
app/src/main/res/drawable-hdpi/ic_feedback_black_24dp.png
Normal file
|
After Width: | Height: | Size: 149 B |
BIN
app/src/main/res/drawable-hdpi/ic_file_upload_black_24dp.png
Normal file
|
After Width: | Height: | Size: 139 B |
BIN
app/src/main/res/drawable-hdpi/ic_info_outline_black_24dp.png
Normal file
|
After Width: | Height: | Size: 487 B |
BIN
app/src/main/res/drawable-hdpi/ic_location_on_black_24dp.png
Normal file
|
After Width: | Height: | Size: 376 B |
BIN
app/src/main/res/drawable-hdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 453 B |
BIN
app/src/main/res/drawable-mdpi/ic_exit_to_app_black_24dp.png
Normal file
|
After Width: | Height: | Size: 171 B |
BIN
app/src/main/res/drawable-mdpi/ic_feedback_black_24dp.png
Normal file
|
After Width: | Height: | Size: 127 B |
BIN
app/src/main/res/drawable-mdpi/ic_file_upload_black_24dp.png
Normal file
|
After Width: | Height: | Size: 114 B |
BIN
app/src/main/res/drawable-mdpi/ic_info_outline_black_24dp.png
Normal file
|
After Width: | Height: | Size: 323 B |
BIN
app/src/main/res/drawable-mdpi/ic_location_on_black_24dp.png
Normal file
|
After Width: | Height: | Size: 263 B |
BIN
app/src/main/res/drawable-mdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 322 B |
BIN
app/src/main/res/drawable-xhdpi/ic_exit_to_app_black_24dp.png
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
app/src/main/res/drawable-xhdpi/ic_feedback_black_24dp.png
Normal file
|
After Width: | Height: | Size: 187 B |
BIN
app/src/main/res/drawable-xhdpi/ic_file_upload_black_24dp.png
Normal file
|
After Width: | Height: | Size: 144 B |
BIN
app/src/main/res/drawable-xhdpi/ic_info_outline_black_24dp.png
Normal file
|
After Width: | Height: | Size: 640 B |
BIN
app/src/main/res/drawable-xhdpi/ic_location_on_black_24dp.png
Normal file
|
After Width: | Height: | Size: 457 B |
BIN
app/src/main/res/drawable-xhdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 557 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_exit_to_app_black_24dp.png
Normal file
|
After Width: | Height: | Size: 354 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_feedback_black_24dp.png
Normal file
|
After Width: | Height: | Size: 246 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_file_upload_black_24dp.png
Normal file
|
After Width: | Height: | Size: 175 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_info_outline_black_24dp.png
Normal file
|
After Width: | Height: | Size: 940 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_location_on_black_24dp.png
Normal file
|
After Width: | Height: | Size: 683 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 827 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_exit_to_app_black_24dp.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_feedback_black_24dp.png
Normal file
|
After Width: | Height: | Size: 311 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_file_upload_black_24dp.png
Normal file
|
After Width: | Height: | Size: 214 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_info_outline_black_24dp.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_location_on_black_24dp.png
Normal file
|
After Width: | Height: | Size: 868 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_settings_black_24dp.png
Normal file
|
After Width: | Height: | Size: 1 KiB |
15
app/src/main/res/drawable/hamburger_item_bg.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_pressed="true">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@color/hamburger_item_pressed_color" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item android:state_enabled="true">
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</selector>
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
<vector android:height="24dp" android:viewportHeight="235.0"
|
<vector android:height="24dp" android:viewportHeight="32.0"
|
||||||
android:viewportWidth="235.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:viewportWidth="32.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<path android:fillColor="#B1B1B1" android:pathData="M0,0h235v235h-235z"/>
|
<path android:fillColor="#006598" android:pathData="m15.87,3.79c-0.52,0.03 -0.91,0.06 -1.34,0.17 -1.55,0.38 -2.92,1.35 -3.81,2.69 -0.71,1.06 -1.08,2.29 -1.08,3.57 0,0.37 0.02,0.6 0.02,0.88l1.86,0c-0.07,-0.31 -0.12,-0.63 -0.12,-0.95 0,-2.6 2.12,-4.69 4.72,-4.69 2.6,0 4.69,2.1 4.69,4.69 0,2.33 -1.59,4.27 -3.81,4.82 -0.38,0.21 -0.73,0.24 -1,0.51 -0.24,0.24 -0.42,0.44 -0.59,0.73 -0.19,0.33 -0.36,0.76 -0.46,1.17 -0.03,0.12 -0.01,0.12 -0.02,0.12 -0.01,0 -0.16,-0.05 -0.42,-0.15 -0.54,-0.21 -0.68,-0.24 -0.76,-0.24 -0.05,-0 -0.06,0.01 -0.05,0.05 0.01,0.04 0.06,0.1 0.15,0.2 0.32,0.37 0.59,0.88 0.9,1.61 0.26,0.62 0.56,1.43 0.78,2.2 0.03,0.09 0.05,0.19 0.05,0.2 0,0 0.48,-0.79 0.81,-1.34 0.96,-1.63 1.46,-2.62 1.39,-2.71 -0.01,-0.01 -0.01,0.01 -0.05,0.02 -0.02,0.01 -0.07,0.04 -0.15,0.12 -0.07,0.07 -0.16,0.15 -0.2,0.17 -0.11,0.08 -0.27,0.16 -0.42,0.2 -0.13,0.03 -0.26,0.04 -0.27,0.02 -0.01,-0.01 0.03,-0.15 0.07,-0.27 0.17,-0.5 0.38,-0.82 0.76,-1.08 0.22,-0.15 0.44,-0.24 1.05,-0.49 0.48,-0.2 0.61,-0.27 0.86,-0.39 0.52,-0.26 0.92,-0.54 1.3,-0.93 0.54,-0.56 0.97,-1.22 1.27,-1.93 0.34,-0.8 0.51,-1.67 0.51,-2.54 0,-1.27 -0.37,-2.51 -1.08,-3.57 -0.35,-0.52 -0.76,-0.99 -1.25,-1.39 -0.88,-0.73 -1.93,-1.21 -3.06,-1.39 -0.23,-0.04 -0.43,-0.05 -0.68,-0.07 -0.1,-0.01 -0.5,-0 -0.59,0z"/>
|
||||||
<path android:fillColor="#E3E3E3" android:pathData="M117.5,18.5c-54.68,0 -99,44.32 -99,99c0,54.67 44.32,99 99,99c54.67,0 99,-44.32 99,-99C216.5,62.83 172.18,18.5 117.5,18.5zM117.5,202.98c-47.21,0 -85.48,-38.27 -85.48,-85.48c0,-47.21 38.27,-85.48 85.48,-85.48c47.21,0 85.48,38.27 85.48,85.48C202.98,164.71 164.71,202.98 117.5,202.98z"/>
|
<path android:fillColor="#980000" android:pathData="m15.61,25.72c-0.51,-0.04 -0.97,-0.29 -1.29,-0.68 -0.18,-0.23 -0.31,-0.49 -0.37,-0.78 -0.03,-0.15 -0.03,-0.19 -0.03,-0.38 0,-0.16 0,-0.19 0.01,-0.26 0.05,-0.34 0.18,-0.63 0.39,-0.89 0.06,-0.08 0.2,-0.22 0.28,-0.28 0.35,-0.28 0.78,-0.42 1.21,-0.41 0.41,0.01 0.77,0.14 1.09,0.4 0.08,0.06 0.23,0.21 0.29,0.28 0.18,0.22 0.29,0.45 0.36,0.71 0.04,0.15 0.05,0.28 0.05,0.45 0,0.12 -0.01,0.2 -0.02,0.3 -0.1,0.6 -0.48,1.1 -1.03,1.36 -0.29,0.14 -0.62,0.2 -0.94,0.17z"/>
|
||||||
<path android:fillColor="#EDA33F" android:pathData="M197.23,117.5c0,44.03 -35.69,79.72 -79.73,79.72c-44.03,0 -79.73,-35.69 -79.73,-79.72c0,-44.03 35.69,-79.73 79.73,-79.73C161.53,37.77 197.23,73.47 197.23,117.5z"/>
|
|
||||||
<path android:fillColor="#634207" android:pathData="M143.37,98.87c0,3.36 -0.49,6.32 -1.47,8.9s-2.37,4.81 -4.16,6.7c-1.79,1.89 -3.94,3.59 -6.45,5.08c-2.51,1.5 -5.34,2.86 -8.49,4.09v11.36h-17.53v-16.8c2.36,-0.63 4.49,-1.28 6.4,-1.94c1.91,-0.67 3.91,-1.75 6,-3.24c1.96,-1.33 3.49,-2.88 4.61,-4.64c1.11,-1.76 1.67,-3.76 1.67,-5.98c0,-3.32 -1.07,-5.69 -3.21,-7.11c-2.14,-1.41 -5.15,-2.12 -9.04,-2.12c-2.39,0 -5.09,0.51 -8.09,1.54c-3.01,1.03 -5.75,2.36 -8.24,3.98h-1.99V83.51c2.12,-0.9 5.39,-1.83 9.81,-2.81c4.41,-0.98 8.9,-1.47 13.44,-1.47c8.2,0 14.7,1.81 19.52,5.43S143.37,93.02 143.37,98.87zM124.2,154.91h-20.12V141.77h20.12V154.91z"/>
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
||||||
|
|
@ -1,71 +1,103 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:id="@+id/drawer_layout"
|
||||||
android:gravity="center"
|
|
||||||
android:layout_marginLeft="12dp"
|
|
||||||
android:layout_marginRight="12dp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
>
|
|
||||||
|
|
||||||
<ImageView
|
<RelativeLayout
|
||||||
android:src="@drawable/ic_launcher"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:layout_width="wrap_content"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<include
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="wrap_content"
|
layout="@layout/toolbar"
|
||||||
android:text="@string/app_name"
|
android:layout_width="match_parent"
|
||||||
style="?android:textAppearanceLarge"
|
android:layout_height="wrap_content" />
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/about_version"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_below="@id/toolbar"
|
||||||
/>
|
android:layout_marginLeft="12dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
<ImageView
|
||||||
android:id="@+id/about_license"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:src="@drawable/ic_launcher" />
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
style="?android:textAppearanceSmall"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/about_license"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
<TextView
|
||||||
android:id="@+id/about_improve"
|
style="?android:textAppearanceLarge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:text="@string/app_name" />
|
||||||
style="?android:textAppearanceSmall"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/about_improve"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
<TextView
|
||||||
android:id="@+id/about_privacy_policy"
|
android:id="@+id/about_version"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
style="?android:textAppearanceSmall"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="@string/about_privacy_policy"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
||||||
android:id="@+id/about_credits"
|
android:id="@+id/about_license"
|
||||||
android:layout_width="wrap_content"
|
style="?android:textAppearanceSmall"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_height="wrap_content"
|
||||||
style="?android:textAppearanceSmall"
|
android:layout_marginTop="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="@string/about_credits"
|
android:text="@string/about_license" />
|
||||||
/>
|
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
||||||
|
android:id="@+id/about_improve"
|
||||||
|
style="?android:textAppearanceSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/about_improve" />
|
||||||
|
|
||||||
|
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
||||||
|
android:id="@+id/about_privacy_policy"
|
||||||
|
style="?android:textAppearanceSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/about_privacy_policy" />
|
||||||
|
|
||||||
|
<fr.free.nrw.commons.ui.widget.HtmlTextView
|
||||||
|
android:id="@+id/about_credits"
|
||||||
|
style="?android:textAppearanceSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/about_credits" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/about_uploads_to"
|
||||||
|
style="?android:textAppearanceSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:alpha="0.2"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
@ -1,17 +1,48 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="horizontal"
|
|
||||||
android:id="@+id/contributionsFragmentContainer"
|
|
||||||
>
|
|
||||||
|
|
||||||
<fragment
|
<RelativeLayout
|
||||||
android:name="fr.free.nrw.commons.contributions.ContributionsListFragment"
|
|
||||||
android:id="@+id/contributionsListFragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
tools:layout="@layout/fragment_contributions" />
|
<include
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</FrameLayout>
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/contributionsFragmentContainer"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_below="@id/toolbar">
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/contributionsListFragment"
|
||||||
|
android:name="fr.free.nrw.commons.contributions.ContributionsListFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:layout="@layout/fragment_contributions" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
@ -1,8 +1,38 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/uploadsFragmentContainer"
|
android:id="@+id/drawer_layout"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/uploadsFragmentContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@id/toolbar"
|
||||||
|
android:orientation="vertical"></FrameLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
android:layout_gravity="start"
|
||||||
</FrameLayout>
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
@ -1,22 +1,50 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="horizontal"
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
>
|
|
||||||
|
|
||||||
<ProgressBar
|
<RelativeLayout
|
||||||
android:id="@+id/progressBar"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:layout_centerInParent="true"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FrameLayout
|
<include
|
||||||
android:id="@+id/container"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
layout="@layout/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_below="@id/toolbar">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"></FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
android:layout_gravity="start"
|
||||||
</FrameLayout>
|
android:background="@android:color/white">
|
||||||
|
|
||||||
</LinearLayout>
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
40
app/src/main/res/layout/activity_settings.xml
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/settingsFragment"
|
||||||
|
android:name="fr.free.nrw.commons.settings.SettingsFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:layout="@xml/preferences"
|
||||||
|
android:layout_below="@id/toolbar"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
@ -1,20 +1,50 @@
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="?attr/mainBackground"
|
|
||||||
>
|
|
||||||
|
|
||||||
<ImageView
|
<RelativeLayout
|
||||||
android:id="@+id/backgroundImage"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:scaleType="centerCrop"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FrameLayout
|
<include
|
||||||
android:id="@+id/single_upload_fragment_container"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
layout="@layout/toolbar"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
/>
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</FrameLayout>
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@id/toolbar"
|
||||||
|
android:background="?attr/mainBackground">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/backgroundImage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/single_upload_fragment_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/drawer_pane"
|
||||||
|
android:layout_width="320dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/drawer_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@android:id/text1"
|
android:id="@android:id/text1"
|
||||||
style="?android:attr/spinnerDropDownItemStyle"
|
style="?android:attr/spinnerDropDownItemStyle"
|
||||||
android:singleLine="true"
|
android:maxLines="1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
android:ellipsize="marquee"
|
android:ellipsize="marquee"
|
||||||
|
|
|
||||||
176
app/src/main/res/layout/navigation_drawer_menu.xml
Normal file
|
|
@ -0,0 +1,176 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@android:color/darker_gray">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/pictureOfTheDay"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_height="140dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0.5dp"
|
||||||
|
android:background="@android:color/black"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/upload_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="52dp"
|
||||||
|
android:background="@drawable/hamburger_item_bg"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:src="@drawable/ic_file_upload_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:text="@string/navigation_item_upload"
|
||||||
|
android:letterSpacing="0.02"
|
||||||
|
android:textColor="@color/main_background_dark"
|
||||||
|
android:textSize="@dimen/hamburger_menu_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/nearby_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="52dp"
|
||||||
|
android:background="@drawable/hamburger_item_bg"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:src="@drawable/ic_location_on_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:text="@string/navigation_item_nearby"
|
||||||
|
android:letterSpacing="0.02"
|
||||||
|
android:textColor="@color/main_background_dark"
|
||||||
|
android:textSize="@dimen/hamburger_menu_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/about_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="52dp"
|
||||||
|
android:background="@drawable/hamburger_item_bg"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:src="@drawable/ic_info_outline_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:text="@string/navigation_item_about"
|
||||||
|
android:letterSpacing="0.02"
|
||||||
|
android:textColor="@color/main_background_dark"
|
||||||
|
android:textSize="@dimen/hamburger_menu_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/settings_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="52dp"
|
||||||
|
android:background="@drawable/hamburger_item_bg"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:src="@drawable/ic_settings_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:text="@string/navigation_item_settings"
|
||||||
|
android:letterSpacing="0.02"
|
||||||
|
android:textColor="@color/main_background_dark"
|
||||||
|
android:textSize="@dimen/hamburger_menu_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/feedback_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="52dp"
|
||||||
|
android:background="@drawable/hamburger_item_bg"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:src="@drawable/ic_feedback_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:text="@string/navigation_item_feedback"
|
||||||
|
android:letterSpacing="0.02"
|
||||||
|
android:textColor="@color/main_background_dark"
|
||||||
|
android:textSize="@dimen/hamburger_menu_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/logout_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="52dp"
|
||||||
|
android:background="@drawable/hamburger_item_bg"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:src="@drawable/ic_exit_to_app_black_24dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
|
android:text="@string/navigation_item_logout"
|
||||||
|
android:letterSpacing="0.02"
|
||||||
|
android:textColor="@color/main_background_dark"
|
||||||
|
android:textSize="@dimen/hamburger_menu_item" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</LinearLayout>
|
||||||
12
app/src/main/res/layout/toolbar.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
android:minHeight="?attr/actionBarSize"
|
||||||
|
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
android:background="?attr/colorPrimaryDark">
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout 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"
|
||||||
|
|
|
||||||