Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for my fork #4

Merged
merged 19 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 14 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,13 @@ Initially started by the Wikimedia Foundation, this app is now maintained by gra

## Documentation

We try to have an extensive documentation at [our wiki here at Github][5]:
We try to have an extensive documentation at [our wiki here at Github][4]:

* [User Documentation][6]
* [Contributor Documentation][7]
* [Volunteers Welcome!][9]
* [User Documentation][5]
* [Contributor Documentation][6]
* [Volunteers Welcome!][7]
* [Developer Documentation][8]

## Libraries Used ##

* [Picasso][11]
* [RSS-Parser][12]
* [ViewPagerIndicator][13]
* [PhotoView][14]
* [Acra][15]
* [Renderers][16]
* [Gson][17]
* [Timber][18]
* [Java-String-Similarity][19]
* [ReadMoreTextView][20]
* [MaterialShowcaseView][21]
* [Butterknife][22]
* [OKHttp][23]
* [Okio][24]
* [RxJava][25]
* [JSoup][26]
* [Fresco][27]
* [Stetho][28]
* [Dagger][29]
* [Java-HTTP-Fluent][30]
* [CircleProgressBar][31]
* [Leak Canary][32]
* [Libraries Used][9]

## Contributors ##

Expand All @@ -60,37 +36,18 @@ Thank you all for your work!

## License ##

This software is open source, licensed under the [Apache License 2.0][4].

This software is open source, licensed under the [Apache License 2.0][10].


[1]: https://play.google.com/store/apps/details?id=fr.free.nrw.commons
[2]: https://commons-app.github.io/
[3]: https://github.com/commons-app/apps-android-commons/issues
[4]: https://www.apache.org/licenses/LICENSE-2.0
[5]: https://github.com/commons-app/apps-android-commons/wiki
[6]: https://github.com/commons-app/apps-android-commons/wiki#user-documentation
[7]: https://github.com/commons-app/apps-android-commons/wiki#contributor-documentation

[4]: https://github.com/commons-app/apps-android-commons/wiki
[5]: https://github.com/commons-app/apps-android-commons/wiki#user-documentation
[6]: https://github.com/commons-app/apps-android-commons/wiki#contributor-documentation
[7]: https://github.com/commons-app/apps-android-commons/wiki/Volunteers-welcome%21
[8]: https://github.com/commons-app/apps-android-commons/wiki#developer-documentation
[9]: https://github.com/commons-app/apps-android-commons/wiki/Volunteers-welcome%21
[10]: https://meta.wikimedia.org/wiki/Grants:Project/Improve_%27Upload_to_Commons%27_Android_App/Renewal
[11]: https://github.com/square/picasso
[13]: https://github.com/avianey/Android-ViewPagerIndicator
[14]: https://github.com/chrisbanes/PhotoView
[15]: https://github.com/ACRA/acra
[16]: https://github.com/pedrovgs/Renderers
[17]: https://github.com/google/gson
[18]: https://github.com/JakeWharton/timber
[19]: https://github.com/tdebatty/java-string-similarity
[20]: https://github.com/bravoborja/ReadMoreTextView
[21]: https://github.com/deano2390/MaterialShowcaseView
[22]: https://github.com/JakeWharton/butterknife
[23]: https://github.com/square/okhttp
[24]: https://github.com/square/okio
[25]: https://github.com/ReactiveX/RxJava
[27]: https://github.com/facebook/fresco
[28]: https://github.com/facebook/stetho
[29]: https://github.com/google/dagger
[30]: https://github.com/yuvipanda/java-http-fluent/blob/master/src/main/java/in/yuvi/http/fluent/Http.java
[31]: https://github.com/dinuscxj/CircleProgressBar
[32]: https://github.com/square/leakcanary
[9]: https://github.com/commons-app/apps-android-commons/wiki/Libraries-used

