Skip to content

Commit 6ae5282

Browse files
committed
Initial commit
0 parents  commit 6ae5282

32 files changed

+516
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# built application files
2+
*.apk
3+
*.ap_
4+
5+
# files for the dex VM
6+
*.dex
7+
8+
# Java class files
9+
*.class
10+
11+
# generated files
12+
bin/
13+
gen/
14+
15+
# Local configuration file (sdk path, etc)
16+
local.properties

.project

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>commons</name>
4+
<comment></comment>
5+
<projects>
6+
<project>ActionBarSherlock</project>
7+
<project>java-mwapi</project>
8+
</projects>
9+
<buildSpec>
10+
<buildCommand>
11+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
12+
<arguments>
13+
</arguments>
14+
</buildCommand>
15+
<buildCommand>
16+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
17+
<arguments>
18+
</arguments>
19+
</buildCommand>
20+
<buildCommand>
21+
<name>org.eclipse.jdt.core.javabuilder</name>
22+
<arguments>
23+
</arguments>
24+
</buildCommand>
25+
<buildCommand>
26+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
27+
<arguments>
28+
</arguments>
29+
</buildCommand>
30+
</buildSpec>
31+
<natures>
32+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
33+
<nature>org.eclipse.jdt.core.javanature</nature>
34+
</natures>
35+
</projectDescription>

AndroidManifest.xml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="org.wikimedia.commons"
3+
android:versionCode="1"
4+
android:versionName="1.0" >
5+
6+
<uses-sdk
7+
android:minSdkVersion="8"
8+
android:targetSdkVersion="15" />
9+
10+
<uses-permission android:name="android.permission.INTERNET" />
11+
12+
<application
13+
android:name=".CommonsApplication"
14+
android:icon="@drawable/ic_launcher"
15+
android:label="@string/app_name"
16+
android:theme="@style/AppTheme" >
17+
<activity
18+
android:name=".LoginActivity"
19+
android:label="@string/title_activity_login"
20+
android:theme="@style/NoTitle" >
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
<activity
28+
android:name=".ShareActivity"
29+
android:label="@string/title_activity_share" >
30+
<intent-filter>
31+
<action android:name="android.intent.action.SEND" />
32+
<category android:name="android.intent.category.DEFAULT" />
33+
<data android:mimeType="image/*" />
34+
</intent-filter>
35+
</activity>
36+
</application>
37+
38+
</manifest>

ic_launcher-web.png

36.2 KB
Loading

libs/android-support-v4.jar

330 KB
Binary file not shown.

libs/commons-logging-1.1.1.jar

59.3 KB
Binary file not shown.

libs/httpclient-4.2.1.jar

417 KB
Binary file not shown.

libs/httpcore-4.2.1.jar

218 KB
Binary file not shown.

libs/httpmime-4.2.1.jar

26 KB
Binary file not shown.

libs/java-mwapi.jar

725 KB
Binary file not shown.

project.properties

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
14+
target=android-15
15.8 KB
Loading
3.05 KB
Loading

res/drawable-hdpi/ic_launcher.png

2.94 KB
Loading

res/drawable-ldpi/ic_launcher.png

1.47 KB
Loading
2.96 KB
Loading

res/drawable-mdpi/ic_launcher.png

1.92 KB
Loading
3.12 KB
Loading

res/drawable-xhdpi/ic_launcher.png

3.91 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:shape="rectangle">
5+
<gradient
6+
android:startColor="#ffffffff"
7+
android:endColor="#f4f4f4ff"
8+
android:type="linear"
9+
/>
10+
</shape>

res/layout/activity_login.xml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:gravity="center"
6+
android:orientation="vertical" >
7+
8+
<ImageView
9+
android:id="@+id/commonsLogo"
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:layout_marginTop="16dp"
13+
android:src="@drawable/commons_logo_large" />
14+
15+
<TextView
16+
android:id="@+id/loginSubtitle"
17+
android:layout_width="wrap_content"
18+
android:layout_height="wrap_content"
19+
android:layout_marginTop="10dp"
20+
android:text="@string/login_subtitle"
21+
android:textAllCaps="true"
22+
android:textAppearance="?android:attr/textAppearanceSmall" />
23+
24+
<LinearLayout
25+
android:layout_width="fill_parent"
26+
android:layout_height="fill_parent"
27+
android:layout_margin="16dip"
28+
android:gravity="center"
29+
android:orientation="vertical" >
30+
31+
<EditText
32+
android:id="@+id/loginUsername"
33+
android:layout_width="fill_parent"
34+
android:layout_height="wrap_content"
35+
android:hint="@string/username" >
36+
37+
<requestFocus />
38+
</EditText>
39+
40+
<EditText
41+
android:id="@+id/loginPassword"
42+
android:layout_width="fill_parent"
43+
android:layout_height="wrap_content"
44+
android:hint="@string/password"
45+
android:inputType="textPassword" />
46+
47+
<Button
48+
android:id="@+id/loginButton"
49+
android:layout_width="fill_parent"
50+
android:layout_height="wrap_content"
51+
android:text="@string/login" />
52+
53+
</LinearLayout>
54+
55+
</LinearLayout>

