#466 Header title not aligned

Move to toolbars
This commit is contained in:
stefan-niedermann 2020-01-25 09:29:44 +01:00
parent bb2110ac3b
commit 65bd9e3530
11 changed files with 102 additions and 35 deletions

View file

@ -30,8 +30,7 @@
<activity
android:name="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
@ -85,8 +84,7 @@
android:parentActivityName="it.niedermann.owncloud.notes.android.activity.NotesListViewActivity" />
<activity
android:name=".android.activity.SelectSingleNoteActivity"
android:theme="@style/AppTheme.NoActionBar">
android:name=".android.activity.SelectSingleNoteActivity">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>

View file

@ -4,6 +4,7 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
@ -21,6 +22,8 @@ import it.niedermann.owncloud.notes.util.ExceptionHandler;
public class AboutActivity extends AppCompatActivity {
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.pager)
ViewPager mViewPager;
@BindView(R.id.tabs)
@ -33,6 +36,7 @@ public class AboutActivity extends AppCompatActivity {
setContentView(R.layout.activity_about);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
mViewPager.setAdapter(new TabsPagerAdapter(getSupportFragmentManager()));
mTabLayout.setupWithViewPager(mViewPager);
}

View file

@ -8,8 +8,8 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import java.io.BufferedReader;
@ -19,6 +19,8 @@ import java.io.InputStreamReader;
import java.util.Calendar;
import java.util.Objects;
import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.fragment.BaseNoteFragment;
import it.niedermann.owncloud.notes.android.fragment.NoteEditFragment;
@ -45,6 +47,9 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
public static final String PARAM_CATEGORY = "category";
public static final String PARAM_CONTENT = "content";
@BindView(R.id.toolbar)
Toolbar toolbar;
private BaseNoteFragment fragment;
@Override
@ -52,15 +57,17 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new ExceptionHandler(this));
setContentView(R.layout.activity_edit);
ButterKnife.bind(this);
if (savedInstanceState == null) {
launchNoteFragment();
} else {
fragment = (BaseNoteFragment) getSupportFragmentManager().findFragmentById(android.R.id.content);
}
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
fragment = (BaseNoteFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container_view);
}
setSupportActionBar(toolbar);
}
@Override
@ -144,7 +151,7 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
if (savedState != null) {
fragment.setInitialSavedState(savedState);
}
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_view, fragment).commit();
}
/**
@ -179,7 +186,7 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
}
CloudNote newNote = new CloudNote(0, Calendar.getInstance(), NoteUtil.generateNonEmptyNoteTitle(content, this), content, favorite, category, null);
fragment = NoteEditFragment.newInstanceWithNewNote(newNote);
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_view, fragment).commit();
}
private void launchReadonlyNote() {
@ -197,7 +204,7 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
}
fragment = NoteReadonlyFragment.newInstance(content.toString());
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_view, fragment).commit();
}
@Override
@ -249,11 +256,10 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
@Override
public void onNoteUpdated(DBNote note) {
ActionBar actionBar = Objects.requireNonNull(getSupportActionBar());
if (note != null) {
actionBar.setTitle(note.getTitle());
toolbar.setTitle(note.getTitle());
if (!note.getCategory().isEmpty()) {
actionBar.setSubtitle(NoteUtil.extendCategory(note.getCategory()));
toolbar.setSubtitle(NoteUtil.extendCategory(note.getCategory()));
}
} else {
// Maybe account is not authenticated -> note == null

View file

@ -9,6 +9,7 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import java.util.Objects;
@ -22,6 +23,8 @@ public class ExceptionActivity extends AppCompatActivity {
Throwable throwable;
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.message)
TextView message;
@BindView(R.id.stacktrace)
@ -35,6 +38,7 @@ public class ExceptionActivity extends AppCompatActivity {
setContentView(R.layout.activity_exception);
ButterKnife.bind(this);
super.onCreate(savedInstanceState);
setSupportActionBar(toolbar);
throwable = ((Throwable) getIntent().getSerializableExtra(KEY_THROWABLE));
throwable.printStackTrace();
Objects.requireNonNull(getSupportActionBar()).setTitle(getString(R.string.simple_error));

View file

@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="#FFFFFF" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/primary" />
<item android:drawable="@drawable/ic_launcher_background" />
<item>
<bitmap

View file

@ -2,8 +2,22 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetStartWithNavigation="0dp"
app:elevation="4dp"
app:titleMarginStart="0dp"
app:navigationIcon="@drawable/ic_arrow_back_white_24dp"
tools:title="@string/simple_about"/>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetStartWithNavigation="0dp"
app:elevation="4dp"
app:titleMarginStart="0dp"
app:navigationIcon="@drawable/ic_arrow_back_white_24dp"
tools:title="Edit Sample note"/>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View file

@ -1,31 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
android:orientation="vertical">
<LinearLayout
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetStartWithNavigation="0dp"
app:elevation="4dp"
app:titleMarginStart="0dp"
tools:title="@string/simple_exception" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_weight="1"
android:hint="An error appeared."
tools:ignore="HardcodedText" />
</LinearLayout>
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_margin"
android:hint="An error appeared."
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/stacktrace"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_marginStart="@dimen/activity_margin"
android:layout_marginLeft="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:background="@color/bg_highlighted"
android:padding="8dp"
@ -38,6 +45,7 @@
style="?android:buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:gravity="end"
android:orientation="horizontal"
android:weightSum="1.0">

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -17,6 +18,8 @@
android:background="?attr/colorPrimary"
app:titleMarginStart="0dp"
app:contentInsetStartWithNavigation="0dp"
tools:title="@string/app_name"
tools:navigationIcon="@drawable/ic_arrow_back_white_24dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="4dp" />

View file

@ -7,9 +7,6 @@
<item name="colorAccent">@color/primary</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowBackground">@color/bg_normal</item>
</style>
<style name="AppTheme.NoActionBar" parent="AppTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
@ -17,6 +14,8 @@
<style name="Preferences" parent="AppTheme">
<item name="android:textColor">@color/fg_default</item>
<item name="android:textColorSecondary">@color/fg_default_low</item>
<item name="windowActionBar">true</item>
<item name="windowNoTitle">false</item>
</style>
<style name="ncAlertDialog" parent="@style/Theme.AppCompat.DayNight.Dialog.Alert">