[10]: https://www.apache.org/licenses/LICENSE-2.0
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies {

implementation 'ch.acra:acra:4.9.2'

implementation 'org.mediawiki:api:1.3'
implementation 'commons-codec:commons-codec:1.10'
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation 'com.google.code.gson:gson:2.8.5'
Expand All @@ -32,6 +31,7 @@ dependencies {
transitive = true
}
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'

//noinspection GradleCompatible
implementation "com.android.support:support-v4:$SUPPORT_LIB_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
Expand All @@ -44,6 +44,7 @@ dependencies {
implementation 'com.squareup.okio:okio:1.14.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
// Because RxAndroid releases are few and far between, it is recommended you also

// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
Expand Down Expand Up @@ -131,7 +132,7 @@ android {
flavorDimensions 'tier'
productFlavors {
prod {

applicationId 'fr.free.nrw.commons'

buildConfigField "String", "WIKIMEDIA_API_POTD", "\"https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&feedformat=rss&language=en\""
Expand Down

This file was deleted.

43 changes: 14 additions & 29 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>


Expand All @@ -41,56 +41,44 @@
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

<activity android:name=".WelcomeActivity" />

<activity
android:name=".upload.ShareActivity"
<activity android:name=".upload.UploadActivity"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<intent-filter android:label="@string/intent_share_upload_label">
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
<data android:mimeType="audio/ogg" />
</intent-filter>
</activity>

<activity
android:name=".upload.MultipleShareActivity"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<intent-filter android:label="@string/intent_share_upload_label">
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
<data android:mimeType="audio/ogg" />
</intent-filter>
</activity>

<activity
android:name=".contributions.ContributionsActivity"
android:name=".contributions.MainActivity"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" />

<activity
android:name=".settings.SettingsActivity"
android:label="@string/title_activity_settings" />

<activity
android:name=".AboutActivity"
android:label="@string/title_activity_about"
android:parentActivityName=".contributions.ContributionsActivity" />
android:parentActivityName=".contributions.MainActivity" />

<activity
android:name=".auth.SignupActivity"
android:label="@string/title_activity_signup" />

<activity
android:name=".nearby.NearbyActivity"
android:label="@string/title_activity_nearby"
android:parentActivityName=".contributions.ContributionsActivity" />

<activity
android:name=".notification.NotificationActivity"
android:label="@string/navigation_item_notification" />
Expand All @@ -104,18 +92,18 @@
<activity
android:name=".category.CategoryImagesActivity"
android:label="@string/title_activity_featured_images"
android:parentActivityName=".contributions.ContributionsActivity" />
android:parentActivityName=".contributions.MainActivity" />

<activity
android:name=".category.CategoryDetailsActivity"
android:label="@string/title_activity_featured_images"
android:parentActivityName=".contributions.ContributionsActivity" />
android:parentActivityName=".contributions.MainActivity" />

<activity
android:name=".explore.SearchActivity"
android:label="@string/title_activity_search"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".contributions.ContributionsActivity"
android:parentActivityName=".contributions.MainActivity"
/>

<activity
Expand All @@ -140,24 +128,24 @@
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>

<service
android:name=".contributions.ContributionsSyncService"
android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>

<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/contributions_sync_adapter" />
</service>

<service
android:name=".modifications.ModificationsSyncService"
android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>

<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/modifications_sync_adapter" />
Expand All @@ -177,21 +165,18 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>

<provider
android:name=".contributions.ContributionsContentProvider"
android:authorities="${applicationId}.contributions.contentprovider"
android:exported="false"
android:label="@string/provider_contributions"
android:syncable="true" />

<provider
android:name=".modifications.ModificationsContentProvider"
android:authorities="${applicationId}.modifications.contentprovider"
android:exported="false"
android:label="@string/provider_modifications"
android:syncable="true" />

<provider
android:name=".category.CategoryContentProvider"
android:authorities="${applicationId}.categories.contentprovider"
Expand Down
53 changes: 50 additions & 3 deletions app/src/main/java/fr/free/nrw/commons/Utils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.free.nrw.commons;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
Expand All @@ -14,12 +15,11 @@
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -110,6 +110,31 @@ public static int licenseNameFor(String license) {
throw new RuntimeException("Unrecognized license value: " + license);
}

/**
* Generates license url with given ID
* @param license License ID
* @return Url of license
*/


@NonNull
public static String licenseUrlFor(String license) {
switch (license) {
case Prefs.Licenses.CC_BY_3:
return "https://creativecommons.org/licenses/by/3.0/";
case Prefs.Licenses.CC_BY_4:
return "https://creativecommons.org/licenses/by/4.0/";
case Prefs.Licenses.CC_BY_SA_3:
return "https://creativecommons.org/licenses/by-sa/3.0/";
case Prefs.Licenses.CC_BY_SA_4:
return "https://creativecommons.org/licenses/by-sa/4.0/";
case Prefs.Licenses.CC0:
return "https://creativecommons.org/publicdomain/zero/1.0/";
default:
throw new RuntimeException("Unrecognized license value: " + license);
}
}

/**
* Adds extension to filename. Converts to .jpg if system provides .jpeg, adds .jpg if no extension detected
* @param title File name
Expand Down Expand Up @@ -176,6 +201,18 @@ public static void handleWebUrl(Context context, Uri url) {
customTabsIntent.launchUrl(context, url);
}

public static void handleGeoCoordinates(Context context, String coords) {
try {
Uri gmmIntentUri = Uri.parse("google.streetview:cbll=" + coords);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
context.startActivity(mapIntent);
} catch (ActivityNotFoundException ex) {
Toast toast = Toast.makeText(context, context.getString(R.string.map_application_missing), LENGTH_SHORT);
toast.show();
}
}

/**
* To take screenshot of the screen and return it in Bitmap format
*
Expand All @@ -190,4 +227,14 @@ public static Bitmap getScreenShot(View view) {
return bitmap;
}

public static <K,V> Map<K,V> arraysToMap(K[] kArray, V[] vArray){
if(kArray.length!=vArray.length)
throw new RuntimeException("arraysToMap array sizes don't match");
Map<K,V> map=new LinkedHashMap<>();
for (int i=0;i<vArray.length;i++){
map.put(kArray[i], vArray[i]);
}
return map;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

public abstract class AuthenticatedActivity extends NavigationBaseActivity {

@Inject SessionManager sessionManager;
@Inject
protected SessionManager sessionManager;
@Inject
MediaWikiApi mediaWikiApi;
private String authCookie;
Expand Down
Loading