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

Enable non-final resource IDs #21179

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,22 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) {
}

@Override
@SuppressLint("NonConstantResourceId")
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.app_log_share:
shareAppLog();
return true;
case R.id.app_log_copy_to_clipboard:
copyAppLogToClipboard();
return true;
default:
return super.onOptionsItemSelected(item);
if (item.getItemId() == android.R.id.home) {
finish();
return true;
}

if (item.getItemId() == R.id.app_log_share) {
shareAppLog();
return true;
}

if (item.getItemId() == R.id.app_log_copy_to_clipboard) {
copyAppLogToClipboard();
return true;
}

return super.onOptionsItemSelected(item);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package org.wordpress.android.ui.avatars

import android.annotation.SuppressLint
import androidx.annotation.DimenRes
import org.wordpress.android.R
import org.wordpress.android.ui.avatars.TrainOfAvatarsViewType.AVATAR
import org.wordpress.android.ui.avatars.TrainOfAvatarsViewType.TRAILING_LABEL
import org.wordpress.android.ui.utils.UiString

@DimenRes
@SuppressLint("NonConstantResourceId")
const val AVATAR_LEFT_OFFSET_DIMEN = R.dimen.margin_small_medium
var AVATAR_LEFT_OFFSET_DIMEN = R.dimen.margin_small_medium

@DimenRes
@SuppressLint("NonConstantResourceId")
const val AVATAR_SIZE_DIMEN = R.dimen.avatar_sz_small
var AVATAR_SIZE_DIMEN = R.dimen.avatar_sz_small

