mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Some fixes
This commit is contained in:
		| @@ -234,4 +234,5 @@ | ||||
|     <string name="blur">Blur</string> | ||||
|     <string name="display">Display</string> | ||||
|     <string name="no_opinion">No opinion</string> | ||||
|     <string name="pickup_languages">Pickup languages</string> | ||||
| </resources> | ||||
|   | ||||
| @@ -250,4 +250,5 @@ | ||||
|     <string name="help">Help</string> | ||||
|  | ||||
|     <string name="pickup_categories">Pickup categories</string> | ||||
|     <string name="pickup_languages">Pickup languages</string> | ||||
| </resources> | ||||
| @@ -56,10 +56,14 @@ public class InstancePickerActivity extends AppCompatActivity { | ||||
|  | ||||
|  | ||||
|     private RelativeLayout mainLoader, textviewNoAction; | ||||
|     boolean[] checkedItems; | ||||
|     String[] itemsLabel; | ||||
|     boolean[] checkedItemsCategory; | ||||
|     int[] itemsKeyCategory; | ||||
|     String[] itemsLabelCategory; | ||||
|     boolean[] checkedItemsLanguage; | ||||
|     String[] itemsKeyLanguage; | ||||
|     String[] itemsLabelLanguage; | ||||
|     InstanceParams instanceParams; | ||||
|     private TextView categories_view; | ||||
|     private TextView categories_view, languages_view; | ||||
|     private InstancesVM viewModel; | ||||
|  | ||||
|     @Override | ||||
| @@ -76,7 +80,9 @@ public class InstancePickerActivity extends AppCompatActivity { | ||||
|         textviewNoAction = findViewById(R.id.no_action); | ||||
|         mainLoader.setVisibility(View.VISIBLE); | ||||
|         Button pickup_categories = findViewById(R.id.pickup_categories); | ||||
|         Button pickup_languages = findViewById(R.id.pickup_languages); | ||||
|         categories_view = findViewById(R.id.categories_view); | ||||
|         languages_view  = findViewById(R.id.languages_view); | ||||
|         Spinner sensitive = findViewById(R.id.sensitive); | ||||
|  | ||||
|         String[] channelSensitive = new String[]{"do_not_list", "blur", "display", "no_opinion"}; | ||||
| @@ -103,29 +109,91 @@ public class InstancePickerActivity extends AppCompatActivity { | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories()); | ||||
|         checkedItems = new boolean[categories.size()]; | ||||
|         itemsLabel = new String[categories.size()]; | ||||
|  | ||||
|         pickup_categories.setOnClickListener(v -> { | ||||
|         LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages()); | ||||
|         checkedItemsLanguage = new boolean[languages.size()]; | ||||
|         itemsLabelLanguage = new String[languages.size()]; | ||||
|         itemsKeyLanguage = new String[languages.size()]; | ||||
|  | ||||
|         pickup_languages.setOnClickListener(v -> { | ||||
|             AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(InstancePickerActivity.this); | ||||
|  | ||||
|  | ||||
|             int i = 0; | ||||
|             if (categories.size() > 0) { | ||||
|                 Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator(); | ||||
|             if (languages.size() > 0) { | ||||
|                 Iterator<Map.Entry<String, String>> it = languages.entrySet().iterator(); | ||||
|                 while (it.hasNext()) { | ||||
|                     Map.Entry<Integer, String> pair = it.next(); | ||||
|                     itemsLabel[i] = pair.getValue(); | ||||
|                     checkedItems[i] = false; | ||||
|                     Map.Entry<String, String> pair = it.next(); | ||||
|                     itemsLabelLanguage[i] = pair.getValue(); | ||||
|                     checkedItemsLanguage[i] = false; | ||||
|                     itemsKeyLanguage[i] = pair.getKey(); | ||||
|                     it.remove(); | ||||
|                     i++; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             dialogBuilder.setMultiChoiceItems(itemsLabel, checkedItems, (dialog, which, isChecked) -> { | ||||
|             dialogBuilder.setMultiChoiceItems(itemsLabelLanguage, checkedItemsLanguage, (dialog, which, isChecked) -> { | ||||
|                 // The user checked or unchecked a box | ||||
|                 checkedItems[which] = isChecked; | ||||
|                 checkedItemsLanguage[which] = isChecked; | ||||
|             }); | ||||
|  | ||||
|             dialogBuilder.setOnDismissListener(dialogInterface -> { | ||||
|  | ||||
|                 SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); | ||||
|                 String between = ""; | ||||
|                 stringBuilder.append(between); | ||||
|                 List<String> langs = new ArrayList<>(); | ||||
|                 int j = 0; | ||||
|                 for(boolean itemcheked: checkedItemsLanguage){ | ||||
|                     if( itemcheked) { | ||||
|                         langs.add(itemsKeyLanguage[j]); | ||||
|                         String lang = itemsLabelLanguage[j]; | ||||
|                         if (lang != null && lang.trim().toLowerCase().compareTo("null") != 0) { | ||||
|                             if (between.length() == 0) between = "  "; | ||||
|                             String tag = "  " + lang + "  "; | ||||
|                             stringBuilder.append(tag); | ||||
|                             stringBuilder.setSpan(new RoundedBackgroundSpan(InstancePickerActivity.this), stringBuilder.length() - tag.length(), stringBuilder.length() - tag.length() + tag.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); | ||||
|                             stringBuilder.append(" "); | ||||
|                         } | ||||
|                     } | ||||
|                     j++; | ||||
|                 } | ||||
|                 instanceParams.setLanguagesOr(langs); | ||||
|                 languages_view.setText(stringBuilder, TextView.BufferType.SPANNABLE); | ||||
|                 mainLoader.setVisibility(View.VISIBLE); | ||||
|                 viewModel.getInstances(instanceParams).observe(InstancePickerActivity.this, this::manageVIewInstance); | ||||
|             }); | ||||
|             dialogBuilder.setPositiveButton(R.string.validate,  (dialog, id) -> dialog.dismiss()); | ||||
|  | ||||
|             AlertDialog alertDialog = dialogBuilder.create(); | ||||
|             alertDialog.setTitle(getString(R.string.pickup_languages)); | ||||
|             alertDialog.show(); | ||||
|         }); | ||||
|  | ||||
|         LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories()); | ||||
|         checkedItemsCategory = new boolean[categories.size()]; | ||||
|         itemsLabelCategory = new String[categories.size()]; | ||||
|         itemsKeyCategory = new int[categories.size()]; | ||||
|  | ||||
|  | ||||
|         pickup_categories.setOnClickListener(v -> { | ||||
|             AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(InstancePickerActivity.this); | ||||
|             int i = 0; | ||||
|             if (categories.size() > 0) { | ||||
|                 Iterator<Map.Entry<Integer, String>> it = categories.entrySet().iterator(); | ||||
|                 while (it.hasNext()) { | ||||
|                     Map.Entry<Integer, String> pair = it.next(); | ||||
|                     itemsLabelCategory[i] = pair.getValue(); | ||||
|                     itemsKeyCategory[i] = pair.getKey(); | ||||
|                     checkedItemsCategory[i] = false; | ||||
|                     it.remove(); | ||||
|                     i++; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             dialogBuilder.setMultiChoiceItems(itemsLabelCategory, checkedItemsCategory, (dialog, which, isChecked) -> { | ||||
|                 // The user checked or unchecked a box | ||||
|                 checkedItemsCategory[which] = isChecked; | ||||
|             }); | ||||
|  | ||||
|             dialogBuilder.setOnDismissListener(dialogInterface -> { | ||||
| @@ -134,10 +202,10 @@ public class InstancePickerActivity extends AppCompatActivity { | ||||
|                 String between = ""; | ||||
|                 stringBuilder.append(between); | ||||
|                 List<Integer> cats = new ArrayList<>(); | ||||
|                 for(boolean itemcheked: checkedItems){ | ||||
|                 for(boolean itemcheked: checkedItemsCategory){ | ||||
|                     if( itemcheked) { | ||||
|                         cats.add(j); | ||||
|                         String cat = itemsLabel[j]; | ||||
|                         cats.add(itemsKeyCategory[j]); | ||||
|                         String cat = itemsLabelCategory[j]; | ||||
|                         if (cat != null && cat.trim().toLowerCase().compareTo("null") != 0) { | ||||
|                             if (between.length() == 0) between = "  "; | ||||
|                             String tag = "  " + cat + "  "; | ||||
| @@ -156,7 +224,7 @@ public class InstancePickerActivity extends AppCompatActivity { | ||||
|             dialogBuilder.setPositiveButton(R.string.validate,  (dialog, id) -> dialog.dismiss()); | ||||
|  | ||||
|             AlertDialog alertDialog = dialogBuilder.create(); | ||||
|             alertDialog.setTitle(getString(R.string.action_playlist_create)); | ||||
|             alertDialog.setTitle(getString(R.string.pickup_categories)); | ||||
|             alertDialog.show(); | ||||
|         }); | ||||
|  | ||||
|   | ||||
| @@ -17,13 +17,13 @@ public class RoundedBackgroundSpan extends ReplacementSpan { | ||||
|  | ||||
|     public RoundedBackgroundSpan(Context context) { | ||||
|         super(); | ||||
|         backgroundColor = context.getResources().getColor(R.color.colorAccent_full); | ||||
|         textColor = context.getResources().getColor(R.color.browser_actions_bg_grey); | ||||
|         backgroundColor = context.getResources().getColor(R.color.tag_color); | ||||
|         textColor = context.getResources().getColor(R.color.tag_color_text); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @NotNull Paint paint) { | ||||
|         RectF rect = new RectF(x, top, x + measureText(paint, text, start, end), bottom); | ||||
|         RectF rect = new RectF(x, top+2, x + measureText(paint, text, start, end), bottom-1); | ||||
|         paint.setColor(backgroundColor); | ||||
|         canvas.drawRoundRect(rect, 8, 8, paint); | ||||
|         paint.setColor(textColor); | ||||
|   | ||||
							
								
								
									
										16
									
								
								app/src/main/res/drawable/ic_baseline_category_24.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/src/main/res/drawable/ic_baseline_category_24.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     android:width="24dp" | ||||
|     android:height="24dp" | ||||
|     android:viewportWidth="24" | ||||
|     android:viewportHeight="24" | ||||
|     android:tint="?attr/colorControlNormal"> | ||||
|   <path | ||||
|       android:fillColor="@android:color/white" | ||||
|       android:pathData="M12,2l-5.5,9h11z"/> | ||||
|   <path | ||||
|       android:fillColor="@android:color/white" | ||||
|       android:pathData="M17.5,17.5m-4.5,0a4.5,4.5 0,1 1,9 0a4.5,4.5 0,1 1,-9 0"/> | ||||
|   <path | ||||
|       android:fillColor="@android:color/white" | ||||
|       android:pathData="M3,13.5h8v8H3z"/> | ||||
| </vector> | ||||
| @@ -30,6 +30,11 @@ | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             > | ||||
|             <androidx.constraintlayout.widget.ConstraintLayout | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             android:id="@+id/filters_container" | ||||
|             > | ||||
|             <Button | ||||
|                 android:id="@+id/pickup_categories" | ||||
|                 style="@style/Base.Widget.AppCompat.Button.Colored" | ||||
| @@ -40,21 +45,41 @@ | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 /> | ||||
|             <Button | ||||
|                 android:id="@+id/pickup_languages" | ||||
|                 style="@style/Base.Widget.AppCompat.Button.Colored" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:gravity="center" | ||||
|                 android:text="@string/pickup_languages" | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|                 app:layout_constraintStart_toEndOf="@id/pickup_categories" | ||||
|                 /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:layout_marginTop="5dp" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/pickup_categories" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 android:id="@+id/categories_view" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:minHeight="50dp" | ||||
|                 android:layout_height="wrap_content" /> | ||||
|                 android:layout_height="wrap_content" | ||||
|                 app:drawableStartCompat="@drawable/ic_baseline_category_24" /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:layout_marginTop="5dp" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/categories_view" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 android:id="@+id/languages_view" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 app:drawableStartCompat="@drawable/ic_baseline_forum_24"/> | ||||
|  | ||||
|             <TextView | ||||
|                 android:layout_marginTop="14dp" | ||||
|                 android:id="@+id/text_spinner" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/categories_view" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/languages_view" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
| @@ -62,16 +87,16 @@ | ||||
|                 android:labelFor="@+id/sensitive"/> | ||||
|  | ||||
|             <Spinner | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/categories_view" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/languages_view" | ||||
|                 app:layout_constraintStart_toEndOf="@+id/text_spinner" | ||||
|                 android:id="@+id/sensitive" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginStart="10dp" /> | ||||
|  | ||||
|  | ||||
|             </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|             <LinearLayout | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/text_spinner" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/filters_container" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintBottom_toBottomOf="parent" | ||||
|   | ||||
| @@ -8,7 +8,8 @@ | ||||
|     <color name="colorPrimary_full">#212529</color> | ||||
|     <color name="colorPrimaryDark_full">#000000</color> | ||||
|     <color name="colorAccent_full">#F2690D</color> | ||||
|  | ||||
|     <color name="tag_color">#bbF2690D</color> | ||||
|     <color name="tag_color_text">#FAFAFA</color> | ||||
|     <color name="positive_thumbs">#2b90d9</color> | ||||
|     <color name="negative_thumbs">#F44336</color> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user