Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8966a5f4 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

Make code & resources compliant with API 25

Added resources for API 25 inheriting from default
themes and colors.
parent bdb4bbf5
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
package org.microg.tools.ui;

import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.ViewGroup;
@@ -19,14 +20,12 @@ public abstract class AbstractSettingsActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings_activity);
        if (showHomeAsUp && getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);

            getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back);
        if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
            onCreateNougat();
        } else {
            onCreateOthersApi();
        }

        switchBar = findViewById(R.id.switch_bar);

        customBarContainer = findViewById(R.id.custom_bar);
@@ -39,6 +38,21 @@ public abstract class AbstractSettingsActivity extends AppCompatActivity {
                .commit();
    }

    private void onCreateNougat() {
        if (showHomeAsUp) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    private void onCreateOthersApi() {
        if (showHomeAsUp && getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
            getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back);
        }
    }

    public void setCustomBarLayout(int layout) {
        customBarLayout = layout;
        if (customBarContainer != null) {
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2013-2022 microG Project Team
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<resources>
    <color name="settings_theme_primary">#222222</color>
    <color name="settings_theme_primary_dark">#000000</color>
    <color name="settings_theme_accent">#077fff</color>
    <color name="settings_text_appbar">#ffffff</color>
    <color name="switchbar_background_color">#ff37474f</color>
    <color name="switch_accent_color">#ff7fcac3</color>
    <color name="primary_text_color">#ffffff</color>
</resources>
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2013-2017 microG Project Team
  ~ Copyright (C) 2013-2022 microG Project Team
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
@@ -15,14 +15,8 @@
  -->

<resources>
    <style name="AppTheme" parent="AppTheme.Base">
        <item name="android:navigationBarColor">@color/settings_theme_primary_dark</item>
        <item name="android:navigationBarDividerColor">@color/settings_theme_primary_dark</item>
        <item name="android:statusBarColor">@color/settings_theme_primary_dark</item>
        <item name="android:windowLightNavigationBar">@bool/is_light_mode</item>
        <item name="android:windowLightStatusBar">@bool/is_light_mode</item>
        <item name="android:colorControlActivated">@color/settings_theme_accent</item>
        <item name="android:colorButtonNormal">@color/color_default_blue2</item>
        <item name="android:colorControlHighlight">@color/color_default_gray2</item>
    <style name="AppTheme" parent="AppTheme.Base" />
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar" >
        <item name="colorAccent">@color/settings_theme_accent</item>
    </style>
</resources>
+37 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2013-2017 microG Project Team
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<resources>
    <color name="login_blue_theme_primary">@lineageos.platform:color/color_default_primary</color>
    <color name="login_blue_theme_primary_dark">@lineageos.platform:color/color_default_primary_dark</color>
    <color name="login_blue_theme_accent">@lineageos.platform:color/color_default_accent</color>

    <color name="background_color">@lineageos.platform:color/color_default_background</color>
    <color name="foreground_color">@lineageos.platform:color/color_default_foreground</color>
    <color name="primary_text_color">@lineageos.platform:color/color_default_primary_text</color>
    <color name="secondary_text_color">@lineageos.platform:color/color_default_secondary_text</color>
    <color name="divider_color">@lineageos.platform:color/color_default_divider</color>
    <color name="view_on_accent_color">@lineageos.platform:color/color_default_view_on_accent</color>

    <color name="color_default_blue2">@lineageos.platform:color/color_default_blue2</color>
    <color name="color_default_gray2">@lineageos.platform:color/color_default_gray2</color>

    <color name="dialog_border_color">@lineageos.platform:color/color_default_divider</color>
    <color name="material_error">@lineageos.platform:color/color_default_red1</color>

    <color name="settings_theme_accent">@lineageos.platform:color/color_default_accent</color>
    <color name="settings_theme_primary_dark">@lineageos.platform:color/color_default_primary_dark</color>
</resources>
+58 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2013-2022 microG Project Team
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<resources>
    <style name="customOverFlow">
        <item name="android:src">@lineageos.platform:drawable/ic_menu</item>
        <item name="tint">@color/settings_theme_accent</item>
        <item name="android:paddingRight">10dp</item>
        <item name="android:foreground">?android:attr/selectableItemBackground</item>
    </style>


    <style name="AppTheme" parent="AppTheme.Base"/>

    <style name="AppTheme.Base" parent="Theme.AppCompat.DayNight">
        <item name="colorPrimary">@color/login_blue_theme_primary</item>
        <item name="colorPrimaryDark">@color/login_blue_theme_primary_dark</item>
        <item name="colorAccent">@color/login_blue_theme_accent</item>
        <item name="android:textColorPrimary">@color/primary_text_color</item>
        <item name="android:textColorSecondary">@color/secondary_text_color</item>
        <item name="android:textColorPrimaryInverse">@color/view_on_accent_color</item>
        <item name="android:windowBackground">@color/background_color</item>
        <item name="colorControlActivated">@color/settings_theme_accent</item>
        <item name="colorButtonNormal">@color/color_default_blue2</item>
        <item name="colorControlHighlight">@color/color_default_gray2</item>
        <item name="actionOverflowButtonStyle">@style/customOverFlow</item>
        <item name="homeAsUpIndicator">@drawable/ic_arrow_back</item>
        <item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
        <item name="actionBarTheme">@style/customToolbarTheme</item>
        <item name="android:popupBackground">@color/foreground_color</item>
        <item name="android:divider">@color/divider_color</item>
    </style>

    <style name="Theme.LoginBlue" parent="AppTheme">
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>

    <style name="customToolbarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
        <item name="colorControlNormal">@color/settings_theme_accent</item>
        <item name="android:textColorPrimary">@color/primary_text_color</item>
        <item name="android:textColorSecondary">@color/secondary_text_color</item>
        <item name="android:popupBackground">?android:attr/popupBackground</item>
    </style>
</resources>
Loading