Skip to content

Commit

Permalink
content descriptions + lots of code fixes?
Browse files Browse the repository at this point in the history
  • Loading branch information
Donnnno committed Aug 2, 2024
1 parent 5d2f3f4 commit 6b37dcd
Show file tree
Hide file tree
Showing 105 changed files with 462 additions and 416 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ android {
dependencies {
implementation project(':extLibs:PreLollipopTransitions')

api 'androidx.annotation:annotation:1.8.0'
api 'androidx.annotation:annotation:1.8.1'
api 'androidx.appcompat:appcompat:1.7.0'
api 'com.google.android.apps.muzei:muzei-api:3.4.2'
api 'com.android.billingclient:billing:7.0.0'
Expand Down
5 changes: 3 additions & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_ALARM" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ private void initNavigationViewHeader() {
image.setRatio(16, 9);
}

if (titleText.length() == 0) {
if (titleText.isEmpty()) {
container.setVisibility(View.GONE);
} else {
title.setText(titleText);
Expand Down Expand Up @@ -996,7 +996,6 @@ private void setFragment(Fragment fragment) {
private Fragment getFragment(int position) {
mFragmentTag = Extras.Tag.HOME;
if (position == Extras.Tag.HOME.idx) {
mFragmentTag = Extras.Tag.HOME;
return new HomeFragment();
} else if (position == Extras.Tag.APPLY.idx) {
mFragmentTag = Extras.Tag.APPLY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected boolean run() {
return false;
}

if (list.size() > 0 && list.get(0) instanceof Map) {
if (!list.isEmpty() && list.get(0) instanceof Map) {
Map<?, ?> map = (Map<?, ?>) list.get(0);
String thumbUrl = JsonHelper.getThumbUrl(map);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void onClick(View view) {
p.updateItem(position, item);
if (Preferences.get(this).isCropWallpaper()) {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
return;
}
Expand Down Expand Up @@ -524,7 +524,7 @@ public void onLoadCleared(@Nullable Drawable placeholder) { /* Do nothing */ }

if (Preferences.get(CandyBarWallpaperActivity.this).isCropWallpaper()) {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/candybar/lib/adapters/AboutAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public AboutAdapter(@NonNull Context context, int spanCount) {

mShowContributors = mContext.getResources().getBoolean(R.bool.show_contributors_dialog);

mShowPrivacyPolicy = mContext.getResources().getString(R.string.privacy_policy_link).length() > 0;
mShowPrivacyPolicy = !mContext.getResources().getString(R.string.privacy_policy_link).isEmpty();

mShowTerms = mContext.getResources().getString(R.string.terms_and_conditions_link).length() > 0;
mShowTerms = !mContext.getResources().getString(R.string.terms_and_conditions_link).isEmpty();

mShowExtraInfo = mShowContributors || mShowPrivacyPolicy || mShowTerms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
SocialViewHolder socialViewHolder = (SocialViewHolder) holder;
UrlHelper.Type type = UrlHelper.getType(mUrls[position]);
Drawable drawable = UrlHelper.getSocialIcon(mContext, type);
socialViewHolder.itemView.setContentDescription(R.string.about_item_social_content_description + type.toString());
socialViewHolder.itemView.setContentDescription(R.string.desc_about_item_social_content + type.toString());

if (drawable != null && type != UrlHelper.Type.INVALID) {
socialViewHolder.image.setImageDrawable(drawable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
public void search(String string) {
String query = string.toLowerCase(Locale.getDefault()).trim();
mFAQs.clear();
if (query.length() == 0) mFAQs.addAll(mFAQsAll);
if (query.isEmpty()) mFAQs.addAll(mFAQsAll);
else {
for (int i = 0; i < mFAQsAll.size(); i++) {
FAQs faq = mFAQsAll.get(i);
Expand Down
20 changes: 9 additions & 11 deletions library/src/main/java/candybar/lib/adapters/HomeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public HomeAdapter(@NonNull Context context, @NonNull List<Home> homes, int orie
}

String link = mContext.getResources().getString(R.string.google_play_dev);
if (link.length() > 0) {
if (!link.isEmpty()) {
mItemsCount += 1;
mShowMoreApps = true;
}
Expand Down Expand Up @@ -195,11 +195,9 @@ public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
try {
if (holder.itemView != null) {
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams)
holder.itemView.getLayoutParams();
layoutParams.setFullSpan(isFullSpan(holder.getItemViewType()));
}
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams)
holder.itemView.getLayoutParams();
layoutParams.setFullSpan(isFullSpan(holder.getItemViewType()));
} catch (Exception e) {
LogUtil.d(Log.getStackTraceString(e));
}
Expand All @@ -208,7 +206,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;

String home_title_text = mContext.getResources().getString(R.string.home_title);
if (home_title_text.length() > 0) {
if (!home_title_text.isEmpty()) {
headerViewHolder.title.setText(home_title_text);
} else {
headerViewHolder.title.setVisibility(View.GONE);
Expand Down Expand Up @@ -303,7 +301,7 @@ public boolean onResourceReady(Bitmap bitmap, Object model, Target<Bitmap> targe
contentViewHolder.title.setTypeface(TypefaceHelper.getMedium(mContext));
contentViewHolder.title.setText(mHomes.get(finalPosition).getTitle());

if (mHomes.get(finalPosition).getSubtitle().length() > 0) {
if (!mHomes.get(finalPosition).getSubtitle().isEmpty()) {
contentViewHolder.subtitle.setText(mHomes.get(finalPosition).getSubtitle());
contentViewHolder.subtitle.setVisibility(View.VISIBLE);
}
Expand Down Expand Up @@ -428,15 +426,15 @@ private class HeaderViewHolder extends RecyclerView.ViewHolder implements View.O
card.setCardElevation(0);
}

if (mContext.getResources().getString(R.string.rate_and_review_link).length() == 0) {
if (mContext.getResources().getString(R.string.rate_and_review_link).isEmpty()) {
rate.setVisibility(View.GONE);
}

if (mContext.getResources().getString(R.string.share_link).length() == 0) {
if (mContext.getResources().getString(R.string.share_link).isEmpty()) {
share.setVisibility(View.GONE);
}

if ((!mContext.getResources().getBoolean(R.bool.enable_check_update)) || (CandyBarApplication.getConfiguration().getConfigHandler().configJson(mContext).length() == 0)) {
if ((!mContext.getResources().getBoolean(R.bool.enable_check_update)) || (CandyBarApplication.getConfiguration().getConfigHandler().configJson(mContext).isEmpty())) {
update.setVisibility(View.GONE);
}

Expand Down
6 changes: 3 additions & 3 deletions library/src/main/java/candybar/lib/adapters/IconsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
mode.setTitle(mContext.getResources().getString(R.string.items_selected, mSelectedIcons.size()));
menu.findItem(R.id.menu_select_all).setIcon(mSelectedIcons.size() == mIcons.size()
? R.drawable.ic_toolbar_select_all_selected : R.drawable.ic_toolbar_select_all);
menu.findItem(R.id.menu_delete).setVisible(mSelectedIcons.size() > 0);
menu.findItem(R.id.menu_delete).setVisible(!mSelectedIcons.isEmpty());
return true;
}

Expand Down Expand Up @@ -382,7 +382,7 @@ public void search(String string) {
String query = string.toLowerCase(Locale.ENGLISH).trim();

mIcons = new ArrayList<>();
if (query.length() == 0) mIcons.addAll(mIconsAll);
if (query.isEmpty()) mIcons.addAll(mIconsAll);
else {
for (int i = 0; i < mIconsAll.size(); i++) {
Icon icon = mIconsAll.get(i);
Expand All @@ -394,7 +394,7 @@ public void search(String string) {
}
}

if (mIcons.size() == 0) {
if (mIcons.isEmpty()) {
CandyBarApplication.getConfiguration().getAnalyticsHandler().logEvent(
"click",
new HashMap<String, Object>() {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.BitmapTransitionOptions;

import java.util.HashMap;
import java.util.List;

import candybar.lib.R;
import candybar.lib.applications.CandyBarApplication;
import candybar.lib.helpers.LauncherHelper;
import candybar.lib.items.Icon;
import candybar.lib.preferences.Preferences;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void setType(String type) {
List<String[]> requiredApps = getRequiredApps(type);
LinearLayout linearLayout = itemView.findViewById(R.id.container);

if (requiredApps.size() > 0) {
if (!requiredApps.isEmpty()) {
for (String[] requiredApp : requiredApps) {
View item = LayoutInflater.from(mContext).inflate(R.layout.fragment_presets_item_header_list, linearLayout, false);
((TextView) item.findViewById(R.id.name)).setText(requiredApp[0]);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void onClick(View view) {
intent.setData(Uri.parse("kfile://" + mContext.getPackageName() + "/" + preset.getPath()));
}

if (getRequiredApps(type).size() > 0) {
if (!getRequiredApps(type).isEmpty()) {
new MaterialDialog.Builder(mContext)
.typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
.content(R.string.presets_required_apps_not_installed)
Expand Down
43 changes: 19 additions & 24 deletions library/src/main/java/candybar/lib/adapters/SettingsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
Setting setting = mSettings.get(position);

if (setting.getTitle().length() == 0) {
if (setting.getTitle().isEmpty()) {
contentViewHolder.title.setVisibility(View.GONE);
contentViewHolder.divider.setVisibility(View.GONE);
contentViewHolder.container.setVisibility(View.VISIBLE);

contentViewHolder.subtitle.setText(setting.getSubtitle());

if (setting.getContent().length() == 0) {
if (setting.getContent().isEmpty()) {
contentViewHolder.content.setVisibility(View.GONE);
} else {
contentViewHolder.content.setText(setting.getContent());
contentViewHolder.content.setVisibility(View.VISIBLE);
}

if (setting.getFooter().length() == 0) {
if (setting.getFooter().isEmpty()) {
contentViewHolder.footer.setVisibility(View.GONE);
} else {
contentViewHolder.footer.setText(setting.getFooter());
Expand Down Expand Up @@ -272,16 +272,14 @@ public void onClick(View view) {
LogUtil.e(Log.getStackTraceString(e));
}
})
.onNegative(((dialog, which) -> {
CandyBarApplication.getConfiguration().getAnalyticsHandler().logEvent(
"click",
new HashMap<String, Object>() {{
put("section", "settings");
put("action", "cancel");
put("item", "clear_cache");
}}
);
}))
.onNegative(((dialog, which) -> CandyBarApplication.getConfiguration().getAnalyticsHandler().logEvent(
"click",
new HashMap<String, Object>() {{
put("section", "settings");
put("action", "cancel");
put("item", "clear_cache");
}}
)))
.show();
break;
case ICON_REQUEST:
Expand Down Expand Up @@ -315,16 +313,14 @@ public void onClick(View view) {
Toast.makeText(mContext, R.string.pref_data_request_cleared,
Toast.LENGTH_LONG).show();
})
.onNegative(((dialog, which) -> {
CandyBarApplication.getConfiguration().getAnalyticsHandler().logEvent(
"click",
new HashMap<String, Object>() {{
put("section", "settings");
put("action", "cancel");
put("item", "clear_icon_request_data");
}}
);
}))
.onNegative(((dialog, which) -> CandyBarApplication.getConfiguration().getAnalyticsHandler().logEvent(
"click",
new HashMap<String, Object>() {{
put("section", "settings");
put("action", "cancel");
put("item", "clear_icon_request_data");
}}
)))
.show();
break;
case RESTORE:
Expand Down Expand Up @@ -352,7 +348,6 @@ public void onClick(View view) {
}}
);
FragmentManager fm = ((AppCompatActivity) mContext).getSupportFragmentManager();
if (fm == null) return;

Fragment fragment = fm.findFragmentByTag("settings");
if (fragment == null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> tar
public void search(String string) {
String query = string.toLowerCase(Locale.getDefault()).trim();
mWallpapers.clear();
if (query.length() == 0) mWallpapers.addAll(mWallpapersAll);
if (query.isEmpty()) mWallpapers.addAll(mWallpapersAll);
else {
for (int i = 0; i < mWallpapersAll.size(); i++) {
Wallpaper wallpaper = mWallpapersAll.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public Configuration setShowTabAllIcons(boolean showTabAllIcons) {

public Configuration setTabAllIconsTitle(@NonNull String title) {
mTabAllIconsTitle = title;
if (mTabAllIconsTitle.length() == 0) mTabAllIconsTitle = "All Icons";
if (mTabAllIconsTitle.isEmpty()) mTabAllIconsTitle = "All Icons";
return this;
}

Expand Down Expand Up @@ -417,7 +417,7 @@ public void logEvent(String eventName, HashMap<String, Object> params) {

@Override
public void logException(Exception exception) {
LogUtil.e(exception.getStackTrace().toString());
LogUtil.e(Arrays.toString(exception.getStackTrace()));
}
};
}
Expand Down
8 changes: 4 additions & 4 deletions library/src/main/java/candybar/lib/databases/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public void updateWallpaper(Wallpaper wallpaper) {
values.put(KEY_COLOR, wallpaper.getColor());
}

if (values.size() > 0) {
if (!values.isEmpty()) {
mDatabase.get().mSQLiteDatabase.update(TABLE_WALLPAPERS,
values, KEY_URL + " = ?", new String[]{wallpaper.getURL()});
}
Expand Down Expand Up @@ -477,7 +477,7 @@ public Wallpaper getWallpaper(String url) {

int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
if (name.length() == 0) {
if (name.isEmpty()) {
name = "Wallpaper " + id;
}

Expand Down Expand Up @@ -522,7 +522,7 @@ public List<Wallpaper> getWallpapers(@Nullable SQLiteDatabase db) {

int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
if (name.length() == 0) {
if (name.isEmpty()) {
name = "Wallpaper " + id;
}

Expand Down Expand Up @@ -557,7 +557,7 @@ public Wallpaper getRandomWallpaper() {
do {
int id = cursor.getInt(cursor.getColumnIndex(KEY_ID));
String name = cursor.getString(cursor.getColumnIndex(KEY_NAME));
if (name.length() == 0) {
if (name.isEmpty()) {
name = "Wallpaper " + id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,10 @@ protected boolean run() {
} catch (Exception ignored) {
}

if (installed.size() == 1) {
if (!installed.isEmpty()) {
launchers.add(new Icon(getResources().getString(
R.string.apply_installed), -1, null));
}
else{
launchers.add(new Icon(getResources().getString(
R.string.apply_installed_launchers), -3, null));
}

launchers.addAll(installed);
launchers.add(new Icon(getResources().getString(
Expand Down
Loading

0 comments on commit 6b37dcd

Please sign in to comment.