Renamed MessageListActivity to MainActivity

(it is the main activity, after all)
This commit is contained in:
Christian Basler 2015-11-22 12:28:31 +01:00
parent b676983ba4
commit 73383aa2c2
12 changed files with 55 additions and 58 deletions

View File

@ -18,7 +18,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity <activity
android:name=".MessageListActivity" android:name=".MainActivity"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -29,28 +29,28 @@
<activity <activity
android:name=".MessageDetailActivity" android:name=".MessageDetailActivity"
android:label="@string/title_message_detail" android:label="@string/title_message_detail"
android:parentActivityName=".MessageListActivity" android:parentActivityName=".MainActivity"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".MessageListActivity" /> android:value=".MainActivity" />
</activity> </activity>
<activity <activity
android:name=".SubscriptionDetailActivity" android:name=".SubscriptionDetailActivity"
android:label="@string/title_subscription_detail" android:label="@string/title_subscription_detail"
android:parentActivityName=".MessageListActivity" android:parentActivityName=".MainActivity"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".MessageListActivity" /> android:value=".MainActivity" />
</activity> </activity>
<activity <activity
android:name=".ComposeMessageActivity" android:name=".ComposeMessageActivity"
android:label="Compose" android:label="Compose"
android:parentActivityName=".MessageListActivity"> android:parentActivityName=".MainActivity">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".MessageListActivity" /> android:value=".MainActivity" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SENDTO" /> <action android:name="android.intent.action.SENDTO" />
@ -79,7 +79,7 @@
<activity <activity
android:name=".SettingsActivity" android:name=".SettingsActivity"
android:label="@string/settings" android:label="@string/settings"
android:parentActivityName=".MessageListActivity"> android:parentActivityName=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MANAGE_NETWORK_USAGE" /> <action android:name="android.intent.action.MANAGE_NETWORK_USAGE" />

View File

