From 35aa0fcea1b72fddf3579e9db920516da2fed36d Mon Sep 17 00:00:00 2001 From: Ivan Agosto Date: Fri, 22 Mar 2024 23:23:16 +0000 Subject: [PATCH 1/2] Androidx --- app/build.gradle | 12 ++-- .../agosto/p2play/ExampleInstrumentedTest.kt | 24 ------- app/src/main/AndroidManifest.xml | 17 +++-- .../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 | 47 +++++++------ .../libre/agosto/p2play/RegisterActivity.kt | 2 +- .../agosto/p2play/ReproductorActivity.kt | 13 ++-- .../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 | 28 ++++---- app/src/main/res/layout/activity_channel.xml | 9 ++- app/src/main/res/layout/activity_host.xml | 36 ++++++---- app/src/main/res/layout/activity_login.xml | 62 ++++++++-------- app/src/main/res/layout/activity_main.xml | 6 +- .../main/res/layout/activity_reproductor.xml | 70 ++++++++++--------- app/src/main/res/layout/activity_splash.xml | 11 ++- app/src/main/res/layout/app_bar_main.xml | 17 ++--- app/src/main/res/layout/content_main.xml | 10 +-- app/src/main/res/layout/report_dialog.xml | 27 ++++--- app/src/main/res/layout/view_commentary.xml | 4 +- app/src/main/res/layout/view_video.xml | 9 +-- app/src/main/res/menu/main.xml | 3 +- app/src/main/res/values-es/strings.xml | 3 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-night/themes.xml | 23 ++++++ app/src/main/res/values/colors.xml | 68 +++++++++++++++++- app/src/main/res/values/strings.xml | 3 +- app/src/main/res/values/themes.xml | 23 ++++++ app/src/main/res/xml/pref_general.xml | 2 +- app/src/main/res/xml/pref_headers.xml | 7 +- gradle.properties | 3 + 36 files changed, 342 insertions(+), 249 deletions(-) delete mode 100644 app/src/androidTest/java/org/libre/agosto/p2play/ExampleInstrumentedTest.kt create mode 100644 app/src/main/res/values-night/themes.xml create mode 100644 app/src/main/res/values/themes.xml 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/androidTest/java/org/libre/agosto/p2play/ExampleInstrumentedTest.kt b/app/src/androidTest/java/org/libre/agosto/p2play/ExampleInstrumentedTest.kt deleted file mode 100644 index d86c903..0000000 --- a/app/src/androidTest/java/org/libre/agosto/p2play/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.libre.agosto.p2play - -import android.support.test.InstrumentationRegistry -import android.support.test.runner.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getTargetContext() - assertEquals("org.libre.agosto.p2play", appContext.packageName) - } -} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4743f28..e83f1ca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,33 +11,36 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/P2playTheme"> + android:theme="@style/Theme.P2play"> + android:theme="@style/Theme.P2play.NoActionBar" /> + android:theme="@style/Theme.P2play.NoActionBar"> - + + android:theme="@style/Theme.P2play.NoActionBar" /> + android:theme="@style/Theme.P2play.NoActionBar" /> + android:label="@string/title_activity_settings" + android:theme="@style/Theme.P2play"/> \ No newline at end of file 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..5d05638 100644 --- a/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt +++ b/app/src/main/java/org/libre/agosto/p2play/MainActivity.kt @@ -2,24 +2,25 @@ package org.libre.agosto.p2play import android.content.Intent import android.os.AsyncTask +import android.os.Build 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 android.view.WindowManager + +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 @@ -49,6 +50,8 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte .setAction("Action", null).show() } */ + + val toggle = ActionBarDrawerToggle(this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) drawer_layout.addDrawerListener(toggle) toggle.syncState() @@ -101,7 +104,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte } }) } - // swipeContainer.isRefreshing = false + swipeContainer.isRefreshing = false } private fun addVideos(videos: ArrayList){ @@ -251,10 +254,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 +366,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 +384,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..dae39e9 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 @@ -233,7 +232,7 @@ class ReproductorActivity : AppCompatActivity() { runOnUiThread { if (res) { ManagerSingleton.Toast(getString(R.string.makedCommentaryMsg), this) - commentaryText.text.clear() + commentaryText.text?.clear() this.getComments() } else { ManagerSingleton.Toast(getString(R.string.errorCommentaryMsg), this) 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..a00b1d5 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,5 +1,5 @@ - - @@ -39,11 +39,10 @@ android:layout_height="wrap_content" android:text="@string/aboutLabel" android:textAlignment="center" - android:textAppearance="@android:style/TextAppearance.Material.Medium.Inverse" - android:textColor="@android:color/black" + android:textAppearance="@android:style/TextAppearance.Material.Medium" android:textStyle="bold" /> - @@ -55,7 +54,7 @@ android:textAlignment="textStart" android:textSize="16sp" /> - - @@ -88,7 +87,7 @@ android:textSize="16sp" android:textStyle="bold" /> - @@ -98,11 +97,10 @@ android:layout_height="wrap_content" android:text="@string/aboutInstance" android:textAlignment="center" - android:textAppearance="@android:style/TextAppearance.Material.Medium.Inverse" - android:textColor="@android:color/black" + android:textAppearance="@android:style/TextAppearance.Material.Medium" android:textStyle="bold" /> - @@ -124,7 +122,7 @@ android:textSize="16sp" android:textStyle="bold" /> - @@ -135,7 +133,11 @@ android:text="@string/aboutLicense" android:textAlignment="textStart" android:textSize="16sp" /> + + - \ 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..e838d16 100644 --- a/app/src/main/res/layout/activity_channel.xml +++ b/app/src/main/res/layout/activity_channel.xml @@ -1,5 +1,5 @@ - - + android:layout_height="wrap_content" /> - \ 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..3d3cbaf 100644 --- a/app/src/main/res/layout/activity_host.xml +++ b/app/src/main/res/layout/activity_host.xml @@ -1,5 +1,5 @@ - - - + /> - - + android:layout_margin="4dp" + android:hint="@string/instance" + app:expandedHintEnabled="false"> -