Skip to content

Commit

Permalink
Fix for #177
Browse files Browse the repository at this point in the history
Ad playsment update
Dependency updates
  • Loading branch information
dkrivoruchko committed Jul 5, 2021
1 parent 292bb8f commit ee21787
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 64 deletions.
15 changes: 7 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "info.dvkr.screenstream"
minSdkVersion(21)
targetSdkVersion(30)
versionCode = 30701
versionName = "3.7.1"
versionCode = 30702
versionName = "3.7.2"
resConfigs("en", "ru", "pt-rBR", "zh-rTW", "fr-rFR", "fa", "it", "pl", "hi", "de", "sk", "es", "ar", "ja", "gl", "ca")

vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -44,8 +44,7 @@ android {
flavorDimensions("default")
productFlavors {
create("firebase") {
buildConfigField "String", "AD_UNIT_ID", localProps.getProperty("ad.unitId")
buildConfigField "String", "AD_UNIT_ID_TEST", localProps.getProperty("ad.unitIdTest")
buildConfigField "String", "AD_UNIT_ID", localProps.getProperty("ad.unitId", "ca-app-pub-3940256099942544/6300978111")
}
create("firebasefree") {
firebaseCrashlytics.mappingFileUploadEnabled = false
Expand Down Expand Up @@ -89,13 +88,13 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0")

implementation("androidx.core:core-ktx:1.5.0")
implementation("androidx.core:core-ktx:1.6.0")
implementation("androidx.activity:activity-ktx:1.2.3")
implementation("androidx.fragment:fragment-ktx:1.3.5")
implementation("androidx.appcompat:appcompat:1.3.0")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("com.google.android.material:material:1.3.0")
implementation("com.google.android.material:material:1.4.0")

implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
Expand All @@ -110,9 +109,9 @@ dependencies {
implementation(fileTree("libs/bottomsheets-release.aar"))
// implementation("com.afollestad.material-dialogs:bottomsheets:3.3.0")

implementation("io.insert-koin:koin-android:3.1.1")
implementation("io.insert-koin:koin-android:3.1.2")
implementation("com.github.iamironz:binaryprefs:1.0.1")
implementation("com.elvishew:xlog:1.10.0")
implementation("com.elvishew:xlog:1.10.1")

firebaseImplementation("com.google.android.play:core:1.10.0")
firebaseImplementation("com.google.android.play:core-ktx:1.8.1") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
package info.dvkr.screenstream.ui.activity
package info.dvkr.screenstream.ui.fragment

import android.util.DisplayMetrics
import android.view.ViewTreeObserver
import android.widget.FrameLayout
import androidx.annotation.LayoutRes
import com.google.android.gms.ads.*
import androidx.fragment.app.Fragment
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView
import com.google.android.gms.ads.MobileAds
import info.dvkr.screenstream.BuildConfig


abstract class AdActivity(@LayoutRes contentLayoutId: Int) : AppUpdateActivity(contentLayoutId) {
abstract class AdFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId) {

private var adView: AdView? = null

fun loadAd(adViewContainer: FrameLayout) {
MobileAds.initialize(this) {}
adView = AdView(this)
MobileAds.initialize(requireContext()) {}
adView = AdView(requireContext())
adViewContainer.addView(adView)
adViewContainer.viewTreeObserver.addOnGlobalLayoutListener(
object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
val outMetrics = DisplayMetrics().also { windowManager.defaultDisplay.getMetrics(it) }
val outMetrics =
DisplayMetrics().also { requireActivity().windowManager.defaultDisplay.getMetrics(it) }
var adWidthPixels = adViewContainer.width.toFloat()
if (adWidthPixels == 0f) adWidthPixels = outMetrics.widthPixels.toFloat()
val adWidth = (adWidthPixels / outMetrics.density).toInt()
val adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this@AdActivity, adWidth)
val adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(requireContext(), adWidth)

adView!!.adUnitId = if (BuildConfig.DEBUG) BuildConfig.AD_UNIT_ID_TEST else BuildConfig.AD_UNIT_ID
adView!!.adUnitId =
if (BuildConfig.DEBUG) "ca-app-pub-3940256099942544/6300978111" else BuildConfig.AD_UNIT_ID
adView!!.adSize = adSize
adViewContainer.minimumHeight = adSize.getHeightInPixels(this@AdActivity)
adViewContainer.minimumHeight = adSize.getHeightInPixels(requireContext())
adView!!.loadAd(AdRequest.Builder().build())

adViewContainer.viewTreeObserver.removeOnGlobalLayoutListener(this)
Expand All @@ -46,8 +51,8 @@ abstract class AdActivity(@LayoutRes contentLayoutId: Int) : AppUpdateActivity(c
adView?.resume()
}

override fun onDestroy() {
override fun onDestroyView() {
adView?.destroy()
super.onDestroy()
super.onDestroyView()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package info.dvkr.screenstream.ui.fragment

import android.view.View
import android.widget.FrameLayout
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment


abstract class AdFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId) {

fun loadAd(adViewContainer: FrameLayout) {
adViewContainer.visibility = View.GONE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class AppActivity : PermissionActivity(R.layout.activity_app) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

loadAd(binding.flActivityAppAdViewContainer)

routeIntentAction(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch

abstract class ServiceActivity(@LayoutRes contentLayoutId: Int) : AdActivity(contentLayoutId) {
abstract class ServiceActivity(@LayoutRes contentLayoutId: Int) : AppUpdateActivity(contentLayoutId) {

private val serviceMessageLiveData = MutableLiveData<ServiceMessage>()
private var serviceMessageFlowJob: Job? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import info.dvkr.screenstream.ui.activity.ServiceActivity
import info.dvkr.screenstream.ui.viewBinding
import org.koin.android.ext.android.inject

class StreamFragment : Fragment(R.layout.fragment_stream) {
class StreamFragment : AdFragment(R.layout.fragment_stream) {

private val colorAccent by lazy { ContextCompat.getColor(requireContext(), R.color.colorAccent) }
private val clipboard: ClipboardManager? by lazy {
Expand All @@ -54,6 +54,8 @@ class StreamFragment : Fragment(R.layout.fragment_stream) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

loadAd(binding.flFragmentStreamAdViewContainer)

binding.tvFragmentStreamTrafficHeader.text = getString(R.string.stream_fragment_current_traffic).run {
format(0.0).setColorSpan(colorAccent, indexOf('%'))
}
Expand Down
8 changes: 1 addition & 7 deletions app/src/main/res/layout/activity_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@
android:background="@drawable/view_shadow_bottom"
app:layout_constraintTop_toBottomOf="@id/ll_activity_app_logs" />

<FrameLayout
android:id="@+id/fl_activity_app_ad_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/ll_activity_app_logs" />

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fr_activity_app_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
Expand All @@ -63,7 +57,7 @@
android:layout_marginBottom="24dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/fl_activity_app_ad_view_container"
app:layout_constraintTop_toBottomOf="@id/v_activity_app_logs"
app:navGraph="@navigation/nav_graph" />

<info.dvkr.screenstream.ui.view.CurvedBottomNavigationView
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/layout/fragment_stream.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
app:layout_constraintTop_toBottomOf="@id/ll_fragment_stream_addresses"
tools:text="Pin: 5676" />

<FrameLayout
android:id="@+id/fl_fragment_stream_ad_view_container"
android:layout_width="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_fragment_stream_pin" />

<LinearLayout
android:id="@+id/ll_fragment_stream_traffic"
android:layout_width="0dp"
Expand All @@ -61,7 +69,7 @@
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_fragment_stream_pin">
app:layout_constraintTop_toBottomOf="@id/fl_fragment_stream_ad_view_container">

<info.dvkr.screenstream.ui.view.ExpansionHeader
android:layout_width="match_parent"
Expand Down
19 changes: 4 additions & 15 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">ScreenStream</string>

<string name="error_title">Błąd</string>
<string name="error_port_in_use">Port jest już w użyciu. Wybierz inny.</string>
<string name="error_invalid_media_projection">Błąd bezpieczeństwa: nieprawidłowa projekcja mediów. Spróbuj ponownie.</string>
<string name="error_ip_address_not_found">Nie znaleziono adresu IP. \nSpróbuj wyłączyć \"Używaj tylko WiFi\" w ustawieniach.</string>
<string name="error_wrong_image_format">System nadaje obrazowi niewłaściwy format. Nie ma rozwiązania tego problemu.</string>
<string name="error_exit">Zamknij</string>

<string name="app_activity_collecting_logs">Trwa zbieranie dzienników aplikacji…</string>
<string name="app_activity_send_logs">Wyślij dzienniki do programisty</string>
<string name="app_activity_send_logs_dialog_title">Wyślij dzienniki e-mailem do programisty</string>
Expand Down Expand Up @@ -40,13 +38,13 @@
<string name="stream_fragment_client_slow_network">Wolne połączenie</string>
<string name="stream_fragment_client_connected">Połączony</string>
<string name="stream_fragment_client_blocked">Zablokowany</string>

<string name="item_device_address">Adres urządzenia:</string>
<string name="item_device_address_description_open_address">Otwórz adres</string>
<string name="item_device_address_description_copy_address">Skopiuj adres</string>
<string name="item_device_address_description_share_address">Udostępnij adres</string>
<string name="item_device_address_description_qr_address">Pokaż adres jako kod QR</string>

<string name="permission_activity_error_title_activity_not_found">Błąd dostępu do okna dialogowego</string>
<string name="permission_activity_error_activity_not_found">Błąd systemu Android. Nie sprawdzaj \"Nie pokazuj ponownie\" w oknie dialogowym żądania uprawnień, aby przechwycić ekran. Jeśli już to zrobiłeś, przeinstaluj aplikację.</string>
<string name="permission_activity_cast_permission_required_title">Wymaga pozwolenia</string>
Expand Down Expand Up @@ -109,18 +107,10 @@
<string name="pref_crop_dialog_error_message">Wprowadź prawidłowe wartości przycięcia</string>
<string name="pref_resize">Zmiana rozmiaru obrazu</string>
<string name="pref_resize_summary">Zmienia rozmiar obrazu przed wysłaniem</string>
<string name="pref_resize_value" translatable="false">%1$d%%</string>
<string name="pref_resize_dialog_text">Ustaw współczynnik zmiany rozmiaru obrazu w procentach.\nWartość: 10–150 (Domyślnie: 50)\nRozmiar ekranu: %1$dx%2$d</string>
<string name="pref_resize_dialog_result">Rozmiar obrazu: %1$dx%2$d</string>
<string name="pref_rotate">Obróć zdjęcie zgodnie z ruchem wskazówek zegara</string>
<string name="pref_rotate_summary">Obraca obraz przed wysłaniem</string>
<string name="pref_rotate_value" translatable="false">%1$d\u00B0</string>
<string-array name="pref_rotate_options" translatable="false">
<item>0\u00B0</item>
<item>90\u00B0</item>
<item>180\u00B0</item>
<item>270\u00B0</item>
</string-array>
<string name="pref_fps">Ogranicz liczbę klatek na sekundę</string>
<string name="pref_fps_summary">Ustawia maksymalną liczbę klatek na sekundę</string>
<string name="pref_fps_dialog">Ustaw maksymalną liczbę klatek na sekundę.\nWartość: 1–60 (Domyślnie: 30)</string>
Expand Down Expand Up @@ -156,14 +146,13 @@
<string name="pref_logging">Włącz dzienniki aplikacji</string>
<string name="pref_logging_summary">Zbieraj dzienniki aplikacji</string>

<string name="about_fragment_app_name" translatable="false">Przesyłanie ekranu przez HTTP</string>
<string name="about_fragment_app_version">Wersja: %1$s</string>
<string name="about_fragment_developer_name">Programista Dmitriy Krivoruchko</string>
<string name="about_fragment_rate_app">Oceń aplikację</string>
<string name="about_fragment_write_email">Napisz e-mail do autora</string>
<string name="about_fragment_write_email_dialog">Wysłać e-mail do autora?</string>
<string name="about_fragment_email_chooser_header">Wysłam wiadomość e-mail…</string>
<string name="about_fragment_app_sources">Kod źródłowy aplikacji</string>
<string name="about_fragment_privacy_policy">Polityka prywatności</string
<string name="about_fragment_privacy_policy">Polityka prywatności</string>
<string name="about_fragment_license">Licencja</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
classpath("com.android.tools.build:gradle:4.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20")
classpath("com.google.gms:google-services:4.3.8")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.7.1")
Expand Down
10 changes: 5 additions & 5 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion(21)
targetSdkVersion(30)
versionCode = 30701
versionName = "3.7.1"
versionCode = 30702
versionName = "3.7.2"
}

compileOptions {
Expand All @@ -30,10 +30,10 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.20")

implementation("androidx.core:core:1.5.0")
implementation("androidx.core:core:1.6.0")

implementation("io.ktor:ktor-server-cio:1.6.0")
implementation("io.ktor:ktor-server-cio:1.6.1")

implementation("com.github.iamironz:binaryprefs:1.0.1")
implementation('com.elvishew:xlog:1.10.0')
implementation('com.elvishew:xlog:1.10.1')
}
2 changes: 1 addition & 1 deletion data/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<string name="html_submit_text">Zatwierdź</string>
<string name="html_wrong_pin">Błędny kod PIN!</string>
<string name="html_address_blocked">Adres klienta zablokowany</string>
</resources>
</resources>

0 comments on commit ee21787

Please sign in to comment.