Start of new email activity
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
<activity
|
||||
android:name="i2p.bote.ViewEmailActivity"
|
||||
android:parentActivityName="i2p.bote.EmailListActivity" />
|
||||
<activity
|
||||
android:name="i2p.bote.NewEmailActivity"
|
||||
android:parentActivityName="i2p.bote.EmailListActivity" />
|
||||
<activity
|
||||
android:name="i2p.bote.config.SettingsActivity"
|
||||
android:parentActivityName="i2p.bote.EmailListActivity" />
|
||||
|
||||
BIN
res/drawable-hdpi/ic_content_new_email.png
Normal file
BIN
res/drawable-hdpi/ic_content_new_email.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
res/drawable-mdpi/ic_content_new_email.png
Normal file
BIN
res/drawable-mdpi/ic_content_new_email.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
res/drawable-xhdpi/ic_content_new_email.png
Normal file
BIN
res/drawable-xhdpi/ic_content_new_email.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
43
res/layout/fragment_new_email.xml
Normal file
43
res/layout/fragment_new_email.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp" >
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/sender_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<MultiAutoCompleteTextView
|
||||
android:id="@+id/recipients"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/to" >
|
||||
|
||||
<requestFocus />
|
||||
</MultiAutoCompleteTextView>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/subject"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/subject" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/compose_email"
|
||||
android:inputType="textMultiLine" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
11
res/menu/email_list.xml
Normal file
11
res/menu/email_list.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_new_email"
|
||||
android:icon="@drawable/ic_content_new_email"
|
||||
android:title="@string/action_new_email"
|
||||
i2pandroid:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
@@ -1,9 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:i2pandroid="http://schemas.android.com/apk/res-auto" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
android:title="@string/action_settings"
|
||||
i2pandroid:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
</menu>
|
||||
@@ -2,6 +2,8 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">I2P-Bote</string>
|
||||
<string name="action_new_email">New email</string>
|
||||
<string name="action_send_email">Send email</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
<string name="drawer_open">Open nav</string>
|
||||
@@ -26,6 +28,10 @@
|
||||
<string name="email_sent">Sent:</string>
|
||||
<string name="email_received">Received:</string>
|
||||
|
||||
<string name="to">To</string>
|
||||
<string name="subject">Subject</string>
|
||||
<string name="compose_email">Compose email</string>
|
||||
|
||||
<string name="pref_title_general">General</string>
|
||||
<string name="pref_summ_general">General settings and default identity settings</string>
|
||||
<string name="pref_title_autoMail">Auto-check mail</string>
|
||||
|
||||
@@ -148,7 +148,7 @@ public class EmailListActivity extends ActionBarActivity implements
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,12 +18,16 @@ import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
@@ -71,6 +75,12 @@ public class EmailListFragment extends ListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
@@ -184,6 +194,24 @@ public class EmailListFragment extends ListFragment implements
|
||||
getLoaderManager().initLoader(EMAIL_LIST_LOADER, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.email_list, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_new_email:
|
||||
Intent nei = new Intent(getActivity(), NewEmailActivity.class);
|
||||
startActivity(nei);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView parent, View view, int pos, long id) {
|
||||
super.onListItemClick(parent, view, pos, id);
|
||||
|
||||
20
src/i2p/bote/NewEmailActivity.java
Normal file
20
src/i2p/bote/NewEmailActivity.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package i2p.bote;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
public class NewEmailActivity extends ActionBarActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Enable ActionBar app icon to behave as action to go back
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
NewEmailFragment f = new NewEmailFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add(android.R.id.content, f).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
131
src/i2p/bote/NewEmailFragment.java
Normal file
131
src/i2p/bote/NewEmailFragment.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package i2p.bote;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collection;
|
||||
|
||||
import i2p.bote.email.EmailIdentity;
|
||||
import i2p.bote.fileencryption.PasswordException;
|
||||
import android.content.Context;
|
||||
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.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class NewEmailFragment extends Fragment {
|
||||
Spinner mSpinner;
|
||||
|
||||
@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_new_email, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mSpinner = (Spinner) view.findViewById(R.id.sender_spinner);
|
||||
IdentityAdapter adapter = new IdentityAdapter(getActivity());
|
||||
mSpinner.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.new_email, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_send_email:
|
||||
// TODO Handle
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private class IdentityAdapter extends ArrayAdapter<EmailIdentity> {
|
||||
public IdentityAdapter(Context context) {
|
||||
super(context, android.R.layout.simple_spinner_item);
|
||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
try {
|
||||
Collection<EmailIdentity> identities = I2PBote.getInstance().getIdentities().getAll();
|
||||
for (EmailIdentity identity : identities) {
|
||||
add(identity);
|
||||
if (identity.isDefault())
|
||||
mSpinner.setSelection(getPosition(identity));
|
||||
}
|
||||
} catch (PasswordException e) {
|
||||
// TODO Handle
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Handle
|
||||
e.printStackTrace();
|
||||
} catch (GeneralSecurityException e) {
|
||||
// TODO Handle
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailIdentity getItem(int position) {
|
||||
if (position > 0)
|
||||
return super.getItem(position - 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPosition(EmailIdentity item) {
|
||||
if (item != null)
|
||||
return super.getPosition(item) + 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return super.getCount() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = super.getView(position, convertView, parent);
|
||||
setViewText(v, position);
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView (int position, View convertView, ViewGroup parent) {
|
||||
View v = super.getDropDownView(position, convertView, parent);
|
||||
setViewText(v, position);
|
||||
return v;
|
||||
}
|
||||
|
||||
private void setViewText(View v, int position) {
|
||||
TextView text = (TextView) v.findViewById(android.R.id.text1);
|
||||
EmailIdentity identity = getItem(position);
|
||||
if (identity == null)
|
||||
text.setText("Anonymous");
|
||||
else
|
||||
text.setText(identity.getPublicName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user