Skip to content

Commit

Permalink
Dynamic theme 4.6.0
Browse files Browse the repository at this point in the history
Dynamic utils 4.6.1.
Dynamic locale 2.5.0.
Dynamic toasts 4.3.0.
Dynamic preferences 2.4.0.
Add support for product flavors.
  • Loading branch information
pranavpandey committed Jul 24, 2024
1 parent 3f5ff9f commit 440e395
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 29 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ buildscript {
'targetSdk' : 35,
'buildTools' : '35.0.0',
'multidex' : '2.0.1',
'dynamic' : '4.5.1',
'dynamic' : '4.6.1',
'fragment' : '1.7.0',
'flexbox' : '3.0.0',
'kotlin' : '1.9.24',
'locale' : '2.4.0',
'locale' : '2.5.0',
'material' : '1.12.0',
'preferences' : '2.3.1',
'preferences' : '2.4.0',
'swiperefresh': '1.1.0',
'theme' : '4.5.1',
'toasts' : '4.2.1',
'theme' : '4.6.0',
'toasts' : '4.3.0',
'work' : '2.8.1'
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,6 +36,7 @@
import com.pranavpandey.android.dynamic.locale.DynamicLocaleUtils;
import com.pranavpandey.android.dynamic.preferences.DynamicPreferences;
import com.pranavpandey.android.dynamic.support.listener.DynamicListener;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;
import com.pranavpandey.android.dynamic.support.listener.DynamicResolver;
import com.pranavpandey.android.dynamic.support.model.DynamicAppTheme;
import com.pranavpandey.android.dynamic.support.theme.DynamicTheme;
Expand All @@ -44,6 +45,7 @@
import com.pranavpandey.android.dynamic.theme.Theme;
import com.pranavpandey.android.dynamic.util.DynamicSdkUtils;
import com.pranavpandey.android.dynamic.util.loader.DynamicLoader;
import com.pranavpandey.android.dynamic.util.product.DynamicFlavor;

import java.util.Locale;

Expand All @@ -52,7 +54,7 @@
* and to perform theme change operations.
*/
public abstract class DynamicApplication extends Application
implements androidx.work.Configuration.Provider, DynamicLocale,
implements androidx.work.Configuration.Provider, DynamicProductFlavor, DynamicLocale,
DynamicListener, SharedPreferences.OnSharedPreferenceChangeListener {

/**
Expand Down Expand Up @@ -196,6 +198,11 @@ public float getFontScale() {
: DynamicTheme.getInstance().getDefault(false).getFontScaleRelative();
}

@Override
public @DynamicFlavor String getProductFlavor() {
return DynamicFlavor.DEFAULT;
}

@Override
public @NonNull Context getContext() {
return mContext != null ? mContext : getBaseContext() != null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,6 +66,7 @@
import com.pranavpandey.android.dynamic.support.R;
import com.pranavpandey.android.dynamic.support.intent.DynamicIntent;
import com.pranavpandey.android.dynamic.support.listener.DynamicListener;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;
import com.pranavpandey.android.dynamic.support.listener.DynamicTransitionListener;
import com.pranavpandey.android.dynamic.support.motion.DynamicMotion;
import com.pranavpandey.android.dynamic.support.theme.DynamicTheme;
Expand All @@ -84,6 +85,7 @@
import com.pranavpandey.android.dynamic.util.DynamicSdkUtils;
import com.pranavpandey.android.dynamic.util.DynamicViewUtils;
import com.pranavpandey.android.dynamic.util.DynamicWindowUtils;
import com.pranavpandey.android.dynamic.util.product.DynamicFlavor;

import java.io.Serializable;
import java.util.HashMap;
Expand All @@ -100,7 +102,7 @@
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public abstract class DynamicSystemActivity extends AppCompatActivity
implements DynamicLocale, DynamicListener, DynamicTransitionListener,
implements DynamicProductFlavor, DynamicLocale, DynamicListener, DynamicTransitionListener,
SharedPreferences.OnSharedPreferenceChangeListener {

/**
Expand Down Expand Up @@ -1645,6 +1647,11 @@ public void onDestroy() {
super.onDestroy();
}

@Override
public @DynamicFlavor String getProductFlavor() {
return DynamicTheme.getInstance().getProductFlavor();
}

@Override
public @NonNull Context getContext() {
return mContext != null ? mContext : getBaseContext();
Expand Down Expand Up @@ -1782,6 +1789,7 @@ protected void updateTaskDescription(@ColorInt int color) {
}
}

@SuppressLint("MissingSuperCall")
@Override
public void onBackPressed() {
finishActivity();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,8 +41,11 @@
import com.pranavpandey.android.dynamic.support.Dynamic;
import com.pranavpandey.android.dynamic.support.activity.DynamicSystemActivity;
import com.pranavpandey.android.dynamic.support.dialog.DynamicDialog;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;
import com.pranavpandey.android.dynamic.support.theme.DynamicTheme;
import com.pranavpandey.android.dynamic.support.util.DynamicResourceUtils;
import com.pranavpandey.android.dynamic.util.DynamicSdkUtils;
import com.pranavpandey.android.dynamic.util.product.DynamicFlavor;

/**
* Base dialog fragment to provide all the functionality of {@link DynamicDialog} inside a
Expand All @@ -52,7 +55,7 @@
* @see #onCustomiseDialog(DynamicDialog, View, Bundle)
*/
public class DynamicDialogFragment extends AppCompatDialogFragment
implements SharedPreferences.OnSharedPreferenceChangeListener {
implements DynamicProductFlavor, SharedPreferences.OnSharedPreferenceChangeListener {

/**
* Default button color. it will be used internally if there is no button color is applied.
Expand Down Expand Up @@ -233,6 +236,11 @@ public boolean onKey(DialogInterface dialogInterface,
protected void onCustomiseDialog(@NonNull DynamicDialog alertDialog,
@Nullable View view, @Nullable Bundle savedInstanceState) { }

@Override
public @DynamicFlavor String getProductFlavor() {
return DynamicTheme.getInstance().getProductFlavor();
}

/**
* Returns whether to register a shared preferences listener for this fragment.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,21 +53,24 @@
import com.pranavpandey.android.dynamic.support.activity.DynamicStateActivity;
import com.pranavpandey.android.dynamic.support.activity.DynamicSystemActivity;
import com.pranavpandey.android.dynamic.support.listener.DynamicLifecycle;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;
import com.pranavpandey.android.dynamic.support.listener.DynamicSearchListener;
import com.pranavpandey.android.dynamic.support.listener.DynamicTransitionListener;
import com.pranavpandey.android.dynamic.support.motion.DynamicMotion;
import com.pranavpandey.android.dynamic.support.theme.DynamicTheme;
import com.pranavpandey.android.dynamic.support.util.DynamicMenuUtils;
import com.pranavpandey.android.dynamic.support.util.DynamicResourceUtils;
import com.pranavpandey.android.dynamic.util.DynamicSdkUtils;
import com.pranavpandey.android.dynamic.util.product.DynamicFlavor;

/**
* Base fragment class to provide basic functionality and to work with the {@link DynamicActivity}.
* <p>Extend this fragment to add more functionality according to the requirements.
*/
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class DynamicFragment extends Fragment implements DynamicLifecycle,
DynamicTransitionListener, DynamicSearchListener, MenuProvider,
public class DynamicFragment extends Fragment implements DynamicProductFlavor,
DynamicLifecycle, DynamicTransitionListener, DynamicSearchListener, MenuProvider,
SharedPreferences.OnSharedPreferenceChangeListener {

/**
Expand Down Expand Up @@ -584,6 +587,11 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
mSearchViewExpanded);
}

@Override
public @DynamicFlavor String getProductFlavor() {
return DynamicTheme.getInstance().getProductFlavor();
}

/**
* Get the current saved instance state for this fragment.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,11 +32,12 @@
import com.pranavpandey.android.dynamic.theme.AppTheme;
import com.pranavpandey.android.dynamic.theme.DynamicColors;
import com.pranavpandey.android.dynamic.theme.Theme;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;

/**
* An interface to listen the dynamic change events.
*/
public interface DynamicListener {
public interface DynamicListener extends DynamicProductFlavor {

/**
* Returns the context used by this listener.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,12 +39,14 @@

import com.pranavpandey.android.dynamic.support.Dynamic;
import com.pranavpandey.android.dynamic.support.R;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;
import com.pranavpandey.android.dynamic.support.motion.DynamicMotion;
import com.pranavpandey.android.dynamic.support.theme.DynamicTheme;
import com.pranavpandey.android.dynamic.support.util.DynamicResourceUtils;
import com.pranavpandey.android.dynamic.util.DynamicSdkUtils;
import com.pranavpandey.android.dynamic.util.DynamicViewUtils;
import com.pranavpandey.android.dynamic.util.DynamicWindowUtils;
import com.pranavpandey.android.dynamic.util.product.DynamicFlavor;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -53,7 +55,7 @@
* Base {@link PopupWindow} to provide the basic functionality to its descendants.
* <p>Extend this class to create popup windows according to the requirements.
*/
public abstract class DynamicPopup {
public abstract class DynamicPopup implements DynamicProductFlavor {

/**
* Interface to hold the view types supported by the popup.
Expand Down Expand Up @@ -419,4 +421,9 @@ public void dismiss() {
getPopupWindow().dismiss();
}
}

@Override
public @DynamicFlavor String getProductFlavor() {
return DynamicTheme.getInstance().getProductFlavor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ public void onPreviewClick() {
DynamicLinkUtils.viewUrl(DynamicPreviewActivity.this,
getPreview().getInfo());
} else {
DynamicLinkUtils.share(DynamicPreviewActivity.this,
(String) getTitle(), getPreview().getInfo(), null);
DynamicLinkUtils.share(DynamicPreviewActivity.this, (String) getTitle(),
getPreview().getInfo(), null, getProductFlavor());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.pranavpandey.android.dynamic.support.R;
import com.pranavpandey.android.dynamic.support.permission.DynamicPermissions;
import com.pranavpandey.android.dynamic.support.setting.base.DynamicSpinnerPreference;
import com.pranavpandey.android.dynamic.support.theme.DynamicTheme;
import com.pranavpandey.android.dynamic.theme.ThemeContract;
import com.pranavpandey.android.dynamic.util.DynamicLinkUtils;
import com.pranavpandey.android.dynamic.util.DynamicPackageUtils;
Expand Down Expand Up @@ -55,6 +56,9 @@ public ThemeReceiverPreference(@NonNull Context context,
protected void onInflate() {
super.onInflate();

setDescription(String.format(getContext().getString(R.string.ads_theme_presets_desc_app),
getContext().getString(R.string.ads_theme_presets_app)), false);

setActionButton(getContext().getString(R.string.ads_perm_info_required),
new View.OnClickListener() {
@Override
Expand All @@ -64,8 +68,8 @@ public void onClick(View v) {
DynamicPermissions.getInstance().isGranted(
ThemeContract.Preset.RECEIVER_PERMISSIONS, true);
} else {
DynamicLinkUtils.viewInGooglePlay(getContext(),
ThemeContract.Preset.AUTHORITY);
DynamicLinkUtils.viewApp(getContext(), ThemeContract.Preset.AUTHORITY,
DynamicTheme.getInstance().getProductFlavor());
}
}
});
Expand All @@ -81,7 +85,7 @@ protected void onUpdate() {
Dynamic.setVisibility(getActionView(), DynamicPermissions.getInstance().isGranted(
ThemeContract.Preset.RECEIVER_PERMISSIONS, false) ? GONE :VISIBLE);
} else {
Dynamic.setText(getActionView(), R.string.ads_info_google_play);
Dynamic.setText(getActionView(), R.string.ads_download);
Dynamic.setVisibility(getDescriptionView(), VISIBLE);
Dynamic.setVisibility(getActionView(), VISIBLE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 Pranav Pandey
* Copyright 2018-2024 Pranav Pandey
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +54,7 @@
import com.pranavpandey.android.dynamic.support.Dynamic;
import com.pranavpandey.android.dynamic.support.R;
import com.pranavpandey.android.dynamic.support.listener.DynamicListener;
import com.pranavpandey.android.dynamic.util.product.DynamicProductFlavor;
import com.pranavpandey.android.dynamic.support.listener.DynamicResolver;
import com.pranavpandey.android.dynamic.support.model.DynamicAppTheme;
import com.pranavpandey.android.dynamic.support.model.DynamicRemoteTheme;
Expand All @@ -74,6 +75,7 @@
import com.pranavpandey.android.dynamic.util.DynamicTaskUtils;
import com.pranavpandey.android.dynamic.util.DynamicUnitUtils;
import com.pranavpandey.android.dynamic.util.concurrent.DynamicResult;
import com.pranavpandey.android.dynamic.util.product.DynamicFlavor;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -91,7 +93,7 @@
* heavily dependent on this class to generate colors dynamically.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class DynamicTheme implements DynamicListener, DynamicResolver {
public class DynamicTheme implements DynamicProductFlavor, DynamicListener, DynamicResolver {

/**
* Constant values for the theme styles version.
Expand Down Expand Up @@ -1635,6 +1637,11 @@ public void clearDynamicListeners() {
getDynamicThemes().clear();
}

@Override
public @DynamicFlavor String getProductFlavor() {
return getHandler().getProductFlavor();
}

@Override
public @NonNull Context getContext() {
return getHandler().getContext();
Expand Down
Loading

0 comments on commit 440e395

Please sign in to comment.