LineView: Show product and operator in line cheat sheet.

This commit is contained in:
Andreas Schildbach 2019-01-13 11:08:24 +01:00
parent b189f07e02
commit f740de9af0

View file

@ -28,6 +28,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import de.schildbach.oeffi.R; import de.schildbach.oeffi.R;
import de.schildbach.oeffi.util.CheatSheet; import de.schildbach.oeffi.util.CheatSheet;
import de.schildbach.pte.Standard; import de.schildbach.pte.Standard;
@ -175,9 +178,14 @@ public class LineView extends TextView {
setText(text); setText(text);
if (lines.size() == 1) { if (lines.size() == 1) {
final String name = lines.iterator().next().name; final Line line = lines.iterator().next();
if (name != null) final Context context = getContext();
CheatSheet.setup(this, name); final int productResId = getResources().getIdentifier(
"product_" + Character.toLowerCase(line.productCode()), "string", context.getPackageName());
final String sheet = Joiner.on('\n').skipNulls().join(line.name,
productResId != 0 ? context.getString(productResId) : null, line.network);
if (Strings.emptyToNull(sheet) != null)
CheatSheet.setup(this, sheet);
else else
CheatSheet.remove(this); CheatSheet.remove(this);
} else { } else {