|
@@ -14,6 +14,7 @@ import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
+import com.nextcloud.android.common.ui.theme.utils.ColorRole;
|
|
import com.nextcloud.client.di.Injectable;
|
|
import com.nextcloud.client.di.Injectable;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.features.FeatureItem;
|
|
import com.owncloud.android.features.FeatureItem;
|
|
@@ -29,7 +30,8 @@ import androidx.fragment.app.Fragment;
|
|
|
|
|
|
public class FeatureFragment extends Fragment implements Injectable {
|
|
public class FeatureFragment extends Fragment implements Injectable {
|
|
private FeatureItem item;
|
|
private FeatureItem item;
|
|
- @Inject ViewThemeUtils viewThemeUtils;
|
|
|
|
|
|
+ @Inject ViewThemeUtils.Factory viewThemeUtilsFactory;
|
|
|
|
+ private ViewThemeUtils viewThemeUtils;
|
|
|
|
|
|
static public FeatureFragment newInstance(FeatureItem item) {
|
|
static public FeatureFragment newInstance(FeatureItem item) {
|
|
FeatureFragment f = new FeatureFragment();
|
|
FeatureFragment f = new FeatureFragment();
|
|
@@ -41,6 +43,7 @@ public class FeatureFragment extends Fragment implements Injectable {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
+ viewThemeUtils = viewThemeUtilsFactory.withPrimaryAsBackground();
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
item = getArguments() != null ? (FeatureItem) getArguments().getParcelable("feature") : null;
|
|
item = getArguments() != null ? (FeatureItem) getArguments().getParcelable("feature") : null;
|
|
}
|
|
}
|
|
@@ -51,18 +54,19 @@ public class FeatureFragment extends Fragment implements Injectable {
|
|
@Nullable ViewGroup container,
|
|
@Nullable ViewGroup container,
|
|
@Nullable Bundle savedInstanceState) {
|
|
@Nullable Bundle savedInstanceState) {
|
|
View view = inflater.inflate(R.layout.whats_new_element, container, false);
|
|
View view = inflater.inflate(R.layout.whats_new_element, container, false);
|
|
- int fontColor = getResources().getColor(R.color.login_text_color);
|
|
|
|
|
|
|
|
ImageView whatsNewImage = view.findViewById(R.id.whatsNewImage);
|
|
ImageView whatsNewImage = view.findViewById(R.id.whatsNewImage);
|
|
if (item.shouldShowImage()) {
|
|
if (item.shouldShowImage()) {
|
|
final Drawable image = ResourcesCompat.getDrawable(getResources(), item.getImage(), null);
|
|
final Drawable image = ResourcesCompat.getDrawable(getResources(), item.getImage(), null);
|
|
- whatsNewImage.setImageDrawable(viewThemeUtils.platform.colorDrawable(image, fontColor));
|
|
|
|
|
|
+ if (image != null) {
|
|
|
|
+ whatsNewImage.setImageDrawable(viewThemeUtils.platform.tintDrawable(requireContext(), image, ColorRole.ON_PRIMARY));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
TextView whatsNewTitle = view.findViewById(R.id.whatsNewTitle);
|
|
TextView whatsNewTitle = view.findViewById(R.id.whatsNewTitle);
|
|
if (item.shouldShowTitleText()) {
|
|
if (item.shouldShowTitleText()) {
|
|
whatsNewTitle.setText(item.getTitleText());
|
|
whatsNewTitle.setText(item.getTitleText());
|
|
- whatsNewTitle.setTextColor(fontColor);
|
|
|
|
|
|
+ viewThemeUtils.platform.colorTextView(whatsNewTitle, ColorRole.ON_PRIMARY);
|
|
whatsNewTitle.setVisibility(View.VISIBLE);
|
|
whatsNewTitle.setVisibility(View.VISIBLE);
|
|
} else {
|
|
} else {
|
|
whatsNewTitle.setVisibility(View.GONE);
|
|
whatsNewTitle.setVisibility(View.GONE);
|
|
@@ -74,14 +78,14 @@ public class FeatureFragment extends Fragment implements Injectable {
|
|
String[] texts = getText(item.getContentText()).toString().split("\n");
|
|
String[] texts = getText(item.getContentText()).toString().split("\n");
|
|
|
|
|
|
for (String text : texts) {
|
|
for (String text : texts) {
|
|
- TextView textView = generateTextView(text, getContext(),
|
|
|
|
- item.shouldContentCentered(), fontColor, true);
|
|
|
|
|
|
+ TextView textView = generateTextView(text, requireContext(),
|
|
|
|
+ item.shouldContentCentered(), true);
|
|
|
|
|
|
linearLayout.addView(textView);
|
|
linearLayout.addView(textView);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
TextView textView = generateTextView(getText(item.getContentText()).toString(),
|
|
TextView textView = generateTextView(getText(item.getContentText()).toString(),
|
|
- getContext(), item.shouldContentCentered(), fontColor, false);
|
|
|
|
|
|
+ requireContext(), item.shouldContentCentered(), false);
|
|
|
|
|
|
linearLayout.addView(textView);
|
|
linearLayout.addView(textView);
|
|
}
|
|
}
|
|
@@ -93,30 +97,30 @@ public class FeatureFragment extends Fragment implements Injectable {
|
|
}
|
|
}
|
|
|
|
|
|
private TextView generateTextView(String text, Context context,
|
|
private TextView generateTextView(String text, Context context,
|
|
- boolean shouldContentCentered, int fontColor,
|
|
|
|
|
|
+ boolean shouldContentCentered,
|
|
boolean showBulletPoints) {
|
|
boolean showBulletPoints) {
|
|
int standardMargin = context.getResources().getDimensionPixelSize(R.dimen.standard_margin);
|
|
int standardMargin = context.getResources().getDimensionPixelSize(R.dimen.standard_margin);
|
|
int doubleMargin = context.getResources()
|
|
int doubleMargin = context.getResources()
|
|
- .getDimensionPixelSize(R.dimen.standard_double_margin);
|
|
|
|
|
|
+ .getDimensionPixelSize(R.dimen.standard_double_margin);
|
|
int zeroMargin = context.getResources().getDimensionPixelSize(R.dimen.zero);
|
|
int zeroMargin = context.getResources().getDimensionPixelSize(R.dimen.zero);
|
|
|
|
|
|
TextView textView = new TextView(context);
|
|
TextView textView = new TextView(context);
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
|
- ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
|
+ ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
layoutParams.setMargins(doubleMargin, standardMargin, doubleMargin, zeroMargin);
|
|
layoutParams.setMargins(doubleMargin, standardMargin, doubleMargin, zeroMargin);
|
|
textView.setTextAppearance(context, R.style.NextcloudTextAppearanceMedium);
|
|
textView.setTextAppearance(context, R.style.NextcloudTextAppearanceMedium);
|
|
textView.setLayoutParams(layoutParams);
|
|
textView.setLayoutParams(layoutParams);
|
|
|
|
|
|
if (showBulletPoints) {
|
|
if (showBulletPoints) {
|
|
- BulletSpan bulletSpan = new BulletSpan(standardMargin, fontColor);
|
|
|
|
|
|
+ BulletSpan bulletSpan = new BulletSpan(standardMargin);
|
|
SpannableString spannableString = new SpannableString(text);
|
|
SpannableString spannableString = new SpannableString(text);
|
|
spannableString.setSpan(bulletSpan, 0, spannableString.length(),
|
|
spannableString.setSpan(bulletSpan, 0, spannableString.length(),
|
|
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
|
|
+ Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
textView.setText(spannableString);
|
|
textView.setText(spannableString);
|
|
} else {
|
|
} else {
|
|
textView.setText(text);
|
|
textView.setText(text);
|
|
}
|
|
}
|
|
- textView.setTextColor(fontColor);
|
|
|
|
|
|
+ viewThemeUtils.platform.colorTextView(textView, ColorRole.ON_PRIMARY);
|
|
|
|
|
|
if (!shouldContentCentered) {
|
|
if (!shouldContentCentered) {
|
|
textView.setGravity(Gravity.START);
|
|
textView.setGravity(Gravity.START);
|