Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 39927c2

Browse files
Update to release 1.5.2
- Fixed [#12](#12) - Fixed [#13](#13)
1 parent 405dd81 commit 39927c2

12 files changed

+40
-22
lines changed

core/src/main/java/com/dm/material/dashboard/candybar/activities/CandyBarMainActivity.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ public void OnWallpapersChecked(@Nullable Intent intent) {
480480

481481
ViewCompat.setBackground(counter, DrawableHelper.getTintedDrawable(this,
482482
R.drawable.ic_toolbar_circle, accent));
483-
counter.setTextColor(ColorHelper.getTitleTextColor(this, accent));
483+
counter.setTextColor(ColorHelper.getTitleTextColor(accent));
484484
int newItem = (size - offlineSize);
485485
counter.setText(String.valueOf(newItem > 99 ? "99+" : newItem));
486486
container.setVisibility(View.VISIBLE);
@@ -680,8 +680,8 @@ private void initHomeImage() {
680680
}
681681

682682
private void initRateReviewFab() {
683-
int color = ColorHelper.getTitleTextColor(this,
684-
ColorHelper.getAttributeColor(this, R.attr.colorAccent));
683+
int color = ColorHelper.getTitleTextColor(ColorHelper
684+
.getAttributeColor(this, R.attr.colorAccent));
685685
Drawable icon = DrawableHelper.getTintedDrawable(this,
686686
R.drawable.ic_fab_star, color);
687687
mFab.setImageDrawable(icon);

core/src/main/java/com/dm/material/dashboard/candybar/activities/CandyBarSplashActivity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public void initSplashActivity(Bundle savedInstanceState, Class<?> mainActivity,
4040
super.onCreate(savedInstanceState);
4141
setContentView(R.layout.activity_splash);
4242

43-
int titleColor = ColorHelper.getTitleTextColor(this,
44-
ContextCompat.getColor(this, R.color.splashColor));
43+
int titleColor = ColorHelper.getTitleTextColor(ContextCompat
44+
.getColor(this, R.color.splashColor));
4545
TextView splashTitle = (TextView) findViewById(R.id.splash_title);
4646
splashTitle.setTextColor(ColorHelper.setColorAlpha(titleColor, 0.6f ));
4747

core/src/main/java/com/dm/material/dashboard/candybar/activities/CandyBarWallpaperActivity.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ public void onTransitionResume(Transition transition) {
180180
mRunnable = () -> {
181181
toolbar.setVisibility(View.VISIBLE);
182182
loadWallpaper(mUrl);
183+
mRunnable = null;
184+
mHandler = null;
183185
};
184186
mHandler = new Handler();
185187
mHandler.postDelayed(mRunnable, 700);
@@ -286,7 +288,7 @@ public void onLoadingStarted(String imageUri, View view) {
286288
@Override
287289
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
288290
super.onLoadingFailed(imageUri, view, failReason);
289-
int text = ColorHelper.getTitleTextColor(CandyBarWallpaperActivity.this, mColor);
291+
int text = ColorHelper.getTitleTextColor(mColor);
290292
OnWallpaperLoaded(text);
291293

292294
int color = ColorHelper.getAttributeColor(CandyBarWallpaperActivity.this, R.attr.main_background);
@@ -311,7 +313,7 @@ public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
311313
CandyBarWallpaperActivity.this, R.attr.colorAccent);
312314
int color = palette.getVibrantColor(accent);
313315
mColor = color;
314-
int text = ColorHelper.getTitleTextColor(CandyBarWallpaperActivity.this, color);
316+
int text = ColorHelper.getTitleTextColor(color);
315317
mFab.setBackgroundTintList(ColorHelper.getColorStateList(
316318
android.R.attr.state_pressed,
317319
color, ColorHelper.getDarkerColor(color, 0.9f)));

core/src/main/java/com/dm/material/dashboard/candybar/adapters/LauncherAdapter.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.widget.ImageView;
1111
import android.widget.LinearLayout;
1212
import android.widget.TextView;
13+
import android.widget.Toast;
1314

1415
import com.dm.material.dashboard.candybar.R;
1516
import com.dm.material.dashboard.candybar.helpers.LauncherHelper;
@@ -84,9 +85,17 @@ public void onClick(View view) {
8485
int position = getAdapterPosition();
8586
if (id == R.id.container) {
8687
if (position < 0 || position > mLaunchers.size()) return;
87-
LauncherHelper.apply(mContext,
88-
mLaunchers.get(position).getPackageName(),
89-
mLaunchers.get(position).getTitle());
88+
try {
89+
LauncherHelper.apply(mContext,
90+
mLaunchers.get(position).getPackageName(),
91+
mLaunchers.get(position).getTitle());
92+
} catch (SecurityException e) {
93+
Toast.makeText(mContext, mContext.getResources().getString(R.string.unable_launch)
94+
+ " " +mLaunchers.get(position).getTitle()+ " " +
95+
mContext.getResources().getString(R.string.unable_launch2),
96+
Toast.LENGTH_LONG).show();
97+
}
98+
9099
}
91100
}
92101
}

core/src/main/java/com/dm/material/dashboard/candybar/adapters/WallpapersAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
130130
if (color == vibrant)
131131
color = palette.getMutedColor(vibrant);
132132
holder.card.setCardBackgroundColor(color);
133-
int text = ColorHelper.getTitleTextColor(mContext, color);
133+
int text = ColorHelper.getTitleTextColor(color);
134134
holder.name.setTextColor(text);
135135
holder.author.setTextColor(text);
136136
});

core/src/main/java/com/dm/material/dashboard/candybar/fragments/ApplyFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private void initApplyTipsFab() {
134134
if (!Preferences.getPreferences(getActivity()).isShowApplyTips()) return;
135135

136136
int accent = ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent);
137-
int textColor = ColorHelper.getTitleTextColor(getActivity(), accent);
137+
int textColor = ColorHelper.getTitleTextColor(accent);
138138
FloatingActionButton fab = (FloatingActionButton) getActivity()
139139
.findViewById(R.id.apply_tips_fab);
140140
fab.setImageDrawable(DrawableHelper.getTintedDrawable(getActivity(),

core/src/main/java/com/dm/material/dashboard/candybar/fragments/IconsSearchFragment.java

+3
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ protected Boolean doInBackground(Void... voids) {
185185
while (!isCancelled()) {
186186
try {
187187
Thread.sleep(1);
188+
if (!getActivity().getResources().getBoolean(R.bool.enable_icons_sort))
189+
return true;
190+
188191
Collections.sort(mIcons, new AlphanumComparator() {
189192
@Override
190193
public int compare(Object o1, Object o2) {

core/src/main/java/com/dm/material/dashboard/candybar/fragments/RequestFragment.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
124124
ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent),
125125
PorterDuff.Mode.SRC_IN);
126126

127-
int color = ColorHelper.getTitleTextColor(getActivity(),
128-
ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent));
127+
int color = ColorHelper.getTitleTextColor(ColorHelper
128+
.getAttributeColor(getActivity(), R.attr.colorAccent));
129129
mFab.setImageDrawable(DrawableHelper.getTintedDrawable(
130130
getActivity(), R.drawable.ic_fab_send, color));
131131
mFab.setOnClickListener(this);
@@ -250,7 +250,7 @@ private void initPremiumRequest() {
250250
if (premiumRequest) {
251251
int accent = ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent);
252252
AppCompatButton buy = (AppCompatButton) getActivity().findViewById(R.id.premium_request_buy);
253-
buy.setTextColor(ColorHelper.getTitleTextColor(getActivity(), accent));
253+
buy.setTextColor(ColorHelper.getTitleTextColor(accent));
254254
buy.setOnClickListener(this);
255255

256256
int toolbarIcon = ColorHelper.getAttributeColor(getActivity(), R.attr.toolbar_icon);

core/src/main/java/com/dm/material/dashboard/candybar/fragments/WallpapersFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private void initWallpaperTipsFab() {
179179
if (!Preferences.getPreferences(getActivity()).isShowWallpaperTips()) return;
180180

181181
int accent = ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent);
182-
int textColor = ColorHelper.getTitleTextColor(getActivity(), accent);
182+
int textColor = ColorHelper.getTitleTextColor(accent);
183183
FloatingActionButton fab = (FloatingActionButton) getActivity()
184184
.findViewById(R.id.wallpaper_tips_fab);
185185
fab.setImageDrawable(DrawableHelper.getTintedDrawable(getActivity(),

core/src/main/java/com/dm/material/dashboard/candybar/helpers/ColorHelper.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ public static int getAttributeColor(@NonNull Context context, int attr) {
7171
return typedValue.data;
7272
}
7373

74-
public static int getTitleTextColor(@NonNull Context context, @ColorInt int color) {
74+
public static int getTitleTextColor(@ColorInt int color) {
7575
double darkness = 1-(0.299*Color.red(color) + 0.587*Color.green(color) + 0.114*Color.blue(color))/255;
76-
return (darkness < 0.35) ? getDarkerColor(color, 0.25f) :
77-
ContextCompat.getColor(context, android.R.color.white);
76+
return (darkness < 0.35) ? getDarkerColor(color, 0.25f) : Color.WHITE;
7877
}
7978

8079
public static int setColorAlpha(@ColorInt int color, float alpha) {

core/src/main/java/com/dm/material/dashboard/candybar/helpers/WallpaperHelper.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ protected void onPostExecute(Boolean aBoolean) {
196196
downloaded +" "+ file.toString(), 6000)
197197
.setAction(context.getResources().getString(R.string.open), view -> {
198198
try {
199+
Uri uri = FileHelper.getUriFromFile(context, context.getPackageName(), file);
200+
if (uri == null) return;
201+
199202
context.startActivity(new Intent()
200203
.setAction(Intent.ACTION_VIEW)
201-
.setDataAndType(Uri.fromFile(
202-
new File(file.toString())),
203-
"image/*"));
204+
.setDataAndType(uri, "image/*")
205+
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION));
204206
} catch (ActivityNotFoundException e) {
205207
Toast.makeText(context,
206208
context.getResources().getString(R.string.wallpaper_noapp),

core/src/main/res/xml/file_provider_paths.xml

+3
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
<cache-path
44
name="cache"
55
path="/" />
6+
<external-path
7+
name="external_files"
8+
path="."/>
69
</paths>

0 commit comments

Comments
 (0)