Browse Source

Added up navigation

Fixes #6
main
M66B 6 years ago
parent
commit
c8f48b0f65
4 changed files with 44 additions and 7 deletions
  1. +6
    -2
      app/src/main/AndroidManifest.xml
  2. +13
    -0
      app/src/main/java/eu/faircode/email/ActivityCompose.java
  3. +13
    -0
      app/src/main/java/eu/faircode/email/ActivitySetup.java
  4. +12
    -5
      app/src/main/java/eu/faircode/email/ActivityView.java

+ 6
- 2
app/src/main/AndroidManifest.xml View File

@ -25,7 +25,9 @@
android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="false" />
<activity android:name=".ActivitySetup" />
<activity
android:name=".ActivitySetup"
android:parentActivityName=".ActivityView" />
<activity android:name=".ActivityView">
<intent-filter>
@ -35,7 +37,9 @@
</intent-filter>
</activity>
<activity android:name=".ActivityCompose" />
<activity
android:name=".ActivityCompose"
android:parentActivityName=".ActivityView" />
<service android:name=".ServiceSynchronize" />


+ 13
- 0
app/src/main/java/eu/faircode/email/ActivityCompose.java View File

@ -22,6 +22,7 @@ package eu.faircode.email;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;
public class ActivityCompose extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
static final int LOADER_COMPOSE_GET = 1;
@ -37,6 +38,8 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compose);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportFragmentManager().addOnBackStackChangedListener(this);
if (getSupportFragmentManager().getFragments().size() == 0) {
@ -53,6 +56,16 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)


+ 13
- 0
app/src/main/java/eu/faircode/email/ActivitySetup.java View File

@ -27,6 +27,7 @@ import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.LocalBroadcastManager;
import android.view.MenuItem;
public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
static final String ACTION_EDIT_ACCOUNT = BuildConfig.APPLICATION_ID + ".EDIT_ACCOUNT";
@ -37,6 +38,8 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setup);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportFragmentManager().addOnBackStackChangedListener(this);
if (getSupportFragmentManager().getFragments().size() == 0) {
@ -63,6 +66,16 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
lbm.unregisterReceiver(receiver);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0)


+ 12
- 5
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -135,6 +135,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
drawerToggle.syncState();
syncState();
}
@Override
@ -159,6 +160,7 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
drawerToggle.onConfigurationChanged(newConfig);
}
@Override
@ -188,6 +190,14 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
finish();
}
private void syncState() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean eula = prefs.getBoolean("eula", false);
drawerToggle.setDrawerIndicatorEnabled(eula);
getSupportActionBar().setDisplayHomeAsUpEnabled(eula);
getSupportActionBar().setHomeButtonEnabled(eula);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (drawerToggle.onOptionsItemSelected(item))
@ -197,10 +207,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
private void init() {
syncState();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (prefs.getBoolean("eula", false)) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
Bundle args = new Bundle();
args.putLong("folder", -1);
@ -225,8 +235,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
});
} else {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentEula(), "eula");
fragmentTransaction.commit();
@ -234,7 +242,6 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack
}
public void updateDrawer() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
ArrayAdapterDrawer drawerArray = new ArrayAdapterDrawer(this, R.layout.item_drawer);
drawerArray.add(new DrawerItem(ActivityView.this, R.string.menu_unified));
drawerArray.add(new DrawerItem(ActivityView.this, R.string.menu_folders));


Loading…
Cancel
Save