add enclosure url share button

This commit is contained in:
Andrew Dolgov 2012-09-19 09:45:03 +04:00
parent 4686603697
commit 8f88419419
5 changed files with 47 additions and 9 deletions

View File

@ -82,6 +82,13 @@
android:layout_weight="0"
android:text="@string/attachment_view" />
<Button
android:id="@+id/attachment_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:text="@string/attachment_share" />
<Button
android:id="@+id/attachment_copy"
android:layout_width="wrap_content"

View File

@ -129,4 +129,5 @@
<string name="notify_article_unpublished">Article unpublished</string>
<string name="notify_article_note_set">Article note saved</string>
<string name="update_headlines">Refresh</string>
<string name="attachment_share">Share</string>
</resources>

View File

@ -42,7 +42,8 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
private String m_api;
private boolean m_trustAny = false;
private boolean m_transportDebugging = false;
protected int m_httpStatusCode = 0;
protected int m_responseCode = 0;
protected String m_responseMessage;
protected int m_apiStatusCode = 0;
protected Context m_context;
private SharedPreferences m_prefs;
@ -154,10 +155,11 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
out.write(postData);
out.close();
m_httpStatusCode = conn.getResponseCode();
m_responseCode = conn.getResponseCode();
m_responseMessage = conn.getResponseMessage();
switch (m_httpStatusCode) {
case 200:
switch (m_responseCode) {
case HttpURLConnection.HTTP_OK:
BufferedReader buffer = new BufferedReader(
new InputStreamReader(conn.getInputStream()), 8192);
@ -201,16 +203,16 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
}
return null;
case 401:
case HttpURLConnection.HTTP_UNAUTHORIZED:
m_lastError = ApiError.HTTP_UNAUTHORIZED;
break;
case 403:
case HttpURLConnection.HTTP_FORBIDDEN:
m_lastError = ApiError.HTTP_FORBIDDEN;
break;
case 404:
case HttpURLConnection.HTTP_NOT_FOUND:
m_lastError = ApiError.HTTP_NOT_FOUND;
break;
case 500:
case HttpURLConnection.HTTP_INTERNAL_ERROR:
m_lastError = ApiError.HTTP_SERVER_ERROR;
break;
default:

View File

@ -214,7 +214,7 @@ public class ArticleFragment extends Fragment {
String strUrl = url.toString().trim();
if (a.content_type.indexOf("image") != -1 && !articleContent.contains(strUrl)) {
content += "<br/><img src=\"" + strUrl.replace("\"", "\\\"") + "\">";
content += "<p><img src=\"" + strUrl.replace("\"", "\\\"") + "\"></p>";
}
spinnerArray.add(a);
@ -256,7 +256,25 @@ public class ArticleFragment extends Fragment {
}
}
});
Button attachmentsShare = (Button) view.findViewById(R.id.attachment_share);
if (!m_activity.isPortrait()) {
attachmentsShare.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Attachment attachment = (Attachment) spinner.getSelectedItem();
if (attachment != null) {
m_activity.shareText(attachment.content_url);
}
}
});
} else {
attachmentsShare.setVisibility(View.GONE);
}
} else {
view.findViewById(R.id.attachments_holder).setVisibility(View.GONE);
}

View File

@ -964,6 +964,16 @@ public class OnlineActivity extends CommonActivity {
return tmp.replaceAll(",$", "");
}
public void shareText(String text) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(intent, text));
}
public void shareArticle(Article article) {
if (article != null) {