Enable search on primary archive

pull/147/head
M66B 6 years ago
parent 16f8759a08
commit 3304732e9e

@ -78,6 +78,7 @@
<activity <activity
android:name=".ActivitySearch" android:name=".ActivitySearch"
android:enabled="false"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:exported="true" android:exported="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"

@ -385,12 +385,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
protected Long onLoad(Context context, Bundle args) { protected Long onLoad(Context context, Bundle args) {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityFolder archive = db.folder().getPrimaryArchive();
if (archive == null)
throw new IllegalArgumentException(getString(R.string.title_no_primary_archive));
db.message().resetSearch(); db.message().resetSearch();
EntityFolder archive = db.folder().getPrimaryArchive();
if (archive == null)
throw new IllegalArgumentException("No primary archive");
return archive.id; return archive.id;
} }

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.Manifest; import android.Manifest;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -93,7 +94,6 @@ public class FragmentSetup extends FragmentEx {
private Button btnAccount; private Button btnAccount;
private TextView tvAccountDone; private TextView tvAccountDone;
private TextView tvNoPrimaryDrafts; private TextView tvNoPrimaryDrafts;
private TextView tvNoPrimaryArchive;
private Button btnIdentity; private Button btnIdentity;
private TextView tvIdentityDone; private TextView tvIdentityDone;
@ -138,7 +138,6 @@ public class FragmentSetup extends FragmentEx {
btnAccount = view.findViewById(R.id.btnAccount); btnAccount = view.findViewById(R.id.btnAccount);
tvAccountDone = view.findViewById(R.id.tvAccountDone); tvAccountDone = view.findViewById(R.id.tvAccountDone);
tvNoPrimaryDrafts = view.findViewById(R.id.tvNoPrimaryDrafts); tvNoPrimaryDrafts = view.findViewById(R.id.tvNoPrimaryDrafts);
tvNoPrimaryArchive = view.findViewById(R.id.tvNoPrimaryArchive);
btnIdentity = view.findViewById(R.id.btnIdentity); btnIdentity = view.findViewById(R.id.btnIdentity);
tvIdentityDone = view.findViewById(R.id.tvIdentityDone); tvIdentityDone = view.findViewById(R.id.tvIdentityDone);
@ -286,7 +285,6 @@ public class FragmentSetup extends FragmentEx {
tvAccountDone.setText(null); tvAccountDone.setText(null);
tvAccountDone.setCompoundDrawables(null, null, null, null); tvAccountDone.setCompoundDrawables(null, null, null, null);
tvNoPrimaryDrafts.setVisibility(View.GONE); tvNoPrimaryDrafts.setVisibility(View.GONE);
tvNoPrimaryArchive.setVisibility(View.GONE);
btnIdentity.setEnabled(false); btnIdentity.setEnabled(false);
tvIdentityDone.setText(null); tvIdentityDone.setText(null);
@ -386,7 +384,13 @@ public class FragmentSetup extends FragmentEx {
livePrimaryArchive.observe(getViewLifecycleOwner(), new Observer<EntityFolder>() { livePrimaryArchive.observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
@Override @Override
public void onChanged(EntityFolder archive) { public void onChanged(EntityFolder archive) {
tvNoPrimaryArchive.setVisibility(done && archive == null ? View.VISIBLE : View.GONE); PackageManager pm = getContext().getPackageManager();
pm.setComponentEnabledSetting(
new ComponentName(getContext(), ActivitySearch.class),
archive == null
? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
: PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
} }
}); });
} }

@ -66,18 +66,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAccountDone" /> app:layout_constraintTop_toBottomOf="@id/tvAccountDone" />
<TextView
android:id="@+id/tvNoPrimaryArchive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_no_primary_archive"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNoPrimaryDrafts" />
<View <View
android:id="@+id/vSeparatorAccount" android:id="@+id/vSeparatorAccount"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -85,7 +73,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:background="?attr/colorSeparator" android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNoPrimaryArchive" /> app:layout_constraintTop_toBottomOf="@id/tvNoPrimaryDrafts" />
<!-- identity --> <!-- identity -->

@ -194,7 +194,6 @@
<string name="title_no_password">Password missing</string> <string name="title_no_password">Password missing</string>
<string name="title_no_drafts">No drafts folder selected</string> <string name="title_no_drafts">No drafts folder selected</string>
<string name="title_no_primary_drafts">No primary account or no drafts folder</string> <string name="title_no_primary_drafts">No primary account or no drafts folder</string>
<string name="title_no_primary_archive">No primary account or no archive folder</string>
<string name="title_no_idle">This provider does not support push messages. This will delay reception of new messages and increase battery usage.</string> <string name="title_no_idle">This provider does not support push messages. This will delay reception of new messages and increase battery usage.</string>
<string name="title_account_delete">Delete this account permanently?</string> <string name="title_account_delete">Delete this account permanently?</string>
<string name="title_identity_delete">Delete this identity permanently?</string> <string name="title_identity_delete">Delete this identity permanently?</string>

Loading…
Cancel
Save