sealed class TrainOfAvatarsItem(val type: TrainOfAvatarsViewType) {
data class AvatarItem(val userAvatarUrl: String) : TrainOfAvatarsItem(AVATAR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.wordpress.android.ui.jetpackoverlay

import android.annotation.SuppressLint
import org.wordpress.android.R
import java.time.LocalDate
import java.time.temporal.ChronoUnit
Expand All @@ -13,36 +12,31 @@ sealed class JetpackBrandingUiState {
val otherRes: Int

companion object {
@SuppressLint("NonConstantResourceId")
const val RES_ARE_MOVING_IN = R.string.wp_jetpack_powered_phase_3_feature_are_moving_in
@SuppressLint("NonConstantResourceId")
const val RES_IS_MOVING_IN = R.string.wp_jetpack_powered_phase_3_feature_is_moving_in
var RES_ARE_MOVING_IN = R.string.wp_jetpack_powered_phase_3_feature_are_moving_in
var RES_IS_MOVING_IN = R.string.wp_jetpack_powered_phase_3_feature_is_moving_in
}
}

object Soon : JetpackBrandingUiState(), Indeterminate {
@SuppressLint("NonConstantResourceId")
const val RES_ARE_MOVING_SOON = R.string.wp_jetpack_powered_phase_3_feature_are_moving_soon
@SuppressLint("NonConstantResourceId")
const val RES_IS_MOVING_SOON = R.string.wp_jetpack_powered_phase_3_feature_is_moving_soon
var RES_ARE_MOVING_SOON = R.string.wp_jetpack_powered_phase_3_feature_are_moving_soon
var RES_IS_MOVING_SOON = R.string.wp_jetpack_powered_phase_3_feature_is_moving_soon
}

data class Weeks(override val number: Long) : JetpackBrandingUiState(), Pluralisable {
override val oneRes = R.string.weeks_quantity_one
override val otherRes = R.string.weeks_quantity_other
override var oneRes = R.string.weeks_quantity_one
override var otherRes = R.string.weeks_quantity_other
}

data class Days(override val number: Long) : JetpackBrandingUiState(), Pluralisable {
override val oneRes = R.string.days_quantity_one
override val otherRes = R.string.days_quantity_other
override var oneRes = R.string.days_quantity_one
override var otherRes = R.string.days_quantity_other
}

object Unknown : JetpackBrandingUiState(), Indeterminate
object Passed : JetpackBrandingUiState()
data object Passed : JetpackBrandingUiState()

companion object {
@SuppressLint("NonConstantResourceId")
const val RES_JP_POWERED = R.string.wp_jetpack_powered
var RES_JP_POWERED = R.string.wp_jetpack_powered

fun between(startDate: LocalDate, endDate: LocalDate): JetpackBrandingUiState {
val days = ChronoUnit.DAYS.between(startDate, endDate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.wordpress.android.ui.media;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
Expand Down Expand Up @@ -662,29 +661,31 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) {
}

@Override
@SuppressLint("NonConstantResourceId")
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
getOnBackPressedDispatcher().onBackPressed();
return true;
case R.id.menu_new_media:
// Do Nothing (handled in action view click listener)
return true;
case R.id.menu_search:
mSearchMenuItem = item;
mSearchMenuItem.setOnActionExpandListener(this);
mSearchMenuItem.expandActionView();

mSearchView = (SearchView) item.getActionView();
mSearchView.setOnQueryTextListener(this);

// load last saved query
if (!TextUtils.isEmpty(mQuery)) {
onQueryTextSubmit(mQuery);
mSearchView.setQuery(mQuery, true);
}
return true;
if (item.getItemId() == android.R.id.home) {
getOnBackPressedDispatcher().onBackPressed();
return true;
}

if (item.getItemId() == R.id.menu_new_media) {
// Do Nothing (handled in action view click listener)
return true;
}

if (item.getItemId() == R.id.menu_search) {
mSearchMenuItem = item;
mSearchMenuItem.setOnActionExpandListener(this);
mSearchMenuItem.expandActionView();

mSearchView = (SearchView) item.getActionView();
mSearchView.setOnQueryTextListener(this);

// load last saved query
if (!TextUtils.isEmpty(mQuery)) {
onQueryTextSubmit(mQuery);
mSearchView.setQuery(mQuery, true);
}
return true;
}

return super.onOptionsItemSelected(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,19 @@ public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
GalleryType galleryType;
switch (checkedId) {
case R.id.radio_circles:
galleryType = GalleryType.CIRCLES;
break;
case R.id.radio_slideshow:
galleryType = GalleryType.SLIDESHOW;
break;
case R.id.radio_squares:
galleryType = GalleryType.SQUARES;
break;
case R.id.radio_tiled:
galleryType = GalleryType.TILED;
break;
default:
galleryType = GalleryType.DEFAULT;
break;

if (checkedId == R.id.radio_circles) {
galleryType = GalleryType.CIRCLES;
} else if (checkedId == R.id.radio_slideshow) {
galleryType = GalleryType.SLIDESHOW;
} else if (checkedId == R.id.radio_squares) {
galleryType = GalleryType.SQUARES;
} else if (checkedId == R.id.radio_tiled) {
galleryType = GalleryType.SQUARES;
} else {
galleryType = GalleryType.DEFAULT;
}

setGalleryType(galleryType);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2232,38 +2232,38 @@ public void onSelectTimezone(@NonNull String timezone) {

private final class ActionModeCallback implements ActionMode.Callback {
@Override
@SuppressLint("NonConstantResourceId")
public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_delete:
SparseBooleanArray checkedItems = getAdapter().getItemsSelected();
if (item.getItemId() == R.id.menu_delete) {
SparseBooleanArray checkedItems = getAdapter().getItemsSelected();

HashMap<String, Object> properties = new HashMap<>();
properties.put("num_items_deleted", checkedItems.size());
AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_DELETED_LIST_ITEMS,
mSite, properties);
HashMap<String, Object> properties = new HashMap<>();
properties.put("num_items_deleted", checkedItems.size());
AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_DELETED_LIST_ITEMS,
mSite, properties);

for (int i = checkedItems.size() - 1; i >= 0; i--) {
final int index = checkedItems.keyAt(i);
for (int i = checkedItems.size() - 1; i >= 0; i--) {
final int index = checkedItems.keyAt(i);

if (checkedItems.get(index)) {
mEditingList.remove(index);
}
if (checkedItems.get(index)) {
mEditingList.remove(index);
}
}

mSiteSettings.saveSettings();
mActionMode.finish();
return true;
case R.id.menu_select_all:
for (int i = 0; i < getAdapter().getItemCount(); i++) {
getAdapter().setItemSelected(i);
}
mSiteSettings.saveSettings();
mActionMode.finish();
return true;
}

if (item.getItemId() == R.id.menu_select_all) {
for (int i = 0; i < getAdapter().getItemCount(); i++) {
getAdapter().setItemSelected(i);
}

mActionMode.invalidate();
return true;
default:
return false;
mActionMode.invalidate();
return true;
}

return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.wordpress.android.ui.reader;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
Expand Down Expand Up @@ -206,15 +205,15 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) {
}

@Override
@SuppressLint("NonConstantResourceId")
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
getOnBackPressedDispatcher().onBackPressed();
return true;
case R.id.menu_share:
shareSite();
return true;
if (item.getItemId() == android.R.id.home) {
getOnBackPressedDispatcher().onBackPressed();
return true;
}

if (item.getItemId() == R.id.menu_share) {
shareSite();
return true;
}

return super.onOptionsItemSelected(item);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package org.wordpress.android.ui.sitecreation.services

import android.annotation.SuppressLint
import android.app.Notification
import android.content.Context
import org.wordpress.android.R
import org.wordpress.android.util.AutoForegroundNotification

object SiteCreationServiceNotification {
@SuppressLint("NonConstantResourceId")
private const val channelResId = R.string.notification_channel_normal_id
@SuppressLint("NonConstantResourceId")
private const val colorResId = R.color.primary_50
@SuppressLint("NonConstantResourceId")
private const val drawableResId = R.drawable.ic_app_white_24dp
private var channelResId = R.string.notification_channel_normal_id
private var colorResId = R.color.primary_50
private var drawableResId = R.drawable.ic_app_white_24dp

fun createCreatingSiteNotification(context: Context): Notification {
return AutoForegroundNotification.progressIndeterminate(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.wordpress.android.viewmodel.pages

import android.annotation.SuppressLint
import androidx.annotation.ColorRes
import org.wordpress.android.R
import org.wordpress.android.fluxc.model.PostModel
Expand All @@ -15,12 +14,9 @@ import org.wordpress.android.viewmodel.pages.PostModelUploadUiStateUseCase.PostU
import org.wordpress.android.viewmodel.pages.PostModelUploadUiStateUseCase.PostUploadUiState.UploadingPost
import javax.inject.Inject

@SuppressLint("NonConstantResourceId")
const val ERROR_COLOR = R.color.error
@SuppressLint("NonConstantResourceId")
const val PROGRESS_INFO_COLOR = R.color.neutral_50
@SuppressLint("NonConstantResourceId")
const val STATE_INFO_COLOR = R.color.warning_dark
var ERROR_COLOR = R.color.error
var PROGRESS_INFO_COLOR = R.color.neutral_50
var STATE_INFO_COLOR = R.color.warning_dark

class PostPageListLabelColorUseCase @Inject constructor() {
@ColorRes
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties-example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android.useAndroidX=true
android.enableJetifier=false

android.nonTransitiveRClass=true
android.nonFinalResIds=false
android.nonFinalResIds=true
android.enableR8.fullMode=false

# For more details on what these properties do visit
Expand Down
Loading