Added move dialog shown on activity resume.
This commit is contained in:
parent
9cbfa8bf86
commit
b575d442cf
3 changed files with 35 additions and 11 deletions
|
@ -30,17 +30,12 @@ public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActiv
|
|||
|
||||
@SmallTest
|
||||
public void testOrientation() {
|
||||
try {
|
||||
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
Thread.sleep(50);
|
||||
getInstrumentation().waitForIdleSync();
|
||||
assertTrue(true);
|
||||
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
Thread.sleep(50);
|
||||
getInstrumentation().waitForIdleSync();
|
||||
assertTrue(true);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Log.w(TAG, "Sleep failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package com.nutomic.zertman;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ListActivity;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ListView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MainActivity extends ListActivity {
|
||||
|
||||
|
@ -32,4 +36,25 @@ public class MainActivity extends ListActivity {
|
|||
mListView.setAdapter(mCertificateAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final List<Certificate> list = mCertificateManager.getCertificates(false);
|
||||
if (!list.isEmpty()) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.dialog_move_certs_title)
|
||||
.setMessage(R.string.dialog_move_certs_message)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
for (Certificate c : list) {
|
||||
mCertificateManager.moveCertificateToSystem(c);
|
||||
mMovedCertificatesStorage.insert(c);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,4 +3,8 @@
|
|||
|
||||
<string name="app_name">Zert Man</string>
|
||||
|
||||
<string name="dialog_move_certs_title">User Certificates Found</string>
|
||||
|
||||
<string name="dialog_move_certs_message">Should they be moved to system storage?</string>
|
||||
|
||||
</resources>
|
||||
|
|
Reference in a new issue