Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material theming #1132

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
99e94d5
Base the theme onto material theming
proletarius101 Jan 24, 2021
7ef2e36
Rebase onto material dark theming scheme and fit its namespaces
proletarius101 Jan 24, 2021
b6c9086
Fix inconsistencies in Theme.App
proletarius101 Jan 25, 2021
0d76927
Fix progress bar 0 division
proletarius101 Jan 26, 2021
abefa71
Fix tab bar and toolbar legibility
proletarius101 Jan 26, 2021
9a21cc5
Fix bottom stepper legibility
proletarius101 Jan 26, 2021
67687f7
Fix dark theme switching
proletarius101 Jan 26, 2021
fff8d59
Add default (daynight) themes and fix default theme inconsistency
proletarius101 Jan 26, 2021
db936bf
Fix tabs background
proletarius101 Jan 26, 2021
a6bac89
Remove unused resource
proletarius101 Jan 26, 2021
2cd8feb
Elevate tabs rather than app bar in article list
proletarius101 Jan 26, 2021
c0a32a4
Revert populating "this" and "final"
proletarius101 Jan 26, 2021
e87e2af
Fix progress indication animation
proletarius101 Jan 26, 2021
22d5124
Fix inheritance of the default night theme's properties
proletarius101 Jan 26, 2021
c7c4456
Change Activity to AppCompatActivity and misc fixes
proletarius101 Feb 6, 2021
e491059
Use the same color as app bar for status bar and misc fixes
proletarius101 Feb 6, 2021
8110fcc
fix: tint on status bar was dark in dark theme
proletarius101 Feb 8, 2021
cde7ca2
feat: apply dark theme for the webview
proletarius101 Feb 8, 2021
be51f45
fix: duplicated action bars
proletarius101 Feb 9, 2021
1494ab9
fix: ReadArticleActivity crashing via another approach
proletarius101 Feb 9, 2021
c4b4be3
fix: transparent background of share to add url dialog
proletarius101 Feb 9, 2021
588b73e
fix: redundant top app bar in ReadArticleActivity
proletarius101 Feb 9, 2021
acb572a
Fix: dark app bar in Article activity
proletarius101 Feb 23, 2021
5668642
Remove unnecessary style changes and AppCompatActivity casting
proletarius101 Apr 7, 2021
299c902
Fix places invoking applyDarkTheme()
proletarius101 May 9, 2021
575e6d3
Restore splash screen
proletarius101 May 9, 2021
7f966bd
Remove unused imports
proletarius101 May 9, 2021
892860b
Rollback removing public scope, fix the default theme
proletarius101 May 15, 2021
81939c1
Fix the transparent background
proletarius101 May 15, 2021
e4a767c
Change the default theme name to Follow system
proletarius101 May 15, 2021
8e9fead
Align the elevation of top app bar and tab bar
proletarius101 May 18, 2021
d610006
Fix legacy dialog theming inconsistency
proletarius101 May 18, 2021
3cfc7c1
Use new Material Toolbar scheme
proletarius101 May 19, 2021
04c789e
Add top app bar disappearing upon scrolling up for ReadArticleActivity
proletarius101 May 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {

javaCompileOptions {
annotationProcessorOptions {
arguments = [ eventBusIndex : 'fr.gaulupeau.apps.Poche.EventBusIndex' ]
arguments = [eventBusIndex: 'fr.gaulupeau.apps.Poche.EventBusIndex']
}
}
}
Expand Down Expand Up @@ -55,8 +55,10 @@ greendao {
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.media:media:1.3.1'
implementation "androidx.webkit:webkit:1.4.0"
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.google.android.material:material:1.3.0'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'org.greenrobot:greendao:3.3.0'
Expand Down
17 changes: 6 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="fr.gaulupeau.apps.InThePoche"
android:installLocation="auto">

Expand All @@ -22,20 +21,18 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/LightTheme"
android:theme="@style/Theme.App"
android:networkSecurityConfig="@xml/network_security_config">
<activity
android:name="fr.gaulupeau.apps.Poche.ui.SplashActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/SplashTheme">
android:theme="@style/Theme.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="fr.gaulupeau.apps.Poche.ui.MainActivity"
android:theme="@style/LightTheme.NoActionBar">
<activity android:name="fr.gaulupeau.apps.Poche.ui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
Expand All @@ -55,7 +52,7 @@
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@style/ProxyTheme">
android:theme="@style/Theme.App.ProxyTheme">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND" />

Expand All @@ -69,8 +66,7 @@
android:autoRemoveFromRecents="true"
android:enabled="false"
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@style/ProxyTheme">
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand All @@ -96,8 +92,7 @@
</activity>

<activity
android:name="fr.gaulupeau.apps.Poche.ui.EditAddedArticleActivity"
android:theme="@style/DialogTheme" />
android:name="fr.gaulupeau.apps.Poche.ui.EditAddedArticleActivity" />

<activity android:name="fr.gaulupeau.apps.Poche.ui.preferences.SettingsActivity">
<intent-filter>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/fr/gaulupeau/apps/Poche/data/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void initPreferences() {
} else { // preferences are not migrated -- set some default values
boolean isOnyxDevice = Build.MANUFACTURER.equals("Onyx");
boolean isEreader = isOnyxDevice || Build.MODEL.equals("NOOK");
Themes.Theme theme = isEreader ? Themes.Theme.E_INK : Themes.Theme.LIGHT;
Themes.Theme theme = isEreader ? Themes.Theme.E_INK : Themes.Theme.FOLLOW_SYSTEM;
prefEditor.putString(context.getString(R.string.pref_key_ui_theme), theme.toString());
prefEditor.putBoolean(context.getString(R.string.pref_key_ui_onyxworkaround_enabled), isOnyxDevice);
}
Expand Down Expand Up @@ -441,7 +441,7 @@ public Themes.Theme getTheme() {
} catch(IllegalArgumentException ignored) {}
}

