parent
0689a39735
commit
2d27ba4086
@ -294,6 +294,9 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
final TextView lastUpdateView;
|
final TextView lastUpdateView;
|
||||||
final TextView descriptionView;
|
final TextView descriptionView;
|
||||||
final TextView descriptionMoreView;
|
final TextView descriptionMoreView;
|
||||||
|
final TextView antiFeaturesLabelView;
|
||||||
|
final TextView antiFeaturesView;
|
||||||
|
final View antiFeaturesWarningView;
|
||||||
final View buttonLayout;
|
final View buttonLayout;
|
||||||
final Button buttonPrimaryView;
|
final Button buttonPrimaryView;
|
||||||
final Button buttonSecondaryView;
|
final Button buttonSecondaryView;
|
||||||
@ -303,6 +306,7 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
final TextView progressPercent;
|
final TextView progressPercent;
|
||||||
final View progressCancel;
|
final View progressCancel;
|
||||||
final DisplayImageOptions displayImageOptions;
|
final DisplayImageOptions displayImageOptions;
|
||||||
|
boolean descriptionIsExpanded;
|
||||||
|
|
||||||
HeaderViewHolder(View view) {
|
HeaderViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
@ -312,6 +316,9 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
lastUpdateView = (TextView) view.findViewById(R.id.text_last_update);
|
lastUpdateView = (TextView) view.findViewById(R.id.text_last_update);
|
||||||
descriptionView = (TextView) view.findViewById(R.id.description);
|
descriptionView = (TextView) view.findViewById(R.id.description);
|
||||||
descriptionMoreView = (TextView) view.findViewById(R.id.description_more);
|
descriptionMoreView = (TextView) view.findViewById(R.id.description_more);
|
||||||
|
antiFeaturesLabelView = (TextView) view.findViewById(R.id.label_anti_features);
|
||||||
|
antiFeaturesView = (TextView) view.findViewById(R.id.text_anti_features);
|
||||||
|
antiFeaturesWarningView = view.findViewById(R.id.anti_features_warning);
|
||||||
buttonLayout = view.findViewById(R.id.button_layout);
|
buttonLayout = view.findViewById(R.id.button_layout);
|
||||||
buttonPrimaryView = (Button) view.findViewById(R.id.primaryButtonView);
|
buttonPrimaryView = (Button) view.findViewById(R.id.primaryButtonView);
|
||||||
buttonSecondaryView = (Button) view.findViewById(R.id.secondaryButtonView);
|
buttonSecondaryView = (Button) view.findViewById(R.id.secondaryButtonView);
|
||||||
@ -341,10 +348,13 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
if (TextViewCompat.getMaxLines(descriptionView) != MAX_LINES) {
|
if (TextViewCompat.getMaxLines(descriptionView) != MAX_LINES) {
|
||||||
descriptionView.setMaxLines(MAX_LINES);
|
descriptionView.setMaxLines(MAX_LINES);
|
||||||
descriptionMoreView.setText(R.string.more);
|
descriptionMoreView.setText(R.string.more);
|
||||||
|
descriptionIsExpanded = false;
|
||||||
} else {
|
} else {
|
||||||
descriptionView.setMaxLines(Integer.MAX_VALUE);
|
descriptionView.setMaxLines(Integer.MAX_VALUE);
|
||||||
descriptionMoreView.setText(R.string.less);
|
descriptionMoreView.setText(R.string.less);
|
||||||
|
descriptionIsExpanded = true;
|
||||||
}
|
}
|
||||||
|
updateAntiFeaturesWarning();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Set ALL caps (in a way compatible with SDK 10)
|
// Set ALL caps (in a way compatible with SDK 10)
|
||||||
@ -421,13 +431,27 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
descriptionView.post(new Runnable() {
|
descriptionView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (descriptionView.getLineCount() <= HeaderViewHolder.MAX_LINES) {
|
if (descriptionView.getLineCount() <= HeaderViewHolder.MAX_LINES && app.antiFeatures == null) {
|
||||||
descriptionMoreView.setVisibility(View.GONE);
|
descriptionMoreView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
descriptionMoreView.setVisibility(View.VISIBLE);
|
descriptionMoreView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (app.antiFeatures != null) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String af : app.antiFeatures) {
|
||||||
|
String afdesc = descAntiFeature(af);
|
||||||
|
sb.append("\t• ").append(afdesc).append('\n');
|
||||||
|
}
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
sb.setLength(sb.length() - 1);
|
||||||
|
antiFeaturesView.setText(sb.toString());
|
||||||
|
} else {
|
||||||
|
antiFeaturesView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateAntiFeaturesWarning();
|
||||||
buttonSecondaryView.setText(R.string.menu_uninstall);
|
buttonSecondaryView.setText(R.string.menu_uninstall);
|
||||||
buttonSecondaryView.setVisibility(app.isInstalled() ? View.VISIBLE : View.INVISIBLE);
|
buttonSecondaryView.setVisibility(app.isInstalled() ? View.VISIBLE : View.INVISIBLE);
|
||||||
buttonSecondaryView.setOnClickListener(onUnInstallClickListener);
|
buttonSecondaryView.setOnClickListener(onUnInstallClickListener);
|
||||||
@ -473,6 +497,39 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAntiFeaturesWarning() {
|
||||||
|
if (app.antiFeatures == null || TextUtils.isEmpty(antiFeaturesView.getText())) {
|
||||||
|
antiFeaturesLabelView.setVisibility(View.GONE);
|
||||||
|
antiFeaturesView.setVisibility(View.GONE);
|
||||||
|
antiFeaturesWarningView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
antiFeaturesLabelView.setVisibility(descriptionIsExpanded ? View.VISIBLE : View.GONE);
|
||||||
|
antiFeaturesView.setVisibility(descriptionIsExpanded ? View.VISIBLE : View.GONE);
|
||||||
|
antiFeaturesWarningView.setVisibility(descriptionIsExpanded ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String descAntiFeature(String af) {
|
||||||
|
switch (af) {
|
||||||
|
case "Ads":
|
||||||
|
return itemView.getContext().getString(R.string.antiadslist);
|
||||||
|
case "Tracking":
|
||||||
|
return itemView.getContext().getString(R.string.antitracklist);
|
||||||
|
case "NonFreeNet":
|
||||||
|
return itemView.getContext().getString(R.string.antinonfreenetlist);
|
||||||
|
case "NonFreeAdd":
|
||||||
|
return itemView.getContext().getString(R.string.antinonfreeadlist);
|
||||||
|
case "NonFreeDep":
|
||||||
|
return itemView.getContext().getString(R.string.antinonfreedeplist);
|
||||||
|
case "UpstreamNonFree":
|
||||||
|
return itemView.getContext().getString(R.string.antiupstreamnonfreelist);
|
||||||
|
case "NonFreeAssets":
|
||||||
|
return itemView.getContext().getString(R.string.antinonfreeassetslist);
|
||||||
|
default:
|
||||||
|
return af;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
9
app/src/main/res/drawable/ic_warning_black_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_warning_black_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
|
||||||
|
</vector>
|
@ -165,6 +165,26 @@
|
|||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
tools:text="This is the app description of this awezome app. It can be several lines long, but will be truncated at just a few if it is. A 'read more' button will appear so that you can expand the view and view the full text, if you wish. Yes, it will be blue and beautiful." />
|
tools:text="This is the app description of this awezome app. It can be several lines long, but will be truncated at just a few if it is. A 'read more' button will appear so that you can expand the view and view the full text, if you wish. Yes, it will be blue and beautiful." />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/label_anti_features"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
android:text="@string/antifeatures" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_anti_features"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:scrollbars="none"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
tools:text="\t• This app tracks and reports your activity." />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/description_more"
|
android:id="@+id/description_more"
|
||||||
style="@style/DetailsMoreButtonStyle"
|
style="@style/DetailsMoreButtonStyle"
|
||||||
@ -175,5 +195,17 @@
|
|||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
tools:text="more" />
|
tools:text="more" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/anti_features_warning"
|
||||||
|
style="@style/DetailsAntiFeaturesWarningStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
|
android:drawableStart="@drawable/ic_warning_black_24dp"
|
||||||
|
android:drawableLeft="@drawable/ic_warning_black_24dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:drawablePadding="10dp"
|
||||||
|
android:text="@string/antifeatureswarning" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
|
@ -170,6 +170,8 @@
|
|||||||
<string name="details_installed">Version %s installed</string>
|
<string name="details_installed">Version %s installed</string>
|
||||||
<string name="details_notinstalled">Not installed</string>
|
<string name="details_notinstalled">Not installed</string>
|
||||||
|
|
||||||
|
<string name="antifeatureswarning">This app has features you may not like.</string>
|
||||||
|
<string name="antifeatures">Anti-features</string>
|
||||||
<string name="antiadslist">This app contains advertising</string>
|
<string name="antiadslist">This app contains advertising</string>
|
||||||
<string name="antitracklist">This app tracks and reports your activity</string>
|
<string name="antitracklist">This app tracks and reports your activity</string>
|
||||||
<string name="antinonfreeadlist">This app promotes non-free add-ons</string>
|
<string name="antinonfreeadlist">This app promotes non-free add-ons</string>
|
||||||
|
@ -41,4 +41,8 @@
|
|||||||
<style name="DetailsLastUpdatedStyle" parent="TextAppearance.AppCompat.Small">
|
<style name="DetailsLastUpdatedStyle" parent="TextAppearance.AppCompat.Small">
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="DetailsAntiFeaturesWarningStyle" parent="TextAppearance.AppCompat.Body1">
|
||||||
|
<item name="android:textStyle">bold</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user