mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 05:13:53 +01:00
Merge branch 'master' into chooseLicense
This commit is contained in:
commit
6fe242c33d
29 changed files with 108 additions and 225 deletions
|
|
@ -230,7 +230,7 @@ public class Media implements Parcelable {
|
|||
}
|
||||
|
||||
public Media(Parcel in) {
|
||||
localUri = (Uri)in.readParcelable(Uri.class.getClassLoader());
|
||||
localUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
imageUrl = in.readString();
|
||||
filename = in.readString();
|
||||
description = in.readString();
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ public class Prefs {
|
|||
public static final String DEFAULT_LICENSE = "defaultLicense";
|
||||
|
||||
public static class Licenses {
|
||||
public static final String CC_BY_SA = "CC BY-SA";
|
||||
public static final String CC_BY = "CC BY";
|
||||
public static final String CC_BY_SA_3 = "CC BY-SA";
|
||||
public static final String CC_BY_3 = "CC BY";
|
||||
public static final String CC_BY_SA_4 = "CC BY-SA 4.0";
|
||||
public static final String CC_BY_4 = "CC BY 4.0";
|
||||
public static final String CC0 = "CC0";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,16 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
|||
licensePreference.setEntries(new String[]{
|
||||
getString(R.string.license_name_cc0),
|
||||
getString(R.string.license_name_cc_by),
|
||||
getString(R.string.license_name_cc_by_sa)
|
||||
getString(R.string.license_name_cc_by_four),
|
||||
getString(R.string.license_name_cc_by_sa),
|
||||
getString(R.string.license_name_cc_by_sa_four)
|
||||
});
|
||||
licensePreference.setEntryValues(new String[]{
|
||||
Prefs.Licenses.CC0,
|
||||
Prefs.Licenses.CC_BY,
|
||||
Prefs.Licenses.CC_BY_SA
|
||||
Prefs.Licenses.CC_BY_3,
|
||||
Prefs.Licenses.CC_BY_4,
|
||||
Prefs.Licenses.CC_BY_SA_3,
|
||||
Prefs.Licenses.CC_BY_SA_4
|
||||
});
|
||||
|
||||
licensePreference.setSummary(getString(Utils.licenseNameFor(licensePreference.getValue())));
|
||||
|
|
|
|||
|
|
@ -205,10 +205,14 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static String licenseTemplateFor(String license) {
|
||||
if(license.equals(Prefs.Licenses.CC_BY)) {
|
||||
if(license.equals(Prefs.Licenses.CC_BY_3)) {
|
||||
return "{{self|cc-by-3.0}}";
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA)) {
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_4)) {
|
||||
return "{{self|cc-by-4.0}}";
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA_3)) {
|
||||
return "{{self|cc-by-sa-3.0}}";
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA_4)) {
|
||||
return "{{self|cc-by-sa-4.0}}";
|
||||
} else if(license.equals(Prefs.Licenses.CC0)) {
|
||||
return "{{self|cc-zero}}";
|
||||
}
|
||||
|
|
@ -216,10 +220,14 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static int licenseNameFor(String license) {
|
||||
if(license.equals(Prefs.Licenses.CC_BY)) {
|
||||
if(license.equals(Prefs.Licenses.CC_BY_3)) {
|
||||
return R.string.license_name_cc_by;
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA)) {
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_4)) {
|
||||
return R.string.license_name_cc_by_four;
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA_3)) {
|
||||
return R.string.license_name_cc_by_sa;
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA_4)) {
|
||||
return R.string.license_name_cc_by_sa_four;
|
||||
} else if(license.equals(Prefs.Licenses.CC0)) {
|
||||
return R.string.license_name_cc0;
|
||||
}
|
||||
|
|
@ -227,11 +235,16 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static String licenseUrlFor(String license) {
|
||||
if(license.equals(Prefs.Licenses.CC_BY)) {
|
||||
if(license.equals(Prefs.Licenses.CC_BY_3)) {
|
||||
return "https://creativecommons.org/licenses/by/3.0/";
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA)) {
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_4)) {
|
||||
return "https://creativecommons.org/licenses/by/4.0/";
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA_3)) {
|
||||
return "https://creativecommons.org/licenses/by-sa/3.0/";
|
||||
} else if(license.equals(Prefs.Licenses.CC0)) {
|
||||
} else if(license.equals(Prefs.Licenses.CC_BY_SA_4)) {
|
||||
return "https://creativecommons.org/licenses/by-sa/4.0/";
|
||||
}
|
||||
else if(license.equals(Prefs.Licenses.CC0)) {
|
||||
return "https://creativecommons.org/publicdomain/zero/1.0/";
|
||||
}
|
||||
throw new RuntimeException("Unrecognized license value");
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class Contribution extends Media {
|
|||
|
||||
public Contribution(Parcel in) {
|
||||
super(in);
|
||||
contentUri = (Uri)in.readParcelable(Uri.class.getClassLoader());
|
||||
contentUri = in.readParcelable(Uri.class.getClassLoader());
|
||||
source = in.readString();
|
||||
timestamp = (Date) in.readSerializable();
|
||||
state = in.readInt();
|
||||
|
|
@ -369,7 +369,7 @@ public class Contribution extends Media {
|
|||
db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN height INTEGER;");
|
||||
db.execSQL("UPDATE " + TABLE_NAME + " SET height = 0");
|
||||
db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN license STRING;");
|
||||
db.execSQL("UPDATE " + TABLE_NAME + " SET license='" + Prefs.Licenses.CC_BY_SA + "';");
|
||||
db.execSQL("UPDATE " + TABLE_NAME + " SET license='" + Prefs.Licenses.CC_BY_SA_3 + "';");
|
||||
from++;
|
||||
onUpdate(db, from, to);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class ContributionController {
|
|||
|
||||
public void loadState(Bundle savedInstanceState) {
|
||||
if(savedInstanceState != null) {
|
||||
lastGeneratedCaptureURI = (Uri) savedInstanceState.getParcelable("lastGeneratedCaptureURI");
|
||||
lastGeneratedCaptureURI = savedInstanceState.getParcelable("lastGeneratedCaptureURI");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class ContributionsListAdapter extends CursorAdapter {
|
|||
|
||||
if(views.url == null || !views.url.equals(actualUrl)) {
|
||||
if(actualUrl.startsWith("http")) {
|
||||
MediaWikiImageView mwImageView = (MediaWikiImageView)views.imageView;
|
||||
MediaWikiImageView mwImageView = views.imageView;
|
||||
mwImageView.setMedia(contribution, ((CommonsApplication) activity.getApplicationContext()).getImageLoader());
|
||||
// FIXME: For transparent images
|
||||
} else {
|
||||
|
|
@ -65,7 +65,7 @@ class ContributionsListAdapter extends CursorAdapter {
|
|||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
super.onLoadingFailed(imageUri, view, failReason);
|
||||
MediaWikiImageView mwImageView = (MediaWikiImageView)views.imageView;
|
||||
MediaWikiImageView mwImageView = views.imageView;
|
||||
mwImageView.setMedia(contribution, ((CommonsApplication) activity.getApplicationContext()).getImageLoader());
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ public class NearbyListFragment extends ListFragment implements TaskListener {
|
|||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// Get the data item for this position
|
||||
Place place = (Place) getItem(position);
|
||||
Place place = getItem(position);
|
||||
Log.d(TAG, "Place " + place.name);
|
||||
|
||||
// Check if an existing view is being reused, otherwise inflate the view
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public class ShareActivity
|
|||
Intent intent = getIntent();
|
||||
|
||||
if(intent.getAction().equals(Intent.ACTION_SEND)) {
|
||||
mediaUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
mediaUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if(intent.hasExtra(UploadService.EXTRA_SOURCE)) {
|
||||
source = intent.getStringExtra(UploadService.EXTRA_SOURCE);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -94,9 +94,11 @@ public class SingleUploadFragment extends Fragment {
|
|||
licenseItems.add(getString(R.string.license_name_cc0));
|
||||
licenseItems.add(getString(R.string.license_name_cc_by));
|
||||
licenseItems.add(getString(R.string.license_name_cc_by_sa));
|
||||
licenseItems.add(getString(R.string.license_name_cc_by_four));
|
||||
licenseItems.add(getString(R.string.license_name_cc_by_sa_four));
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||
final String license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA);
|
||||
final String license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
||||
|
||||
Log.d("Single Upload fragment", license);
|
||||
|
||||
|
|
@ -112,13 +114,17 @@ public class SingleUploadFragment extends Fragment {
|
|||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
String licenseName = parent.getItemAtPosition(position).toString();
|
||||
|
||||
String license = Prefs.Licenses.CC_BY_SA; // default value
|
||||
String license = Prefs.Licenses.CC_BY_SA_3; // default value
|
||||
if(getString(R.string.license_name_cc0).equals(licenseName)) {
|
||||
license = Prefs.Licenses.CC0;
|
||||
} else if(getString(R.string.license_name_cc_by).equals(licenseName)) {
|
||||
license = Prefs.Licenses.CC_BY;
|
||||
license = Prefs.Licenses.CC_BY_3;
|
||||
} else if(getString(R.string.license_name_cc_by_sa).equals(licenseName)) {
|
||||
license = Prefs.Licenses.CC_BY_SA;
|
||||
license = Prefs.Licenses.CC_BY_SA_3;
|
||||
} else if(getString(R.string.license_name_cc_by_four).equals(licenseName)) {
|
||||
license = Prefs.Licenses.CC_BY_4;
|
||||
} else if(getString(R.string.license_name_cc_by_sa_four).equals(licenseName)) {
|
||||
license = Prefs.Licenses.CC_BY_SA_4;
|
||||
}
|
||||
|
||||
setLicenseSummary(license);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class UploadController {
|
|||
contribution.setDescription("");
|
||||
}
|
||||
|
||||
String license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA);
|
||||
String license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
||||
contribution.setLicense(license);
|
||||
|
||||
//FIXME: Add permission request here. Only executeAsyncTask if permission has been granted
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue