Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit ec2d11c

Browse files
author
Michael Farb
committed
correcting premature passphrase closing issues
- db parse corrections for 'else' cases - fixed 2.3 device change password is erratic, behavior from settings closes too quickly - Fixed #76 cumbersome message opening flow
1 parent d9d6067 commit ec2d11c

8 files changed

Lines changed: 52 additions & 46 deletions

File tree

safeslinger-messenger/res/layout/pickrecipients.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525

2626
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2727
xmlns:myapp="http://schemas.android.com/apk/res-auto"
28+
xmlns:app="http://schemas.android.com/apk/res/edu.cmu.cylab.starslinger"
2829
android:layout_width="fill_parent"
2930
android:layout_height="fill_parent"
3031
android:descendantFocusability="beforeDescendants"
3132
android:focusableInTouchMode="true"
32-
android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res/edu.cmu.cylab.starslinger">
33+
android:orientation="vertical" >
3334

3435
<android.support.v7.widget.SearchView
3536
android:id="@+id/fragment_address_search"
3637
android:layout_width="match_parent"
3738
android:layout_height="wrap_content"
38-
android:layout_margin="@dimen/size_5dp"
3939
android:textColor="@color/black"
4040
android:textSize="@dimen/text_size_medium"
4141
myapp:iconifiedByDefault="false"
@@ -45,7 +45,6 @@
4545
android:id="@+id/tvInstruct"
4646
android:layout_width="match_parent"
4747
android:layout_height="wrap_content"
48-
android:layout_margin="@dimen/size_5dp"
4948
android:gravity="center"
5049
android:text="@string/label_InstNoRecipients"
5150
android:textSize="@dimen/text_size_medium" />

safeslinger-messenger/src/edu/cmu/cylab/starslinger/SafeSlinger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,11 @@ synchronized public static boolean isAppVisible() {
461461
return sAppVisible;
462462
}
463463

464-
synchronized public static void activityResumed() {
464+
synchronized public static void appRunning() {
465465
sAppVisible = true;
466466
}
467467

468-
synchronized public static void activityPaused() {
468+
synchronized public static void appClosing() {
469469
sAppVisible = false;
470470
}
471471

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/BaseActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,13 +1271,12 @@ public void onUserInteraction() {
12711271
@Override
12721272
protected void onResume() {
12731273
super.onResume();
1274-
SafeSlinger.activityResumed();
1274+
SafeSlinger.appRunning();
12751275
}
12761276

12771277
@Override
12781278
protected void onPause() {
12791279
super.onPause();
1280-
SafeSlinger.activityPaused();
12811280
}
12821281

12831282
protected void showBackupQuery() {

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/HomeActivity.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,13 +1297,13 @@ public void onComposeResultListener(Bundle data) {
12971297
try {
12981298
if (c.moveToFirst()) {
12991299
d.setRecip(new RecipientRow(c));
1300+
} else {
1301+
showNote(R.string.error_InvalidRecipient);
1302+
return;
13001303
}
13011304
} finally {
13021305
c.close();
13031306
}
1304-
} else {
1305-
showNote(R.string.error_InvalidRecipient);
1306-
return;
13071307
}
13081308
}
13091309
}
@@ -1422,13 +1422,13 @@ public void onMessageResultListener(Bundle data) {
14221422
try {
14231423
if (c.moveToFirst()) {
14241424
recip = new RecipientRow(c);
1425+
} else {
1426+
showNote(R.string.error_InvalidRecipient);
1427+
return;
14251428
}
14261429
} finally {
14271430
c.close();
14281431
}
1429-
} else {
1430-
showNote(R.string.error_InvalidRecipient);
1431-
return;
14321432
}
14331433
}
14341434
}
@@ -1691,13 +1691,13 @@ public void onIntroResultListener(Bundle data) {
16911691
try {
16921692
if (c.moveToFirst()) {
16931693
recip1 = new RecipientRow(c);
1694+
} else {
1695+
showNote(R.string.error_InvalidRecipient);
1696+
break;
16941697
}
16951698
} finally {
16961699
c.close();
16971700
}
1698-
} else {
1699-
showNote(R.string.error_InvalidRecipient);
1700-
break;
17011701
}
17021702
}
17031703

@@ -1708,13 +1708,13 @@ public void onIntroResultListener(Bundle data) {
17081708
try {
17091709
if (c.moveToFirst()) {
17101710
recip2 = new RecipientRow(c);
1711+
} else {
1712+
showNote(R.string.error_InvalidRecipient);
1713+
break;
17111714
}
17121715
} finally {
17131716
c.close();
17141717
}
1715-
} else {
1716-
showNote(R.string.error_InvalidRecipient);
1717-
break;
17181718
}
17191719
}
17201720

@@ -1943,7 +1943,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
19431943
deleteUser(user);
19441944
}
19451945
}
1946-
1946+
// this separate task is now finished
1947+
showExit(RESULT_CANCELED);
1948+
break;
1949+
case PassPhraseActivity.RESULT_BACKPRESSED:
19471950
// this separate task is now finished
19481951
showExit(RESULT_CANCELED);
19491952
break;
@@ -1984,15 +1987,15 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
19841987