return theme != null ? theme : Themes.Theme.LIGHT;
return theme != null ? theme : Themes.Theme.FOLLOW_SYSTEM;
}

public void setTheme(Themes.Theme theme) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void onUpdateArticlesStartedEvent(UpdateArticlesStartedEvent event) {
detailedMessage = prependAppName(detailedMessage);

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID_SYNC)
.setSmallIcon(R.drawable.ic_action_refresh)
.setSmallIcon(R.drawable.ic_sync)
.setContentTitle(context.getString(R.string.notification_updatingArticles))
.setContentText(detailedMessage)
.setOngoing(true);
Expand Down Expand Up @@ -209,7 +209,7 @@ public void onSweepDeletedArticlesStartedEvent(SweepDeletedArticlesStartedEvent
Context context = getContext();

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID_SYNC)
.setSmallIcon(R.drawable.ic_action_refresh)
.setSmallIcon(R.drawable.ic_sync)
.setContentTitle(context.getString(R.string.notification_sweepingDeletedArticles))
.setOngoing(true);

Expand Down Expand Up @@ -253,7 +253,7 @@ public void onFetchImagesProgressEvent(FetchImagesProgressEvent event) {
Context context = getContext();

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID_SYNC)
.setSmallIcon(R.drawable.ic_action_refresh)
.setSmallIcon(R.drawable.ic_sync)
.setContentTitle(context.getString(R.string.notification_downloadingImages))
.setOngoing(true);

