Merge branch 'master' into chooseLicense

This commit is contained in:
Vivek Maskara 2017-03-05 22:55:34 +05:30 committed by GitHub
commit 6fe242c33d
29 changed files with 108 additions and 225 deletions

View file

@ -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();

View file

@ -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";
}
}

View file

@ -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())));

View file

@ -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");

View file

@ -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;

View file

@ -98,7 +98,7 @@ public class ContributionController {
public void loadState(Bundle savedInstanceState) {
if(savedInstanceState != null) {
lastGeneratedCaptureURI = (Uri) savedInstanceState.getParcelable("lastGeneratedCaptureURI");
lastGeneratedCaptureURI = savedInstanceState.getParcelable("lastGeneratedCaptureURI");
}
}

View file

@ -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());
}
});

View file

@ -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

View file

@ -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 {

View file

@ -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);

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="90" android:startColor="#60ffffff" android:endColor="#40ffffff"/>
</shape>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#70000000"
android:endColor="#00000000"
android:angle="270"
>
</gradient>
</shape>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#00000000"
android:endColor="#ff000000"
android:angle="270"
>
</gradient>
</shape>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ffffffff"
android:endColor="#f4f4f4ff"
android:type="linear"
/>
</shape>

View file

@ -8,95 +8,76 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="16dp"
android:gravity="center"
android:orientation="vertical"
>
<ImageView
android:id="@+id/commonsLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:src="@drawable/commons_logo_large"
/>
<TextView
android:id="@+id/loginSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="48dp"
android:drawablePadding="8dp"
android:drawableTop="@drawable/commons_logo_large"
android:gravity="center_horizontal"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<LinearLayout
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dip"
android:gravity="center"
android:orientation="vertical"
android:layout_height="wrap_content"
>
<FrameLayout
android:id="@+id/loginErrors"
android:layout_width="match_parent"
android:layout_height="48dp"
/>
<android.support.design.widget.TextInputLayout
<android.support.design.widget.TextInputEditText
android:id="@+id/loginUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
>
<android.support.design.widget.TextInputEditText
android:id="@+id/loginUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:imeOptions="flagNoExtractUi"
android:inputType="textNoSuggestions"
>
<requestFocus/>
<requestFocus/>
</android.support.design.widget.TextInputEditText>
</android.support.design.widget.TextInputEditText>
</android.support.design.widget.TextInputLayout>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false"
>
<android.support.design.widget.TextInputLayout
<android.support.design.widget.TextInputEditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="false"
>
<android.support.design.widget.TextInputEditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/login"
android:hint="@string/password"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
/>
<Button
android:id="@+id/signupButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/signup"
android:layout_gravity="center_horizontal"
android:onClick="signUp"
/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="@string/login"
/>
<Button
android:id="@+id/signupButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="signUp"
android:text="@string/signup"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -1,8 +0,0 @@
<?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"
>
</LinearLayout>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

View file

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/commonsLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="@drawable/commons_logo_large"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/commonsLogo"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:padding="20dp"
>
<EditText
android:id="@+id/loginUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
>
<requestFocus />
</EditText>
<EditText
android:id="@+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:inputType="textPassword"
/>
<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="@string/login"
/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>

View file

@ -7,27 +7,33 @@
android:gravity="center_vertical"
>
<!-- Sorry about the hardcoded sizes here. They're image-related. -->
<LinearLayout
<RelativeLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="180dp"
android:gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
>
<ImageView
android:src="@drawable/welcome_wikipedia"
android:id="@+id/welcome_wikipedia"
android:layout_width="150dp"
android:layout_height="180dp"
android:src="@drawable/welcome_wikipedia"
android:layout_marginLeft="30dp"
/>
<ImageView
android:src="@drawable/welcome_copyright"
android:layout_width="160dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@drawable/welcome_copyright"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/welcome_wikipedia"
/>
</LinearLayout>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"

View file

@ -1,6 +0,0 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

View file

@ -2,7 +2,5 @@
<resources>
<color name="text_background">#90000000</color>
<color name="transparent_actionbar_background">#22000000</color>
<color name="lighter_gray">#ddd</color>
</resources>

View file

@ -1,7 +1,4 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="icon_size">120dp</dimen>
<dimen name="tiny_margin">4dp</dimen>
<dimen name="small_margin">8dp</dimen>

View file

@ -90,6 +90,8 @@ Tap this message (or hit back) to skip this step.</string>
<string name="use_previous">Use previous title/description</string>
<string name="allow_gps">Automatically get current location</string>
<string name="allow_gps_summary">Retrieve current location to offer category suggestions if image is not geotagged</string>
<string name="license_name_cc_by_sa_four"> Attribution-ShareAlike 4.0</string>
<string name="license_name_cc_by_four"> Attribution 4.0</string>
<string name="license_name_cc_by_sa"> Attribution-ShareAlike 3.0</string>
<string name="license_name_cc_by"> Attribution 3.0</string>
<string name="license_name_cc0">CC0</string>

View file

@ -6,19 +6,6 @@
<item name="android:windowNoTitle">true</item>
</style>
<style name="LightNoTitle" parent="Theme.AppCompat.Light.NoActionBar"/>
<style name="NotificationText" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="NotificationTitle">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textStyle">bold</item>
</style>
<style name="NotificationProgress" parent="AppTheme" />
<style name="ProgressBar" parent="Widget.AppCompat.ProgressBar.Horizontal" />
</resources>