translate kiosk name using resources

fix CDATA fuu
This commit is contained in:
Christian Schabesberger 2017-09-28 16:15:09 +02:00
parent 29fee28d1d
commit 46fa9a9366
10 changed files with 82 additions and 8 deletions

View File

@ -126,10 +126,18 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
if(PreferenceManager.getDefaultSharedPreferences(getActivity())
.getString(getString(R.string.main_page_content_key), getString(R.string.blank_page_key))
.equals(getString(R.string.subscription_page_key))) {
return new SubscriptionFragment();
} else {
return getMainPageFramgent();
}
case 1:
return new SubscriptionFragment();
default:
return getMainPageFramgent();
return new BlankFragment();
}
}
@ -140,7 +148,13 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
@Override
public int getCount() {
return this.tabTitles.length;
if(PreferenceManager.getDefaultSharedPreferences(getActivity())
.getString(getString(R.string.main_page_content_key), getString(R.string.blank_page_key))
.equals(getString(R.string.subscription_page_key))) {
return 1;
} else {
return 2;
}
}
}
@ -186,4 +200,10 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
return new BlankFragment();
}
}
/*//////////////////////////////////////////////////////////////////////////
// Main page content
//////////////////////////////////////////////////////////////////////////*/
}

View File

@ -89,7 +89,8 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_channel, container, false);
View v = inflater.inflate(R.layout.fragment_channel, container, false);
return v;
}
@Override
@ -110,6 +111,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
headerTitleView = headerRootLayout.findViewById(R.id.channel_title_view);
headerSubscribersTextView = headerRootLayout.findViewById(R.id.channel_subscriber_view);
headerSubscribeButton = headerRootLayout.findViewById(R.id.channel_subscribe_button);
return headerRootLayout;
}
@ -123,7 +125,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
ActionBar supportActionBar = activity.getSupportActionBar();
if(useAsFrontPage) {
supportActionBar.setDisplayHomeAsUpEnabled(false);
supportActionBar.setDisplayShowTitleEnabled(false);
//supportActionBar.setDisplayShowTitleEnabled(false);
} else {
inflater.inflate(R.menu.menu_channel, menu);

View File

@ -122,7 +122,7 @@ public class FeedFragment extends BaseListFragment<List<SubscriptionEntity>, Voi
if(useAsFrontPage) {
supportActionBar.setDisplayHomeAsUpEnabled(false);
supportActionBar.setDisplayShowTitleEnabled(false);
//supportActionBar.setDisplayShowTitleEnabled(false);
}
}

View File

@ -24,6 +24,7 @@ import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.KioskTranslator;
import org.schabi.newpipe.util.NavigationHelper;
import io.reactivex.Single;
@ -90,7 +91,7 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
super.onCreateOptionsMenu(menu, inflater);
ActionBar supportActionBar = activity.getSupportActionBar();
if (supportActionBar != null && useAsFrontPage) {
supportActionBar.setDisplayShowTitleEnabled(false);
//supportActionBar.setDisplayShowTitleEnabled(false);
supportActionBar.setDisplayHomeAsUpEnabled(false);
}
}
@ -140,7 +141,7 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
super.handleResult(result);
animateView(headerRootLayout, true, 100);
headerTitleView.setText("★★ " +result.name+ " ★★");
headerTitleView.setText("★★ " + KioskTranslator.getTranslatedKioskName(result.id, getActivity())+ " ★★");
if (!result.errors.isEmpty()) {
showSnackBarError(result.errors,

View File

@ -62,6 +62,8 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
activity.getSupportActionBar().setDisplayShowTitleEnabled(true);
activity.setTitle(R.string.tab_subscriptions);
return inflater.inflate(R.layout.fragment_subscription, container, false);
}

View File

@ -94,6 +94,8 @@ public class ContentSettingsFragment extends BasePreferenceFragment {
return R.string.kiosk_page_summary;
} else if(key.equals(getString(R.string.feed_page_key))) {
return R.string.feed_page_summary;
} else if(key.equals(getString(R.string.subscription_page_key))) {
return R.string.subscription_page_summary;
} else if(key.equals(getString(R.string.channel_page_key))) {
return R.string.channel_page_summary;
}

View File

@ -0,0 +1,38 @@
package org.schabi.newpipe.util;
import android.content.Context;
import org.schabi.newpipe.R;
/**
* Created by Chrsitian Schabesberger on 28.09.17.
* KioskTranslator.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NewPipe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class KioskTranslator {
public static String getTranslatedKioskName(String kioskId, Context c) {
switch(kioskId) {
case "Trending":
return c.getString(R.string.trending);
case "Top 50":
return c.getString(R.string.top_50);
case "New & hot":
return c.getString(R.string.new_and_hot);
default:
return kioskId;
}
}
}

View File

@ -20,6 +20,6 @@
<item android:id="@+id/action_about"
android:orderInCategory="1000"
android:title="@string/action_about" />
android:title="@string/action_about"/>
</menu>

View File

@ -105,12 +105,14 @@
<string name="main_page_content_key" translatable="false">main_page_content</string>
<string name="blank_page_key" translatable="false">blank_page</string>
<string name="feed_page_key" translatable="false">feed_page</string>
<string name="subscription_page_key" translatable="false">subscription_page_key</string>
<string name="kiosk_page_key" translatable="false">kiosk_page</string>
<string name="channel_page_key" translatable="false">channel_page</string>
<string-array name="main_page_content_pages" translatable="false">
<item>@string/blank_page_key</item>
<item>@string/kiosk_page_key</item>
<item>@string/feed_page_key</item>
<item>@string/subscription_page_key</item>
<item>@string/channel_page_key</item>
</string-array>
<string name="main_page_selected_service" translatable="false">main_page_selected_service</string>

View File

@ -270,14 +270,21 @@
<string name="main_page_content">Content of main page</string>
<string name="blank_page_summary">Blank Page</string>
<string name="kiosk_page_summary">Kiosk Page</string>
<string name="subscription_page_summary">Subscription Page</string>
<string name="feed_page_summary">Feed Page</string>
<string name="channel_page_summary">Channel Page</string>
<string-array name="main_page_content_names">
<item>@string/blank_page_summary</item>
<item>@string/kiosk_page_summary</item>
<item>@string/feed_page_summary</item>
<item>@string/subscription_page_summary</item>
<item>@string/channel_page_summary</item>
</string-array>
<string name="select_a_channel">Select a channel</string>
<string name="no_channel_subscribed_yet">No channel subscribed yet</string>
<!-- Kiosk Names -->
<string name="trending">Trending</string>
<string name="top_50">Top 50</string>
<string name="new_and_hot">New &amp; hot</string>
</resources>