Expand Down Expand Up @@ -306,7 +306,7 @@ public void onSyncQueueProgressEvent(SyncQueueProgressEvent event) {
Context context = getContext();

notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID_SYNC)
.setSmallIcon(R.drawable.ic_action_refresh)
.setSmallIcon(R.drawable.ic_sync)
.setContentTitle(getContext().getString(R.string.notification_syncingQueue))
.setOngoing(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected Notification getForegroundNotification() {

return new NotificationCompat.Builder(
this, NotificationsHelper.CHANNEL_ID_BACKGROUND_OPERATIONS)
.setSmallIcon(R.drawable.ic_action_refresh)
.setSmallIcon(R.drawable.ic_sync)
.setContentTitle(getString(R.string.notification_backgroundOperations))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected Notification getForegroundNotification() {

return new NotificationCompat.Builder(
this, NotificationsHelper.CHANNEL_ID_BACKGROUND_OPERATIONS)
.setSmallIcon(R.drawable.ic_action_refresh)
.setSmallIcon(R.drawable.ic_sync)
.setContentTitle(getString(R.string.notification_backgroundOperations))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.MenuItem;
import android.view.View;

import com.google.android.material.appbar.MaterialToolbar;

import fr.gaulupeau.apps.InThePoche.R;

public abstract class BaseActionBarActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Themes.applyTheme(this);
super.onCreate(savedInstanceState);

addBackButtonToActionBar();
}

@Override
Expand All @@ -22,9 +27,8 @@ protected void onStart() {
Themes.checkTheme(this);
}

protected void addBackButtonToActionBar() {
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true);
protected void addBackButtonToActionBar(Toolbar toolbar) {
toolbar.setNavigationOnClickListener(v -> onBackPressed());
}

protected void hideBackButtonFromActionBar() {
Expand Down
40 changes: 7 additions & 33 deletions app/src/main/java/fr/gaulupeau/apps/Poche/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -33,6 +32,7 @@
import androidx.fragment.app.Fragment;

import com.google.android.material.navigation.NavigationView;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.mikepenz.aboutlibraries.Libs;
import com.mikepenz.aboutlibraries.LibsBuilder;

Expand Down Expand Up @@ -84,7 +84,7 @@ public class MainActivity extends AppCompatActivity

private ConfigurationTestHelper configurationTestHelper;

private ProgressBar progressBar;
private LinearProgressIndicator progressBar;

private NavigationView navigationView;
private TextView lastUpdateTimeView;
Expand Down Expand Up @@ -136,22 +136,6 @@ protected void onCreate(Bundle savedInstanceState) {
if (headerView != null) {
lastUpdateTimeView = headerView.findViewById(R.id.lastUpdateTime);
}

// Set different colors for items in the navigation bar in dark (high contrast) theme
if (Themes.getCurrentTheme() == Themes.Theme.DARK_CONTRAST) {
@SuppressLint("ResourceType") XmlResourceParser parser = getResources().getXml(R.color.dark_contrast_menu_item);
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
navigationView.setItemTextColor(ColorStateList.createFromXml(getResources(), parser, getTheme()));
navigationView.setItemIconTintList(ColorStateList.createFromXml(getResources(), parser, getTheme()));
} else {
navigationView.setItemTextColor(ColorStateList.createFromXml(getResources(), parser));
navigationView.setItemIconTintList(ColorStateList.createFromXml(getResources(), parser));
}
} catch (XmlPullParserException | IOException e) {
Log.e(TAG, "onCreate()", e);
}
}
}

DrawerLayout drawer = findViewById(R.id.drawer_layout);
Expand Down Expand Up @@ -468,23 +452,11 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
break;

case R.id.nav_about:
Libs.ActivityStyle style;
switch (Themes.getCurrentTheme()) {
case DARK:
case DARK_CONTRAST:
style = Libs.ActivityStyle.DARK;
break;

default:
style = Libs.ActivityStyle.LIGHT_DARK_TOOLBAR;
break;
}
CharSequence aboutCharSequence = getText(R.string.aboutText);
String aboutString = aboutCharSequence instanceof Spanned
? Html.toHtml((Spanned) aboutCharSequence)
: aboutCharSequence.toString();
new LibsBuilder()
.withActivityStyle(style)
.withAboutIconShown(true)
.withAboutVersionShown(true)
.withAboutDescription(aboutString)
Expand Down Expand Up @@ -546,8 +518,10 @@ public void onUpdateArticlesProgressEvent(UpdateArticlesProgressEvent event) {

if (progressBar != null) {
progressBar.setIndeterminate(false);
progressBar.setMax(event.getTotal());
progressBar.setProgress(event.getCurrent());
if (event.getTotal() > 0) {
progressBar.setMax(event.getTotal());
progressBar.setProgressCompat(event.getCurrent(), true);
}
}
}

Expand Down Expand Up @@ -585,7 +559,7 @@ private void updateStateChanged(boolean started) {
updateRunning = started;

if (progressBar != null) {
progressBar.setVisibility(started ? View.VISIBLE : View.GONE);
progressBar.setVisibility(started ? View.VISIBLE : View.INVISIBLE);
progressBar.setIndeterminate(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand Down Expand Up @@ -87,6 +88,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

setContentView(R.layout.activity_manage_article_tags);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> onBackPressed());

String[] currentTagsArray = null;
String text;
if (savedInstanceState != null) {
Expand Down
Loading