diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fd78ad84..23c8b6f2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,7 +5,7 @@
-
+
-
-
+ android:name=".ActivityMain"
+ android:theme="@style/Theme.Transparent">
@@ -40,6 +35,16 @@
+
+
+
+
diff --git a/app/src/main/java/eu/faircode/email/ActivityMain.java b/app/src/main/java/eu/faircode/email/ActivityMain.java
new file mode 100644
index 00000000..6ad9f654
--- /dev/null
+++ b/app/src/main/java/eu/faircode/email/ActivityMain.java
@@ -0,0 +1,68 @@
+package eu.faircode.email;
+
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+
+import java.util.List;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.lifecycle.Observer;
+
+public class ActivityMain extends AppCompatActivity implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ getSupportFragmentManager().addOnBackStackChangedListener(this);
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ prefs.registerOnSharedPreferenceChangeListener(this);
+
+ if (prefs.getBoolean("eula", false)) {
+ DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer>() {
+ @Override
+ public void onChanged(@Nullable List accounts) {
+ if (accounts.size() == 0)
+ startActivity(new Intent(ActivityMain.this, ActivitySetup.class));
+ else {
+ startActivity(new Intent(ActivityMain.this, ActivityView.class));
+ ServiceSynchronize.start(ActivityMain.this);
+ }
+ finish();
+ }
+ });
+ } else {
+ setTheme(R.style.AppThemeLight);
+ setContentView(R.layout.activity_main);
+
+ FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
+ fragmentTransaction.replace(R.id.content_frame, new FragmentEula()).addToBackStack("eula");
+ fragmentTransaction.commit();
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
+ super.onDestroy();
+ }
+
+ @Override
+ public void onBackStackChanged() {
+ int count = getSupportFragmentManager().getBackStackEntryCount();
+ if (count == 0)
+ finish();
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
+ if ("eula".equals(key))
+ if (prefs.getBoolean(key, false))
+ recreate();
+ }
+}
diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java
index 5024c4a3..6e046470 100644
--- a/app/src/main/java/eu/faircode/email/ActivitySetup.java
+++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java
@@ -39,7 +39,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setup);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportFragmentManager().addOnBackStackChangedListener(this);
diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java
index 9cd51ee0..2d5e77f4 100644
--- a/app/src/main/java/eu/faircode/email/ActivityView.java
+++ b/app/src/main/java/eu/faircode/email/ActivityView.java
@@ -23,11 +23,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
@@ -56,7 +54,7 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-public class ActivityView extends ActivityBase implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
+public class ActivityView extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
private boolean newIntent = false;
private DrawerLayout drawerLayout;
private ListView drawerList;
@@ -66,14 +64,15 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
static final int LOADER_ACCOUNT_PUT = 2;
static final int LOADER_IDENTITY_PUT = 3;
static final int LOADER_FOLDER_PUT = 4;
- static final int LOADER_MESSAGE_SEEN = 5;
- static final int LOADER_MESSAGE_EDIT = 6;
- static final int LOADER_MESSAGE_SPAM = 7;
- static final int LOADER_MESSAGE_TRASH = 8;
- static final int LOADER_MESSAGE_MOVE = 9;
- static final int LOADER_MESSAGE_ARCHIVE = 10;
- static final int LOADER_SEEN_UNTIL = 11;
- static final int LOADER_DEBUG_INFO = 12;
+ static final int LOADER_MESSAGE_VIEW = 5;
+ static final int LOADER_MESSAGE_SEEN = 6;
+ static final int LOADER_MESSAGE_EDIT = 7;
+ static final int LOADER_MESSAGE_SPAM = 8;
+ static final int LOADER_MESSAGE_TRASH = 9;
+ static final int LOADER_MESSAGE_MOVE = 10;
+ static final int LOADER_MESSAGE_ARCHIVE = 11;
+ static final int LOADER_SEEN_UNTIL = 12;
+ static final int LOADER_DEBUG_INFO = 13;
static final int REQUEST_VIEW = 1;
static final int REQUEST_UNSEEN = 2;
@@ -132,7 +131,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
});
- PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
getSupportFragmentManager().addOnBackStackChangedListener(this);
DB.getInstance(this).account().liveAccounts().observe(this, new Observer>() {
@@ -162,8 +160,17 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
});
- if (getSupportFragmentManager().getFragments().size() == 0)
- init();
+ if (getSupportFragmentManager().getFragments().size() == 0) {
+ Bundle args = new Bundle();
+ args.putLong("folder", -1);
+
+ FragmentMessages fragment = new FragmentMessages();
+ fragment.setArguments(args);
+
+ FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
+ fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("unified");
+ fragmentTransaction.commit();
+ }
checkIntent(getIntent());
}
@@ -173,14 +180,13 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
Log.i(Helper.TAG, "View post create");
super.onPostCreate(savedInstanceState);
drawerToggle.syncState();
- syncState();
}
- private void syncState() {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- boolean eula = prefs.getBoolean("eula", false);
- int count = getSupportFragmentManager().getBackStackEntryCount();
- drawerToggle.setDrawerIndicatorEnabled(count == 1 && eula);
+ @Override
+ protected void onNewIntent(Intent intent) {
+ newIntent = true;
+ checkIntent(intent);
+ super.onNewIntent(intent);
}
@Override
@@ -209,29 +215,19 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
lbm.unregisterReceiver(receiver);
}
- @Override
- protected void onNewIntent(Intent intent) {
- newIntent = true;
- checkIntent(intent);
- super.onNewIntent(intent);
- }
-
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i(Helper.TAG, "View configuration changed");
super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig);
- syncState();
}
@Override
protected void onDestroy() {
Log.i(Helper.TAG, "View destroyed");
- PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy();
}
-
@Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(drawerList))
@@ -245,14 +241,8 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
int count = getSupportFragmentManager().getBackStackEntryCount();
if (count == 0)
finish();
- syncState();
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
- super.onSharedPreferenceChanged(prefs, key);
- if ("eula".equals(key))
- init();
+ else
+ drawerToggle.setDrawerIndicatorEnabled(count == 1);
}
@Override
@@ -300,39 +290,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
}
- private void init() {
- invalidateOptionsMenu();
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- if (prefs.getBoolean("eula", false)) {
- getSupportFragmentManager().popBackStack(); // eula
-
- Bundle args = new Bundle();
- args.putLong("folder", -1);
-
- FragmentMessages fragment = new FragmentMessages();
- fragment.setArguments(args);
-
- FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
- fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("unified");
- fragmentTransaction.commit();
-
- DB.getInstance(this).account().liveAccounts(true).observe(this, new Observer>() {
- @Override
- public void onChanged(@Nullable List accounts) {
- if (accounts.size() == 0)
- startActivity(new Intent(ActivityView.this, ActivitySetup.class));
- else
- ServiceSynchronize.start(ActivityView.this);
- }
- });
- } else {
- FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
- fragmentTransaction.replace(R.id.content_frame, new FragmentEula()).addToBackStack("eula");
- fragmentTransaction.commit();
- }
- }
-
private Intent getIntentFAQ() {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://github.com/M66B/open-source-email/blob/master/FAQ.md"));
@@ -432,6 +389,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("messages");
fragmentTransaction.commit();
+
} else if (ACTION_VIEW_MESSAGE.equals(intent.getAction())) {
new SimpleLoader() {
@@ -476,7 +434,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
} else
Toast.makeText(ActivityView.this, result.ex.toString(), Toast.LENGTH_LONG).show();
}
- }.load(ActivityView.this, 0000, intent.getExtras());
+ }.load(ActivityView.this, LOADER_MESSAGE_VIEW, intent.getExtras());
} else if (ACTION_EDIT_FOLDER.equals(intent.getAction())) {
FragmentFolder fragment = new FragmentFolder();
diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java
index d811d5f5..341f84ff 100644
--- a/app/src/main/java/eu/faircode/email/FragmentAccount.java
+++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java
@@ -22,6 +22,7 @@ package eu.faircode.email;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
+import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@@ -35,6 +36,7 @@ import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ProgressBar;
+import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.Toast;
@@ -139,6 +141,7 @@ public class FragmentAccount extends FragmentEx {
etName.setText(provider.name);
etHost.setText(provider.imap_host);
etPort.setText(Integer.toString(provider.imap_port));
+ etUser.requestFocus();
}
}
@@ -474,6 +477,12 @@ public class FragmentAccount extends FragmentEx {
grpFolders.setVisibility(View.VISIBLE);
btnSave.setVisibility(View.VISIBLE);
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ ((ScrollView) view).smoothScrollTo(0, btnSave.getBottom());
+ }
+ });
} else {
Log.w(Helper.TAG, data.ex + "\n" + Log.getStackTraceString(data.ex));
Toast.makeText(getContext(), Helper.formatThrowable(data.ex), Toast.LENGTH_LONG).show();
diff --git a/app/src/main/java/eu/faircode/email/FragmentEula.java b/app/src/main/java/eu/faircode/email/FragmentEula.java
index 4dc027cb..88aee173 100644
--- a/app/src/main/java/eu/faircode/email/FragmentEula.java
+++ b/app/src/main/java/eu/faircode/email/FragmentEula.java
@@ -35,6 +35,8 @@ public class FragmentEula extends FragmentEx {
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ setSubtitle(R.string.title_eula);
+
View view = inflater.inflate(R.layout.fragment_eula, container, false);
Button btnAgree = view.findViewById(R.id.btnOk);
diff --git a/app/src/main/java/eu/faircode/email/FragmentIdentity.java b/app/src/main/java/eu/faircode/email/FragmentIdentity.java
index a983f446..6e51d1e2 100644
--- a/app/src/main/java/eu/faircode/email/FragmentIdentity.java
+++ b/app/src/main/java/eu/faircode/email/FragmentIdentity.java
@@ -277,11 +277,12 @@ public class FragmentIdentity extends FragmentEx {
btnSave.setEnabled(true);
pbWait.setVisibility(View.GONE);
+ etName.requestFocus();
+
db.account().liveAccounts().removeObservers(getViewLifecycleOwner());
db.account().liveAccounts().observe(getViewLifecycleOwner(), new Observer>() {
@Override
public void onChanged(List accounts) {
-
EntityAccount unselected = new EntityAccount();
unselected.id = -1L;
unselected.name = "";
diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java
index 73a0e8ad..94640c2e 100644
--- a/app/src/main/java/eu/faircode/email/FragmentSetup.java
+++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java
@@ -20,6 +20,7 @@ package eu.faircode.email;
*/
import android.Manifest;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
@@ -55,6 +56,8 @@ public class FragmentSetup extends FragmentEx {
private Button btnPermissions;
private TextView tvPermissionsDone;
+ private Button btnMessages;
+
private CheckBox cbDarkTheme;
private CheckBox cbDebug;
@@ -83,6 +86,8 @@ public class FragmentSetup extends FragmentEx {
btnPermissions = view.findViewById(R.id.btnPermissions);
tvPermissionsDone = view.findViewById(R.id.tvPermissionsDone);
+ btnMessages = view.findViewById(R.id.btnMessages);
+
cbDarkTheme = view.findViewById(R.id.cbDarkTheme);
cbDebug = view.findViewById(R.id.cbDebug);
@@ -113,6 +118,14 @@ public class FragmentSetup extends FragmentEx {
}
});
+ btnMessages.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActivity(new Intent(getContext(), ActivityView.class));
+ getFragmentManager().popBackStack();
+ }
+ });
+
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String theme = prefs.getString("theme", "light");
@@ -145,6 +158,7 @@ public class FragmentSetup extends FragmentEx {
tvAccountDone.setVisibility(View.INVISIBLE);
tvIdentityDone.setVisibility(View.INVISIBLE);
tvPermissionsDone.setVisibility(View.INVISIBLE);
+ btnMessages.setEnabled(false);
int[] grantResults = new int[permissions.length];
for (int i = 0; i < permissions.length; i++)
@@ -182,6 +196,7 @@ public class FragmentSetup extends FragmentEx {
@Override
public void onChanged(@Nullable List accounts) {
tvAccountDone.setVisibility(accounts.size() > 0 ? View.VISIBLE : View.INVISIBLE);
+ btnMessages.setEnabled(accounts.size() > 0);
}
});
diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml
index 7178bf64..cb050269 100644
--- a/app/src/main/res/layout/activity_compose.xml
+++ b/app/src/main/res/layout/activity_compose.xml
@@ -1,12 +1,6 @@
-
-
-
-
\ No newline at end of file
+ tools:context=".ActivityCompose" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 00000000..1030b66e
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_setup.xml b/app/src/main/res/layout/activity_setup.xml
index 7178bf64..e53281b9 100644
--- a/app/src/main/res/layout/activity_setup.xml
+++ b/app/src/main/res/layout/activity_setup.xml
@@ -1,12 +1,6 @@
-
-
-
-
\ No newline at end of file
+ tools:context=".ActivitySetup" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_account.xml b/app/src/main/res/layout/fragment_account.xml
index e06e8ceb..b6178c99 100644
--- a/app/src/main/res/layout/fragment_account.xml
+++ b/app/src/main/res/layout/fragment_account.xml
@@ -219,9 +219,10 @@
@@ -238,8 +239,9 @@
@@ -256,8 +258,9 @@
@@ -274,8 +277,9 @@
@@ -292,8 +296,9 @@
diff --git a/app/src/main/res/layout/fragment_setup.xml b/app/src/main/res/layout/fragment_setup.xml
index 44b3e07c..14f14a38 100644
--- a/app/src/main/res/layout/fragment_setup.xml
+++ b/app/src/main/res/layout/fragment_setup.xml
@@ -135,6 +135,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPermissions" />
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/btnMessages" />
FAQ
About
+ End-user license agreement
I agree
I disagree
@@ -48,6 +49,7 @@
To send email
Grant permissions
To read contacts (optional)
+ View messages
Done
Dark theme
Debug
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 6d42bb2b..9d52b955 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -32,4 +32,13 @@
- @color/darkColorDrawerText
- @color/darkColorDrawerBackground
+
+