Made search for sender public

This commit is contained in:
M66B
2019-05-13 14:08:51 +02:00
parent a8eed5fead
commit 35c7993d92
4 changed files with 44 additions and 12 deletions

View File

@@ -133,6 +133,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
static final String ACTION_VIEW_FOLDERS = BuildConfig.APPLICATION_ID + ".VIEW_FOLDERS";
static final String ACTION_VIEW_MESSAGES = BuildConfig.APPLICATION_ID + ".VIEW_MESSAGES";
static final String ACTION_SEARCH = BuildConfig.APPLICATION_ID + ".SEARCH";
static final String ACTION_VIEW_THREAD = BuildConfig.APPLICATION_ID + ".VIEW_THREAD";
static final String ACTION_STORE_RAW = BuildConfig.APPLICATION_ID + ".STORE_RAW";
static final String ACTION_EDIT_FOLDER = BuildConfig.APPLICATION_ID + ".EDIT_FOLDER";
@@ -534,6 +535,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
IntentFilter iff = new IntentFilter();
iff.addAction(ACTION_VIEW_FOLDERS);
iff.addAction(ACTION_VIEW_MESSAGES);
iff.addAction(ACTION_SEARCH);
iff.addAction(ACTION_VIEW_THREAD);
iff.addAction(ACTION_STORE_RAW);
iff.addAction(ACTION_EDIT_FOLDER);
@@ -1012,6 +1014,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
onViewFolders(intent);
else if (ACTION_VIEW_MESSAGES.equals(action))
onViewMessages(intent);
else if (ACTION_SEARCH.equals(action))
onSearchMessages(intent);
else if (ACTION_VIEW_THREAD.equals(action))
onViewThread(intent);
else if (ACTION_STORE_RAW.equals(action))
@@ -1061,6 +1065,14 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
fragmentTransaction.commit();
}
private void onSearchMessages(Intent intent) {
long folder = intent.getLongExtra("folder", -1);
String query = intent.getStringExtra("search");
FragmentMessages.search(
this, this, getSupportFragmentManager(),
folder, false, query);
}
private void onViewThread(Intent intent) {
boolean found = intent.getBooleanExtra("found", false);

View File

@@ -26,7 +26,6 @@ import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
@@ -144,7 +143,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean hasWebView;
private boolean contacts;
private boolean search;
private float textSize;
private boolean date;
@@ -759,9 +757,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpExpanded.setVisibility(View.VISIBLE);
boolean hasFrom = (message.from != null && message.from.length > 0);
boolean hasTo = (message.to != null && message.to.length > 0);
boolean hasChannel = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);
ibSearchContact.setVisibility(show_addresses && search && BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
ibSearchContact.setVisibility(show_addresses && (hasFrom || hasTo) ? View.VISIBLE : View.GONE);
ibNotifyContact.setVisibility(show_addresses && hasChannel && hasFrom ? View.VISIBLE : View.GONE);
ibAddContact.setVisibility(show_addresses && contacts && hasFrom ? View.VISIBLE : View.GONE);
@@ -1205,11 +1204,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onExecuted(Bundle args, Address[] addresses) {
if (addresses != null && addresses.length > 0) {
Intent search = new Intent(context, ActivityView.class);
search.putExtra(Intent.EXTRA_PROCESS_TEXT, ((InternetAddress) addresses[0]).getAddress());
context.startActivity(search);
}
String query = ((InternetAddress) addresses[0]).getAddress();
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_SEARCH)
.putExtra("folder", -1L)
.putExtra("query", query));
}
@Override
@@ -3012,9 +3012,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.hasWebView = Helper.hasWebView(context);
this.contacts = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);
this.search = (context.getPackageManager().getComponentEnabledSetting(
new ComponentName(context, ActivitySearch.class)) ==
PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
this.textSize = Helper.getTextSize(context, zoom);
this.date = prefs.getBoolean("date", true);