Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmedack committed Dec 30, 2017
2 parents 8138e77 + b94f239 commit 836d7bd
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 27 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Apache License](http://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](http://choosealicense.com/licenses/apache-2.0/)

[<img src="https://upload.wikimedia.org/wikipedia/commons/c/cd/Get_it_on_Google_play.svg" alt="Get it on Google Play" width="230">][play] &nbsp;&nbsp;&nbsp; **OR** [get an APK][releases]
[<img src="https://upload.wikimedia.org/wikipedia/commons/c/cd/Get_it_on_Google_play.svg" alt="Get it on Google Play" width="230">][play] &nbsp;&nbsp;&nbsp; **OR** &nbsp;&nbsp;&nbsp; [<img src="https://images-na.ssl-images-amazon.com/images/G/01/mobile-apps/devportal2/res/images/amazon-appsstore-us-black-v2.png" alt="Available at Amazon AppStore" width="210">][amazon] &nbsp;&nbsp;&nbsp; **OR** &nbsp;&nbsp;&nbsp; [Download an APK][releases]

# cccTV

Expand Down Expand Up @@ -55,4 +55,5 @@ If you want to build a `release` version, it is important to replace the placeho
[voctocat]: https://morr.cc/voctocat/

[play]: https://play.google.com/store/apps/details?id=de.stefanmedack.ccctv
[releases]: https://github.com/stefanmedack/cccTV/releases
[amazon]: https://www.amazon.de/cccTV-Chaos-Computer-Club-Videos/dp/B0787JP7RF
[releases]: https://github.com/stefanmedack/cccTV/releases
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ android {
applicationId "de.stefanmedack.ccctv"
minSdkVersion 21
targetSdkVersion 26
versionCode 8
versionName "2.0.0-RC5"
versionCode 9
versionName "2.0.0"
resConfigs "en", "de"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
46 changes: 43 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,46 @@
android:required="false"
/>

<uses-feature
android:name="android.hardware.faketouch"
android:required="false"
/>
<uses-feature
android:name="android.hardware.telephony"
android:required="false"
/>
<uses-feature
android:name="android.hardware.camera"
android:required="false"
/>
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false"
/>
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false"
/>
<uses-feature
android:name="android.hardware.nfc"
android:required="false"
/>
<uses-feature
android:name="android.hardware.location"
android:required="false"
/>
<uses-feature
android:name="android.hardware.location.gps"
android:required="false"
/>
<uses-feature
android:name="android.hardware.microphone"
android:required="false"
/>
<uses-feature
android:name="android.hardware.sensor"
android:required="false"
/>
<uses-feature
android:name="android.software.leanback"
android:required="true"
Expand All @@ -35,7 +75,6 @@
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</activity>
Expand All @@ -54,11 +93,12 @@

<activity
android:name=".ui.playback.ExoPlayerActivity"
android:exported="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|layoutDirection"
android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:supportsPictureInPicture="true"/>
android:supportsPictureInPicture="true"
/>

<meta-data
android:name="io.fabric.ApiKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.stefanmedack.ccctv.ui.base.BaseInjectableActivity
import de.stefanmedack.ccctv.util.EVENT_ID
import de.stefanmedack.ccctv.util.EVENT_PICTURE
import de.stefanmedack.ccctv.util.SHARED_DETAIL_TRANSITION
import de.stefanmedack.ccctv.util.replaceFragmentInTransaction

class DetailActivity : BaseInjectableActivity() {

Expand All @@ -27,15 +28,13 @@ class DetailActivity : BaseInjectableActivity() {
// prevent stand-by while playing videos
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

if (savedInstanceState == null) {
fragment = DetailFragment()
fragment?.arguments = Bundle(2).apply {
fragment = DetailFragment()
fragment?.let { frag ->
frag.arguments = Bundle(2).apply {
putInt(EVENT_ID, intent.getIntExtra(EVENT_ID, -1))
putString(EVENT_PICTURE, intent.getStringExtra(EVENT_PICTURE))
}
supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment, DETAIL_TAG).commit()
} else {
fragment = supportFragmentManager.findFragmentByTag(DETAIL_TAG) as DetailFragment
replaceFragmentInTransaction(frag, R.id.fragment, DETAIL_TAG)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.KeyEvent
import de.stefanmedack.ccctv.R
import de.stefanmedack.ccctv.ui.base.BaseInjectableActivity
import de.stefanmedack.ccctv.util.replaceFragmentInTransaction

class MainActivity : BaseInjectableActivity() {

Expand All @@ -15,11 +16,9 @@ class MainActivity : BaseInjectableActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.fragment_activity)

if (savedInstanceState == null) {
fragment = MainFragment()
supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment).commit()
} else {
fragment = supportFragmentManager.findFragmentByTag(MAIN_TAG) as MainFragment
fragment = supportFragmentManager.findFragmentByTag(MAIN_TAG) as? MainFragment ?: MainFragment()
fragment?.let { frag ->
replaceFragmentInTransaction(frag, R.id.fragment, MAIN_TAG)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.support.v4.app.FragmentActivity
import android.view.WindowManager
import de.stefanmedack.ccctv.R
import de.stefanmedack.ccctv.util.STREAM_URL
import de.stefanmedack.ccctv.util.addFragmentInTransaction
import info.metadude.java.library.brockman.models.Stream
import info.metadude.java.library.brockman.models.Url.TYPE

Expand All @@ -18,14 +19,12 @@ class ExoPlayerActivity : FragmentActivity() {
// prevent stand-by while playing videos
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

val ft = supportFragmentManager.beginTransaction()
val fragment = ExoPlayerFragment().apply {
arguments = Bundle(1).also {
it.putString(STREAM_URL, intent.getStringExtra(STREAM_URL))
}
}
ft.add(R.id.videoFragment, fragment, ExoPlayerFragment.TAG)
ft.commit()
addFragmentInTransaction(fragment, R.id.videoFragment, ExoPlayerFragment.TAG)
}

override fun onVisibleBehindCanceled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import android.os.Bundle
import de.stefanmedack.ccctv.R
import de.stefanmedack.ccctv.ui.base.BaseInjectableActivity
import de.stefanmedack.ccctv.util.replaceFragmentInTransaction

class SearchActivity : BaseInjectableActivity() {

Expand All @@ -15,11 +16,9 @@ class SearchActivity : BaseInjectableActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.fragment_activity)

if (savedInstanceState == null) {
fragment = SearchFragment()
supportFragmentManager.beginTransaction().replace(R.id.fragment, fragment).commit()
} else {
fragment = supportFragmentManager.findFragmentByTag(SEARCH_TAG) as SearchFragment
fragment = supportFragmentManager.findFragmentByTag(SEARCH_TAG) as? SearchFragment ?: SearchFragment()
fragment?.let { frag ->
replaceFragmentInTransaction(frag, R.id.fragment, SEARCH_TAG)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import android.app.Activity
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.support.v17.leanback.widget.ArrayObjectAdapter
import android.support.v17.leanback.widget.Row
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentTransaction

fun Activity.hasPermission(permission: String) : Boolean =
PERMISSION_GRANTED == this.packageManager.checkPermission(permission, this.packageName)
Expand All @@ -12,4 +16,34 @@ operator fun ArrayObjectAdapter.plusAssign(items: List<*>?) {
items?.forEach { this.add(it) }
}

operator fun ArrayObjectAdapter.plusAssign(row: Row) = this.add(row)
operator fun ArrayObjectAdapter.plusAssign(row: Row) = this.add(row)

inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) {
beginTransaction().func().commit()
}

fun FragmentActivity.addFragmentInTransaction(
fragment: Fragment,
containerId: Int,
tag: String? = null,
addToBackStack: Boolean = false
) {
supportFragmentManager.inTransaction {
add(containerId, fragment, tag).also {
if (addToBackStack) addToBackStack(tag)
}
}
}

fun FragmentActivity.replaceFragmentInTransaction(
fragment: Fragment,
containerId: Int,
tag: String? = null,
addToBackStack: Boolean = false
) {
supportFragmentManager.inTransaction {
replace(containerId, fragment, tag).also {
if (addToBackStack) addToBackStack(tag)
}
}
}

0 comments on commit 836d7bd

Please sign in to comment.