Skip to content

Commit

Permalink
Merge pull request #847 from Bnyro/master
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
Bnyro authored Jul 21, 2022
2 parents 0e48979 + 56b7a8e commit b39e56f
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
applicationId 'com.github.libretube'
minSdk 21
targetSdk 31
versionCode 14
versionCode 15
versionName '0.4.1'
multiDexEnabled true
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down
3 changes: 3 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
#uncomment for debug
#-keepnames class **
-keep class com.github.libretube.obj.** { *; }

# prevents android from removing it
-keep class com.github.libretube.update.** { <fields>; }
16 changes: 8 additions & 8 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"attributes": [],
"versionCode": 14,
"versionCode": 15,
"versionName": "0.4.1",
"outputFile": "app-x86_64-release.apk"
},
Expand All @@ -29,7 +29,7 @@
}
],
"attributes": [],
"versionCode": 14,
"versionCode": 15,
"versionName": "0.4.1",
"outputFile": "app-x86-release.apk"
},
Expand All @@ -38,26 +38,26 @@
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
"value": "arm64-v8a"
}
],
"attributes": [],
"versionCode": 14,
"versionCode": 15,
"versionName": "0.4.1",
"outputFile": "app-armeabi-v7a-release.apk"
"outputFile": "app-arm64-v8a-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "arm64-v8a"
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 14,
"versionCode": 15,
"versionName": "0.4.1",
"outputFile": "app-arm64-v8a-release.apk"
"outputFile": "app-armeabi-v7a-release.apk"
}
],
"elementType": "File"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.libretube.adapters

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
Expand All @@ -22,7 +21,6 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
val TAG = "SubChannelAdapter"

private var subscribed = true
private var isLoading = false

override fun getItemCount(): Int {
return subscriptions.size
Expand All @@ -44,23 +42,22 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
NavigationHelper.navigateChannel(root.context, subscription.url)
}
subscriptionSubscribe.setOnClickListener {
if (!isLoading) {
isLoading = true
val channelId = subscription.url?.replace("/channel/", "")!!
if (subscribed) {
unsubscribe(root.context, channelId)
subscriptionSubscribe.text = root.context.getString(R.string.subscribe)
} else {
subscribe(root.context, channelId)
subscriptionSubscribe.text =
root.context.getString(R.string.unsubscribe)
}
val channelId = subscription.url?.replace("/channel/", "")!!
if (subscribed) {
subscriptionSubscribe.text = root.context.getString(R.string.subscribe)
unsubscribe(channelId)
subscribed = false
} else {
subscriptionSubscribe.text =
root.context.getString(R.string.unsubscribe)
subscribe(channelId)
subscribed = true
}
}
}
}

private fun subscribe(context: Context, channelId: String) {
private fun subscribe(channelId: String) {
fun run() {
CoroutineScope(Dispatchers.IO).launch {
try {
Expand All @@ -72,14 +69,12 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
} catch (e: Exception) {
Log.e(TAG, e.toString())
}
subscribed = true
isLoading = false
}
}
run()
}

private fun unsubscribe(context: Context, channelId: String) {
private fun unsubscribe(channelId: String) {
fun run() {
CoroutineScope(Dispatchers.IO).launch {
try {
Expand All @@ -91,8 +86,6 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscrip
} catch (e: Exception) {
Log.e(TAG, e.toString())
}
subscribed = false
isLoading = false
}
}
run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ class SubscriptionsFragment : Fragment() {
var loadedSubbedChannels = false

binding.toggleSubs.setOnClickListener {
if (!binding.subChannels.isVisible) {
if (!binding.subChannelsContainer.isVisible) {
if (!loadedSubbedChannels) {
binding.subChannels.layoutManager = LinearLayoutManager(context)
fetchChannels(binding.subChannels)
loadedSubbedChannels = true
}
binding.subChannels.visibility = View.VISIBLE
binding.subFeed.visibility = View.GONE
binding.subChannelsContainer.visibility = View.VISIBLE
binding.subFeedContainer.visibility = View.GONE
} else {
binding.subChannels.visibility = View.GONE
binding.subFeed.visibility = View.VISIBLE
binding.subChannelsContainer.visibility = View.GONE
binding.subFeedContainer.visibility = View.VISIBLE
}
}

Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/com/github/libretube/preferences/MainSettings.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.libretube.preferences

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
Expand Down Expand Up @@ -82,8 +81,17 @@ class MainSettings : PreferenceFragmentCompat() {
CoroutineScope(Dispatchers.IO).launch {
// check for update
val updateInfo = UpdateChecker.getLatestReleaseInfo()
Log.e(TAG, updateInfo?.name.toString())
if (updateInfo?.name != null && BuildConfig.VERSION_NAME != updateInfo?.name) {
if (updateInfo?.name == null) {
// request failed
val settingsActivity = activity as SettingsActivity
val snackBar = Snackbar
.make(
settingsActivity.binding.root,
R.string.unknown_error,
Snackbar.LENGTH_SHORT
)
snackBar.show()
} else if (BuildConfig.VERSION_NAME != updateInfo.name) {
// show the UpdateAvailableDialog if there's an update available
val updateAvailableDialog = UpdateDialog(updateInfo)
updateAvailableDialog.show(childFragmentManager, "UpdateAvailableDialog")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/channel_subscription_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:stateListAnimator="@null"
android:text="@string/subscribe"
android:text="@string/unsubscribe"
android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp"
app:cornerRadius="20dp"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_subscriptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
</com.google.android.material.card.MaterialCardView>

<RelativeLayout
android:id="@+id/sub_channels_container"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">

<androidx.recyclerview.widget.RecyclerView

android:visibility="gone"
android:id="@+id/sub_channels"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -110,6 +110,7 @@
</RelativeLayout>

<RelativeLayout
android:id="@+id/sub_feed_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
Expand Down

0 comments on commit b39e56f

Please sign in to comment.