diff options
author | TacoTheDank <SkytkRSfan3895@gmail.com> | 2021-01-07 19:51:42 +0300 |
---|---|---|
committer | TacoTheDank <SkytkRSfan3895@gmail.com> | 2021-01-07 19:51:42 +0300 |
commit | 2441815e56dc7b99731d86100ef4d9a1f53a2aa3 (patch) | |
tree | 8e96dc42b73f69a67df0a5748126143f1590a63e /app | |
parent | a1d71ff923655260e24388828b242bec40b397d6 (diff) |
Use some Compat classes
Diffstat (limited to 'app')
7 files changed, 14 insertions, 9 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index 4fc618134..18d12f91c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -26,6 +26,7 @@ import androidx.annotation.RequiresApi; import androidx.annotation.UiThread; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatDelegate; +import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.util.Pair; @@ -516,7 +517,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener } else { // If we notice after updating the capabilities, that the new version is not supported, but it was previously, recreate the activity to make sure all elements are disabled properly if (mainViewModel.getCurrentAccount().getServerDeckVersionAsObject().isSupported(MainActivity.this) && !response.getDeckVersion().isSupported(MainActivity.this)) { - recreate(); + ActivityCompat.recreate(MainActivity.this); } } } @@ -761,7 +762,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener switch (requestCode) { case MainActivity.ACTIVITY_SETTINGS: if (resultCode == RESULT_OK) { - recreate(); + ActivityCompat.recreate(this); } break; case ImportAccountActivity.REQUEST_CODE_IMPORT_ACCOUNT: diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentsActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentsActivity.java index 6618f7f72..b65b727aa 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentsActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/attachments/AttachmentsActivity.java @@ -50,7 +50,7 @@ public class AttachmentsActivity extends AppCompatActivity { supportPostponeEnterTransition(); setSupportActionBar(binding.toolbar); - final Drawable navigationIcon = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp); + final Drawable navigationIcon = ContextCompat.getDrawable(this, R.drawable.ic_arrow_back_white_24dp); DrawableCompat.setTint(navigationIcon, ContextCompat.getColor(this, android.R.color.white)); binding.toolbar.setNavigationIcon(navigationIcon); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java index 0a1281fae..9f4e1a671 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlAdapter.java @@ -93,7 +93,8 @@ public class AccessControlAdapter extends RecyclerView.Adapter<RecyclerView.View ViewUtil.addAvatar(acHolder.binding.avatar, account.getUrl(), ac.getUser().getUid(), R.drawable.ic_person_grey600_24dp); acHolder.binding.username.setText(ac.getUser().getDisplayname()); - acHolder.binding.username.setCompoundDrawables(null, null, ac.getStatus() == DBStatus.LOCAL_EDITED.getId() ? context.getResources().getDrawable(R.drawable.ic_sync_blue_24dp) : null, null); + acHolder.binding.username.setCompoundDrawables(null, null, ac.getStatus() == DBStatus.LOCAL_EDITED.getId() + ? ContextCompat.getDrawable(context, R.drawable.ic_sync_blue_24dp) : null, null); acHolder.binding.delete.setOnClickListener((v) -> accessControlChangedListener.deleteAccessControl(ac)); if (hasManagePermission) { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/managelabels/ManageLabelsAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/managelabels/ManageLabelsAdapter.java index d8bb57a11..4010b3a00 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/managelabels/ManageLabelsAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/managelabels/ManageLabelsAdapter.java @@ -5,6 +5,7 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import java.util.LinkedList; @@ -33,7 +34,7 @@ public class ManageLabelsAdapter extends RecyclerView.Adapter<ManageLabelsViewHo ManageLabelsAdapter(@NonNull ManageLabelListener listener, @NonNull Context context) { this.listener = listener; this.context = context; - this.mainColor = context.getResources().getColor(R.color.primary); + this.mainColor = ContextCompat.getColor(context, R.color.primary); setHasStableIds(true); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/LabelAutoCompleteAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/LabelAutoCompleteAdapter.java index fe974f2a0..de9d23829 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/LabelAutoCompleteAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/LabelAutoCompleteAdapter.java @@ -12,6 +12,7 @@ import androidx.activity.ComponentActivity; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.lifecycle.LiveData; @@ -68,7 +69,7 @@ public class LabelAutoCompleteAdapter extends AutoCompleteAdapter<Label> { binding.label.setTextColor(color); if (ITEM_CREATE == label.getLocalId()) { - final Drawable plusIcon = DrawableCompat.wrap(binding.label.getContext().getResources().getDrawable(R.drawable.ic_plus)); + final Drawable plusIcon = DrawableCompat.wrap(ContextCompat.getDrawable(binding.label.getContext(), R.drawable.ic_plus)); DrawableCompat.setTint(plusIcon, color); binding.label.setChipIcon(plusIcon); } else { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java index 4c96f5bf3..647dfd651 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/filter/FilterDialogFragment.java @@ -47,7 +47,7 @@ public class FilterDialogFragment extends BrandedDialogFragment { indicator = ContextCompat.getDrawable(requireContext(), R.drawable.circle_grey600_8dp); assert indicator != null; - indicator.setColorFilter(getResources().getColor(R.color.defaultBrand), PorterDuff.Mode.SRC_ATOP); + indicator.setColorFilter(ContextCompat.getColor(getContext(), R.color.defaultBrand), PorterDuff.Mode.SRC_ATOP); filterViewModel = new ViewModelProvider(requireActivity()).get(FilterViewModel.class); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java index c3222cf3b..1cf675f54 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/settings/SettingsFragment.java @@ -5,6 +5,7 @@ import android.content.Context; import android.os.Bundle; import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; @@ -45,7 +46,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Brande themePref.setOnPreferenceChangeListener((Preference preference, Object newValue) -> { setAppTheme(Integer.parseInt((String) newValue)); requireActivity().setResult(Activity.RESULT_OK); - requireActivity().recreate(); + ActivityCompat.recreate(requireActivity()); return true; }); } else { @@ -58,7 +59,7 @@ public class SettingsFragment extends PreferenceFragmentCompat implements Brande final Boolean branding = (Boolean) newValue; DeckLog.log("branding: " + branding); requireActivity().setResult(Activity.RESULT_OK); - requireActivity().recreate(); + ActivityCompat.recreate(requireActivity()); return true; }); } else { |