mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-22 21:06:09 +03:00
Fix some lint issues
This commit is contained in:
parent
331b3206da
commit
20a53eb828
15 changed files with 30 additions and 25 deletions
|
@ -160,7 +160,7 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
|
|||
String category = null;
|
||||
boolean favorite = false;
|
||||
if (intent.hasExtra(PARAM_CATEGORY)) {
|
||||
Category categoryPreselection = (Category) intent.getSerializableExtra(PARAM_CATEGORY);
|
||||
Category categoryPreselection = (Category) Objects.requireNonNull(intent.getSerializableExtra(PARAM_CATEGORY));
|
||||
category = categoryPreselection.category;
|
||||
favorite = categoryPreselection.favorite != null ? categoryPreselection.favorite : false;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
|
|||
String content = "";
|
||||
if (
|
||||
intent.hasExtra(Intent.EXTRA_TEXT) &&
|
||||
MIMETYPE_TEXT_PLAIN.equals(intent.getType()) &&
|
||||
MIMETYPE_TEXT_PLAIN.equals(intent.getType()) &&
|
||||
(Intent.ACTION_SEND.equals(intent.getAction()) ||
|
||||
INTENT_GOOGLE_ASSISTANT.equals(intent.getAction()))
|
||||
) {
|
||||
|
|
|
@ -11,6 +11,8 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import it.niedermann.nextcloud.exception.ExceptionUtil;
|
||||
import it.niedermann.owncloud.notes.R;
|
||||
|
||||
|
@ -36,7 +38,7 @@ public class ExceptionActivity extends AppCompatActivity {
|
|||
findViewById(R.id.close).setOnClickListener((v) -> close());
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
throwable = ((Throwable) getIntent().getSerializableExtra(KEY_THROWABLE));
|
||||
throwable = (Throwable) Objects.requireNonNull(getIntent().getSerializableExtra(KEY_THROWABLE));
|
||||
throwable.printStackTrace();
|
||||
toolbar.setTitle(getString(R.string.simple_error));
|
||||
message.setText(throwable.getMessage());
|
||||
|
@ -45,7 +47,7 @@ public class ExceptionActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
void copyStacktraceToClipboard() {
|
||||
final ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
final ClipboardManager clipboardManager = (ClipboardManager) Objects.requireNonNull(getSystemService(CLIPBOARD_SERVICE));
|
||||
ClipData clipData = ClipData.newPlainText(getString(R.string.simple_exception), "```\n" + this.stacktrace.getText() + "\n```");
|
||||
clipboardManager.setPrimaryClip(clipData);
|
||||
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
|
||||
|
|
|
@ -63,8 +63,8 @@ import it.niedermann.owncloud.notes.model.NavigationAdapter;
|
|||
import it.niedermann.owncloud.notes.model.NavigationAdapter.NavigationItem;
|
||||
import it.niedermann.owncloud.notes.persistence.LoadNotesListTask;
|
||||
import it.niedermann.owncloud.notes.persistence.LoadNotesListTask.NotesLoadedListener;
|
||||
import it.niedermann.owncloud.notes.persistence.NotesDatabase;
|
||||
import it.niedermann.owncloud.notes.persistence.NoteServerSyncHelper;
|
||||
import it.niedermann.owncloud.notes.persistence.NotesDatabase;
|
||||
import it.niedermann.owncloud.notes.util.NoteUtil;
|
||||
|
||||
import static it.niedermann.owncloud.notes.util.SSOUtil.askForNewAccount;
|
||||
|
@ -415,7 +415,9 @@ public class NotesListViewActivity extends AppCompatActivity implements ItemAdap
|
|||
}
|
||||
|
||||
Map<String, Integer> favorites = db.getFavoritesCount(localAccount.getId());
|
||||
//noinspection ConstantConditions
|
||||
int numFavorites = favorites.containsKey("1") ? favorites.get("1") : 0;
|
||||
//noinspection ConstantConditions
|
||||
int numNonFavorites = favorites.containsKey("0") ? favorites.get("0") : 0;
|
||||
itemFavorites.count = numFavorites;
|
||||
itemRecent.count = numFavorites + numNonFavorites;
|
||||
|
|
|
@ -145,7 +145,9 @@ public class NoteListWidgetConfiguration extends AppCompatActivity {
|
|||
}
|
||||
|
||||
Map<String, Integer> favorites = db.getFavoritesCount(localAccount.getId());
|
||||
//noinspection ConstantConditions
|
||||
int numFavorites = favorites.containsKey("1") ? favorites.get("1") : 0;
|
||||
//noinspection ConstantConditions
|
||||
int numNonFavorites = favorites.containsKey("0") ? favorites.get("0") : 0;
|
||||
itemFavorites.count = numFavorites;
|
||||
itemRecent.count = numFavorites + numNonFavorites;
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CategoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||
}
|
||||
}
|
||||
categoryViewHolder.getCategory().setText(NoteUtil.extendCategory(category.label));
|
||||
if (category.count > 0) {
|
||||
if (category.count != null && category.count > 0) {
|
||||
categoryViewHolder.getCount().setText(String.valueOf(category.count));
|
||||
} else {
|
||||
categoryViewHolder.getCount().setVisibility(View.GONE);
|
||||
|
|
|
@ -61,7 +61,7 @@ public class CategoryDialogFragment extends AppCompatDialogFragment {
|
|||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
if (requireArguments() != null && requireArguments().containsKey(PARAM_ACCOUNT_ID)) {
|
||||
if (getArguments() != null && requireArguments().containsKey(PARAM_ACCOUNT_ID)) {
|
||||
accountId = requireArguments().getLong(PARAM_ACCOUNT_ID);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Provide at least \"" + PARAM_ACCOUNT_ID + "\"");
|
||||
|
@ -151,7 +151,7 @@ public class CategoryDialogFragment extends AppCompatDialogFragment {
|
|||
super.onActivityCreated(savedInstanceState);
|
||||
if (editCategory.getText() == null || editCategory.getText().length() == 0) {
|
||||
editCategory.requestFocus();
|
||||
if (getDialog().getWindow() != null) {
|
||||
if (getDialog() != null && getDialog().getWindow() != null) {
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
} else {
|
||||
Log.w(TAG, "can not set SOFT_INPUT_STATE_ALWAYAS_VISIBLE because getWindow() == null");
|
||||
|
|
|
@ -94,7 +94,7 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment implements O
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup
|
||||
container, @Nullable Bundle savedInstanceState) {
|
||||
binding = FragmentNotePreviewBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
|
|
@ -87,7 +87,7 @@ public class NoteReadonlyFragment extends SearchableBaseNoteFragment {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup
|
||||
container, @Nullable Bundle savedInstanceState) {
|
||||
binding = FragmentNotePreviewBinding.inflate(inflater, container, false);
|
||||
return binding.getRoot();
|
||||
|
|
|
@ -31,8 +31,8 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
|||
assert themePref != null;
|
||||
themePref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
Notes.setAppTheme(DarkModeSetting.valueOf((String) newValue));
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
getActivity().recreate();
|
||||
requireActivity().setResult(Activity.RESULT_OK);
|
||||
requireActivity().recreate();
|
||||
return true;
|
||||
});
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat {
|
|||
assert syncPref != null;
|
||||
syncPref.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
Log.v(TAG, "syncPref: " + preference + " - newValue: " + newValue);
|
||||
SyncWorker.update(getContext(), newValue.toString());
|
||||
SyncWorker.update(requireContext(), newValue.toString());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ import it.niedermann.owncloud.notes.util.NoteUtil;
|
|||
* It can be directly generated from the JSON answer from the server.
|
||||
*/
|
||||
public class CloudNote implements Serializable {
|
||||
private long remoteId = 0;
|
||||
private long remoteId;
|
||||
private String title = "";
|
||||
private Calendar modified = null;
|
||||
private Calendar modified;
|
||||
private String content = "";
|
||||
private boolean favorite = false;
|
||||
private String category = "";
|
||||
|
@ -51,7 +51,6 @@ public class CloudNote implements Serializable {
|
|||
this.title = NoteUtil.removeMarkDown(title);
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public Calendar getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
|
|
@ -57,9 +57,6 @@ public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.Vi
|
|||
@NonNull
|
||||
private final View view;
|
||||
|
||||
@NonNull
|
||||
private final ItemNavigationBinding binding;
|
||||
|
||||
@NonNull
|
||||
private final TextView name;
|
||||
@NonNull
|
||||
|
@ -72,7 +69,7 @@ public class NavigationAdapter extends RecyclerView.Adapter<NavigationAdapter.Vi
|
|||
ViewHolder(@NonNull View itemView, @NonNull final ClickListener clickListener) {
|
||||
super(itemView);
|
||||
view = itemView;
|
||||
binding = ItemNavigationBinding.bind(view);
|
||||
ItemNavigationBinding binding = ItemNavigationBinding.bind(view);
|
||||
this.name = binding.navigationItemLabel;
|
||||
this.count = binding.navigationItemCount;
|
||||
this.icon = binding.navigationItemIcon;
|
||||
|
|
|
@ -32,6 +32,7 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper {
|
|||
private static final String TAG = AbstractNotesDatabase.class.getSimpleName();
|
||||
|
||||
private static final int database_version = 11;
|
||||
@NonNull
|
||||
private final Context context;
|
||||
|
||||
protected static final String database_name = "OWNCLOUD_NOTES";
|
||||
|
@ -55,12 +56,13 @@ abstract class AbstractNotesDatabase extends SQLiteOpenHelper {
|
|||
protected static final String key_category = "CATEGORY";
|
||||
protected static final String key_etag = "ETAG";
|
||||
|
||||
protected AbstractNotesDatabase(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory) {
|
||||
protected AbstractNotesDatabase(@NonNull Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory) {
|
||||
super(context, name, factory, database_version);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class NotesDatabase extends AbstractNotesDatabase {
|
|||
|
||||
private final NoteServerSyncHelper serverSyncHelper;
|
||||
|
||||
private NotesDatabase(Context context) {
|
||||
private NotesDatabase(@NonNull Context context) {
|
||||
super(context, database_name, null);
|
||||
serverSyncHelper = NoteServerSyncHelper.getInstance(this);
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ public class NotesDatabase extends AbstractNotesDatabase {
|
|||
table_notes,
|
||||
new String[]{key_category, "COUNT(*)"},
|
||||
key_status + " != ? AND " + key_account_id + " = ? AND " + key_category + " LIKE ? AND " + key_category + " != \"\"",
|
||||
new String[]{DBStatus.LOCAL_DELETED.getTitle(), String.valueOf(accountId), "%" + (search == null ? search : search.trim()) + "%"},
|
||||
new String[]{DBStatus.LOCAL_DELETED.getTitle(), String.valueOf(accountId), "%" + (search == null ? null : search.trim()) + "%"},
|
||||
key_category,
|
||||
null,
|
||||
key_category);
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.nextcloud.android.sso.AccountImporter;
|
|||
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
|
||||
import com.nextcloud.android.sso.model.SingleSignOnAccount;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import it.niedermann.owncloud.notes.R;
|
||||
|
@ -23,7 +24,7 @@ import it.niedermann.owncloud.notes.model.LocalAccount;
|
|||
|
||||
public class SyncWorker extends Worker {
|
||||
|
||||
private static final String TAG = SyncWorker.class.getCanonicalName();
|
||||
private static final String TAG = Objects.requireNonNull(SyncWorker.class.getCanonicalName());
|
||||
private static final String WORKER_TAG = "background_synchronization";
|
||||
|
||||
private static final Constraints constraints = new Constraints.Builder()
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ClipboardUtil {
|
|||
try {
|
||||
clipboardURL = new URL(clipboardData.getItemAt(0).getText().toString()).toString();
|
||||
} catch (MalformedURLException e) {
|
||||
Log.d(TAG, "Clipboard does not contain a valid URL: " + clipboardURL);
|
||||
Log.d(TAG, "Clipboard does not contain a valid URL: " + clipboardData.getItemAt(0).getText().toString());
|
||||
}
|
||||
}
|
||||
return clipboardURL;
|
||||
|
|
Loading…
Reference in a new issue