@ -42,6 +42,8 @@ import org.slf4j.LoggerFactory;
import java.io.Serializable; import java.io.Serializable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import ch.dissem.apps.abit.listener.ActionBarListener; import ch.dissem.apps.abit.listener.ActionBarListener;
import ch.dissem.apps.abit.listener.ListSelectionListener; import ch.dissem.apps.abit.listener.ListSelectionListener;
@ -77,12 +79,12 @@ import static ch.dissem.apps.abit.synchronization.StubProvider.AUTHORITY;
* to listen for item selections. * to listen for item selections.
* </p> * </p>
*/ */
public class MessageListActivity extends AppCompatActivity public class MainActivity extends AppCompatActivity
implements ListSelectionListener<Serializable>, ActionBarListener { implements ListSelectionListener<Serializable>, ActionBarListener {
public static final String EXTRA_SHOW_MESSAGE = "ch.dissem.abit.ShowMessage"; public static final String EXTRA_SHOW_MESSAGE = "ch.dissem.abit.ShowMessage";
public static final String ACTION_SHOW_INBOX = "ch.dissem.abit.ShowInbox"; public static final String ACTION_SHOW_INBOX = "ch.dissem.abit.ShowInbox";
private static final Logger LOG = LoggerFactory.getLogger(MessageListActivity.class); private static final Logger LOG = LoggerFactory.getLogger(MainActivity.class);
private static final long SYNC_FREQUENCY = 15 * 60; // seconds private static final long SYNC_FREQUENCY = 15 * 60; // seconds
private static final int ADD_IDENTITY = 1; private static final int ADD_IDENTITY = 1;
@ -99,8 +101,8 @@ public class MessageListActivity extends AppCompatActivity
private static ServiceConnection connection = new ServiceConnection() { private static ServiceConnection connection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
MessageListActivity.service = new Messenger(service); MainActivity.service = new Messenger(service);
MessageListActivity.bound = true; MainActivity.bound = true;
} }
@Override @Override
@ -121,8 +123,10 @@ public class MessageListActivity extends AppCompatActivity
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
messageRepo = Singleton.getMessageRepository(this); messageRepo = Singleton.getMessageRepository(this);
addressRepo = Singleton.getAddressRepository(this); addressRepo = Singleton.getAddressRepository(this);
List<Label> labels = messageRepo.getLabels();
selectedLabel = messageRepo.getLabels().get(0); if (selectedLabel == null) {
selectedLabel = labels.get(0);
}
setContentView(R.layout.activity_message_list); setContentView(R.layout.activity_message_list);
@ -144,7 +148,7 @@ public class MessageListActivity extends AppCompatActivity
listFragment.setActivateOnItemClick(true); listFragment.setActivateOnItemClick(true);
} }
createDrawer(toolbar); createDrawer(toolbar, labels);
Singleton.getMessageListener(this).resetNotification(); Singleton.getMessageListener(this).resetNotification();
@ -185,7 +189,7 @@ public class MessageListActivity extends AppCompatActivity
} }
} }
private void createDrawer(Toolbar toolbar) { private void createDrawer(Toolbar toolbar, Collection<Label> labels) {
final ArrayList<IProfile> profiles = new ArrayList<>(); final ArrayList<IProfile> profiles = new ArrayList<>();
for (BitmessageAddress identity : addressRepo.getIdentities()) { for (BitmessageAddress identity : addressRepo.getIdentities()) {
LOG.info("Adding identity " + identity.getAddress()); LOG.info("Adding identity " + identity.getAddress());
@ -242,7 +246,7 @@ public class MessageListActivity extends AppCompatActivity
incomingHandler.updateAccountHeader(accountHeader); incomingHandler.updateAccountHeader(accountHeader);
ArrayList<IDrawerItem> drawerItems = new ArrayList<>(); ArrayList<IDrawerItem> drawerItems = new ArrayList<>();
for (Label label : messageRepo.getLabels()) { for (Label label : labels) {
PrimaryDrawerItem item = new PrimaryDrawerItem().withName(label.toString()).withTag(label); PrimaryDrawerItem item = new PrimaryDrawerItem().withName(label.toString()).withTag(label);
if (label.getType() == null) { if (label.getType() == null) {
item.withIcon(CommunityMaterial.Icon.cmd_label); item.withIcon(CommunityMaterial.Icon.cmd_label);
@ -335,7 +339,7 @@ public class MessageListActivity extends AppCompatActivity
} }
break; break;
case R.string.settings: case R.string.settings:
startActivity(new Intent(MessageListActivity.this, SettingsActivity.class)); startActivity(new Intent(MainActivity.this, SettingsActivity.class));
break; break;
case R.string.archive: case R.string.archive:
selectedLabel = null; selectedLabel = null;

View File

@ -3,7 +3,6 @@ package ch.dissem.apps.abit;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.NavUtils; import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
@ -13,7 +12,7 @@ import android.view.MenuItem;
* An activity representing a single Message detail screen. This * An activity representing a single Message detail screen. This
* activity is only used on handset devices. On tablet-size devices, * activity is only used on handset devices. On tablet-size devices,
* item details are presented side-by-side with a list of items * item details are presented side-by-side with a list of items
* in a {@link MessageListActivity}. * in a {@link MainActivity}.
* <p/> * <p/>
* This activity is mostly just a 'shell' activity containing nothing * This activity is mostly just a 'shell' activity containing nothing
* more than a {@link MessageDetailFragment}. * more than a {@link MessageDetailFragment}.
@ -64,7 +63,7 @@ public class MessageDetailActivity extends AppCompatActivity {
// //
// http://developer.android.com/design/patterns/navigation.html#up-vs-back // http://developer.android.com/design/patterns/navigation.html#up-vs-back
// //
NavUtils.navigateUpTo(this, new Intent(this, MessageListActivity.class)); NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View File

@ -5,7 +5,6 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.text.util.Linkify.TransformFilter; import android.text.util.Linkify.TransformFilter;
import android.util.Patterns;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -19,7 +18,6 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import java.util.Iterator; import java.util.Iterator;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.service.Singleton;
import ch.dissem.apps.abit.util.Drawables; import ch.dissem.apps.abit.util.Drawables;
@ -28,8 +26,6 @@ import ch.dissem.bitmessage.entity.Plaintext;
import ch.dissem.bitmessage.entity.valueobject.Label; import ch.dissem.bitmessage.entity.valueobject.Label;
import ch.dissem.bitmessage.ports.MessageRepository; import ch.dissem.bitmessage.ports.MessageRepository;
import static android.text.util.Linkify.ALL;
import static android.text.util.Linkify.EMAIL_ADDRESSES;
import static android.text.util.Linkify.WEB_URLS; import static android.text.util.Linkify.WEB_URLS;
import static ch.dissem.apps.abit.util.Constants.BITMESSAGE_ADDRESS_PATTERN; import static ch.dissem.apps.abit.util.Constants.BITMESSAGE_ADDRESS_PATTERN;
import static ch.dissem.apps.abit.util.Constants.BITMESSAGE_URL_SCHEMA; import static ch.dissem.apps.abit.util.Constants.BITMESSAGE_URL_SCHEMA;
@ -37,7 +33,7 @@ import static ch.dissem.apps.abit.util.Constants.BITMESSAGE_URL_SCHEMA;
/** /**
* A fragment representing a single Message detail screen. * A fragment representing a single Message detail screen.
* This fragment is either contained in a {@link MessageListActivity} * This fragment is either contained in a {@link MainActivity}
* in two-pane mode (on tablets) or a {@link MessageDetailActivity} * in two-pane mode (on tablets) or a {@link MessageDetailActivity}
* on handsets. * on handsets.
*/ */

View File

@ -1,7 +1,5 @@
package ch.dissem.apps.abit; package ch.dissem.apps.abit;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
@ -55,7 +53,7 @@ public class MessageListFragment extends AbstractItemListFragment<Plaintext> {
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
updateList(((MessageListActivity) getActivity()).getSelectedLabel()); doUpdateList(((MainActivity) getActivity()).getSelectedLabel());
} }
@Override @Override
@ -64,6 +62,10 @@ public class MessageListFragment extends AbstractItemListFragment<Plaintext> {
if (!isVisible()) return; if (!isVisible()) return;
doUpdateList(label);
}
private void doUpdateList(Label label) {
setListAdapter(new ArrayAdapter<Plaintext>( setListAdapter(new ArrayAdapter<Plaintext>(
getActivity(), getActivity(),
android.R.layout.simple_list_item_activated_1, android.R.layout.simple_list_item_activated_1,
@ -114,7 +116,7 @@ public class MessageListFragment extends AbstractItemListFragment<Plaintext> {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent intent = new Intent(getActivity().getApplicationContext(), ComposeMessageActivity.class); Intent intent = new Intent(getActivity().getApplicationContext(), ComposeMessageActivity.class);
intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, ((MessageListActivity)getActivity()).getSelectedIdentity()); intent.putExtra(ComposeMessageActivity.EXTRA_IDENTITY, ((MainActivity) getActivity()).getSelectedIdentity());
startActivity(intent); startActivity(intent);
} }
}); });

View File

@ -28,7 +28,7 @@ import android.view.MenuItem;
* An activity representing a single Subscription detail screen. This * An activity representing a single Subscription detail screen. This
* activity is only used on handset devices. On tablet-size devices, * activity is only used on handset devices. On tablet-size devices,
* item details are presented side-by-side with a list of items * item details are presented side-by-side with a list of items
* in a {@link MessageListActivity}. * in a {@link MainActivity}.
* <p/> * <p/>
* This activity is mostly just a 'shell' activity containing nothing * This activity is mostly just a 'shell' activity containing nothing
* more than a {@link SubscriptionDetailFragment}. * more than a {@link SubscriptionDetailFragment}.
@ -79,7 +79,7 @@ public class SubscriptionDetailActivity extends AppCompatActivity {
// //
// http://developer.android.com/design/patterns/navigation.html#up-vs-back // http://developer.android.com/design/patterns/navigation.html#up-vs-back
// //
NavUtils.navigateUpTo(this, new Intent(this, MessageListActivity.class)); NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View File

@ -34,7 +34,7 @@ import ch.dissem.bitmessage.entity.BitmessageAddress;
/** /**
* A fragment representing a single Message detail screen. * A fragment representing a single Message detail screen.
* This fragment is either contained in a {@link MessageListActivity} * This fragment is either contained in a {@link MainActivity}
* in two-pane mode (on tablets) or a {@link MessageDetailActivity} * in two-pane mode (on tablets) or a {@link MessageDetailActivity}
* on handsets. * on handsets.
*/ */

View File

@ -18,25 +18,13 @@ package ch.dissem.apps.abit.listener;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.support.v7.app.NotificationCompat; import android.support.v7.app.NotificationCompat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StyleSpan;
import ch.dissem.apps.abit.Identicon;
import ch.dissem.apps.abit.MessageListActivity;
import ch.dissem.apps.abit.R;
import ch.dissem.apps.abit.notification.NewMessageNotification; import ch.dissem.apps.abit.notification.NewMessageNotification;
import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.entity.Plaintext; import ch.dissem.bitmessage.entity.Plaintext;

View File

@ -10,7 +10,7 @@ import android.support.v7.app.NotificationCompat;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import ch.dissem.apps.abit.MessageListActivity; import ch.dissem.apps.abit.MainActivity;
import ch.dissem.apps.abit.R; import ch.dissem.apps.abit.R;
import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.BitmessageContext;
import ch.dissem.bitmessage.utils.Property; import ch.dissem.bitmessage.utils.Property;
@ -64,7 +64,7 @@ public class NetworkNotification extends AbstractNotification {
} }
builder.setContentText(info); builder.setContentText(info);
} }
Intent showMessageIntent = new Intent(ctx, MessageListActivity.class); Intent showMessageIntent = new Intent(ctx, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 1, showMessageIntent, 0); PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 1, showMessageIntent, 0);
builder.setContentIntent(pendingIntent); builder.setContentIntent(pendingIntent);
notification = builder.build(); notification = builder.build();

View File

@ -13,7 +13,7 @@ import android.text.style.StyleSpan;
import java.util.LinkedList; import java.util.LinkedList;
import ch.dissem.apps.abit.Identicon; import ch.dissem.apps.abit.Identicon;
import ch.dissem.apps.abit.MessageListActivity; import ch.dissem.apps.abit.MainActivity;
import ch.dissem.apps.abit.R; import ch.dissem.apps.abit.R;
import ch.dissem.bitmessage.entity.Plaintext; import ch.dissem.bitmessage.entity.Plaintext;
@ -38,8 +38,8 @@ public class NewMessageNotification extends AbstractNotification {
.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText)) .setStyle(new NotificationCompat.BigTextStyle().bigText(bigText))
.setContentInfo("Info"); .setContentInfo("Info");
Intent showMessageIntent = new Intent(ctx, MessageListActivity.class); Intent showMessageIntent = new Intent(ctx, MainActivity.class);
showMessageIntent.putExtra(MessageListActivity.EXTRA_SHOW_MESSAGE, plaintext); showMessageIntent.putExtra(MainActivity.EXTRA_SHOW_MESSAGE, plaintext);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, showMessageIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, showMessageIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent); builder.setContentIntent(pendingIntent);
@ -66,8 +66,8 @@ public class NewMessageNotification extends AbstractNotification {
} }
builder.setStyle(inboxStyle); builder.setStyle(inboxStyle);
Intent intent = new Intent(ctx, MessageListActivity.class); Intent intent = new Intent(ctx, MainActivity.class);
intent.setAction(MessageListActivity.ACTION_SHOW_INBOX); intent.setAction(MainActivity.ACTION_SHOW_INBOX);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 1, intent, 0); PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 1, intent, 0);
builder.setContentIntent(pendingIntent); builder.setContentIntent(pendingIntent);
notification = builder.build(); notification = builder.build();

