Initial commit
16
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# built application files
|
||||||
|
*.apk
|
||||||
|
*.ap_
|
||||||
|
|
||||||
|
# files for the dex VM
|
||||||
|
*.dex
|
||||||
|
|
||||||
|
# Java class files
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# generated files
|
||||||
|
bin/
|
||||||
|
gen/
|
||||||
|
|
||||||
|
# Local configuration file (sdk path, etc)
|
||||||
|
local.properties
|
||||||
35
.project
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>commons</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
<project>ActionBarSherlock</project>
|
||||||
|
<project>java-mwapi</project>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
38
AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.wikimedia.commons"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0" >
|
||||||
|
|
||||||
|
<uses-sdk
|
||||||
|
android:minSdkVersion="8"
|
||||||
|
android:targetSdkVersion="15" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".CommonsApplication"
|
||||||
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme" >
|
||||||
|
<activity
|
||||||
|
android:name=".LoginActivity"
|
||||||
|
android:label="@string/title_activity_login"
|
||||||
|
android:theme="@style/NoTitle" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ShareActivity"
|
||||||
|
android:label="@string/title_activity_share" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="image/*" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
BIN
ic_launcher-web.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
libs/android-support-v4.jar
Normal file
BIN
libs/commons-logging-1.1.1.jar
Normal file
BIN
libs/httpclient-4.2.1.jar
Normal file
BIN
libs/httpcore-4.2.1.jar
Normal file
BIN
libs/httpmime-4.2.1.jar
Normal file
BIN
libs/java-mwapi.jar
Normal file
14
project.properties
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems.
|
||||||
|
#
|
||||||
|
# To customize properties used by the Ant build system edit
|
||||||
|
# "ant.properties", and override values to adapt the script to your
|
||||||
|
# project structure.
|
||||||
|
#
|
||||||
|
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||||
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
|
# Project target.
|
||||||
|
target=android-15
|
||||||
BIN
res/drawable-hdpi/commons_logo_large.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
res/drawable-hdpi/ic_action_search.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
res/drawable-hdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
res/drawable-ldpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
res/drawable-mdpi/ic_action_search.png
Normal file
|
After Width: | Height: | Size: 3 KiB |
BIN
res/drawable-mdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
res/drawable-xhdpi/ic_action_search.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
res/drawable-xhdpi/ic_launcher.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
10
res/drawable/share_overlay_background_gradient.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?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>
|
||||||
55
res/layout/activity_login.xml
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
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="10dp"
|
||||||
|
android:text="@string/login_subtitle"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_margin="16dip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/loginUsername"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/username" >
|
||||||
|
|
||||||
|
<requestFocus />
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/loginPassword"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/password"
|
||||||
|
android:inputType="textPassword" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/loginButton"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/login" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
73
res/layout/activity_share.xml
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/backgroundImage"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:scaleType="centerCrop" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="fill_horizontal"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginBottom="64dip"
|
||||||
|
android:layout_marginLeft="16dip"
|
||||||
|
android:layout_marginRight="16dip"
|
||||||
|
android:layout_marginTop="64dip"
|
||||||
|
android:paddingLeft="16dip"
|
||||||
|
android:paddingRight="16dip"
|
||||||
|
android:paddingTop="24dip"
|
||||||
|
android:paddingBottom="24dip"
|
||||||
|
android:background="@drawable/share_overlay_background_gradient" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/overlayTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/upload_overlay_title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Title"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_below="@id/overlayTitle"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/overlayTitleEdit"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Description"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_below="@id/overlayTitle"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/overlayDescEdit"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/overlayUploadButton"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Upload"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
6
res/menu/activity_login.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/menu_settings"
|
||||||
|
android:title="@string/menu_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
</menu>
|
||||||
6
res/menu/activity_share.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/menu_settings"
|
||||||
|
android:title="@string/menu_settings"
|
||||||
|
android:orderInCategory="100"
|
||||||
|
android:showAsAction="never" />
|
||||||
|
</menu>
|
||||||
5
res/values-v11/styles.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="AppTheme" parent="android:Theme.Holo.Light" />
|
||||||
|
|
||||||
|
</resources>
|
||||||
5
res/values-v14/styles.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
|
||||||
|
|
||||||
|
</resources>
|
||||||
16
res/values/strings.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<string name="app_name">Wikimedia Commons</string>
|
||||||
|
<string name="hello_world">Hello world!</string>
|
||||||
|
<string name="menu_settings">Settings</string>
|
||||||
|
<string name="title_activity_login">LoginActivity</string>
|
||||||
|
<string name="login_subtitle">Login to upload media to commons</string>
|
||||||
|
<string name="username">Username</string>
|
||||||
|
<string name="password">Password</string>
|
||||||
|
<string name="login">Log In</string>
|
||||||
|
<string name="logging_in_title">Logging In</string>
|
||||||
|
<string name="logging_in_message">Witty text here</string>
|
||||||
|
<string name="title_activity_share">ShareActivity</string>
|
||||||
|
<string name="upload_overlay_title">Upload to Commons</string>
|
||||||
|
|
||||||
|
</resources>
|
||||||
9
res/values/styles.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="AppTheme" parent="android:Theme.Light" />
|
||||||
|
|
||||||
|
<style name="NoTitle" parent="AppTheme">
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
||||||
23
src/org/wikimedia/commons/CommonsApplication.java
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.wikimedia.commons;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import org.mediawiki.api.*;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
|
||||||
|
public class CommonsApplication extends Application {
|
||||||
|
|
||||||
|
private MWApi api;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onCreate();
|
||||||
|
DefaultHttpClient client = new DefaultHttpClient();
|
||||||
|
api = new MWApi("http://test.wikipedia.org/w/api.php", client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MWApi getApi() {
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
47
src/org/wikimedia/commons/ImageLoaderTask.java
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.wikimedia.commons;
|
||||||
|
|
||||||
|
import java.net.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import android.graphics.*;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.*;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.widget.*;
|
||||||
|
|
||||||
|
class ImageLoaderTask extends AsyncTask<Uri, String, Bitmap> {
|
||||||
|
ImageView view;
|
||||||
|
|
||||||
|
private Bitmap getBitmap(Uri url) throws MalformedURLException, IOException {
|
||||||
|
if(url.getScheme().equals("content")) {
|
||||||
|
return MediaStore.Images.Media.getBitmap(view.getContext().getContentResolver(), url);
|
||||||
|
} else {
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(url.toString()).getContent());
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageLoaderTask(ImageView view) {
|
||||||
|
this.view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Bitmap doInBackground(Uri... params) {
|
||||||
|
Uri url = params[0];
|
||||||
|
Bitmap bitmap;
|
||||||
|
try {
|
||||||
|
bitmap = getBitmap(url);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Bitmap result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
view.setImageBitmap(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
104
src/org/wikimedia/commons/LoginActivity.java
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
package org.wikimedia.commons;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.*;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.support.v4.app.NavUtils;
|
||||||
|
|
||||||
|
public class LoginActivity extends Activity {
|
||||||
|
|
||||||
|
private CommonsApplication app;
|
||||||
|
|
||||||
|
Button loginButton;
|
||||||
|
EditText usernameEdit;
|
||||||
|
EditText passwordEdit;
|
||||||
|
|
||||||
|
private class LoginTask extends AsyncTask<String, String, String> {
|
||||||
|
|
||||||
|
Context context;
|
||||||
|
ProgressDialog dialog;
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
if(result.equals("Success")) {
|
||||||
|
dialog.cancel();
|
||||||
|
} else {
|
||||||
|
dialog.setMessage("Ayyooo poche!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
dialog = new ProgressDialog(context);
|
||||||
|
dialog.setIndeterminate(true);
|
||||||
|
dialog.setTitle(getString(R.string.logging_in_title));
|
||||||
|
dialog.setMessage(getString(R.string.logging_in_message));
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
LoginTask(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(String... params) {
|
||||||
|
String username = params[0];
|
||||||
|
String password = params[1];
|
||||||
|
try {
|
||||||
|
return app.getApi().login(username, password);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Do something better!
|
||||||
|
return "Failure";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
app = (CommonsApplication)this.getApplicationContext();
|
||||||
|
setContentView(R.layout.activity_login);
|
||||||
|
loginButton = (Button)findViewById(R.id.loginButton);
|
||||||
|
usernameEdit = (EditText)findViewById(R.id.loginUsername);
|
||||||
|
passwordEdit = (EditText)findViewById(R.id.loginPassword);
|
||||||
|
final Context that = this;
|
||||||
|
loginButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
String username = usernameEdit.getText().toString();
|
||||||
|
String password = passwordEdit.getText().toString();
|
||||||
|
|
||||||
|
LoginTask task = new LoginTask(that);
|
||||||
|
task.execute(username, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_login, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
src/org/wikimedia/commons/ShareActivity.java
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
package org.wikimedia.commons;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.*;
|
||||||
|
import android.view.*;
|
||||||
|
import android.widget.*;
|
||||||
|
import android.support.v4.app.NavUtils;
|
||||||
|
|
||||||
|
public class ShareActivity extends Activity {
|
||||||
|
|
||||||
|
private CommonsApplication app;
|
||||||
|
|
||||||
|
private ImageView backgroundImageView;
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_share);
|
||||||
|
app = (CommonsApplication)this.getApplicationContext();
|
||||||
|
backgroundImageView = (ImageView)findViewById(R.id.backgroundImage);
|
||||||
|
Intent intent = getIntent();
|
||||||
|
if(intent.getAction().equals(Intent.ACTION_SEND)) {
|
||||||
|
if(intent.getType().startsWith("image/")) {
|
||||||
|
ImageLoaderTask loader = new ImageLoaderTask(backgroundImageView);
|
||||||
|
Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||||
|
loader.execute(imageUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_share, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case android.R.id.home:
|
||||||
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||