88
99package org .telegram .ui ;
1010
11+ import static org .telegram .messenger .LocaleController .getString ;
12+
1113import android .content .Context ;
1214import android .content .DialogInterface ;
1315import android .graphics .Canvas ;
4244import org .telegram .ui .Cells .HeaderCell ;
4345import org .telegram .ui .Cells .LanguageCell ;
4446import org .telegram .ui .Cells .ShadowSectionCell ;
47+ import org .telegram .ui .Cells .TextCell ;
4548import org .telegram .ui .Cells .TextCheckCell ;
4649import org .telegram .ui .Cells .TextInfoPrivacyCell ;
4750import org .telegram .ui .Cells .TextRadioCell ;
6063import java .util .Iterator ;
6164import java .util .Timer ;
6265
66+ import tw .nekomimi .nekogram .settings .NekoTranslatorSettingsActivity ;
67+
6368public class LanguageSelectActivity extends BaseFragment implements NotificationCenter .NotificationCenterDelegate {
6469
6570 private ListAdapter listAdapter ;
@@ -196,21 +201,19 @@ protected void onMoveAnimationUpdate(RecyclerView.ViewHolder holder) {
196201 if (view instanceof TextCheckCell ) {
197202 final boolean prevFullValue = getContextValue () || getChatValue ();
198203 if (position == 1 ) {
199- // boolean value = !getContextValue();
200- // getMessagesController().getTranslateController().setContextTranslateEnabled(value);
201- // ((TextCheckCell) view).setChecked(value);
202- // NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateSearchSettings);
203- return ;
204+ boolean value = !getContextValue ();
205+ getMessagesController ().getTranslateController ().setContextTranslateEnabled (value );
206+ ((TextCheckCell ) view ).setChecked (value );
207+ NotificationCenter .getInstance (currentAccount ).postNotificationName (NotificationCenter .updateSearchSettings );
204208 } else if (position == 2 ) {
205- // boolean value = !getChatValue();
206- // if (value && !getUserConfig().isPremium()) {
207- // showDialog(new PremiumFeatureBottomSheet(LanguageSelectActivity.this, PremiumPreviewFragment.PREMIUM_FEATURE_TRANSLATIONS, false));
208- // return;
209- // }
210- // getMessagesController().getTranslateController().setChatTranslateEnabled(value);
211- // NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateSearchSettings);
212- // ((TextCheckCell) view).setChecked(value);
213- return ;
209+ boolean value = !getChatValue ();
210+ if (value && !getUserConfig ().isPremium ()) {
211+ showDialog (new PremiumFeatureBottomSheet (LanguageSelectActivity .this , PremiumPreviewFragment .PREMIUM_FEATURE_TRANSLATIONS , false ));
212+ return ;
213+ }
214+ getMessagesController ().getTranslateController ().setChatTranslateEnabled (value );
215+ NotificationCenter .getInstance (currentAccount ).postNotificationName (NotificationCenter .updateSearchSettings );
216+ ((TextCheckCell ) view ).setChecked (value );
214217 }
215218 final boolean currentFullValue = getContextValue () || getChatValue ();
216219 if (currentFullValue != prevFullValue ) {
@@ -232,6 +235,9 @@ protected void onMoveAnimationUpdate(RecyclerView.ViewHolder holder) {
232235 }
233236 }
234237 return ;
238+ } else if (view instanceof TextCell ) {
239+ presentFragment (new NekoTranslatorSettingsActivity ());
240+ return ;
235241 } else if (view instanceof TextSettingsCell ) {
236242 presentFragment (new RestrictedLanguagesSelectActivity ());
237243 return ;
@@ -241,7 +247,7 @@ protected void onMoveAnimationUpdate(RecyclerView.ViewHolder holder) {
241247 }
242248 boolean search = listView .getAdapter () == searchListViewAdapter ;
243249 if (!search ) {
244- position -= (7 - (!(getChatValue () || getContextValue ()) ? 1 : 0 ) - (getMessagesController ().premiumFeaturesBlocked () ? 1 : 0 ));
250+ position -= 4 ; /* (7 - (!(getChatValue() || getContextValue()) ? 1 : 0) - (getMessagesController().premiumFeaturesBlocked() ? 1 : 0));*/
245251 }
246252 LocaleController .LocaleInfo localeInfo ;
247253 if (search ) {
@@ -306,7 +312,7 @@ protected void onMoveAnimationUpdate(RecyclerView.ViewHolder holder) {
306312 }
307313 boolean search = listView .getAdapter () == searchListViewAdapter ;
308314 if (!search ) {
309- position -= (7 - (!(getChatValue () || getContextValue ()) ? 1 : 0 ) - (getMessagesController ().premiumFeaturesBlocked () ? 1 : 0 ));
315+ position -= 4 ; /* (7 - (!(getChatValue() || getContextValue()) ? 1 : 0) - (getMessagesController().premiumFeaturesBlocked() ? 1 : 0));*/
310316 }
311317 LocaleController .LocaleInfo localeInfo ;
312318 if (search ) {
@@ -543,7 +549,7 @@ public int getItemCount() {
543549 if (!unofficialLanguages .isEmpty ()) {
544550 count += unofficialLanguages .size () + 1 ;
545551 }
546- return 4 + (getMessagesController ().premiumFeaturesBlocked () ? 0 : 1 ) + (getChatValue () || getContextValue () ? 1 : 0 ) + 1 + count ;
552+ return 4 + /* (getMessagesController().premiumFeaturesBlocked() ? 0 : 1) + (getChatValue() || getContextValue() ? 1 : 0) + 1 + */ count ;
547553 }
548554 }
549555
@@ -562,7 +568,9 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
562568 view = switchCell ;
563569 break ;
564570 case VIEW_TYPE_SETTINGS :
565- TextSettingsCell settingsCell = new TextSettingsCell (mContext );
571+ /*TextSettingsCell settingsCell = new TextSettingsCell(mContext);
572+ settingsCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));*/
573+ TextCell settingsCell = new TextCell (mContext );
566574 settingsCell .setBackgroundColor (Theme .getColor (Theme .key_windowBackgroundWhite ));
567575 view = settingsCell ;
568576 break ;
@@ -596,7 +604,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
596604 switch (holder .getItemViewType ()) {
597605 case VIEW_TYPE_LANGUAGE : {
598606 if (!search ) {
599- position -= (7 - (!(getChatValue () || getContextValue ()) ? 1 : 0 ) - (getMessagesController ().premiumFeaturesBlocked () ? 1 : 0 ));
607+ position -= 4 ; /* (7 - (!(getChatValue() || getContextValue()) ? 1 : 0) - (getMessagesController().premiumFeaturesBlocked() ? 1 : 0));*/
600608 }
601609 TextRadioCell textSettingsCell = (TextRadioCell ) holder .itemView ;
602610 textSettingsCell .updateRTL ();
@@ -641,8 +649,9 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
641649 break ;
642650 }
643651 case VIEW_TYPE_SETTINGS : {
644- TextSettingsCell settingsCell = (TextSettingsCell ) holder .itemView ;
645- settingsCell .updateRTL ();
652+ TextCell settingsCell = (TextCell ) holder .itemView ;
653+ settingsCell .setTextAndIcon (getString (R .string .TranslatorSettings ), R .drawable .ic_translate , false );
654+ /*settingsCell.updateRTL();
646655 HashSet<String> langCodes = RestrictedLanguagesSelectActivity.getRestrictedLanguages();
647656 final String doNotTranslateCellName = LocaleController.getString(R.string.DoNotTranslate);
648657 String doNotTranslateCellValue = null;
@@ -676,19 +685,17 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
676685 if (doNotTranslateCellValue == null) {
677686 doNotTranslateCellValue = String.format(LocaleController.getPluralString("Languages", langCodes.size()), langCodes.size());
678687 }
679- settingsCell .setTextAndValue (doNotTranslateCellName , doNotTranslateCellValue , true , false );
688+ settingsCell.setTextAndValue(doNotTranslateCellName, doNotTranslateCellValue, true, false);*/
680689 break ;
681690 }
682691 case VIEW_TYPE_SWITCH : {
683692 TextCheckCell cell = (TextCheckCell ) holder .itemView ;
684693 cell .updateRTL ();
685694 if (position == 1 ) {
686- cell .setTextAndCheck (LocaleController .getString (R .string .ShowTranslateButton ), true , true );
687- cell .setEnabled (false , null );
695+ cell .setTextAndCheck (LocaleController .getString (R .string .ShowTranslateButton ), getContextValue (), true );
688696 cell .setCheckBoxIcon (0 );
689697 } else if (position == 2 ) {
690698 cell .setTextAndCheck (LocaleController .getString (R .string .ShowTranslateChatButton ), getChatValue (), getContextValue () || getChatValue ());
691- cell .setEnabled (false , null );
692699 cell .setCheckBoxIcon (!getUserConfig ().isPremium () ? R .drawable .permission_locked : 0 );
693700 }
694701 break ;
@@ -704,7 +711,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
704711 } else {
705712 infoCell .setTopPadding (0 );
706713 infoCell .setBottomPadding (16 );
707- infoCell .setText (LocaleController .getString (R .string .TranslateMessagesInfo3 ));
714+ infoCell .setText (LocaleController .getString (R .string .TranslateMessagesInfo2 ));
708715 infoCell .setBackground (Theme .getThemedDrawableByKey (mContext , R .drawable .greydivider_top , Theme .key_windowBackgroundGrayShadow ));
709716 }
710717 break ;
@@ -723,15 +730,17 @@ public int getItemViewType(int i) {
723730 return VIEW_TYPE_LANGUAGE ;
724731 } else {
725732 if (i -- == 0 ) return VIEW_TYPE_HEADER ;
726- if (i -- == 0 ) return VIEW_TYPE_SWITCH ;
733+ if (i -- == 0 ) return VIEW_TYPE_SETTINGS ;
734+ if (i -- == 0 ) return VIEW_TYPE_SHADOW ;
735+ /*if (i-- == 0) return VIEW_TYPE_SWITCH;
727736 if (!getMessagesController().premiumFeaturesBlocked()) {
728737 if (i-- == 0) return VIEW_TYPE_SWITCH;
729738 }
730739 if (getChatValue() || getContextValue()) {
731740 if (i-- == 0) return VIEW_TYPE_SETTINGS;
732741 }
733742 if (i-- == 0) return VIEW_TYPE_INFO;
734- if (i -- == 0 ) return VIEW_TYPE_INFO ;
743+ if (i-- == 0) return VIEW_TYPE_INFO;*/
735744 if (i -- == 0 ) return VIEW_TYPE_HEADER ;
736745 if (!unofficialLanguages .isEmpty () && (i == unofficialLanguages .size () || i == unofficialLanguages .size () + sortedLanguages .size () + 1 ) || unofficialLanguages .isEmpty () && i == sortedLanguages .size ()) {
737746 return VIEW_TYPE_SHADOW ;
0 commit comments