mirror of
https://github.com/cwinfo/envayasms.git
synced 2024-12-04 20:45:32 +00:00
add menu option to forward existing messages from inbox (delivered when kalsms was not enabled)
This commit is contained in:
parent
61d24b2f64
commit
41141fa5fd
@ -23,6 +23,10 @@
|
|||||||
<activity android:name=".Help" android:label="@string/app_name">
|
<activity android:name=".Help" android:label="@string/app_name">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".ForwardInbox" android:label="@string/app_name">
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
<receiver android:name=".IncomingMessageForwarder">
|
<receiver android:name=".IncomingMessageForwarder">
|
||||||
<intent-filter android:priority="101">
|
<intent-filter android:priority="101">
|
||||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||||
|
BIN
res/drawable-hdpi/ic_menu_dialog.png
Executable file
BIN
res/drawable-hdpi/ic_menu_dialog.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
res/drawable-ldpi/ic_menu_dialog.png
Executable file
BIN
res/drawable-ldpi/ic_menu_dialog.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 944 B |
BIN
res/drawable-mdpi/ic_menu_dialog.png
Executable file
BIN
res/drawable-mdpi/ic_menu_dialog.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
18
res/layout/inbox.xml
Executable file
18
res/layout/inbox.xml
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp">
|
||||||
|
<ListView android:id="@android:id/list"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawSelectorOnTop="false"/>
|
||||||
|
<Button
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:text="Forward selected"
|
||||||
|
android:onClick="forwardSelected" />
|
||||||
|
</LinearLayout>
|
31
res/layout/inbox_item.xml
Executable file
31
res/layout/inbox_item.xml
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="6sp"
|
||||||
|
android:background="#cccccc">
|
||||||
|
<CheckBox android:id="@+id/inbox_checkbox"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/inbox_address"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#333333"
|
||||||
|
android:layout_marginTop="4sp"
|
||||||
|
android:layout_marginLeft="6sp"
|
||||||
|
android:textSize="14sp"></TextView>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/inbox_body"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#666666"
|
||||||
|
android:layout_marginLeft="6sp"
|
||||||
|
android:textSize="14sp"></TextView>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
@ -9,10 +9,14 @@
|
|||||||
<item android:id="@+id/check_now"
|
<item android:id="@+id/check_now"
|
||||||
android:icon="@drawable/ic_menu_tick"
|
android:icon="@drawable/ic_menu_tick"
|
||||||
android:title="@string/check_now" />
|
android:title="@string/check_now" />
|
||||||
<item android:id="@+id/help"
|
<item android:id="@+id/forward_inbox"
|
||||||
android:icon="@drawable/ic_menu_puzzle"
|
android:icon="@drawable/ic_menu_dialog"
|
||||||
android:title="@string/help" />
|
android:title="@string/forward_inbox" />
|
||||||
<item android:id="@+id/retry_now"
|
<item android:id="@+id/retry_now"
|
||||||
android:icon="@drawable/ic_menu_magnet"
|
android:icon="@drawable/ic_menu_magnet"
|
||||||
android:title="@string/retry_now" />
|
android:title="@string/retry_now" />
|
||||||
|
<item android:id="@+id/help"
|
||||||
|
android:icon="@drawable/ic_menu_puzzle"
|
||||||
|
android:title="@string/help" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -6,4 +6,5 @@
|
|||||||
<string name="check_now">Check Messages</string>
|
<string name="check_now">Check Messages</string>
|
||||||
<string name="help">Help</string>
|
<string name="help">Help</string>
|
||||||
<string name="retry_now">Retry</string>
|
<string name="retry_now">Retry</string>
|
||||||
|
<string name="forward_inbox">Fwd Inbox...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
69
src/org/envaya/kalsms/ForwardInbox.java
Executable file
69
src/org/envaya/kalsms/ForwardInbox.java
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
|
||||||
|
package org.envaya.kalsms;
|
||||||
|
|
||||||
|
import android.app.ListActivity;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.SimpleCursorAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
|
public class ForwardInbox extends ListActivity {
|
||||||
|
|
||||||
|
private App app;
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
app = App.getInstance(getApplicationContext());
|
||||||
|
|
||||||
|
setContentView(R.layout.inbox);
|
||||||
|
|
||||||
|
// undocumented API; see
|
||||||
|
// core/java/android/provider/Telephony.java
|
||||||
|
|
||||||
|
Uri inboxUri = Uri.parse("content://sms/inbox");
|
||||||
|
|
||||||
|
Cursor cur = getContentResolver().query(inboxUri, null, null, null, null);
|
||||||
|
|
||||||
|
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
|
||||||
|
R.layout.inbox_item,
|
||||||
|
cur,
|
||||||
|
new String[] {"address","body"},
|
||||||
|
new int[] {R.id.inbox_address, R.id.inbox_body});
|
||||||
|
|
||||||
|
setListAdapter(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forwardSelected(View view) {
|
||||||
|
|
||||||
|
ListView listView = getListView();
|
||||||
|
|
||||||
|
// there is probably a less hacky way to do this...
|
||||||
|
int childCount = listView.getChildCount();
|
||||||
|
for (int i = 0; i < childCount; i++)
|
||||||
|
{
|
||||||
|
View entry = listView.getChildAt(i);
|
||||||
|
CheckBox checkbox = (CheckBox) entry.findViewById(R.id.inbox_checkbox);
|
||||||
|
|
||||||
|
if (checkbox.isChecked())
|
||||||
|
{
|
||||||
|
TextView addressView = (TextView) entry.findViewById(R.id.inbox_address);
|
||||||
|
TextView bodyView = (TextView) entry.findViewById(R.id.inbox_body);
|
||||||
|
IncomingMessage sms = new IncomingMessage(app,
|
||||||
|
addressView.getText().toString(),
|
||||||
|
bodyView.getText().toString());
|
||||||
|
|
||||||
|
app.forwardToServer(sms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.finish();
|
||||||
|
}
|
||||||
|
}
|
@ -42,7 +42,7 @@ public class Help extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
startActivity(new Intent(this, Main.class));
|
this.finish();
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
@ -7,30 +7,40 @@ import org.apache.http.message.BasicNameValuePair;
|
|||||||
|
|
||||||
public class IncomingMessage extends QueuedMessage {
|
public class IncomingMessage extends QueuedMessage {
|
||||||
|
|
||||||
public SmsMessage sms;
|
public String from;
|
||||||
|
public String message;
|
||||||
|
public long timestampMillis = 0;
|
||||||
|
|
||||||
public IncomingMessage(App app, SmsMessage sms) {
|
public IncomingMessage(App app, SmsMessage sms) {
|
||||||
super(app);
|
super(app);
|
||||||
this.sms = sms;
|
this.from = sms.getOriginatingAddress();
|
||||||
|
this.message = sms.getMessageBody();
|
||||||
|
this.timestampMillis = sms.getTimestampMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IncomingMessage(App app, String from, String message) {
|
||||||
|
super(app);
|
||||||
|
this.from = from;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMessageBody()
|
public String getMessageBody()
|
||||||
{
|
{
|
||||||
return sms.getMessageBody();
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFrom()
|
public String getFrom()
|
||||||
{
|
{
|
||||||
return sms.getOriginatingAddress();
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return sms.getOriginatingAddress() + ":" + sms.getMessageBody() + ":" + sms.getTimestampMillis();
|
return from + ":" + message + ":" + timestampMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retryNow() {
|
public void retryNow() {
|
||||||
app.log("Retrying forwarding SMS from " + sms.getOriginatingAddress());
|
app.log("Retrying forwarding SMS from " + from);
|
||||||
tryForwardToServer();
|
tryForwardToServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,10 @@ public class Main extends Activity {
|
|||||||
return true;
|
return true;
|
||||||
case R.id.retry_now:
|
case R.id.retry_now:
|
||||||
app.retryStuckMessages();
|
app.retryStuckMessages();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.forward_inbox:
|
||||||
|
startActivity(new Intent(this, ForwardInbox.class));
|
||||||
|
return true;
|
||||||
case R.id.help:
|
case R.id.help:
|
||||||
startActivity(new Intent(this, Help.class));
|
startActivity(new Intent(this, Help.class));
|
||||||
return true;
|
return true;
|
||||||
|
@ -93,17 +93,10 @@ public class Prefs extends PreferenceActivity implements OnSharedPreferenceChang
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// first time the Menu key is pressed
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
startActivity(new Intent(this, Prefs.class));
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// any other time the Menu key is pressed
|
// any other time the Menu key is pressed
|
||||||
@Override
|
@Override
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
startActivity(new Intent(this, Prefs.class));
|
this.finish();
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user