Moved manage local contacts to send settings

This commit is contained in:
M66B 2019-10-16 15:12:39 +02:00
parent 52639dd5c5
commit 1e200e3e10
4 changed files with 44 additions and 22 deletions

View File

@ -122,6 +122,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
static final String ACTION_VIEW_IDENTITIES = BuildConfig.APPLICATION_ID + ".ACTION_VIEW_IDENTITIES";
static final String ACTION_EDIT_ACCOUNT = BuildConfig.APPLICATION_ID + ".EDIT_ACCOUNT";
static final String ACTION_EDIT_IDENTITY = BuildConfig.APPLICATION_ID + ".EDIT_IDENTITY";
static final String ACTION_MANAGE_LOCAL_CONTACTS = BuildConfig.APPLICATION_ID + ".LOCAL_CONTACTS";
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -191,13 +192,14 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
}
}));
menus.add(new NavMenuItem(R.drawable.baseline_reorder_24, R.string.title_setup_reorder_folders, new Runnable() {
NavMenuItem order = new NavMenuItem(R.drawable.baseline_reorder_24, R.string.title_setup_reorder_folders, new Runnable() {
@Override
public void run() {
drawerLayout.closeDrawer(drawerContainer);
onMenuOrder(R.string.title_setup_reorder_folders, TupleFolderSort.class);
}
}));
});
menus.add(order);
if (Helper.canAuthenticate(this))
menus.add(new NavMenuItem(R.drawable.baseline_fingerprint_24, R.string.title_setup_authentication, new Runnable() {
@ -206,15 +208,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
drawerLayout.closeDrawer(drawerContainer);
onMenuBiometrics();
}
}));
menus.add(new NavMenuItem(R.drawable.baseline_person_24, R.string.menu_contacts, new Runnable() {
@Override
public void run() {
drawerLayout.closeDrawer(drawerContainer);
onMenuContacts();
}
}).setSeparated());
}).setSeparated());
else
order.setSeparated();
menus.add(new NavMenuItem(R.drawable.baseline_help_24, R.string.menu_legend, new Runnable() {
@Override
@ -304,6 +300,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
iff.addAction(ACTION_VIEW_IDENTITIES);
iff.addAction(ACTION_EDIT_ACCOUNT);
iff.addAction(ACTION_EDIT_IDENTITY);
iff.addAction(ACTION_MANAGE_LOCAL_CONTACTS);
lbm.registerReceiver(receiver, iff);
}
@ -440,15 +437,6 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
});
}
private void onMenuContacts() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("contacts", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentContacts()).addToBackStack("contacts");
fragmentTransaction.commit();
}
private void onMenuLegend() {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
getSupportFragmentManager().popBackStack("legend", FragmentManager.POP_BACK_STACK_INCLUSIVE);
@ -1082,6 +1070,12 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
fragmentTransaction.commit();
}
private void onManageLocalContacts(Intent intent) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentContacts()).addToBackStack("contacts");
fragmentTransaction.commit();
}
private static Intent getIntentExport() {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
@ -1171,6 +1165,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
onEditAccount(intent);
else if (ACTION_EDIT_IDENTITY.equals(action))
onEditIdentity(intent);
else if (ACTION_MANAGE_LOCAL_CONTACTS.equals(action))
onManageLocalContacts(intent);
}
}
};

View File

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2019 by Marcel Bokhorst (M66B)
*/
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -28,6 +29,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.TextView;
@ -37,12 +39,14 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import androidx.lifecycle.Lifecycle;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
public class FragmentOptionsSend extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swKeyboard;
private SwitchCompat swSuggestSent;
private SwitchCompat swSuggestReceived;
private Button btnLocalContacts;
private SwitchCompat swPrefixOnce;
private SwitchCompat swPlainOnly;
private SwitchCompat swUsenetSignature;
@ -72,6 +76,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swKeyboard = view.findViewById(R.id.swKeyboard);
swSuggestSent = view.findViewById(R.id.swSuggestSent);
swSuggestReceived = view.findViewById(R.id.swSuggestReceived);
btnLocalContacts = view.findViewById(R.id.btnLocalContacts);
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swPlainOnly = view.findViewById(R.id.swPlainOnly);
swUsenetSignature = view.findViewById(R.id.swUsenetSignature);
@ -110,6 +115,14 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
btnLocalContacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_MANAGE_LOCAL_CONTACTS));
}
});
swPrefixOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {

View File

@ -71,6 +71,19 @@
app:layout_constraintTop_toBottomOf="@id/swSuggestSent"
app:switchPadding="12dp" />
<Button
android:id="@+id/btnLocalContacts"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@string/title_setup_manage"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSuggestReceived" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPrefixOnce"
android:layout_width="0dp"
@ -80,7 +93,7 @@
android:text="@string/title_advanced_prefix_once"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSuggestReceived"
app:layout_constraintTop_toBottomOf="@id/btnLocalContacts"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -342,7 +342,7 @@
<string name="title_advanced_sync_folders_hint">Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too</string>
<string name="title_advanced_sync_delay_hint">This will slow down synchronizing messages</string>
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android</string>
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string>
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
<string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string>