forked from arthurzaczek/launcherforblind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27c250b
commit 65fb900
Showing
6 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" > | ||
|
||
<TextView | ||
android:id="@+id/txtMain" | ||
style="@style/Main" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:gravity="center" | ||
android:text="@string/sms" /> | ||
|
||
<TextView | ||
android:id="@+id/txtHelp" | ||
style="@style/Help" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/txtMain" | ||
android:gravity="center" | ||
android:text="@string/main_help" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.zaczek.launcherforblind; | ||
|
||
import net.zaczek.launcherforblind.activitysupport.AbstractCursorActivity; | ||
import net.zaczek.launcherforblind.listentries.ListEntry; | ||
import net.zaczek.launcherforblind.listentries.SMSListEntry; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.text.format.DateUtils; | ||
import android.util.Log; | ||
import android.widget.TextView; | ||
|
||
public class SMSActivity extends AbstractCursorActivity { | ||
private static final String TAG = "launcherforblind"; | ||
|
||
private static final String[] PROJECTION = new String[] { "address", "date", "body" }; | ||
|
||
private TextView txtMain; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
Log.i(TAG, "onCreate"); | ||
setContentView(R.layout.sms); | ||
|
||
txtMain = (TextView) findViewById(R.id.txtMain); | ||
} | ||
|
||
@Override | ||
protected Cursor getCursor() { | ||
Cursor c = managedQuery(Uri.parse("content://sms/inbox"), PROJECTION, | ||
null, null, "date DESC"); | ||
return c; | ||
} | ||
|
||
@Override | ||
protected ListEntry getListEntry(Cursor c) { | ||
long date = c.getLong(1); | ||
String strDate = DateUtils.formatDateTime(this, date, | ||
DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); | ||
return new SMSListEntry(this, c.getString(0), strDate, c.getString(2)); | ||
} | ||
|
||
@Override | ||
protected void giveFeedback(String label) { | ||
txtMain.setText(label); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/net/zaczek/launcherforblind/listentries/SMSListEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package net.zaczek.launcherforblind.listentries; | ||
|
||
import net.zaczek.launcherforblind.Helper; | ||
import android.content.Context; | ||
|
||
public class SMSListEntry extends AbstractListEntry { | ||
String mNumber; | ||
String mDate; | ||
String mMessage; | ||
Context mCtx; | ||
|
||
public SMSListEntry(Context ctx, String number, String date, String msg) { | ||
super(date); | ||
mCtx = ctx; | ||
mNumber = number; | ||
mDate = date; | ||
mMessage = msg; | ||
} | ||
|
||
@Override | ||
public String getLabelToSay() { | ||
return Helper.getContactName(mCtx, mNumber) + ", " + mDate + ".\n" + mMessage; | ||
} | ||
|
||
public String getNumber() { | ||
return mNumber; | ||
} | ||
} |