19851988
setTab(Tabs.COMPOSE);
19861989
refreshView();
1990+
} else {
1991+
showNote(R.string.error_InvalidRecipient);
1992+
setTab(Tabs.COMPOSE);
1993+
refreshView();
1994+
break;
19871995
}
19881996
} finally {
19891997
c.close();
19901998
}
1991-
} else {
1992-
showNote(R.string.error_InvalidRecipient);
1993-
setTab(Tabs.COMPOSE);
1994-
refreshView();
1995-
break;
19961999
}
19972000
break;
19982001
case Activity.RESULT_CANCELED:
@@ -2026,13 +2029,13 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
20262029
if (c.moveToFirst()) {
20272030
d.setRecip1(new RecipientRow(c));
20282031
refreshView();
2032+
} else {
2033+
showNote(R.string.error_InvalidRecipient);
2034+
break;
20292035
}
20302036
} finally {
20312037
c.close();
20322038
}
2033-
} else {
2034-
showNote(R.string.error_InvalidRecipient);
2035-
break;
20362039
}
20372040
break;
20382041
case Activity.RESULT_CANCELED:
@@ -2066,13 +2069,13 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
20662069
if (c.moveToFirst()) {
20672070
d.setRecip2(new RecipientRow(c));
20682071
refreshView();
2072+
} else {
2073+
showNote(R.string.error_InvalidRecipient);
2074+
break;
20692075
}
20702076
} finally {
20712077
c.close();
20722078
}
2073-
} else {
2074-
showNote(R.string.error_InvalidRecipient);
2075-
break;
20762079
}
20772080
break;
20782081
case Activity.RESULT_CANCELED:
@@ -2736,6 +2739,7 @@ private boolean showPassphraseWhenExpired() {
27362739
@Override
27372740
protected void onPause() {
27382741
super.onPause();
2742+
27392743
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)
27402744
SafeSlinger.getApplication().setMessageFragActive(false);
27412745
// restoreView();
@@ -3440,6 +3444,7 @@ private void showErrorExit(int resId) {
34403444
private void showExit(int resultCode) {
34413445
setResult(resultCode);
34423446
finish();
3447+
SafeSlinger.appClosing();
34433448
}
34443449

34453450
private void reInitForExit() {

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/MessagesAdapter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,10 @@ private void drawMessageItem(View convertView, MessageRow msg) {
145145
+ DateUtils.getRelativeTimeSpanString(mCtx, date).toString();
146146
}
147147
long diff = System.currentTimeMillis() - Long.valueOf(date);
148-
if (msg.getStatus() == MessageDbAdapter.MESSAGE_STATUS_QUEUED) {
149-
if (!TextUtils.isEmpty(msg.getProgress())) {
150-
tvDate.setText(msg.getProgress());
151-
} else {
152-
tvDate.setText(mCtx.getString(R.string.prog_pending));
153-
}
148+
if (!TextUtils.isEmpty(msg.getProgress())) {
149+
tvDate.setText(msg.getProgress());
150+
} else if (msg.getStatus() == MessageDbAdapter.MESSAGE_STATUS_QUEUED) {
151+
tvDate.setText(mCtx.getString(R.string.prog_pending));
154152
} else {
155153
tvDate.setText(dateTime);
156154
}

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/MessagesFragment.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
254254
}
255255
});
256256

257-
updateMessageList(true);
257+
updateMessageList(false);
258258

259259
return vFrag;
260260
}
@@ -365,14 +365,14 @@ public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
365365
// messages with matching key ids in
366366
// database
367367
mRecip = new RecipientRow(c);
368+
} else {
369+
// messages without matching key ids
370+
mRecip = RecipientRow.createKeyIdOnlyRecipient(t.getMsgRow()
371+
.getKeyId());
368372
}
369373
} finally {
370374
c.close();
371375
}
372-
} else {
373-
// messages without matching key ids
374-
mRecip = RecipientRow
375-
.createKeyIdOnlyRecipient(t.getMsgRow().getKeyId());
376376
}
377377
}
378378
} else {

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/PassPhraseActivity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public class PassPhraseActivity extends Activity {
8686
private Handler mHandler;
8787
private final static int mMsPollInterval = 1000;
8888
public static final int RESULT_CLOSEANDCONTINUE = 999;
89+
public static final int RESULT_BACKPRESSED = 998;
8990
private ArrayList<UserData> mUsers;
9091
private UserAdapter mUserAdapter;
9192
private Spinner mSpinnerUser;
@@ -247,13 +248,12 @@ protected void onDestroy() {
247248
@Override
248249
protected void onResume() {
249250
super.onResume();
250-
SafeSlinger.activityResumed();
251+
SafeSlinger.appRunning();
251252
}
252253

253254
@Override
254255
protected void onPause() {
255256
super.onPause();
256-
SafeSlinger.activityPaused();
257257
}
258258

259259
private void doUpdateUserSelection(int position) {
@@ -505,4 +505,10 @@ public void onCancel(DialogInterface dialog) {
505505
return ad;
506506
}
507507

508+
@Override
509+
public void onBackPressed() {
510+
// eat the back key to find the manual vs auto close
511+
setResult(RESULT_BACKPRESSED);
512+
finish();
513+
}
508514
}

safeslinger-messenger/src/edu/cmu/cylab/starslinger/view/SettingsActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,12 @@ protected void showNote(int resId) {
683683
@Override
684684
protected void onResume() {
685685
super.onResume();
686-
SafeSlinger.activityResumed();
686+
SafeSlinger.appRunning();
687687
}
688688

689689
@Override
690690
protected void onPause() {
691691
super.onPause();
692-
SafeSlinger.activityPaused();
693692

694693
// exit and update timer when pass ttl changes
695694
if (sTtlChanged) {

0 commit comments

Comments
 (0)