From 65e061fd25e188ab7c6fb850623f4cc0c3fff065 Mon Sep 17 00:00:00 2001 From: Ivan Agosto Date: Wed, 20 Mar 2024 21:04:16 -0600 Subject: [PATCH 01/13] First changes to androidx --- app/build.gradle | 12 +-- .../org/libre/agosto/p2play/AboutActivity.kt | 4 +- .../p2play/AppCompatPreferenceActivity.kt | 8 +- .../libre/agosto/p2play/ChannelActivity.kt | 6 +- .../org/libre/agosto/p2play/HostActivity.kt | 4 +- .../org/libre/agosto/p2play/LoginActivity.kt | 3 +- .../org/libre/agosto/p2play/MainActivity.kt | 43 ++++++----- .../libre/agosto/p2play/RegisterActivity.kt | 2 +- .../agosto/p2play/ReproductorActivity.kt | 11 ++- .../org/libre/agosto/p2play/SplashActivity.kt | 2 +- .../p2play/adapters/CommentariesAdapter.kt | 11 +-- .../agosto/p2play/adapters/VideosAdapter.kt | 12 +-- app/src/main/res/layout/activity_about.xml | 8 +- app/src/main/res/layout/activity_channel.xml | 4 +- app/src/main/res/layout/activity_host.xml | 17 ++--- app/src/main/res/layout/activity_login.xml | 4 +- app/src/main/res/layout/activity_main.xml | 6 +- app/src/main/res/layout/activity_splash.xml | 4 +- app/src/main/res/layout/app_bar_main.xml | 10 +-- app/src/main/res/layout/content_main.xml | 10 +-- app/src/main/res/layout/view_video.xml | 6 +- app/src/main/res/menu/main.xml | 3 +- app/src/main/res/values/colors.xml | 75 +++++++++++++++++++ gradle.properties | 3 + 24 files changed, 164 insertions(+), 104 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 089f7b7..cfda8bc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,12 +36,12 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:2.0.4' - implementation 'com.android.support:support-v4:28.0.0' - implementation 'com.android.support:design:28.0.0' implementation 'com.squareup.picasso:picasso:2.71828' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'com.google.android.material:material:1.4.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + androidTestImplementation 'androidx.test:runner:1.5.2' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' } diff --git a/app/src/main/java/org/libre/agosto/p2play/AboutActivity.kt b/app/src/main/java/org/libre/agosto/p2play/AboutActivity.kt index cdb81e2..5bae4df 100644 --- a/app/src/main/java/org/libre/agosto/p2play/AboutActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/AboutActivity.kt @@ -1,8 +1,8 @@ package org.libre.agosto.p2play -import android.support.v7.app.AppCompatActivity + import android.os.Bundle -import android.text.method.LinkMovementMethod +import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.activity_about.* class AboutActivity : AppCompatActivity() { diff --git a/app/src/main/java/org/libre/agosto/p2play/AppCompatPreferenceActivity.kt b/app/src/main/java/org/libre/agosto/p2play/AppCompatPreferenceActivity.kt index 39b3f04..73cb581 100644 --- a/app/src/main/java/org/libre/agosto/p2play/AppCompatPreferenceActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/AppCompatPreferenceActivity.kt @@ -1,15 +1,15 @@ package org.libre.agosto.p2play +import androidx.appcompat.app.ActionBar import android.content.res.Configuration import android.os.Bundle import android.preference.PreferenceActivity -import android.support.annotation.LayoutRes -import android.support.v7.app.ActionBar -import android.support.v7.app.AppCompatDelegate -import android.support.v7.widget.Toolbar import android.view.MenuInflater import android.view.View import android.view.ViewGroup +import androidx.annotation.LayoutRes +import androidx.appcompat.app.AppCompatDelegate +import androidx.appcompat.widget.Toolbar /** * A [android.preference.PreferenceActivity] which implements and proxies the necessary calls diff --git a/app/src/main/java/org/libre/agosto/p2play/ChannelActivity.kt b/app/src/main/java/org/libre/agosto/p2play/ChannelActivity.kt index 34fb5dd..5ea9c8a 100644 --- a/app/src/main/java/org/libre/agosto/p2play/ChannelActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/ChannelActivity.kt @@ -1,10 +1,10 @@ package org.libre.agosto.p2play import android.os.AsyncTask -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import android.os.Bundle -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import android.view.View import com.squareup.picasso.Picasso import kotlinx.android.synthetic.main.activity_channel.* diff --git a/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt b/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt index ea5d62a..f9f7e53 100644 --- a/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/HostActivity.kt @@ -3,14 +3,12 @@ package org.libre.agosto.p2play import android.content.Intent import android.content.SharedPreferences import android.os.AsyncTask -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Looper import android.preference.PreferenceManager -import android.util.Log import kotlinx.android.synthetic.main.activity_host.* import org.libre.agosto.p2play.ajax.Auth -import org.libre.agosto.p2play.ajax.Client class HostActivity : AppCompatActivity() { lateinit var settings: SharedPreferences diff --git a/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt b/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt index 656a7a0..68d33d1 100644 --- a/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/LoginActivity.kt @@ -3,11 +3,10 @@ package org.libre.agosto.p2play import android.content.Intent import android.content.SharedPreferences import android.os.AsyncTask -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Looper import android.preference.PreferenceManager -import android.util.Log import kotlinx.android.synthetic.main.activity_login.* import org.libre.agosto.p2play.ajax.Auth diff --git a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt index c350fba..038ccd4 100644 --- a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt @@ -4,22 +4,21 @@ import android.content.Intent import android.os.AsyncTask import android.os.Bundle import android.os.Handler -import android.support.design.widget.Snackbar -import android.support.design.widget.NavigationView -import android.support.v4.view.GravityCompat -import android.support.v7.app.ActionBarDrawerToggle -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView import android.view.Menu -import android.view.MenuInflater import android.view.MenuItem -import android.widget.ImageView -import android.widget.SearchView + +import androidx.appcompat.app.ActionBarDrawerToggle +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.SearchView +import androidx.core.view.GravityCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.navigation.NavigationView import com.squareup.picasso.Picasso -import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.app_bar_main.* -import kotlinx.android.synthetic.main.content_main.* +import kotlinx.android.synthetic.main.activity_main.drawer_layout +import kotlinx.android.synthetic.main.activity_main.nav_view +import kotlinx.android.synthetic.main.app_bar_main.toolbar +import kotlinx.android.synthetic.main.content_main.swipeContainer import kotlinx.android.synthetic.main.nav_header_main.* import org.libre.agosto.p2play.adapters.VideosAdapter import org.libre.agosto.p2play.ajax.Videos @@ -101,7 +100,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte } }) } - // swipeContainer.isRefreshing = false + swipeContainer.isRefreshing = false } private fun addVideos(videos: ArrayList){ @@ -251,10 +250,10 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte override fun onBackPressed() { if (drawer_layout.isDrawerOpen(GravityCompat.START)) { - drawer_layout.closeDrawer(GravityCompat.START) + drawer_layout.closeDrawer(GravityCompat.START) } else if(!section.equals("trending")) { - this.getTrengindVideos() + this.getTrengindVideos() } else { super.onBackPressed() @@ -363,11 +362,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte if(ManagerSingleton.user.avatar!="" && side_imageView != null) { Picasso.get().load("https://" + ManagerSingleton.url + ManagerSingleton.user.avatar).into(side_imageView) } -// side_imageView?.setOnClickListener { -// pagination = 0 -// getMyVideos() -// drawer_layout.closeDrawer(GravityCompat.START) -// } + side_imageView?.setOnClickListener { + pagination = 0 + getMyVideos() + drawer_layout.closeDrawer(GravityCompat.START) + } if(::myMenu.isInitialized){ myMenu.findItem(R.id.action_login).isVisible = false myMenu.findItem(R.id.action_logout).isVisible = true @@ -381,7 +380,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte myMenu.findItem(R.id.action_login).isVisible = true myMenu.findItem(R.id.action_logout).isVisible = false } - nav_view.menu.findItem(R.id.ml).isVisible = false + //nav_view.menu.findItem(R.id.ml).isVisible = false side_usernameTxt?.text = getString(R.string.nav_header_title) side_emailTxt?.text = getString(R.string.nav_header_subtitle) + " " + this.packageManager.getPackageInfo(this.packageName, 0).versionName side_imageView?.setImageResource(R.drawable.default_avatar) diff --git a/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt b/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt index 544b50c..a6609ff 100644 --- a/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/RegisterActivity.kt @@ -2,7 +2,7 @@ package org.libre.agosto.p2play import android.content.SharedPreferences import android.os.AsyncTask -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Looper import android.preference.PreferenceManager diff --git a/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt b/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt index 1f685a9..644118b 100644 --- a/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/ReproductorActivity.kt @@ -8,19 +8,18 @@ import android.content.pm.ActivityInfo import android.graphics.Bitmap import android.graphics.BitmapFactory import android.os.AsyncTask -import android.support.v7.app.AppCompatActivity import android.os.Bundle import android.os.Looper -import android.support.v4.content.ContextCompat -import android.support.v7.app.AlertDialog -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView -import android.util.Log +import androidx.appcompat.app.AlertDialog import android.view.View import android.view.WindowManager import android.webkit.WebChromeClient import android.widget.EditText import android.widget.FrameLayout +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import com.squareup.picasso.Picasso import kotlinx.android.synthetic.main.activity_reproductor.* import org.libre.agosto.p2play.adapters.CommentariesAdapter diff --git a/app/src/main/java/org/libre/agosto/p2play/SplashActivity.kt b/app/src/main/java/org/libre/agosto/p2play/SplashActivity.kt index 64bbe31..4a2150e 100644 --- a/app/src/main/java/org/libre/agosto/p2play/SplashActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/SplashActivity.kt @@ -3,7 +3,7 @@ package org.libre.agosto.p2play import android.content.Intent import android.content.SharedPreferences import android.os.AsyncTask -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Handler import android.os.Looper diff --git a/app/src/main/java/org/libre/agosto/p2play/adapters/CommentariesAdapter.kt b/app/src/main/java/org/libre/agosto/p2play/adapters/CommentariesAdapter.kt index d7545e5..be36410 100644 --- a/app/src/main/java/org/libre/agosto/p2play/adapters/CommentariesAdapter.kt +++ b/app/src/main/java/org/libre/agosto/p2play/adapters/CommentariesAdapter.kt @@ -1,25 +1,16 @@ package org.libre.agosto.p2play.adapters -import android.app.Activity import android.content.Context -import android.content.Intent -import android.graphics.drawable.Drawable -import android.os.AsyncTask -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.text.Html import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView -import android.widget.LinearLayout import android.widget.TextView import com.squareup.picasso.Picasso import org.libre.agosto.p2play.* import org.libre.agosto.p2play.models.CommentaryModel -import org.libre.agosto.p2play.models.VideoModel -import java.io.InputStream -import java.io.Serializable -import java.net.URL @Suppress("DEPRECATION") class CommentariesAdapter(private val myDataset: ArrayList) : diff --git a/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt b/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt index 8281661..169fa9f 100644 --- a/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt +++ b/app/src/main/java/org/libre/agosto/p2play/adapters/VideosAdapter.kt @@ -1,24 +1,17 @@ package org.libre.agosto.p2play.adapters -import android.app.Activity import android.content.Context import android.content.Intent -import android.graphics.drawable.Drawable -import android.os.AsyncTask -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView -import android.widget.LinearLayout import android.widget.TextView import com.squareup.picasso.Picasso import org.libre.agosto.p2play.* import org.libre.agosto.p2play.models.VideoModel -import java.io.InputStream import java.io.Serializable -import java.net.URL -import java.util.concurrent.TimeUnit class VideosAdapter(private val myDataset: ArrayList) : RecyclerView.Adapter() { @@ -46,8 +39,7 @@ class VideosAdapter(private val myDataset: ArrayList) : } // Create new views (invoked by the layout manager) - override fun onCreateViewHolder(parent: ViewGroup, - viewType: Int): VideosAdapter.ViewHolder { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { // create a new view val view = LayoutInflater.from(parent.context) .inflate(R.layout.view_video, parent, false) as View diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 6c7ed94..23f1b48 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,5 +1,5 @@ - + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_channel.xml b/app/src/main/res/layout/activity_channel.xml index c78b087..ee3af1c 100644 --- a/app/src/main/res/layout/activity_channel.xml +++ b/app/src/main/res/layout/activity_channel.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_host.xml b/app/src/main/res/layout/activity_host.xml index 25f7f13..e22837e 100644 --- a/app/src/main/res/layout/activity_host.xml +++ b/app/src/main/res/layout/activity_host.xml @@ -1,5 +1,5 @@ - - - + /> - - -