From 8a56416618ff47ab7306a1634dfd4a418db22d2b Mon Sep 17 00:00:00 2001 From: Pranav Pandey Date: Thu, 25 Jul 2024 04:16:44 +0530 Subject: [PATCH] Improve external links for author Add big info view for author. --- .../view/DynamicInfoViewBigAuthor.java | 87 +++++++++++++++++++ .../src/main/res/values/arrays.xml | 10 +-- 2 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/view/DynamicInfoViewBigAuthor.java diff --git a/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/view/DynamicInfoViewBigAuthor.java b/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/view/DynamicInfoViewBigAuthor.java new file mode 100644 index 000000000..618738e54 --- /dev/null +++ b/dynamic-support/src/main/java/com/pranavpandey/android/dynamic/support/view/DynamicInfoViewBigAuthor.java @@ -0,0 +1,87 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.pranavpandey.android.dynamic.support.view; + +import android.content.Context; +import android.util.AttributeSet; + +import androidx.annotation.AttrRes; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.pranavpandey.android.dynamic.support.R; +import com.pranavpandey.android.dynamic.support.theme.DynamicTheme; +import com.pranavpandey.android.dynamic.support.view.base.DynamicInfoView; +import com.pranavpandey.android.dynamic.util.DynamicDeviceUtils; +import com.pranavpandey.android.dynamic.util.product.DynamicFlavor; + +/** + * A {@link DynamicInfoView} with bigger fallback icon. + *

Showing author info according to the product flavor. + * + * @see DynamicFlavor + */ +public class DynamicInfoViewBigAuthor extends DynamicInfoView { + + public DynamicInfoViewBigAuthor(@NonNull Context context) { + super(context); + } + + public DynamicInfoViewBigAuthor(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public DynamicInfoViewBigAuthor(@NonNull Context context, + @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected @LayoutRes int getLayoutRes() { + return R.layout.ads_info_view_big; + } + + @Override + protected void onInflate() { + super.onInflate(); + + if (DynamicFlavor.EXTERNAL.equals( + DynamicTheme.getInstance().getProductFlavor()) + && DynamicDeviceUtils.isSamsungOneUI()) { + setLinksSubtitles(new CharSequence[] { + getContext().getString(R.string.ads_info_website_me_desc), + String.format(getContext().getString(R.string.ads_info_apps_desc), + getContext().getString(R.string.adu_store_samsung_galaxy_store)) + }); + setLinksUrls(new CharSequence[] { + getContext().getString(R.string.adu_url_me_website), + getContext().getString(R.string.adu_url_me_samsung_galaxy_store) + }); + } else { + setLinksSubtitles(new CharSequence[] { + getContext().getString(R.string.ads_info_website_me_desc), + String.format(getContext().getString(R.string.ads_info_apps_desc), + getContext().getString(R.string.adu_store_google_play)) + }); + setLinksUrls(new CharSequence[] { + getContext().getString(R.string.adu_url_me_website), + getContext().getString(R.string.adu_url_me_google_play) + }); + } + } +} diff --git a/dynamic-support/src/main/res/values/arrays.xml b/dynamic-support/src/main/res/values/arrays.xml index 39b067823..b929f68c6 100644 --- a/dynamic-support/src/main/res/values/arrays.xml +++ b/dynamic-support/src/main/res/values/arrays.xml @@ -1,6 +1,6 @@ @string/ads_info_website_me_desc - @string/ads_info_apps_desc + @string/ads_info_apps_desc_google_play - https://pranavpandey.com - https://play.google.com/store/apps/dev?id=6608630615059087491 + @string/adu_url_me_website + @string/adu_url_me_google_play @drawable/ads_ic_public - @drawable/ads_ic_shop + @drawable/ads_ic_open_alt