Move to AppCompat theme
Party like it's 2014
Change-Id: I6fed6d37dec8bb756bf2ce7e8b601cd99d1153ec
Signed-off-by: Joey <joey@lineageos.org>
diff --git a/build.gradle b/build.gradle
index f64c387..37b5791 100644
--- a/build.gradle
+++ b/build.gradle
@@ -137,4 +137,7 @@
// see https://developer.android.com/jetpack/androidx/releases/constraintlayout
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
+
+ // see https://github.com/material-components/material-components-android/releases
+ implementation "com.google.android.material:material:1.0.0"
}
diff --git a/res/layout/activity_base.xml b/res/layout/activity_base.xml
index 71ecb27..8e3541a 100644
--- a/res/layout/activity_base.xml
+++ b/res/layout/activity_base.xml
@@ -19,30 +19,30 @@
-->
<org.lineageos.eleven.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:sothree="http://schemas.android.com/apk/res-auto"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
- sothree:dragView="@+id/firstPanelDragArea"
- sothree:dragViewClickable="false"
- sothree:panelHeight="@dimen/bottom_action_bar_height"
- sothree:shadowHeight="@dimen/sliding_panel_shadow_height"
- sothree:slidePanelOffset="@dimen/bottom_action_bar_height">
+ app:dragView="@+id/firstPanelDragArea"
+ app:dragViewClickable="false"
+ app:panelHeight="@dimen/bottom_action_bar_height"
+ app:shadowHeight="@dimen/sliding_panel_shadow_height"
+ app:slidePanelOffset="@dimen/bottom_action_bar_height">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:visibility="gone">
- <Toolbar
+ <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:elevation="@dimen/action_bar_elevation"
- android:popupTheme="@style/ToolBarPopupTheme"
- android:theme="@style/ToolBarTheme" />
+ android:theme="@style/ToolBarTheme"
+ app:popupTheme="@style/ToolBarPopupTheme" />
<FrameLayout
android:id="@+id/activity_base_content"
@@ -57,11 +57,11 @@
android:layout_height="match_parent"
android:background="@color/activity_base_background_color"
android:gravity="bottom"
- sothree:directOffset="true"
- sothree:dragView="@+id/secondPanelDragArea"
- sothree:fadeColor="@color/transparent"
- sothree:panelHeight="@dimen/sliding_panel_indicator_height"
- sothree:shadowHeight="@dimen/sliding_panel_shadow_height">
+ app:directOffset="true"
+ app:dragView="@+id/secondPanelDragArea"
+ app:fadeColor="@color/transparent"
+ app:panelHeight="@dimen/sliding_panel_indicator_height"
+ app:shadowHeight="@dimen/sliding_panel_shadow_height">
<include
layout="@layout/blur_scrim_image"
diff --git a/res/menu/activity_base.xml b/res/menu/activity_base.xml
index 7bd7616..cad17c5 100644
--- a/res/menu/activity_base.xml
+++ b/res/menu/activity_base.xml
@@ -15,12 +15,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_settings"
android:orderInCategory="1000"
- android:showAsAction="never"
- android:title="@string/menu_settings"/>
+ android:title="@string/menu_settings"
+ app:showAsAction="never"/>
</menu>
\ No newline at end of file
diff --git a/res/menu/album_sort_by.xml b/res/menu/album_sort_by.xml
index 51eeee6..3dfbe5e 100644
--- a/res/menu/album_sort_by.xml
+++ b/res/menu/album_sort_by.xml
@@ -15,13 +15,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_sort_by"
- android:showAsAction="never"
android:orderInCategory="200"
- android:title="@string/menu_sort_by">
+ android:title="@string/menu_sort_by"
+ app:showAsAction="never">
<menu>
<item
android:id="@+id/menu_sort_by_az"
diff --git a/res/menu/artist_album_sort_by.xml b/res/menu/artist_album_sort_by.xml
index da58f3c..672348a 100644
--- a/res/menu/artist_album_sort_by.xml
+++ b/res/menu/artist_album_sort_by.xml
@@ -14,12 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_sort_by"
- android:showAsAction="never"
- android:title="@string/menu_sort_by">
+ android:title="@string/menu_sort_by"
+ app:showAsAction="never">
<menu>
<item
android:id="@+id/menu_sort_by_az"
diff --git a/res/menu/artist_song_sort_by.xml b/res/menu/artist_song_sort_by.xml
index 5cb76bc..3de99bc 100644
--- a/res/menu/artist_song_sort_by.xml
+++ b/res/menu/artist_song_sort_by.xml
@@ -14,12 +14,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_sort_by"
- android:showAsAction="never"
- android:title="@string/menu_sort_by">
+ android:title="@string/menu_sort_by"
+ app:showAsAction="never">
<menu>
<item
android:id="@+id/menu_sort_by_az"
diff --git a/res/menu/artist_sort_by.xml b/res/menu/artist_sort_by.xml
index 4498bd7..d9f288f 100644
--- a/res/menu/artist_sort_by.xml
+++ b/res/menu/artist_sort_by.xml
@@ -15,13 +15,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_sort_by"
- android:showAsAction="never"
android:orderInCategory="200"
- android:title="@string/menu_sort_by">
+ android:title="@string/menu_sort_by"
+ app:showAsAction="never">
<menu>
<item
android:id="@+id/menu_sort_by_az"
diff --git a/res/menu/audio_player.xml b/res/menu/audio_player.xml
index 1c2747a..294810a 100644
--- a/res/menu/audio_player.xml
+++ b/res/menu/audio_player.xml
@@ -15,27 +15,28 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_audio_player_equalizer"
- android:showAsAction="never"
android:orderInCategory="41"
- android:title="@string/menu_equalizer"/>
+ android:title="@string/menu_equalizer"
+ app:showAsAction="never" />
<item
android:id="@+id/menu_audio_player_ringtone"
- android:showAsAction="never"
android:orderInCategory="42"
- android:title="@string/context_menu_use_as_ringtone"/>
+ android:title="@string/context_menu_use_as_ringtone"
+ app:showAsAction="never" />
<item
android:id="@+id/menu_audio_player_more_by_artist"
- android:showAsAction="never"
android:orderInCategory="43"
- android:title="@string/context_menu_more_by_artist"/>
+ android:title="@string/context_menu_more_by_artist"
+ app:showAsAction="never" />
<item
android:id="@+id/menu_audio_player_delete"
- android:showAsAction="never"
android:orderInCategory="44"
- android:title="@string/context_menu_delete"/>
+ android:title="@string/context_menu_delete"
+ app:showAsAction="never" />
</menu>
diff --git a/res/menu/clear_list.xml b/res/menu/clear_list.xml
index e80855f..aceee62 100644
--- a/res/menu/clear_list.xml
+++ b/res/menu/clear_list.xml
@@ -15,12 +15,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/clear_list"
- android:showAsAction="never"
android:orderInCategory="150"
- android:title="@string/menu_clear_list"/>
+ android:title="@string/menu_clear_list"
+ app:showAsAction="never" />
</menu>
\ No newline at end of file
diff --git a/res/menu/new_playlist.xml b/res/menu/new_playlist.xml
index 08557ba..ad1f5e2 100644
--- a/res/menu/new_playlist.xml
+++ b/res/menu/new_playlist.xml
@@ -15,12 +15,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_new_playlist"
- android:showAsAction="never"
android:orderInCategory="130"
- android:title="@string/new_playlist"/>
+ android:title="@string/new_playlist"
+ app:showAsAction="never" />
</menu>
\ No newline at end of file
diff --git a/res/menu/queue.xml b/res/menu/queue.xml
index 0e9e5e0..6726098 100644
--- a/res/menu/queue.xml
+++ b/res/menu/queue.xml
@@ -15,17 +15,18 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_save_queue"
- android:showAsAction="never"
android:orderInCategory="50"
- android:title="@string/menu_save_queue"/>
+ android:title="@string/menu_save_queue"
+ app:showAsAction="never" />
<item
android:id="@+id/menu_clear_queue"
- android:showAsAction="never"
android:orderInCategory="51"
- android:title="@string/menu_clear_queue"/>
+ android:title="@string/menu_clear_queue"
+ app:showAsAction="never" />
</menu>
\ No newline at end of file
diff --git a/res/menu/search.xml b/res/menu/search.xml
index d0240a0..f040fbf 100644
--- a/res/menu/search.xml
+++ b/res/menu/search.xml
@@ -14,14 +14,15 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_search"
- android:actionViewClass="android.widget.SearchView"
android:icon="@drawable/ic_action_search"
android:orderInCategory="1"
- android:showAsAction="ifRoom|collapseActionView"
- android:title="@string/menu_search"/>
+ android:title="@string/menu_search"
+ app:actionViewClass="android.widget.SearchView"
+ app:showAsAction="ifRoom|collapseActionView" />
</menu>
diff --git a/res/menu/search_btn.xml b/res/menu/search_btn.xml
index 417ed89..c102956 100644
--- a/res/menu/search_btn.xml
+++ b/res/menu/search_btn.xml
@@ -15,11 +15,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_search"
android:icon="@drawable/ic_action_search"
android:orderInCategory="1"
- android:showAsAction="ifRoom"
- android:title="@string/menu_search"/>
+ android:title="@string/menu_search"
+ app:showAsAction="ifRoom" />
</menu>
diff --git a/res/menu/shuffle_all.xml b/res/menu/shuffle_all.xml
index 2691401..b935095 100644
--- a/res/menu/shuffle_all.xml
+++ b/res/menu/shuffle_all.xml
@@ -15,12 +15,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_shuffle_all"
- android:showAsAction="never"
android:orderInCategory="30"
- android:title="@string/menu_shuffle_all"/>
+ android:title="@string/menu_shuffle_all"
+ app:showAsAction="never" />
</menu>
\ No newline at end of file
diff --git a/res/menu/shuffle_item.xml b/res/menu/shuffle_item.xml
index cd37834..69c3728 100644
--- a/res/menu/shuffle_item.xml
+++ b/res/menu/shuffle_item.xml
@@ -15,12 +15,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_shuffle_item"
- android:showAsAction="never"
android:orderInCategory="30"
- android:title="@string/menu_shuffle_item"/>
+ android:title="@string/menu_shuffle_item"
+ app:showAsAction="never" />
</menu>
\ No newline at end of file
diff --git a/res/menu/song_sort_by.xml b/res/menu/song_sort_by.xml
index 113e9bc..7ee527a 100644
--- a/res/menu/song_sort_by.xml
+++ b/res/menu/song_sort_by.xml
@@ -15,13 +15,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+<menu xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_sort_by"
- android:showAsAction="never"
android:orderInCategory="200"
- android:title="@string/menu_sort_by">
+ android:title="@string/menu_sort_by"
+ app:showAsAction="never">
<menu>
<item
android:id="@+id/menu_sort_by_az"
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 28914b7..723839d 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -93,7 +93,7 @@
<color name="tab_selected_underline_color">@color/white</color>
<!-- Search Colors -->
- <color name="search_hint_color">@color/white</color>
+ <color name="search_hint_color">@color/black</color>
<!-- Color for the text on the audio player -->
<color name="audio_player_text_color">@color/default_text_color_light</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b942e5e..afc31e3 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -16,49 +16,47 @@
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Main Material -->
- <style name="Eleven.Theme" parent="@android:style/Theme.Material.Light.DarkActionBar">
+ <style name="Eleven.Theme" parent="@style/Theme.AppCompat.Light">
<item name="android:windowContentOverlay">@null</item>
- <item name="android:popupMenuStyle">@style/PopupMenu</item>
- <item name="android:dropDownListViewStyle">@style/DropDownListView</item>
- <item name="android:textAppearanceSmallPopupMenu">@style/SmallPopupMenu</item>
- <item name="android:textAppearanceLargePopupMenu">@style/LargePopupMenu</item>
+ <item name="popupMenuStyle">@style/PopupMenu</item>
+ <item name="dropDownListViewStyle">@style/DropDownListView</item>
+ <item name="textAppearanceSmallPopupMenu">@style/SmallPopupMenu</item>
+ <item name="textAppearanceLargePopupMenu">@style/LargePopupMenu</item>
<item name="android:listViewStyle">@style/ListView</item>
- <item name="android:actionBarStyle">@style/ActionBar</item>
- <item name="android:actionBarWidgetTheme">@style/ActionBarWidgetTheme</item>
- <item name="android:colorPrimary">@color/primary</item>
- <item name="android:colorPrimaryDark">@color/primary_dark</item>
- <item name="android:colorAccent">@color/accent</item>
+ <item name="actionBarStyle">@style/ActionBar</item>
+ <item name="actionBarWidgetTheme">@style/ActionBarWidgetTheme</item>
+ <item name="colorPrimary">@color/primary</item>
+ <item name="colorPrimaryDark">@color/primary_dark</item>
+ <item name="colorAccent">@color/accent</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">false</item>
<item name="android:windowAllowReturnTransitionOverlap">false</item>
</style>
- <style name="ActionBarWidgetTheme" parent="@android:style/Theme.Material">
+ <style name="ActionBarWidgetTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- This is the color of the search text hint in the action bar -->
<item name="android:textColorHint">@color/search_hint_color</item>
- <item name="android:popupMenuStyle">@style/PopupMenu</item>
- <item name="android:dropDownListViewStyle">@style/DropDownListView</item>
- <item name="android:textAppearanceSmallPopupMenu">@style/SmallPopupMenu</item>
- <item name="android:textAppearanceLargePopupMenu">@style/LargePopupMenu</item>
- <!-- Empty icon -->
- <item name="android:icon">@android:color/transparent</item>
+ <item name="popupMenuStyle">@style/PopupMenu</item>
+ <item name="dropDownListViewStyle">@style/DropDownListView</item>
+ <item name="textAppearanceSmallPopupMenu">@style/SmallPopupMenu</item>
+ <item name="textAppearanceLargePopupMenu">@style/LargePopupMenu</item>
</style>
<!-- Make the action bar not take up space -->
<style name="Eleven.Theme.ActionBar.Overlay" parent="@style/Eleven.Theme">
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="windowActionBar">false</item>
</style>
<!-- Set the default list view divider color and size -->
- <style name="ListView" parent="@android:style/Widget.Material.ListView">
- <item name="android:divider">@color/list_item_divider_color</item>
+ <style name="ListView" parent="@style/Widget.AppCompat.ListView">
+ <item name="divider">@color/list_item_divider_color</item>
<item name="android:dividerHeight">@dimen/divider_height</item>
</style>
- <style name="PopupMenu" parent="@android:style/Widget.Material.PopupMenu"/>
+ <style name="PopupMenu" parent="@style/Widget.AppCompat.PopupMenu"/>
- <style name="DropDownListView" parent="@android:style/Widget.Material.ListView.DropDown"/>
+ <style name="DropDownListView" parent="@style/Widget.AppCompat.ListView.DropDown"/>
<!-- Sets up the pop up menu text color and size -->
<style name="SmallPopupMenu" parent="@android:style/TextAppearance.Widget.PopupMenu.Small">
@@ -73,12 +71,12 @@
</style>
<!-- Sets the action bar title text style -->
- <style name="ActionBar" parent="@android:style/Widget.Material.ActionBar">
+ <style name="ActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@color/header_action_bar_color</item>
</style>
<!-- Sets the action bar menu icon -->
- <style name="ActionOverFlowButton" parent="@android:style/Widget.Material.ActionButton.Overflow">
+ <style name="ActionOverFlowButton" parent="@style/Widget.AppCompat.ActionButton">
<item name="android:src">@drawable/menu_button_light</item>
<item name="android:minWidth">0dip</item>
<item name="android:paddingLeft">8dip</item>
@@ -128,7 +126,7 @@
</style>
<!-- Shortcut Activity theme -->
- <style name="Theme.Transparent" parent="@android:style/Theme.Material.NoActionBar">
+ <style name="Theme.Transparent" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
@@ -137,7 +135,7 @@
<item name="android:backgroundDimEnabled">false</item>
</style>
- <style name="Theme.AudioPreview" parent="@android:style/Theme.Material.NoActionBar">
+ <style name="Theme.AudioPreview" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
@@ -192,7 +190,7 @@
<item name="android:textSize">@dimen/tab_text_size</item>
</style>
- <style name="ToolBarTheme" parent="android:style/ThemeOverlay.Material.Dark.ActionBar" />
+ <style name="ToolBarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
- <style name="ToolBarPopupTheme" parent="android:style/Theme.Material.Light" />
+ <style name="ToolBarPopupTheme" parent="@style/Theme.AppCompat.Light" />
</resources>
diff --git a/src/org/lineageos/eleven/ui/activities/BaseActivity.java b/src/org/lineageos/eleven/ui/activities/BaseActivity.java
index e27789f..bfac78b 100644
--- a/src/org/lineageos/eleven/ui/activities/BaseActivity.java
+++ b/src/org/lineageos/eleven/ui/activities/BaseActivity.java
@@ -18,7 +18,6 @@
package org.lineageos.eleven.ui.activities;
-import android.app.ActionBar;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -37,8 +36,11 @@
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
-import android.widget.Toolbar;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import org.lineageos.eleven.MusicPlaybackService;
@@ -64,7 +66,7 @@
*
* @author Andrew Neal (andrewdneal@gmail.com)
*/
-public abstract class BaseActivity extends FragmentActivity implements ServiceConnection,
+public abstract class BaseActivity extends AppCompatActivity implements ServiceConnection,
MusicStateListener, ICacheListener {
/**
@@ -132,14 +134,14 @@
// Set the layout
setContentView(setContentView());
- mToolBar = (Toolbar) findViewById(R.id.toolbar);
- setActionBar(mToolBar);
+ mToolBar = findViewById(R.id.toolbar);
+ setSupportActionBar(mToolBar);
setActionBarTitle(getString(R.string.app_name));
// set the background on the root view
getWindow().getDecorView().getRootView().setBackgroundColor(
- getResources().getColor(R.color.background_color));
+ ContextCompat.getColor(this, R.color.background_color));
// Initialze the bottom action bar
initBottomActionBar();
@@ -278,15 +280,18 @@
setActionBarTitle(title);
if (mActionBarBackground == null) {
- final int actionBarColor = getResources().getColor(R.color.header_action_bar_color);
+ final int actionBarColor = ContextCompat.getColor(this,
+ R.color.header_action_bar_color);
mActionBarBackground = new ColorDrawable(actionBarColor);
- mToolBar.setBackgroundDrawable(mActionBarBackground);
+ mToolBar.setBackground(mActionBarBackground);
}
}
public void setActionBarTitle(String title) {
- ActionBar actionBar = getActionBar();
- actionBar.setTitle(title);
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setTitle(title);
+ }
}
public void setActionBarAlpha(int alpha) {
diff --git a/src/org/lineageos/eleven/ui/activities/HomeActivity.java b/src/org/lineageos/eleven/ui/activities/HomeActivity.java
index 0d9617b..39d02fa 100644
--- a/src/org/lineageos/eleven/ui/activities/HomeActivity.java
+++ b/src/org/lineageos/eleven/ui/activities/HomeActivity.java
@@ -33,6 +33,7 @@
import android.view.MenuItem;
import android.view.Window;
+import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -301,7 +302,7 @@
// this happens when they launch search which is its own activity and then
// browse through that back to home activity
mLoadedBaseFragment = true;
- getActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// the current top fragment is about to be hidden by what we are replacing
// it with -- so tell that fragment not to make its action bar menu items visible
@@ -479,14 +480,14 @@
ISetupActionBar setupActionBar = (ISetupActionBar) topFragment;
setupActionBar.setupActionBar();
- getActionBar().setDisplayHomeAsUpEnabled(
+ getSupportActionBar().setDisplayHomeAsUpEnabled(
!(topFragment instanceof MusicBrowserPhoneFragment));
}
}
@Override
- public void onRequestPermissionsResult(int requestCode, String permissions[],
- int[] grantResults) {
+ public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
+ @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSION_REQUEST_STORAGE: {
if (checkPermissionGrantResults(grantResults)) {
diff --git a/src/org/lineageos/eleven/ui/activities/SearchActivity.java b/src/org/lineageos/eleven/ui/activities/SearchActivity.java
index aba0d28..512d563 100644
--- a/src/org/lineageos/eleven/ui/activities/SearchActivity.java
+++ b/src/org/lineageos/eleven/ui/activities/SearchActivity.java
@@ -13,7 +13,6 @@
package org.lineageos.eleven.ui.activities;
-import android.app.ActionBar;
import android.app.SearchManager;
import android.content.ComponentName;
import android.content.Context;
@@ -43,6 +42,9 @@
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
@@ -85,7 +87,7 @@
*
* @author Andrew Neal (andrewdneal@gmail.com)
*/
-public class SearchActivity extends FragmentActivity implements
+public class SearchActivity extends AppCompatActivity implements
LoaderManager.LoaderCallbacks<SectionListContainer<SearchResult>>,
OnScrollListener, OnQueryTextListener, OnItemClickListener, OnTouchListener {
/**
@@ -280,7 +282,7 @@
}
});
- mLoadingEmptyContainer = (LoadingEmptyContainer) findViewById(R.id.loading_empty_container);
+ mLoadingEmptyContainer = findViewById(R.id.loading_empty_container);
// setup the no results container
NoResultsContainer noResults = mLoadingEmptyContainer.getNoResultsContainer();
noResults.setMainText(R.string.empty_search);
@@ -298,8 +300,10 @@
};
// Theme the action bar
- final ActionBar actionBar = getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
+ final ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ }
// Get the query String
mFilterString = getIntent().getStringExtra(SearchManager.QUERY);
@@ -433,7 +437,7 @@
// Filter the list the user is looking it via SearchView
MenuItem searchItem = menu.findItem(R.id.menu_search);
- mSearchView = (SearchView)searchItem.getActionView();
+ mSearchView = (SearchView) searchItem.getActionView();
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getString(R.string.searchHint));
@@ -751,9 +755,10 @@
}
// pre-cache this index
- final int mimeTypeIndex = cursor.getColumnIndex(MediaStore.Audio.Media.MIME_TYPE);
-
if (cursor != null && cursor.moveToFirst()) {
+ final int mimeTypeIndex = cursor.getColumnIndex(
+ MediaStore.Audio.Media.MIME_TYPE);
+
do {
boolean addResult = true;
@@ -825,11 +830,12 @@
// do fancy audio search
Cursor cursor = ElevenUtils.createSearchQueryCursor(getContext(), mQuery);
- // pre-cache this index
- final int mimeTypeIndex = cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE);
-
// walk through the cursor
if (cursor != null && cursor.moveToFirst()) {
+ // pre-cache this index
+ final int mimeTypeIndex = cursor.getColumnIndexOrThrow(
+ MediaStore.Audio.Media.MIME_TYPE);
+
do {
// get the result type
ResultType type = ResultType.getResultType(cursor, mimeTypeIndex);
@@ -925,6 +931,7 @@
* This handles the Loader callbacks for the search history
*/
public class SearchHistoryCallback implements LoaderManager.LoaderCallbacks<ArrayAdapter<String>> {
+ @NonNull
@Override
public Loader<ArrayAdapter<String>> onCreateLoader(int i, Bundle bundle) {
// prep the loader in case the query takes a long time
@@ -934,8 +941,8 @@
}
@Override
- public void onLoadFinished(Loader<ArrayAdapter<String>> searchHistoryAdapterLoader,
- ArrayAdapter<String> searchHistoryAdapter) {
+ public void onLoadFinished(@NonNull Loader<ArrayAdapter<String>> searchHistoryAdapterLoader,
+ ArrayAdapter<String> searchHistoryAdapter) {
// show the search history
setState(VisibleState.SearchHistory);
@@ -943,7 +950,7 @@
}
@Override
- public void onLoaderReset(Loader<ArrayAdapter<String>> cursorAdapterLoader) {
+ public void onLoaderReset(@NonNull Loader<ArrayAdapter<String>> cursorAdapterLoader) {
((ArrayAdapter)mSearchHistoryListView.getAdapter()).clear();
}
}
diff --git a/src/org/lineageos/eleven/ui/activities/SettingsActivity.java b/src/org/lineageos/eleven/ui/activities/SettingsActivity.java
index 2fde1ca..08f9b42 100644
--- a/src/org/lineageos/eleven/ui/activities/SettingsActivity.java
+++ b/src/org/lineageos/eleven/ui/activities/SettingsActivity.java
@@ -45,9 +45,6 @@
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // UP
- getActionBar().setDisplayHomeAsUpEnabled(true);
-
// Add the preferences
addPreferencesFromResource(R.xml.settings);
diff --git a/src/org/lineageos/eleven/ui/activities/preview/AudioPreviewActivity.java b/src/org/lineageos/eleven/ui/activities/preview/AudioPreviewActivity.java
index 4a7c6e3..039d681 100644
--- a/src/org/lineageos/eleven/ui/activities/preview/AudioPreviewActivity.java
+++ b/src/org/lineageos/eleven/ui/activities/preview/AudioPreviewActivity.java
@@ -46,6 +46,9 @@
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
+
+import androidx.appcompat.app.AppCompatActivity;
+
import org.lineageos.eleven.R;
import org.lineageos.eleven.ui.activities.preview.util.Logger;
@@ -57,17 +60,10 @@
* <pre>
* Preview plays external audio files in a dialog over the application
* </pre>
- *
- * @see {@link Activity}
- * @see {@link android.media.MediaPlayer.OnCompletionListener}
- * @see {@link android.media.MediaPlayer.OnErrorListener}
- * @see {@link android.media.MediaPlayer.OnPreparedListener}
- * @see {@link OnClickListener}
- * @see {@link OnAudioFocusChangeListener}
- * @see {@link OnSeekBarChangeListener}
*/
-public class AudioPreviewActivity extends Activity implements MediaPlayer.OnCompletionListener,
- MediaPlayer.OnErrorListener, MediaPlayer.OnPreparedListener, OnClickListener,
+public class AudioPreviewActivity extends AppCompatActivity implements
+ MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener,
+ MediaPlayer.OnPreparedListener, OnClickListener,
OnAudioFocusChangeListener, OnSeekBarChangeListener, OnTouchListener {
// Constants
@@ -196,7 +192,7 @@
}
Logger.logd(TAG, "URI: " + uri);
mPreviewSong.URI = uri;
- PreviewPlayer localPlayer = (PreviewPlayer) getLastNonConfigurationInstance();
+ PreviewPlayer localPlayer = (PreviewPlayer) getLastCustomNonConfigurationInstance();
if (localPlayer == null) {
mPreviewPlayer = new PreviewPlayer();
mPreviewPlayer.setCallbackActivity(this);
@@ -248,7 +244,7 @@
}
@Override
- public Object onRetainNonConfigurationInstance() {
+ public Object onRetainCustomNonConfigurationInstance() {
mPreviewPlayer.clearCallbackActivity();
PreviewPlayer localPlayer = mPreviewPlayer;
mPreviewPlayer = null;