make summary a dynamic string

This commit is contained in:
Christian Schabesberger 2017-10-22 22:06:25 +02:00
parent c3f04ea67d
commit d1f446aae2
2 changed files with 17 additions and 9 deletions

View File

@ -40,16 +40,19 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
.putInt(getString(R.string.main_page_selected_service), service_id).apply(); .putInt(getString(R.string.main_page_selected_service), service_id).apply();
defaultPreferences.edit() defaultPreferences.edit()
.putString(getString(R.string.main_page_selectd_kiosk_id), kioskId).apply(); .putString(getString(R.string.main_page_selectd_kiosk_id), kioskId).apply();
String summary = ""; String serviceName = "";
try { try {
summary += NewPipe.getService(service_id).getServiceInfo().name; serviceName = NewPipe.getService(service_id).getServiceInfo().name;
} catch (ExtractionException e) { } catch (ExtractionException e) {
onError(e); onError(e);
} }
summary += "/"; String kioskName = KioskTranslator.getTranslatedKioskName(kioskId,
summary += KioskTranslator.getTranslatedKioskName(kioskId, getContext()); getContext());
String summary =
String.format(getString(R.string.service_kosk_string),
serviceName,
kioskName);
mainPageContentPref.setSummary(summary); mainPageContentPref.setSummary(summary);
} }
@ -112,13 +115,17 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
StreamingService service = NewPipe.getService( StreamingService service = NewPipe.getService(
defaultPreferences.getInt( defaultPreferences.getInt(
getString(R.string.main_page_selected_service), 0)); getString(R.string.main_page_selected_service), 0));
String summary = "";
summary += service.getServiceInfo().name; String kioskName = KioskTranslator.getTranslatedKioskName(
summary += "/";
summary += KioskTranslator.getTranslatedKioskName(
defaultPreferences.getString( defaultPreferences.getString(
getString(R.string.main_page_selectd_kiosk_id), "Trending"), getString(R.string.main_page_selectd_kiosk_id), "Trending"),
getContext()); getContext());
String summary =
String.format(getString(R.string.service_kosk_string),
service.getServiceInfo().name,
kioskName);
mainPagePref.setSummary(summary); mainPagePref.setSummary(summary);
} catch (Exception e) { } catch (Exception e) {
onError(e); onError(e);

View File

@ -290,4 +290,5 @@
<string name="trending">Trending</string> <string name="trending">Trending</string>
<string name="top_50">Top 50</string> <string name="top_50">Top 50</string>
<string name="new_and_hot">New &amp; hot</string> <string name="new_and_hot">New &amp; hot</string>
<string name="service_kosk_string">%1$s/%2$s</string>
</resources> </resources>