Switched to app bar

pull/215/head
M66B 7 months ago
parent 00ab42f973
commit 1083865e77

@ -69,11 +69,11 @@ public class ActivityAMP extends ActivityBase {
if (savedInstanceState != null)
force_light = savedInstanceState.getBoolean("fair:force_light");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
View view = LayoutInflater.from(this).inflate(R.layout.activity_amp, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
wvAmp = findViewById(R.id.wvAmp);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);

@ -54,11 +54,11 @@ public class ActivityAnswer extends ActivityBase {
final CharSequence query = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
final boolean readonly = intent.getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false);
getSupportActionBar().setSubtitle(query == null ? null : query.toString());
View view = LayoutInflater.from(this).inflate(R.layout.activity_answer, null);
setContentView(view);
getSupportActionBar().setSubtitle(query == null ? null : query.toString());
ListView lvAnswer = view.findViewById(R.id.lvAnswer);
Group grpReady = view.findViewById(R.id.grpReady);
ContentLoadingProgressBar pbWait = view.findViewById(R.id.pbWait);

@ -40,6 +40,7 @@ import android.os.PowerManager;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
@ -52,6 +53,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.graphics.ColorUtils;
import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.Fragment;
@ -92,6 +95,29 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
return originalContext;
}
@Override
public void setContentView(View view) {
LayoutInflater inflater = LayoutInflater.from(this);
ConstraintLayout container = (ConstraintLayout) inflater.inflate(R.layout.toolbar_holder, null);
View placeholder = container.findViewById(R.id.placeholder);
container.removeView(placeholder);
container.addView(view, placeholder.getLayoutParams());
Toolbar toolbar = container.findViewById(R.id.toolbar);
toolbar.setPopupTheme(getThemeId());
setSupportActionBar(toolbar);
super.setContentView(container);
}
@Override
public void setContentView(int layoutResID) {
View view = LayoutInflater.from(this).inflate(layoutResID, null);
setContentView(view);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
EntityLog.log(this, "Activity create " + this.getClass().getName() +

@ -35,9 +35,10 @@ public class ActivityClear extends ActivityBase {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_clear);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(getString(R.string.title_advanced_clear_all));
setContentView(R.layout.activity_clear);
btnClearAll = findViewById(R.id.btnClearAll);
btnCancel = findViewById(R.id.btnCancel);

@ -90,8 +90,6 @@ public class ActivityCode extends ActivityBase {
searching = savedInstanceState.getString("fair:searching");
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
@ -102,6 +100,8 @@ public class ActivityCode extends ActivityBase {
View view = LayoutInflater.from(this).inflate(R.layout.activity_code, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
wvCode = findViewById(R.id.wvCode);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);

@ -56,8 +56,6 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
setContentView(R.layout.activity_compose);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setCustomView(R.layout.action_bar);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportFragmentManager().addOnBackStackChangedListener(this);

@ -64,12 +64,12 @@ public class ActivityDMARC extends ActivityBase {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(R.string.title_advanced_dmarc_viewer);
View view = LayoutInflater.from(this).inflate(R.layout.activity_dmarc, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(R.string.title_advanced_dmarc_viewer);
tvDmarc = findViewById(R.id.tvDmarc);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);

@ -46,12 +46,12 @@ public class ActivityDSN extends ActivityBase {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle("DSN");
View view = LayoutInflater.from(this).inflate(R.layout.activity_dsn, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle("DSN");
tvHeaders = findViewById(R.id.tvHeaders);
pbWait = findViewById(R.id.pbWait);
grpReady = findViewById(R.id.grpReady);

@ -109,12 +109,12 @@ public class ActivityEML extends ActivityBase {
junk = savedInstanceState.getBoolean("fair:junk");
}
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle("EML");
View view = LayoutInflater.from(this).inflate(R.layout.activity_eml, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle("EML");
tvFrom = findViewById(R.id.tvFrom);
tvTo = findViewById(R.id.tvTo);
tvReplyTo = findViewById(R.id.tvReplyTo);

@ -51,9 +51,10 @@ public class ActivityError extends ActivityBase {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_error);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(getString(R.string.title_setup_error));
setContentView(R.layout.activity_error);
tvTitle = findViewById(R.id.tvTitle);
tvMessage = findViewById(R.id.tvMessage);

@ -120,10 +120,7 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
view = LayoutInflater.from(this).inflate(R.layout.activity_setup, null);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setCustomView(R.layout.action_bar);
getSupportActionBar().setDisplayShowCustomEnabled(true);
drawerLayout = findViewById(R.id.drawer_layout);
drawerLayout.setScrimColor(Helper.resolveColor(this, R.attr.colorDrawerScrim));

@ -88,13 +88,13 @@ public class ActivitySignature extends ActivityBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean monospaced = prefs.getBoolean("monospaced", false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(getString(R.string.title_edit_signature));
LayoutInflater inflater = LayoutInflater.from(this);
view = (ViewGroup) inflater.inflate(R.layout.activity_signature, null, false);
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(getString(R.string.title_edit_signature));
tvHtmlRemark = findViewById(R.id.tvHtmlRemark);
etText = findViewById(R.id.etText);
ibFull = findViewById(R.id.ibFull);

@ -269,8 +269,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
setContentView(view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setCustomView(R.layout.action_bar);
getSupportActionBar().setDisplayShowCustomEnabled(true);
content_separator = findViewById(R.id.content_separator);
content_pane = findViewById(R.id.content_pane);

@ -109,9 +109,10 @@ public class ActivityWidget extends ActivityBase {
daynight = daynight && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
setContentView(R.layout.activity_widget);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(R.string.title_widget_title_count);
setContentView(R.layout.activity_widget);
spAccount = findViewById(R.id.spAccount);
spFolder = findViewById(R.id.spFolder);

@ -66,9 +66,10 @@ public class ActivityWidgetSync extends ActivityBase {
daynight = daynight && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
setContentView(R.layout.activity_widget_sync);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(R.string.title_widget_title_sync);
setContentView(R.layout.activity_widget_sync);
cbDayNight = findViewById(R.id.cbDayNight);
cbSemiTransparent = findViewById(R.id.cbSemiTransparent);

@ -127,9 +127,10 @@ public class ActivityWidgetUnified extends ActivityBase {
daynight = daynight && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
setContentView(R.layout.activity_widget_unified);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setSubtitle(R.string.title_widget_title_list);
setContentView(R.layout.activity_widget_unified);
spAccount = findViewById(R.id.spAccount);
spFolder = findViewById(R.id.spFolder);

@ -56,6 +56,7 @@ import androidx.annotation.RequiresApi;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@ -465,15 +466,16 @@ public class FragmentBase extends Fragment {
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity != null && !isPane()) {
ActionBar actionbar = activity.getSupportActionBar();
if (actionbar != null)
if ((actionbar.getDisplayOptions() & DISPLAY_SHOW_CUSTOM) == 0) {
if (actionbar != null) {
Toolbar toolbar = activity.findViewById(R.id.toolbar);
if ((actionbar.getDisplayOptions() & DISPLAY_SHOW_CUSTOM) == 0 && toolbar == null) {
actionbar.setTitle(title == null ? getString(R.string.app_name) : title);
actionbar.setSubtitle(subtitle);
} else {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
boolean list_count = prefs.getBoolean("list_count", false);
View custom = actionbar.getCustomView();
View custom = (toolbar == null ? actionbar.getCustomView() : toolbar);
TextView tvCount = custom.findViewById(R.id.count);
TextView tvTitle = custom.findViewById(R.id.title);
TextView tvSubtitle = custom.findViewById(R.id.subtitle);
@ -487,6 +489,7 @@ public class FragmentBase extends Fragment {
if (tvSubtitle != null)
tvSubtitle.setText(subtitle);
}
}
}
}

@ -1873,7 +1873,9 @@ public class FragmentCompose extends FragmentBase {
final Context context = getContext();
PopupMenuLifecycle.insertIcons(context, menu, false);
LayoutInflater infl = LayoutInflater.from(context);
ActionBar actionBar = getSupportActionBar();
Context actionBarContext = (actionBar == null ? context : actionBar.getThemedContext());
LayoutInflater infl = LayoutInflater.from(actionBarContext);
ImageButton ibOpenAi = (ImageButton) infl.inflate(R.layout.action_button, null);
ibOpenAi.setId(View.generateViewId());

@ -424,7 +424,7 @@ public class FragmentOptions extends FragmentBase {
}
searchView.setSuggestionsAdapter(new SimpleCursorAdapter(
searchView.getContext(),
pager.getContext(),
R.layout.spinner_item1_dropdown,
cursor,
new String[]{"title"},

@ -0,0 +1,60 @@
package eu.faircode.email;
/*
This file is part of FairEmail.
FairEmail is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FairEmail is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018-2024 by Marcel Bokhorst (M66B)
*/
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
public class ToolbarEx extends Toolbar {
public ToolbarEx(@NonNull Context context) {
super(context);
}
public ToolbarEx(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public ToolbarEx(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void setTitle(CharSequence title) {
super.setTitle(null);
TextView tv = findViewById(R.id.title);
tv.setText(title);
tv.setVisibility(title == null ? GONE : VISIBLE);
findViewById(R.id.count).setVisibility(GONE);
}
@Override
public void setSubtitle(CharSequence subtitle) {
super.setSubtitle(null);
TextView tv = findViewById(R.id.subtitle);
tv.setText(subtitle);
tv.setVisibility(subtitle == null ? GONE : VISIBLE);
findViewById(R.id.count).setVisibility(GONE);
}
}

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:colorBackground"
android:padding="12dp">
<TextView

@ -0,0 +1,71 @@
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context="eu.faircode.email.ActivityView">
<eu.faircode.email.ToolbarEx
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/actionBarStyle"
android:elevation="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:text="Title"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
app:layout_constraintEnd_toStartOf="@+id/count"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:paddingStart="6dp"
android:singleLine="true"
android:text="123"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"
android:textSize="12dp"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<TextView
android:id="@+id/subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="start"
android:singleLine="true"
android:text="Subtitle"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ToolbarEx>
<View
android:id="@+id/placeholder"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -26,7 +26,7 @@
<attr name="colorInfoBackground" format="reference" />
<attr name="activatableItemBackground" format="reference" />
<style name="AppThemeBaseLight" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<style name="AppThemeBaseLight" parent="Theme.AppCompat.Light.NoActionBar">
<item name="themeName">light</item>
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="android:windowSplashScreenBackground" tools:targetApi="s">
@ -100,7 +100,7 @@
<item name="viewInflaterClass">eu.faircode.email.AppCompatViewInflaterEx</item>
</style>
<style name="AppThemeBaseDark" parent="Base.Theme.AppCompat">
<style name="AppThemeBaseDark" parent="Theme.AppCompat.NoActionBar">
<item name="themeName">dark</item>
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="android:windowSplashScreenBackground" tools:targetApi="s">
@ -651,4 +651,7 @@
<style name="ChipDark" parent="Base.Theme.Material3.Dark">
<item name="chipCornerRadius">6dp</item>
</style>
<style name="actionBarStyle" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
</style>
</resources>

Loading…
Cancel
Save