Bumps compile API to 29 (Q) removes unecessary casts and deprecated calls

This will help the Android client to evolve with the latest libraries (as the legacy support libs will not be shipped anymore with the com.android.support package).

This PR also makes the app compliant with the new API requirements to start later this year:
android-developers.googleblog.com/2019/02/expanding-target-api-level-requirements.html.

Original commit by rafaeltoledo for Dolphin-emu.
This commit is contained in:
FearlessTobi 2020-03-29 18:50:44 +02:00 committed by bunnei
parent 31c702b89b
commit 3f7cccb6a5
8 changed files with 30 additions and 39 deletions

View File

@ -9,7 +9,7 @@ def autoVersion = (int) (((new Date().getTime() / 1000) - 1451606400) / 10)
def buildType
android {
compileSdkVersion 28
compileSdkVersion 29
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@ -100,16 +100,12 @@ android {
}
}
ext {
androidSupportVersion = '28.0.0'
}
dependencies {
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.exifinterface:exifinterface:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
// Android TV UI libraries.
implementation 'androidx.leanback:leanback:1.0.0'
@ -119,7 +115,7 @@ dependencies {
// Allows FRP-style asynchronous operations in Android.
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'com.nononsenseapps:filepicker:4.1.0'
implementation 'com.nononsenseapps:filepicker:4.2.1'
implementation 'org.ini4j:ini4j:0.5.4'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

View File

@ -5,6 +5,8 @@ import android.database.DataSetObserver;
import android.graphics.Rect;
import android.os.Build;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
@ -203,8 +205,8 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
public void getItemOffsets(Rect outRect, @NonNull View view, @NonNull RecyclerView parent,
@NonNull RecyclerView.State state) {
outRect.left = 0;
outRect.right = 0;
outRect.bottom = space;

View File

@ -5,8 +5,11 @@ import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
@ -20,7 +23,6 @@ public final class DividerItemDecoration extends RecyclerView.ItemDecoration {
private boolean mShowFirstDivider = false;
private boolean mShowLastDivider = false;
public DividerItemDecoration(Context context, AttributeSet attrs) {
final TypedArray a = context
.obtainStyledAttributes(attrs, new int[]{android.R.attr.listDivider});
@ -47,13 +49,13 @@ public final class DividerItemDecoration extends RecyclerView.ItemDecoration {
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent,
@NonNull RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
if (mDivider == null) {
return;
}
if (parent.getChildPosition(view) < 1) {
if (parent.getChildAdapterPosition(view) < 1) {
return;
}
@ -65,7 +67,7 @@ public final class DividerItemDecoration extends RecyclerView.ItemDecoration {
}
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
if (mDivider == null) {
super.onDrawOver(c, parent, state);
return;

View File

@ -4,6 +4,8 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.leanback.app.BrowseFragment;
import androidx.leanback.app.BrowseSupportFragment;
import androidx.leanback.database.CursorMapper;
@ -15,6 +17,7 @@ import androidx.leanback.widget.ListRowPresenter;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.core.content.ContextCompat;
import android.widget.Toast;
import org.citra.citra_emu.R;
@ -67,7 +70,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView {
.commit();
// Set display parameters for the BrowseFragment
mBrowseFragment.setHeadersState(BrowseFragment.HEADERS_ENABLED);
mBrowseFragment.setHeadersState(BrowseSupportFragment.HEADERS_ENABLED);
mBrowseFragment.setBrandColor(ContextCompat.getColor(this, R.color.citra_orange_dark));
buildRowsAdapter();
@ -142,7 +145,7 @@ public final class TvMainActivity extends FragmentActivity implements MainView {
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode) {
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {

View File

@ -2,11 +2,13 @@ package org.citra.citra_emu.ui.platform;
import android.database.Cursor;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -27,7 +29,6 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_grid, container, false);

View File

@ -49,19 +49,6 @@ public final class SettingsFragment extends Fragment implements SettingsFragment
mPresenter.onAttach();
}
/**
* This version of onAttach is needed for versions below Marshmallow.
*
* @param activity
*/
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mActivity = (SettingsActivityView) activity;
mPresenter.onAttach();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@ -11,6 +11,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Environment;
import android.preference.PreferenceManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.citra.citra_emu.NativeLibrary;
@ -22,7 +23,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* A service that spawns its own thread in order to copy several binary and shader files
* from the Dolphin APK to the external file system.

View File

@ -2,7 +2,7 @@
<resources>
<!-- Inherit from the material theme -->
<style name="CitraBase" parent="Theme.AppCompat.Light.NoActionBar">
<style name="CitraBase" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Main theme colors -->
<!-- Branding color for the app bar -->
<item name="colorPrimary">@color/citra_orange</item>
@ -18,7 +18,7 @@
</style>
<!-- Same as above, but use default action bar, and mandate margins. -->
<style name="CitraSettingsBase" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="CitraSettingsBase" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/citra_orange</item>
<item name="colorPrimaryDark">@color/citra_orange_dark</item>
</style>
@ -34,7 +34,7 @@
<!-- Themes for Dialogs -->
<!-- Inherit from the Base Citra Dialog Theme -->
<style name="CitraEmulationBase" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="CitraEmulationBase" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/citra_orange</item>
<item name="colorPrimaryDark">@color/citra_orange_dark</item>
<item name="android:windowTranslucentNavigation">true</item>
@ -52,7 +52,7 @@
<item name="colorAccent">@color/citra_accent</item>
</style>
<style name="CitraEmulationTvBase" parent="Theme.AppCompat.Light.NoActionBar">
<style name="CitraEmulationTvBase" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">@color/citra_orange</item>
<item name="colorPrimaryDark">@color/citra_orange_dark</item>
<item name="android:windowTranslucentNavigation">true</item>
@ -125,7 +125,7 @@
<item name="nnf_toolbarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>
<style name="FilePickerAlertDialogTheme" parent="Theme.AppCompat.Dialog.Alert">
<style name="FilePickerAlertDialogTheme" parent="Theme.MaterialComponents.Dialog.Alert">
<item name="colorPrimary">@color/citra_orange</item>
<item name="colorPrimaryDark">@color/citra_orange_dark</item>
<item name="colorAccent">@color/citra_accent</item>