Fixes / Improvements
- some fixes for tablets - updated API - removed BitmessageService (I really hope it won't be needed)
This commit is contained in:
parent
a7ebfefdbc
commit
3c7fd02613
@ -84,13 +84,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service
|
|
||||||
android:name=".service.BitmessageService"
|
|
||||||
android:enabled="true"
|
|
||||||
android:exported="true"
|
|
||||||
android:permission="">
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".OpenBitmessageLinkActivity"
|
android:name=".OpenBitmessageLinkActivity"
|
||||||
android:label="@string/title_activity_open_bitmessage_link"
|
android:label="@string/title_activity_open_bitmessage_link"
|
||||||
|
@ -9,6 +9,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.listeners.ActionBarListener;
|
import ch.dissem.apps.abit.listeners.ActionBarListener;
|
||||||
import ch.dissem.apps.abit.listeners.ListSelectionListener;
|
import ch.dissem.apps.abit.listeners.ListSelectionListener;
|
||||||
import ch.dissem.apps.abit.service.Singleton;
|
import ch.dissem.apps.abit.service.Singleton;
|
||||||
@ -17,6 +18,7 @@ import ch.dissem.bitmessage.entity.BitmessageAddress;
|
|||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
import ch.dissem.bitmessage.entity.Plaintext;
|
||||||
import ch.dissem.bitmessage.entity.Streamable;
|
import ch.dissem.bitmessage.entity.Streamable;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
import ch.dissem.bitmessage.entity.valueobject.Label;
|
||||||
|
|
||||||
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
|
import com.mikepenz.community_material_typeface_library.CommunityMaterial;
|
||||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||||
import com.mikepenz.iconics.IconicsDrawable;
|
import com.mikepenz.iconics.IconicsDrawable;
|
||||||
@ -31,6 +33,7 @@ import com.mikepenz.materialdrawer.model.SecondaryDrawerItem;
|
|||||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
|
import com.mikepenz.materialdrawer.model.interfaces.IProfile;
|
||||||
import com.mikepenz.materialdrawer.model.interfaces.Nameable;
|
import com.mikepenz.materialdrawer.model.interfaces.Nameable;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -94,10 +97,6 @@ public class MessageListActivity extends AppCompatActivity
|
|||||||
// res/values-sw600dp). If this view is present, then the
|
// res/values-sw600dp). If this view is present, then the
|
||||||
// activity should be in two-pane mode.
|
// activity should be in two-pane mode.
|
||||||
twoPane = true;
|
twoPane = true;
|
||||||
|
|
||||||
// In two-pane mode, list items should be given the
|
|
||||||
// 'activated' state when touched.
|
|
||||||
listFragment.setActivateOnItemClick(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createDrawer(toolbar);
|
createDrawer(toolbar);
|
||||||
@ -106,7 +105,18 @@ public class MessageListActivity extends AppCompatActivity
|
|||||||
|
|
||||||
// handle intents
|
// handle intents
|
||||||
if (getIntent().hasExtra(EXTRA_SHOW_MESSAGE)) {
|
if (getIntent().hasExtra(EXTRA_SHOW_MESSAGE)) {
|
||||||
onItemSelected((Plaintext) getIntent().getSerializableExtra(EXTRA_SHOW_MESSAGE));
|
onItemSelected(getIntent().getSerializableExtra(EXTRA_SHOW_MESSAGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (twoPane) {
|
||||||
|
// In two-pane mode, list items should be given the
|
||||||
|
// 'activated' state when touched.
|
||||||
|
((MessageListFragment) getSupportFragmentManager().findFragmentById(R.id.item_list))
|
||||||
|
.setActivateOnItemClick(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +281,7 @@ public class MessageListActivity extends AppCompatActivity
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.sync_disabled:
|
case R.id.sync_disabled:
|
||||||
bmc.startup(Singleton.getMessageListener(this));
|
bmc.startup();
|
||||||
updateMenu();
|
updateMenu();
|
||||||
return true;
|
return true;
|
||||||
case R.id.sync_enabled:
|
case R.id.sync_enabled:
|
||||||
|
@ -20,12 +20,14 @@ import android.content.ContentValues;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteConstraintException;
|
import android.database.sqlite.SQLiteConstraintException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import ch.dissem.bitmessage.entity.ObjectMessage;
|
import ch.dissem.bitmessage.entity.ObjectMessage;
|
||||||
import ch.dissem.bitmessage.entity.payload.ObjectType;
|
import ch.dissem.bitmessage.entity.payload.ObjectType;
|
||||||
import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
|
import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
|
||||||
import ch.dissem.bitmessage.factory.Factory;
|
import ch.dissem.bitmessage.factory.Factory;
|
||||||
import ch.dissem.bitmessage.ports.Inventory;
|
import ch.dissem.bitmessage.ports.Inventory;
|
||||||
import ch.dissem.bitmessage.utils.Encode;
|
import ch.dissem.bitmessage.utils.Encode;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -177,6 +179,17 @@ public class AndroidInventory implements Inventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(ObjectMessage object) {
|
||||||
|
SQLiteDatabase db = sql.getReadableDatabase();
|
||||||
|
Cursor c = db.query(
|
||||||
|
TABLE_NAME, new String[]{COLUMN_STREAM},
|
||||||
|
"hash = X'" + object.getInventoryVector() + "'",
|
||||||
|
null, null, null, null
|
||||||
|
);
|
||||||
|
return c.getColumnCount() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
SQLiteDatabase db = sql.getWritableDatabase();
|
SQLiteDatabase db = sql.getWritableDatabase();
|
||||||
|
@ -21,6 +21,7 @@ import android.content.Context;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteConstraintException;
|
import android.database.sqlite.SQLiteConstraintException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.R;
|
import ch.dissem.apps.abit.R;
|
||||||
import ch.dissem.bitmessage.InternalContext;
|
import ch.dissem.bitmessage.InternalContext;
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||||
@ -29,6 +30,7 @@ import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
|
|||||||
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 ch.dissem.bitmessage.utils.Encode;
|
import ch.dissem.bitmessage.utils.Encode;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -184,6 +186,11 @@ public class AndroidMessageRepository implements MessageRepository, InternalCont
|
|||||||
return find("status='" + status.name() + "' AND recipient='" + recipient.getAddress() + "'");
|
return find("status='" + status.name() + "' AND recipient='" + recipient.getAddress() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Plaintext> findMessages(BitmessageAddress sender) {
|
||||||
|
return find("sender=" + sender.getAddress());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Plaintext> findMessages(Plaintext.Status status) {
|
public List<Plaintext> findMessages(Plaintext.Status status) {
|
||||||
return find("status='" + status.name() + "'");
|
return find("status='" + status.name() + "'");
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
package ch.dissem.apps.abit.service;
|
|
||||||
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.support.v7.app.NotificationCompat;
|
|
||||||
import ch.dissem.apps.abit.R;
|
|
||||||
import ch.dissem.bitmessage.BitmessageContext;
|
|
||||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
|
||||||
import ch.dissem.bitmessage.entity.Plaintext;
|
|
||||||
import ch.dissem.bitmessage.entity.valueobject.Label;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BitmessageService extends Service {
|
|
||||||
private static BitmessageContext ctx;
|
|
||||||
private ServiceBinder binder = new ServiceBinder();
|
|
||||||
private NotificationCompat.Builder ongoingNotificationBuilder = new NotificationCompat.Builder(this);
|
|
||||||
private NotificationManager notifyManager;
|
|
||||||
|
|
||||||
public BitmessageService() {
|
|
||||||
if (ctx == null) {
|
|
||||||
ctx = Singleton.getBitmessageContext(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
ongoingNotificationBuilder.setOngoing(true);
|
|
||||||
ongoingNotificationBuilder.setContentTitle(getString(R.string.bitmessage_active));
|
|
||||||
ongoingNotificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
|
||||||
// ongoingNotificationBuilder.setSmallIcon(R.drawable.ic_bitmessage);
|
|
||||||
notifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startService() {
|
|
||||||
if (!ctx.isRunning()) {
|
|
||||||
notifyManager.notify(0, ongoingNotificationBuilder.build());
|
|
||||||
ctx.startup(new BitmessageContext.Listener() {
|
|
||||||
@Override
|
|
||||||
public void receive(Plaintext plaintext) {
|
|
||||||
Notification notification = new NotificationCompat.Builder(BitmessageService.this)
|
|
||||||
.setContentTitle(plaintext.getSubject())
|
|
||||||
.setContentText(plaintext.getText())
|
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
|
||||||
.setPriority(plaintext.getType() == Plaintext.Type.BROADCAST
|
|
||||||
? NotificationCompat.PRIORITY_DEFAULT
|
|
||||||
: NotificationCompat.PRIORITY_HIGH)
|
|
||||||
.build();
|
|
||||||
notifyManager.notify(plaintext.getInventoryVector().hashCode(), notification);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopService() {
|
|
||||||
ctx.shutdown();
|
|
||||||
notifyManager.cancel(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<BitmessageAddress> getIdentities() {
|
|
||||||
return ctx.addresses().getIdentities();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<BitmessageAddress> getContacts() {
|
|
||||||
return ctx.addresses().getContacts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Plaintext> getMessages(Label label) {
|
|
||||||
return ctx.messages().findMessages(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return binder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ServiceBinder extends Binder {
|
|
||||||
public BitmessageService getService() {
|
|
||||||
return BitmessageService.this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum NetworkChoice {
|
|
||||||
/**
|
|
||||||
* A full node, receiving and relaying objects all the time.
|
|
||||||
*/
|
|
||||||
FULL,
|
|
||||||
/**
|
|
||||||
* Connect to a trusted node from time to time to get all new objects and disconnect afterwards
|
|
||||||
* (see {@link android.content.AbstractThreadedSyncAdapter})
|
|
||||||
*/
|
|
||||||
TRUSTED,
|
|
||||||
/**
|
|
||||||
* Offline
|
|
||||||
*/
|
|
||||||
NONE
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,8 @@
|
|||||||
package ch.dissem.apps.abit.service;
|
package ch.dissem.apps.abit.service;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import ch.dissem.apps.abit.listeners.MessageListener;
|
import ch.dissem.apps.abit.listeners.MessageListener;
|
||||||
import ch.dissem.apps.abit.repositories.AndroidAddressRepository;
|
import ch.dissem.apps.abit.repositories.AndroidAddressRepository;
|
||||||
import ch.dissem.apps.abit.repositories.AndroidInventory;
|
import ch.dissem.apps.abit.repositories.AndroidInventory;
|
||||||
@ -18,11 +20,11 @@ public class Singleton {
|
|||||||
private static BitmessageContext bitmessageContext;
|
private static BitmessageContext bitmessageContext;
|
||||||
private static MessageListener messageListener;
|
private static MessageListener messageListener;
|
||||||
|
|
||||||
public static BitmessageContext getBitmessageContext(Context ctx) {
|
public static BitmessageContext getBitmessageContext(Context context) {
|
||||||
if (bitmessageContext == null) {
|
if (bitmessageContext == null) {
|
||||||
synchronized (Singleton.class) {
|
synchronized (Singleton.class) {
|
||||||
if (bitmessageContext == null) {
|
if (bitmessageContext == null) {
|
||||||
ctx = ctx.getApplicationContext();
|
final Context ctx = context.getApplicationContext();
|
||||||
SqlHelper sqlHelper = new SqlHelper(ctx);
|
SqlHelper sqlHelper = new SqlHelper(ctx);
|
||||||
bitmessageContext = new BitmessageContext.Builder()
|
bitmessageContext = new BitmessageContext.Builder()
|
||||||
.security(new SpongySecurity())
|
.security(new SpongySecurity())
|
||||||
@ -31,6 +33,7 @@ public class Singleton {
|
|||||||
.addressRepo(new AndroidAddressRepository(sqlHelper))
|
.addressRepo(new AndroidAddressRepository(sqlHelper))
|
||||||
.messageRepo(new AndroidMessageRepository(sqlHelper, ctx))
|
.messageRepo(new AndroidMessageRepository(sqlHelper, ctx))
|
||||||
.networkHandler(new DefaultNetworkHandler())
|
.networkHandler(new DefaultNetworkHandler())
|
||||||
|
.listener(getMessageListener(ctx))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -8,7 +9,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
android:elevation="4dp"/>
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
android:elevation="4dp" />
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
@ -34,6 +37,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
tools:context=".MessageListActivity"
|
||||||
tools:layout="@android:layout/list_content"/>
|
tools:layout="@android:layout/list_content"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user