remove sharing stuff

This commit is contained in:
Andrew Dolgov 2012-09-09 19:22:31 +04:00
parent 9cd9d849e1
commit aa0711147c
4 changed files with 0 additions and 369 deletions

View File

@ -26,16 +26,6 @@
android:name=".offline.OfflineActivity"
android:label="@string/app_name" >
</activity>
<!-- <activity
android:name=".ShareActivity"
android:excludeFromRecents="true"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity> -->
<activity
android:name=".MainActivity"
android:label="@string/app_name" >

View File

@ -1,90 +0,0 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableLayout
android:padding="4dp"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="@string/share_title_prompt"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/title"
android:singleLine="true"
android:layout_width="0dp"
android:hint="@string/share_title_hint"
android:layout_height="wrap_content"
android:layout_weight="0.7" >
</EditText>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="@string/share_url_prompt"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="@+id/url"
android:singleLine="true"
android:hint="@string/share_url_hint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7" />
</TableRow>
<EditText
android:id="@+id/content"
android:layout_width="wrap_content"
android:hint="@string/share_content_hint"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="3">
<requestFocus />
</EditText>
<Button
android:id="@+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/share_share_button" />
</TableLayout>
<LinearLayout
android:id="@+id/loading_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/loading_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/loading_message" />
</LinearLayout>
</LinearLayout>

View File

@ -128,12 +128,4 @@
<string name="notify_article_published">Article published</string>
<string name="notify_article_unpublished">Article unpublished</string>
<string name="notify_article_note_set">Article note saved</string>
<string name="api_too_low">This action requires newer version of Tiny Tiny RSS</string>
<string name="share_url_prompt">URL:</string>
<string name="share_url_hint">Article URL</string>
<string name="share_content_hint">Article Content</string>
<string name="share_title_prompt">Title:</string>
<string name="share_title_hint">Article Title</string>
<string name="share_share_button">Share</string>
<string name="share_article_posted">Article posted.</string>
</resources>

View File

@ -1,261 +0,0 @@
package org.fox.ttrss;
import java.util.HashMap;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
public class ShareActivity extends CommonActivity {
private final String TAG = this.getClass().getSimpleName();
private String m_sessionId;
private SharedPreferences m_prefs;
private int m_apiLevel = 0;
private boolean m_isLoggingIn = false;
private String m_themeName = "";
@Override
public void onCreate(Bundle savedInstanceState) {
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.LightTheme);
}
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
m_themeName = m_prefs.getString("theme", "THEME_DARK");
if (savedInstanceState != null) {
m_sessionId = savedInstanceState.getString("sessionId");
m_apiLevel = savedInstanceState.getInt("apiLevel");
}
setContentView(R.layout.share);
setSmallScreen(findViewById(R.id.headlines_fragment) == null);
if (m_sessionId != null) {
loginSuccess();
} else {
//login(); -- handled in onResume()
}
}
private void loginSuccess() {
findViewById(R.id.loading_container).setVisibility(View.GONE);
setProgressBarIndeterminateVisibility(false);
if (m_apiLevel < 4) {
setLoadingStatus(R.string.api_too_low, false);
} else {
Intent intent = getIntent();
final EditText url = (EditText) findViewById(R.id.url);
url.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
final EditText title = (EditText) findViewById(R.id.title);
title.setText(intent.getStringExtra(Intent.EXTRA_SUBJECT));
final EditText content = (EditText) findViewById(R.id.content);
Button share = (Button) findViewById(R.id.share_button);
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ApiRequest req = new ApiRequest(getApplicationContext()) {
protected void onPostExecute(JsonElement result) {
setProgressBarIndeterminateVisibility(false);
if (m_lastError != ApiError.NO_ERROR) {
toast(getErrorMessage());
} else {
toast(R.string.share_article_posted);
finish();
}
}
};
HashMap<String, String> map = new HashMap<String, String>() {
{
put("sid", m_sessionId);
put("op", "shareToPublished");
put("title", title.getText().toString());
put("url", url.getText().toString());
put("content", content.getText().toString());
}
};
setProgressBarIndeterminateVisibility(true);
req.execute(map);
}
});
}
}
private void logout() {
m_sessionId = null;
findViewById(R.id.loading_container).setVisibility(View.VISIBLE);
TextView tv = (TextView) findViewById(R.id.loading_message);
if (tv != null) {
tv.setText(R.string.login_ready);
}
}
@SuppressWarnings({ "unchecked", "serial" })
public void login() {
logout();
if (m_prefs.getString("ttrss_url", "").trim().length() == 0) {
setLoadingStatus(R.string.login_need_configure, false);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.dialog_need_configure_prompt)
.setCancelable(false)
.setPositiveButton(R.string.dialog_open_preferences, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// launch preferences
Intent intent = new Intent(ShareActivity.this,
PreferencesActivity.class);
startActivityForResult(intent, 0);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
LoginRequest ar = new LoginRequest(getApplicationContext());
HashMap<String, String> map = new HashMap<String, String>() {
{
put("op", "login");
put("user", m_prefs.getString("login", "").trim());
put("password", m_prefs.getString("password", "").trim());
}
};
ar.execute(map);
setLoadingStatus(R.string.login_in_progress, true);
m_isLoggingIn = true;
}
}
private void setLoadingStatus(int status, boolean showProgress) {
TextView tv = (TextView) findViewById(R.id.loading_message);
if (tv != null) {
tv.setText(status);
}
setProgressBarIndeterminateVisibility(showProgress);
}
@Override
public void onResume() {
super.onResume();
if (m_sessionId == null && !m_isLoggingIn) {
login();
}
}
private class LoginRequest extends ApiRequest {
public LoginRequest(Context context) {
super(context);
}
@SuppressWarnings("unchecked")
protected void onPostExecute(JsonElement result) {
m_isLoggingIn = false;
if (result != null) {
try {
JsonObject content = result.getAsJsonObject();
if (content != null) {
m_sessionId = content.get("session_id").getAsString();
Log.d(TAG, "Authenticated!");
ApiRequest req = new ApiRequest(m_context) {
protected void onPostExecute(JsonElement result) {
m_apiLevel = 0;
if (result != null) {
try {
m_apiLevel = result.getAsJsonObject()
.get("level").getAsInt();
} catch (Exception e) {
e.printStackTrace();
}
}
Log.d(TAG, "Received API level: " + m_apiLevel);
loginSuccess();
}
};
@SuppressWarnings("serial")
HashMap<String, String> map = new HashMap<String, String>() {
{
put("sid", m_sessionId);
put("op", "getApiLevel");
}
};
req.execute(map);
setLoadingStatus(R.string.loading_message, true);
return;
}
} catch (Exception e) {
e.printStackTrace();
}
}
m_sessionId = null;
setLoadingStatus(getErrorMessage(), false);
}
}
}