View File

@ -5,7 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.NotificationCompat; import android.support.v7.app.NotificationCompat;
import ch.dissem.apps.abit.MessageListActivity; import ch.dissem.apps.abit.MainActivity;
import ch.dissem.apps.abit.R; import ch.dissem.apps.abit.R;
/** /**
@ -18,7 +18,7 @@ public class ProofOfWorkNotification extends AbstractNotification {
super(ctx); super(ctx);
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx); NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
Intent showMessageIntent = new Intent(ctx, MessageListActivity.class); Intent showMessageIntent = new Intent(ctx, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, showMessageIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(ctx, 0, showMessageIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)

View File

@ -1,21 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp"> android:padding="24dp">
<TextView <TextView
android:id="@+id/address" android:id="@+id/address"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="BM-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" android:text="BM-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textSize="10dp"
tools:ignore="SpUsage" />
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:id="@+id/label_wrapper" android:id="@+id/label_wrapper"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/address"> android:layout_alignLeft="@+id/address"
android:layout_alignStart="@+id/address"
android:layout_below="@+id/address"
android:layout_marginTop="16dp">
<EditText <EditText
android:id="@+id/label" android:id="@+id/label"
@ -30,8 +37,9 @@
android:id="@+id/subscribe" android:id="@+id/subscribe"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/address"
android:layout_alignStart="@+id/address"
android:layout_below="@+id/label_wrapper" android:layout_below="@+id/label_wrapper"
android:layout_centerHorizontal="true"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/subscribe" /> android:text="@string/subscribe" />