res/layout/activity_share.xml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="wrap_content"
4+
android:layout_height="wrap_content" >
5+
6+
<ImageView
7+
android:id="@+id/backgroundImage"
8+
android:layout_width="fill_parent"
9+
android:layout_height="fill_parent"
10+
android:layout_alignParentLeft="true"
11+
android:layout_alignParentTop="true"
12+
android:scaleType="centerCrop" />
13+
14+
<LinearLayout
15+
android:layout_width="match_parent"
16+
android:layout_height="wrap_content"
17+
android:layout_gravity="fill_horizontal"
18+
android:orientation="vertical"
19+
android:layout_marginBottom="64dip"
20+
android:layout_marginLeft="16dip"
21+
android:layout_marginRight="16dip"
22+
android:layout_marginTop="64dip"
23+
android:paddingLeft="16dip"
24+
android:paddingRight="16dip"
25+
android:paddingTop="24dip"
26+
android:paddingBottom="24dip"
27+
android:background="@drawable/share_overlay_background_gradient" >
28+
29+
<TextView
30+
android:id="@+id/overlayTitle"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="@string/upload_overlay_title"
34+
android:textAppearance="?android:attr/textAppearanceLarge" />
35+
36+
<TextView
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:text="Title"
40+
android:textAppearance="?android:attr/textAppearanceMedium"
41+
android:layout_below="@id/overlayTitle"/>
42+
43+
<EditText
44+
android:id="@+id/overlayTitleEdit"
45+
android:layout_width="fill_parent"
46+
android:layout_height="wrap_content"
47+
android:singleLine="true"
48+
/>
49+
50+
<TextView
51+
android:layout_width="wrap_content"
52+
android:layout_height="wrap_content"
53+
android:text="Description"
54+
android:textAppearance="?android:attr/textAppearanceMedium"
55+
android:layout_below="@id/overlayTitle"/>
56+
57+
<EditText
58+
android:id="@+id/overlayDescEdit"
59+
android:layout_width="fill_parent"
60+
android:layout_height="wrap_content"
61+
android:inputType="textMultiLine"
62+
/>
63+
64+
<Button
65+
android:id="@+id/overlayUploadButton"
66+
android:layout_width="fill_parent"
67+
android:layout_height="wrap_content"
68+
android:text="Upload"
69+
/>
70+
71+
</LinearLayout>
72+
73+
</RelativeLayout>

res/menu/activity_login.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
2+
<item android:id="@+id/menu_settings"
3+
android:title="@string/menu_settings"
4+
android:orderInCategory="100"
5+
android:showAsAction="never" />
6+
</menu>

res/menu/activity_share.xml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
2+
<item android:id="@+id/menu_settings"
3+
android:title="@string/menu_settings"
4+
android:orderInCategory="100"
5+
android:showAsAction="never" />
6+
</menu>

res/values-v11/styles.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="android:Theme.Holo.Light" />
4+
5+
</resources>

res/values-v14/styles.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
4+
5+
</resources>

res/values/strings.xml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<resources>
2+
3+
<string name="app_name">Wikimedia Commons</string>
4+
<string name="hello_world">Hello world!</string>
5+
<string name="menu_settings">Settings</string>
6+
<string name="title_activity_login">LoginActivity</string>
7+
<string name="login_subtitle">Login to upload media to commons</string>
8+
<string name="username">Username</string>
9+
<string name="password">Password</string>
10+
<string name="login">Log In</string>
11+
<string name="logging_in_title">Logging In</string>
12+
<string name="logging_in_message">Witty text here</string>
13+
<string name="title_activity_share">ShareActivity</string>
14+
<string name="upload_overlay_title">Upload to Commons</string>
15+
16+
</resources>

res/values/styles.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="android:Theme.Light" />
4+
5+
<style name="NoTitle" parent="AppTheme">
6+
<item name="android:windowNoTitle">true</item>
7+
</style>
8+
9+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.wikimedia.commons;
2+
3+
import android.app.Application;
4+
import org.mediawiki.api.*;
5+
import org.apache.http.impl.client.DefaultHttpClient;
6+
7+
public class CommonsApplication extends Application {
8+
9+
private MWApi api;
10+
11+
@Override
12+
public void onCreate() {
13+
// TODO Auto-generated method stub
14+
super.onCreate();
15+
DefaultHttpClient client = new DefaultHttpClient();
16+
api = new MWApi("http://test.wikipedia.org/w/api.php", client);
17+
}
18+
19+
public MWApi getApi() {
20+
return api;
21+
}
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.wikimedia.commons;
2+
3+
import java.net.*;
4+
import java.io.*;
5+
6+
import android.graphics.*;
7+
import android.net.Uri;
8+
import android.os.*;
9+
import android.provider.MediaStore;
10+
import android.widget.*;
11+
12+
class ImageLoaderTask extends AsyncTask<Uri, String, Bitmap> {
13+
ImageView view;
14+
15+
private Bitmap getBitmap(Uri url) throws MalformedURLException, IOException {
16+
if(url.getScheme().equals("content")) {
17+
return MediaStore.Images.Media.getBitmap(view.getContext().getContentResolver(), url);
18+
} else {
19+
Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(url.toString()).getContent());
20+
return bitmap;
21+
}
22+
}
23+
24+
ImageLoaderTask(ImageView view) {
25+
this.view = view;
26+
}
27+
28+
@Override
29+
protected Bitmap doInBackground(Uri... params) {
30+
Uri url = params[0];
31+
Bitmap bitmap;
32+
try {
33+
bitmap = getBitmap(url);
34+
} catch (MalformedURLException e) {
35+
throw new RuntimeException(e);
36+
} catch (IOException e) {
37+
throw new RuntimeException(e);
38+
}
39+
return bitmap;
40+
}
41+
42+
@Override
43+
protected void onPostExecute(Bitmap result) {
44+
super.onPostExecute(result);
45+
view.setImageBitmap(result);
46+
}
47+
}

0 commit comments

Comments
 (0)