mirror of https://github.com/M66B/FairEmail.git
Simplify folder names
This commit is contained in:
parent
dc7879ccc1
commit
d5d373f835
|
@ -828,20 +828,21 @@ class Core {
|
|||
Map<String, List<EntityFolder>> parentFolders = new HashMap<>();
|
||||
for (Folder ifolder : ifolders) {
|
||||
String fullName = ifolder.getFullName();
|
||||
String[] name = fullName.split("[" + separator + "]");
|
||||
String childName = name[name.length - 1];
|
||||
boolean subscribed = subscription.contains(fullName);
|
||||
String[] attr = ((IMAPFolder) ifolder).getAttributes();
|
||||
String type = EntityFolder.getType(attr, fullName);
|
||||
|
||||
if (EntityFolder.INBOX.equals(type))
|
||||
childName = null;
|
||||
|
||||
Log.i(account.name + ":" + fullName + " subscribed=" + subscribed +
|
||||
" type=" + type + " attrs=" + TextUtils.join(" ", attr));
|
||||
|
||||
if (type != null) {
|
||||
names.remove(fullName);
|
||||
|
||||
String display = null;
|
||||
if (account.prefix != null && fullName.startsWith(account.prefix + separator))
|
||||
display = fullName.substring(account.prefix.length() + 1);
|
||||
|
||||
EntityFolder folder;
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
@ -851,7 +852,7 @@ class Core {
|
|||
folder = new EntityFolder();
|
||||
folder.account = account.id;
|
||||
folder.name = fullName;
|
||||
folder.display = display;
|
||||
folder.display = childName;
|
||||
folder.type = (EntityFolder.SYSTEM.equals(type) ? type : EntityFolder.USER);
|
||||
folder.synchronize = false;
|
||||
folder.subscribed = subscribed;
|
||||
|
@ -866,16 +867,11 @@ class Core {
|
|||
if (folder.subscribed == null || !folder.subscribed.equals(subscribed))
|
||||
db.folder().setFolderSubscribed(folder.id, subscribed);
|
||||
|
||||
if (folder.display == null && display != null) {
|
||||
db.folder().setFolderDisplay(folder.id, display);
|
||||
EntityLog.log(context, account.name + ":" + folder.name +
|
||||
" removed prefix display=" + display + " separator=" + separator);
|
||||
}
|
||||
if (folder.display == null && childName != null)
|
||||
db.folder().setFolderDisplay(folder.id, childName);
|
||||
|
||||
// Compatibility
|
||||
if ("Inbox_sub".equals(folder.type))
|
||||
db.folder().setFolderType(folder.id, EntityFolder.USER);
|
||||
else if (EntityFolder.USER.equals(folder.type) && EntityFolder.SYSTEM.equals(type))
|
||||
if (EntityFolder.USER.equals(folder.type) && EntityFolder.SYSTEM.equals(type))
|
||||
db.folder().setFolderType(folder.id, type);
|
||||
else if (EntityFolder.SYSTEM.equals(folder.type) && EntityFolder.USER.equals(type))
|
||||
db.folder().setFolderType(folder.id, type);
|
||||
|
|
|
@ -52,7 +52,6 @@ public class EmailProvider {
|
|||
public int order;
|
||||
public String link;
|
||||
public String type;
|
||||
public String prefix;
|
||||
public String imap_host;
|
||||
public boolean imap_starttls;
|
||||
public int imap_port;
|
||||
|
@ -108,7 +107,6 @@ public class EmailProvider {
|
|||
provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
|
||||
provider.link = xml.getAttributeValue(null, "link");
|
||||
provider.type = xml.getAttributeValue(null, "type");
|
||||
provider.prefix = xml.getAttributeValue(null, "prefix");
|
||||
} else if ("imap".equals(name)) {
|
||||
provider.imap_host = xml.getAttributeValue(null, "host");
|
||||
provider.imap_port = xml.getAttributeIntValue(null, "port", 0);
|
||||
|
@ -407,12 +405,6 @@ public class EmailProvider {
|
|||
}
|
||||
|
||||
private static EmailProvider addSpecials(Context context, EmailProvider provider) {
|
||||
for (EmailProvider predefined : loadProfiles(context))
|
||||
if (provider.imap_host.equals(predefined.imap_host)) {
|
||||
provider.prefix = predefined.prefix;
|
||||
break;
|
||||
}
|
||||
|
||||
if ("imap.gmail.com".equals(provider.imap_host))
|
||||
addDocumentation(provider,
|
||||
"https://www.google.com/settings/security/lesssecureapps",
|
||||
|
|
|
@ -86,7 +86,7 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
public Long swipe_right;
|
||||
@NonNull
|
||||
public Integer poll_interval; // keep-alive interval
|
||||
public String prefix; // namespace
|
||||
public String prefix; // namespace, obsolete
|
||||
|
||||
public Long created;
|
||||
public Boolean tbd;
|
||||
|
@ -156,7 +156,6 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
json.put("swipe_right", swipe_right);
|
||||
|
||||
json.put("poll_interval", poll_interval);
|
||||
json.put("prefix", prefix);
|
||||
// not created
|
||||
// not state
|
||||
// not error
|
||||
|
@ -197,8 +196,6 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
account.swipe_right = json.getLong("swipe_right");
|
||||
|
||||
account.poll_interval = json.getInt("poll_interval");
|
||||
if (json.has("prefix") && !json.isNull("prefix"))
|
||||
account.prefix = json.getString("prefix");
|
||||
|
||||
return account;
|
||||
}
|
||||
|
@ -225,7 +222,6 @@ public class EntityAccount extends EntityOrder implements Serializable {
|
|||
Objects.equals(this.swipe_left, other.swipe_left) &&
|
||||
Objects.equals(this.swipe_right, other.swipe_right) &&
|
||||
this.poll_interval.equals(other.poll_interval) &&
|
||||
Objects.equals(this.prefix, other.prefix) &&
|
||||
Objects.equals(this.created, other.created) &&
|
||||
Objects.equals(this.tbd, other.tbd) &&
|
||||
Objects.equals(this.state, other.state) &&
|
||||
|
|
|
@ -308,7 +308,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (display == null ? name : display);
|
||||
return name;
|
||||
}
|
||||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
|
|
|
@ -118,7 +118,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
private CheckBox cbNotify;
|
||||
private CheckBox cbBrowse;
|
||||
private EditText etInterval;
|
||||
private EditText etPrefix;
|
||||
|
||||
private Button btnCheck;
|
||||
private ContentLoadingProgressBar pbCheck;
|
||||
|
@ -195,7 +194,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
cbNotify = view.findViewById(R.id.cbNotify);
|
||||
cbBrowse = view.findViewById(R.id.cbBrowse);
|
||||
etInterval = view.findViewById(R.id.etInterval);
|
||||
etPrefix = view.findViewById(R.id.etPrefix);
|
||||
|
||||
btnCheck = view.findViewById(R.id.btnCheck);
|
||||
pbCheck = view.findViewById(R.id.pbCheck);
|
||||
|
@ -261,7 +259,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
etRealm.setEnabled(true);
|
||||
|
||||
etName.setText(position > 1 ? provider.name : null);
|
||||
etPrefix.setText(provider.prefix);
|
||||
|
||||
grpFolders.setVisibility(View.GONE);
|
||||
btnSave.setVisibility(View.GONE);
|
||||
|
@ -762,7 +759,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
args.putBoolean("notify", cbNotify.isChecked());
|
||||
args.putBoolean("browse", cbBrowse.isChecked());
|
||||
args.putString("interval", etInterval.getText().toString());
|
||||
args.putString("prefix", etPrefix.getText().toString());
|
||||
|
||||
args.putSerializable("drafts", drafts);
|
||||
args.putSerializable("sent", sent);
|
||||
|
@ -811,7 +807,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
boolean notify = args.getBoolean("notify");
|
||||
boolean browse = args.getBoolean("browse");
|
||||
String interval = args.getString("interval");
|
||||
String prefix = args.getString("prefix");
|
||||
|
||||
EntityFolder drafts = (EntityFolder) args.getSerializable("drafts");
|
||||
EntityFolder sent = (EntityFolder) args.getSerializable("sent");
|
||||
|
@ -837,8 +832,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
|
||||
if (Color.TRANSPARENT == color)
|
||||
color = null;
|
||||
if (TextUtils.isEmpty(prefix))
|
||||
prefix = null;
|
||||
|
||||
Character separator = null;
|
||||
long now = new Date().getTime();
|
||||
|
@ -854,7 +847,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
!user.equals(account.user) || !password.equals(account.password) ||
|
||||
!Objects.equals(realm, accountRealm)));
|
||||
boolean reload = (check || account == null ||
|
||||
!Objects.equals(account.prefix, prefix) ||
|
||||
account.synchronize != synchronize ||
|
||||
account.notify != notify ||
|
||||
!account.poll_interval.equals(Integer.parseInt(interval)));
|
||||
|
@ -931,7 +923,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
account.notify = notify;
|
||||
account.browse = browse;
|
||||
account.poll_interval = Integer.parseInt(interval);
|
||||
account.prefix = prefix;
|
||||
|
||||
if (!update)
|
||||
account.created = now;
|
||||
|
@ -1018,9 +1009,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
db.folder().setFoldersUser(account.id);
|
||||
|
||||
for (EntityFolder folder : folders) {
|
||||
if (account.prefix != null && folder.name.startsWith(account.prefix + separator))
|
||||
folder.display = folder.name.substring(account.prefix.length() + 1);
|
||||
|
||||
EntityFolder existing = db.folder().getFolderByName(account.id, folder.name);
|
||||
if (existing == null) {
|
||||
folder.account = account.id;
|
||||
|
@ -1143,7 +1131,6 @@ public class FragmentAccount extends FragmentBase {
|
|||
etRealm.setText(account == null ? null : account.realm);
|
||||
|
||||
etName.setText(account == null ? null : account.name);
|
||||
etPrefix.setText(account == null ? null : account.prefix);
|
||||
cbNotify.setChecked(account == null ? false : account.notify);
|
||||
|
||||
cbSynchronize.setChecked(account == null ? true : account.synchronize);
|
||||
|
|
|
@ -343,7 +343,6 @@ public class FragmentQuickSetup extends FragmentBase {
|
|||
account.notify = false;
|
||||
account.browse = true;
|
||||
account.poll_interval = EntityAccount.DEFAULT_KEEP_ALIVE_INTERVAL;
|
||||
account.prefix = provider.prefix;
|
||||
|
||||
account.created = now;
|
||||
account.error = null;
|
||||
|
|
|
@ -457,37 +457,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etInterval" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPrefix"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_account_prefix"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvIntervalRemark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPrefixRemark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/title_account_prefix_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPrefix" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etPrefix"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/title_optional"
|
||||
android:inputType="text"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvPrefixRemark" />
|
||||
|
||||
<!-- check -->
|
||||
|
||||
<Button
|
||||
|
@ -498,7 +467,7 @@
|
|||
android:tag="disable"
|
||||
android:text="@string/title_check"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/etPrefix" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvIntervalRemark" />
|
||||
|
||||
<eu.faircode.email.ContentLoadingProgressBar
|
||||
android:id="@+id/pbCheck"
|
||||
|
@ -768,7 +737,7 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="
|
||||
tvPrefix,tvPrefixRemark,etPrefix,cbNotify,tvNotifyPro,
|
||||
cbNotify,tvNotifyPro,
|
||||
cbSynchronize,cbPrimary,
|
||||
cbBrowse,tvBrowseHint,
|
||||
tvInterval,etInterval,tvIntervalRemark" />
|
||||
|
|
|
@ -275,8 +275,6 @@
|
|||
<string name="title_account_name">Account name</string>
|
||||
<string name="title_account_name_hint">Used to differentiate folders</string>
|
||||
<string name="title_account_interval_hint">Frequency of refreshing the connection for push messages or frequency of checking for new messages</string>
|
||||
<string name="title_account_prefix">Namespace prefix</string>
|
||||
<string name="title_account_prefix_hint">Used to simplify folder names</string>
|
||||
<string name="title_account_signature">Signature text</string>
|
||||
<string name="title_account_color">Color</string>
|
||||
<string name="title_account_notify">Separate notifications</string>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
name="Gmail"
|
||||
link="https://support.google.com/mail/answer/7126229"
|
||||
order="1"
|
||||
prefix="[Gmail]"
|
||||
type="com.google">
|
||||
<imap
|
||||
host="imap.gmail.com"
|
||||
|
|
Loading…
Reference in New Issue