Merge pull request #112 from domdomegg/master

Migrating to gradle
This commit is contained in:
Josephine Lim 2016-06-06 19:43:52 +12:00
commit 307dc7234b
291 changed files with 7140 additions and 1035 deletions

28
.gitignore vendored
View file

@ -1,7 +1,25 @@
.idea
commons/gen-external-apklibs/*
commons/target/*
out/*
# IDEA files
*.iml
*.iws
*.ipr
*.iws
.idea
# Gradle
.gradle
local.properties
/commons/.gradle
/commons/build
/commons/app/build
# IDE / Text editor files
.nb-gradle
.nb-gradle-properties
*.sw[op]
*~
*.sublime-*
.textmate
.java-version
# OS files
*.DS_Store
Thumbs.db

View file

@ -4,71 +4,46 @@ Upload pictures from your Android phone/tablet to Wikimedia Commons.
Initially started by the Wikimedia Foundation, this app is now maintained by volunteers. Anyone is welcome to improve it, just choose among the [open issues](https://github.com/nicolas-raoul/apps-android-commons/issues) and send us a pull request :-)
## Build Requirements ##
1. [Android SDK][1] (Level 23)
2. [Maven][2]
## Build Instructions ##
1. Set the environment variable `ANDROID_HOME` to be the path to your Android SDK
2. Run `mvn install` to build
3. Run `cd commons && mvn android:deploy` to deploy to a device
**Note**: Currently uses a bunch of dependencies that are staged at `yuvi.in/blog/maven`. Will be migrated to either [Maven Central][4] or a Wikimedia staging server soon.
## Set Up IntelliJ or Android Studio for Commons Android App Development ##
## Use Android Studio or IntelliJ ##
### Import and Compile Commons Android App ##
[Download IntelliJ][6] or [Download Android Studio 1.5.2][7]. (Note: The steps below currently only work on Android Studio 1.5.2 and below)
[Download Android Studio][1] (recommended) or [IntelliJ][2].
1. Clone the repository.
2. Open IntelliJ/Android Studio. Tick the box for the Maven Integration plugin by selecting:
``File`` > ``Settings`` > ``Plugins`` > ``Maven Integration``
2. Open Android Studio/IntelliJ. Open the project:
``File`` > ``Open...``
or
(From Quick Start menu): ``Configure`` > ``Plugins`` > ``Maven Integration``
3. Import Project:
``File`` > ``Import Project``
or
(From Quick Start menu): ``Import Project (Eclipse ADT, Gradle, etc.)``
4. Navigate to the folder with the cloned repository (named apps-android-commons). Select ``OK``.
5. Select ``Import Project from external model`` > ``Maven``. Select ``Next``.
6. Tick the boxes ``Search for projects recursively`` and ``Import Maven projects automatically``. Select ``Next``.
7. Select ``Next``.
8. Select ``Next``.
9. Click ``Maven Android API 23 Platform`` or ``Android API 23 Platform`` in the sidebar. Make sure the ``Android SDK home path`` points to the ``/Android/Sdk`` folder. Make sure the ``Java SDK`` is set to 1.8 or higher.
If there are no options for the ``Java SDK``, click the ``+`` button above the sidebar and select 'JDK'. Navigate to your JDK folder, select it, and hit ``OK``, and then select the newly added JDK.
Select ``Next``.
10. Select ``Next``.
11. Select ``Finish``.
12. Set the Module SDKs.
Select the ``Dependencies`` tab on the right pane.
Set the modules as follows:
(From Quick Start menu): ``Open an existing Android Studio project``
3. Navigate to the folder in the cloned repository (named commons). Select ``OK``.
4. Disable Instant Run. To do this untick the box at:
``File`` > ``Settings`` > ``Build, Execution, Deployment`` > ``Instant Run`` > ``Enable Instant Run to hot swap code/resource changes on deploy``
| Name | Module SDK |
|-------------------------------------------------------|---------------------------------------|
| commons | Project SDK (Android API 23 Platform) |
| commons-parent | Project SDK (Android API 23 Platform) |
| ~apklib-com.actionbarsherlock_actionbarsherlock_4.4.0 | Maven Android API 14 Platform |
| ~apklib-com.viewpagerindicator_library_2.4.1 | Maven Android API 16 Platform |
## Build Manually ##
If certain modules are not available, install the correct API levels through the SDK manager. To do this do the following:
* Click ``Cancel``. Navigate to ``File`` > ``Settings`` > ``Appearance & Behaviour`` > ``System Settings`` > ``Android SDK``.
* Tick the boxes for API levels ``14``, ``16``, and ``23`` (or Android ``4.0``, ``4.1.2`` and ``6.0``).
* Then click ``OK``, and allow it to download the new APIs. Once it has finished, click ``File`` > ``Project Structure`` > ``Project Settings`` > ``Modules``, and repeat step 15.
13. Select ``commons``. Click the green ``+`` button on the right. Select ``JARs or directories...``. Choose the ``apps-android-commons/lib`` folder. Select ``OK``.
14. Select ``OK`` to save your changes to the project structre settings.
15. To test it worked, check if it builds (Select ``commons`` on the projects panel. Select ``Build`` > ``Make Module 'commons'``). If there are no errors (warnings are OK) you're set!
Note: It is much harder to build manually. We reccomend you use Android Studio or IntelliJ IDEA, which both have gradle and all the android tools built in.
### Requirements ###
1. [Android SDK][3] (Level 23)
2. [Gradle][4]
### Build Instructions ###
1. Set the environment variable `ANDROID_HOME` to be the path to your Android SDK
2. Set the environment variable `JAVA_HOME` to the path to your Java SDK
3. Run `gradlew.bat assembleRelease` (Windows) or `./gradlew assembleRelease` (Mac / Linux) to build an unisgned apk
4. From your Android SDK's /tools directory run `adb install path/to/app.apk` (Emulator) or `adb -d install path/to/app.apk` (USB debugging)
There are more thorough instructions on the [Android Developers website][5]
## License ##
This software is licensed under the [Apache License][5].
This software is licensed under the [Apache License 2.0][6].
## Bugs ##
Please report any bug [on Github][3].
Please report any bug [on Github][7].
## Code Structure ##
@ -111,10 +86,10 @@ Captured files are not currently stored within the app, but are passed by conten
Thumbnail images are not currently cached. (?)
[1]: https://developer.android.com/sdk/index.html
[2]: https://maven.apache.org/
[3]: https://github.com/nicolas-raoul/apps-android-commons/issues
[4]: http://search.maven.org/
[5]: https://www.apache.org/licenses/LICENSE-2.0
[6]: http://www.jetbrains.com/idea/download/index.html
[7]: https://sites.google.com/a/android.com/tools/download/studio/builds/1-5-2
[1]: https://developer.android.com/studio/index.html
[2]: http://www.jetbrains.com/idea/download/index.html
[3]: https://developer.android.com/sdk/index.html
[4]: http://gradle.org/gradle-download/
[5]: https://developer.android.com/studio/build/building-cmdline.html
[6]: https://www.apache.org/licenses/LICENSE-2.0
[7]: https://github.com/nicolas-raoul/apps-android-commons/issues

41
commons/app/build.gradle Normal file
View file

@ -0,0 +1,41 @@
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.google.code.gson:gson:1.4'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
compile 'in.yuvi:http.fluent:1.3'
compile 'com.android.volley:volley:1.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.8.4'
compile 'ch.acra:acra:4.5.0'
compile 'org.mediawiki:api:1.3'
compile 'de.keyboardsurfer.android.widget:crouton:1.8.5@aar'
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
compile 'com.android.support:support-v4:22.1.0'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "fr.free.nrw.commons"
minSdkVersion 11
targetSdkVersion 23
ndk {
moduleName "libtranscode"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

View file

@ -3,6 +3,7 @@ package fr.free.nrw.commons;
import android.app.Activity;
import android.content.res.Resources;
import android.util.Log;
import org.xmlpull.v1.XmlPullParser;
import java.util.Collection;
@ -11,7 +12,7 @@ import java.util.Map;
import java.util.Set;
public class LicenseList {
Map<String, License> licenses = new HashMap<String, License>();
Map<String, fr.free.nrw.commons.License> licenses = new HashMap<String, fr.free.nrw.commons.License>();
Resources res;
private static String XMLNS_LICENSE = "https://www.mediawiki.org/wiki/Extension:UploadWizard/xmlns/licenses";
@ -19,12 +20,12 @@ public class LicenseList {
public LicenseList(Activity activity) {
res = activity.getResources();
XmlPullParser parser = res.getXml(R.xml.wikimedia_licenses);
while (Utils.xmlFastForward(parser, XMLNS_LICENSE, "license")) {
while (fr.free.nrw.commons.Utils.xmlFastForward(parser, XMLNS_LICENSE, "license")) {
String id = parser.getAttributeValue(null, "id");
String template = parser.getAttributeValue(null, "template");
String url = parser.getAttributeValue(null, "url");
String name = nameForTemplate(template);
License license = new License(id, template, url, name);
fr.free.nrw.commons.License license = new fr.free.nrw.commons.License(id, template, url, name);
licenses.put(id, license);
}
@ -34,18 +35,18 @@ public class LicenseList {
return licenses.keySet();
}
public Collection<License> values() {
public Collection<fr.free.nrw.commons.License> values() {
return licenses.values();
}
public License get(String key) {
public fr.free.nrw.commons.License get(String key) {
return licenses.get(key);
}
public License licenseForTemplate(String template) {
String ucTemplate = Utils.capitalize(template);
for (License license : values()) {
if (ucTemplate.equals(Utils.capitalize(license.getTemplate()))) {
public fr.free.nrw.commons.License licenseForTemplate(String template) {
String ucTemplate = fr.free.nrw.commons.Utils.capitalize(template);
for (fr.free.nrw.commons.License license : values()) {
if (ucTemplate.equals(fr.free.nrw.commons.Utils.capitalize(license.getTemplate()))) {
return license;
}
}
@ -75,4 +76,4 @@ public class LicenseList {
}
return template;
}
}
}

View file

@ -4,30 +4,25 @@ import android.app.Activity;
import android.content.ContentProviderClient;
import android.content.Context;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.*;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.view.*;
import android.widget.*;
import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import fr.free.nrw.commons.Utils;
import org.mediawiki.api.ApiResult;
import org.mediawiki.api.MWApi;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.upload.MwVolleyApi;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@ -38,10 +33,6 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.upload.MwVolleyApi;
/**
* Displays the category suggestion and selection screen. Category search is initiated here.
*/
@ -54,7 +45,7 @@ public class CategorizationFragment extends SherlockFragment{
protected EditText categoriesFilter;
ProgressBar categoriesSearchInProgress;
TextView categoriesNotFoundView;
TextView categoriesExplain;
TextView categoriesSkip;
CategoriesAdapter categoriesAdapter;
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
@ -176,8 +167,8 @@ public class CategorizationFragment extends SherlockFragment{
if (categories.isEmpty()) {
if (TextUtils.isEmpty(filter)) {
// If we found no recent cats, show the explanation message!
categoriesExplain.setVisibility(View.VISIBLE);
// If we found no recent cats, show the skip message!
categoriesSkip.setVisibility(View.VISIBLE);
} else {
categoriesNotFoundView.setText(getString(R.string.categories_not_found, filter));
categoriesNotFoundView.setVisibility(View.VISIBLE);
@ -306,7 +297,14 @@ public class CategorizationFragment extends SherlockFragment{
categoriesFilter = (EditText) rootView.findViewById(R.id.categoriesSearchBox);
categoriesSearchInProgress = (ProgressBar) rootView.findViewById(R.id.categoriesSearchInProgress);
categoriesNotFoundView = (TextView) rootView.findViewById(R.id.categoriesNotFound);
categoriesExplain = (TextView) rootView.findViewById(R.id.categoriesExplanation);
categoriesSkip = (TextView) rootView.findViewById(R.id.categoriesExplanation);
categoriesSkip.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
getActivity().onBackPressed();
getActivity().finish();
}
});
ArrayList<CategoryItem> items;
if(savedInstanceState == null) {

View file

@ -35,7 +35,7 @@ public class MethodAUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
catFragment.categoriesSearchInProgress.setVisibility(View.VISIBLE);
catFragment.categoriesNotFoundView.setVisibility(View.GONE);
catFragment.categoriesExplain.setVisibility(View.GONE);
catFragment.categoriesSkip.setVisibility(View.GONE);
}
@Override

View file

@ -36,7 +36,7 @@ public class PrefixUpdater extends AsyncTask<Void, Void, ArrayList<String>> {
catFragment.categoriesSearchInProgress.setVisibility(View.VISIBLE);
catFragment.categoriesNotFoundView.setVisibility(View.GONE);
catFragment.categoriesExplain.setVisibility(View.GONE);
catFragment.categoriesSkip.setVisibility(View.GONE);
}
@Override

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 640 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 489 B

After

Width:  |  Height:  |  Size: 489 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 905 B

After

Width:  |  Height:  |  Size: 905 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before After
Before After

Some files were not shown because too many files have changed in this diff Show more