Added view of identity
This commit is contained in:
@@ -162,7 +162,7 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
Header header = mIdentityListHeaders[index];
|
||||
if (header != null && header.id != HEADER_ID_UNDEFINED) {
|
||||
String key = header.extras.getString(
|
||||
EditIdentityFragment.IDENTITY_KEY);
|
||||
ViewIdentityFragment.IDENTITY_KEY);
|
||||
if (key != mDeletingIdentityKey) {
|
||||
target.add(header);
|
||||
if (key == mRequestedIdentityKey) {
|
||||
@@ -276,9 +276,9 @@ public class SettingsActivity extends PreferenceActivity {
|
||||
final String desc = identity.getDescription();
|
||||
final String key = identity.getKey();
|
||||
final Intent intent = new Intent(
|
||||
getApplicationContext(), EditIdentityActivity.class);
|
||||
getApplicationContext(), ViewIdentityActivity.class);
|
||||
final Bundle args = new Bundle();
|
||||
args.putString(EditIdentityFragment.IDENTITY_KEY, key);
|
||||
args.putString(ViewIdentityFragment.IDENTITY_KEY, key);
|
||||
intent.putExtras(args);
|
||||
final Header newHeader = new Header();
|
||||
newHeader.id = id;
|
||||
|
||||
24
src/i2p/bote/config/ViewIdentityActivity.java
Normal file
24
src/i2p/bote/config/ViewIdentityActivity.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package i2p.bote.config;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
public class ViewIdentityActivity extends ActionBarActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Enable ActionBar app icon to behave as action to go back
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
String key = null;
|
||||
Bundle args = getIntent().getExtras();
|
||||
if (args != null)
|
||||
key = args.getString(ViewIdentityFragment.IDENTITY_KEY);
|
||||
ViewIdentityFragment f = ViewIdentityFragment.newInstance(key);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(android.R.id.content, f).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
107
src/i2p/bote/config/ViewIdentityFragment.java
Normal file
107
src/i2p/bote/config/ViewIdentityFragment.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package i2p.bote.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
import i2p.bote.R;
|
||||
import i2p.bote.email.EmailIdentity;
|
||||
import i2p.bote.fileencryption.PasswordException;
|
||||
import i2p.bote.util.BoteHelper;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ViewIdentityFragment extends Fragment {
|
||||
public static final String IDENTITY_KEY = "identity_key";
|
||||
|
||||
private String mKey;
|
||||
private EmailIdentity mIdentity;
|
||||
|
||||
TextView mNameField;
|
||||
TextView mDescField;
|
||||
TextView mCryptoField;
|
||||
TextView mKeyField;
|
||||
|
||||
public static ViewIdentityFragment newInstance(String key) {
|
||||
ViewIdentityFragment f = new ViewIdentityFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(IDENTITY_KEY, key);
|
||||
f.setArguments(args);
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_view_identity, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mKey = getArguments().getString(IDENTITY_KEY);
|
||||
if (mKey != null) {
|
||||
try {
|
||||
mIdentity = BoteHelper.getIdentity(mKey);
|
||||
mNameField = (TextView) view.findViewById(R.id.public_name);
|
||||
mDescField = (TextView) view.findViewById(R.id.description);
|
||||
mCryptoField = (TextView) view.findViewById(R.id.crypto_impl);
|
||||
mKeyField = (TextView) view.findViewById(R.id.key);
|
||||
} catch (PasswordException e) {
|
||||
// TODO Handle
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Handle
|
||||
e.printStackTrace();
|
||||
} catch (GeneralSecurityException e) {
|
||||
// TODO Handle
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (mIdentity != null) {
|
||||
mNameField.setText(mIdentity.getPublicName());
|
||||
mDescField.setText(mIdentity.getDescription());
|
||||
mCryptoField.setText(mIdentity.getCryptoImpl().getName());
|
||||
mKeyField.setText(mKey);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.view_identity, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_edit_identity:
|
||||
Intent ei = new Intent(getActivity(), EditIdentityActivity.class);
|
||||
ei.putExtra(EditIdentityFragment.IDENTITY_KEY, mKey);
|
||||
startActivity(ei);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user