Skip to content

Commit

Permalink
Añadir clasificación de canales por ambito, refactorización, actualiz…
Browse files Browse the repository at this point in the history
…ación de dependencias y corregir añadir RSS inicial (ahora se usa el de Meneame tras la eliminación de esa característica por aprte de Bing)
  • Loading branch information
juanro49 committed Jan 1, 2022
1 parent 4651adc commit da54db2
Show file tree
Hide file tree
Showing 21 changed files with 533 additions and 162 deletions.
48 changes: 24 additions & 24 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ apply plugin: 'com.android.application'

android
{
compileSdkVersion 30
buildToolsVersion '31.0.0-rc4'
compileSdkVersion 32
buildToolsVersion '32.0.0'
buildFeatures.viewBinding true
defaultConfig
{
applicationId "org.juanro.feedtv"
minSdkVersion 19
targetSdkVersion 30
versionCode 20210521
versionName "2.0"
targetSdkVersion 32
versionCode 20220101
versionName "2.1"
useLibrary 'org.apache.http.legacy'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
resources {
excludes += ['META-INF/DEPENDENCIES', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt']
}
}

buildTypes

buildTypes
{
release
{
Expand All @@ -46,28 +45,29 @@ dependencies
implementation fileTree(dir: 'libs', include: ['*.jar'])

// RSS Parser
implementation 'com.prof18.rssparser:rssparser:3.1.4'
implementation 'com.prof18.rssparser:rssparser:4.0.2'

// UI
implementation 'androidx.appcompat:appcompat:1.4.0-alpha01'
implementation 'com.google.android.material:material:1.4.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.6.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.3.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-beta02'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'

implementation 'androidx.lifecycle:lifecycle-runtime:2.4.0-alpha01'
implementation 'androidx.lifecycle:lifecycle-runtime:2.4.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.volley:volley:1.2.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'org.conscrypt:conscrypt-android:2.5.2'
implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'org.jetbrains:annotations:21.0.0'
implementation 'androidx.preference:preference:1.2.0-rc01'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'org.jetbrains:annotations:23.0.0'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0-beta01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-beta01'
androidTestImplementation 'androidx.test:runner:1.4.1-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0-alpha03'

//implementation 'dev.dworks.libs:volleyplus:0.1.4'
//implementation 'com.squareup.okhttp3:okhttp:4.4.0'
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="org.juanro.feedtv">

<dist:module dist:instant="true" />
Expand All @@ -19,7 +20,8 @@
android:usesCleartextTraffic="true"
android:appCategory="news"
android:restoreAnyVersion="true"
android:fullBackupContent="true">
android:fullBackupContent="true"
tools:targetApi="o">

<activity
android:name=".SettingsActivity"
Expand All @@ -33,7 +35,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/TemaClaro.NoActionBar">
android:theme="@style/TemaClaro.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand All @@ -49,6 +52,11 @@
android:label="@string/television">
</activity>

<activity
android:name=".ChannelsActivity"
android:label="@string/television">
</activity>

<activity
android:name=".Videoview"
android:configChanges="orientation|keyboardHidden|screenSize"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/juanro/feedtv/AddFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void submitSeguir(View view)
{
if(unlockGN.isChecked())
{
url = "https://news.google.com/rss/search?q=" + topic + "&hl=es-419&gl=MX&ceid=MX:es-419";
url = "https://news.google.com/rss/search?q=" + topic + "&hl=es-419&gl=CU&ceid=CU:es-419";
}
else
{
Expand Down
172 changes: 172 additions & 0 deletions app/src/main/java/org/juanro/feedtv/AmbitsAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/*
* Copyright 2021 Juanro49
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package org.juanro.feedtv;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import org.juanro.feedtv.JSONParser.Ambito;

import java.util.ArrayList;

/**
* Clase que representa el adapter de la lista de canales
*/
public class AmbitsAdapter extends RecyclerView.Adapter<AmbitsAdapter.ViewHolder> implements Filterable
{
private ArrayList<Ambito> ambitos;
private ArrayList<Ambito> ambitosFiltrados;
private ItemFilter mFilter = new ItemFilter();
private Context mContext;

public AmbitsAdapter(Context context, ArrayList<Ambito> ambitos)
{
//super(context, 0, ambitos);
this.ambitos = ambitos;
this.ambitosFiltrados = ambitos;
this.mContext = context;
}

/**
* Obtiene el filtro de búsqueda en la lista
*/
public Filter getFilter()
{
return mFilter;
}


/**
* Establece la vista de los elementos de la lista
*
* @param viewGroup
* @param viewType
* @return
*/
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType)
{
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_list_canales, viewGroup, false);
return new AmbitsAdapter.ViewHolder(v);
}

/**
* Crea la vista de cada elemento en la lista
*
* @param vh
* @param position
*/
@Override
public void onBindViewHolder(@NonNull ViewHolder vh, int position)
{
// Establecer título
vh.titleView.setText(ambitosFiltrados.get(vh.getAbsoluteAdapterPosition()).getNombre());

// Registra las pulsaciones en la lista
vh.itemView.setOnClickListener(view ->
{
// Inicia la activity de detalles del canal seleccionado
Intent intent = new Intent(mContext, ChannelsActivity.class);
intent.putExtra("Ambito", ambitosFiltrados.get(vh.getAbsoluteAdapterPosition()));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
});
}

/**
* Obtiene el tamaño de la lista
*
* @return
*/
@Override
public int getItemCount()
{
return ambitosFiltrados.size();
}

/**
* Clase que realiza el filtrado de las búsquedas
*/
private class ItemFilter extends Filter
{
@Override
protected FilterResults performFiltering(CharSequence constraint)
{
String filtro = constraint.toString().toLowerCase();
FilterResults result = new FilterResults();

ArrayList<Ambito> ambitosFiltrados = new ArrayList<>();
String nombreAmbito;

// Comenzar filtrado de canales
for (int i = 0; i < ambitos.size(); i++)
{
nombreAmbito = ambitos.get(i).getNombre();

// Comprobar que el nombre del canal contiene la secuencia de búsqueda
if (nombreAmbito.toLowerCase().contains(filtro))
{
ambitosFiltrados.add(ambitos.get(i));
}
}

// Enviar lista filtrada a la clase de filtrado
result.values = ambitosFiltrados;
result.count = ambitosFiltrados.size();

return result;
}

@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint, FilterResults results)
{
// Establecer lista con canales filtrados
ambitosFiltrados = (ArrayList<Ambito>) results.values;
notifyDataSetChanged();
}
}

/**
* ViewHolder para asociar variables con elementos gráficos
*/
class ViewHolder extends RecyclerView.ViewHolder
{
ImageView imageView;
TextView titleView;

public ViewHolder(@NonNull View itemView)
{
super(itemView);
imageView = itemView.findViewById(R.id.channel_icon);
titleView = itemView.findViewById(R.id.channel_title);
}
}
}
46 changes: 19 additions & 27 deletions app/src/main/java/org/juanro/feedtv/ArticleAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,40 +147,32 @@ public void onBindViewHolder(@NonNull final ViewHolder viewHolder, int position)
viewHolder.category.setText(categories.toString());

// Accion pulsación larga
viewHolder.itemView.setOnLongClickListener(new AdapterView.OnLongClickListener()
viewHolder.itemView.setOnLongClickListener(v ->
{
@Override
public boolean onLongClick(View v)
{
// Copiar url
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("url", articles.get(viewHolder.getAdapterPosition()).getLink());
clipboard.setPrimaryClip(clip);
// Copiar url
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("url", articles.get(viewHolder.getAbsoluteAdapterPosition()).getLink());
clipboard.setPrimaryClip(clip);

Toast.makeText(mContext, mContext.getString(R.string.url_clipboard), Toast.LENGTH_LONG).show();
Toast.makeText(mContext, mContext.getString(R.string.url_clipboard), Toast.LENGTH_LONG).show();

return true;
}
return true;
});

// Obtener pulsaciones
viewHolder.itemView.setOnClickListener(new AdapterView.OnClickListener()
viewHolder.itemView.setOnClickListener(view ->
{
@Override
public void onClick(View view)
{
// Obtener url del artículo
String url = articles.get(viewHolder.getAdapterPosition()).getLink();

// Abrir url en formato Custom Tab
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.addDefaultShareMenuItem();
CustomTabsIntent cti = builder.build();
cti.intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + mContext.getPackageName()));
// Hacer compatible con versiones anteriores a Android 6
cti.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cti.launchUrl(mContext, Uri.parse(url));
}
// Obtener url del artículo
String url = articles.get(viewHolder.getAbsoluteAdapterPosition()).getLink();

// Abrir url en formato Custom Tab
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setShareState(CustomTabsIntent.SHARE_STATE_DEFAULT);
CustomTabsIntent cti = builder.build();
cti.intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + mContext.getPackageName()));
// Hacer compatible con versiones anteriores a Android 6
cti.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cti.launchUrl(mContext, Uri.parse(url));
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/juanro/feedtv/BBDD/FeedDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ public void sincronizarEntradas(List<Article> lista)

if(link.contains("?"))
{
link = link + "&utm_source=feedtv&utm_medium=feed";
link = link + "&utm_source=FeedTV&utm_medium=RSS";
}
else
{
link = link + "?utm_source=feedtv&utm_medium=feed";
link = link + "?utm_source=FeedTV&utm_medium=RSS";
}

// Comprobar si la entrada necesita ser actualizada
Expand Down
Loading

0 comments on commit da54db2

Please sign in to comment.