-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit becb40f
Showing
51 changed files
with
1,245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
namespace 'com.gulehri.emmiiplayer' | ||
compileSdk 33 | ||
|
||
defaultConfig { | ||
applicationId "com.gulehri.emmiiplayer" | ||
minSdk 21 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
|
||
buildFeatures { | ||
viewBinding true | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.core:core-ktx:1.9.0' | ||
implementation 'androidx.appcompat:appcompat:1.5.1' | ||
implementation 'com.google.android.material:material:1.7.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
implementation "androidx.media:media:1.6.0" | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/com/gulehri/emmiiplayer/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.gulehri.emmiiplayer | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext | ||
assertEquals("com.gulehri.emmiiplayer", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
|
||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".MyApp" | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.EmmiiPlayer" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.app.lib_name" | ||
android:value="" /> | ||
</activity> | ||
|
||
<service android:name=".PlayerService" | ||
android:foregroundServiceType="mediaPlayback"/> | ||
|
||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.gulehri.emmiiplayer | ||
|
||
|
||
// Created by Shahid Iqbal on 12/22/2022. | ||
|
||
object Actions { | ||
|
||
const val ACTION_START = "com.gulehri.emmiiplayer.start" | ||
const val ACTION_PAUSE = "com.gulehri.emmiiplayer.pause" | ||
const val ACTION_PLAY = "com.gulehri.emmiiplayer.play" | ||
const val ACTION_CANCEL = "com.gulehri.emmiiplayer.cancel" | ||
|
||
const val ACTION_FF = "com.gulehri.emmiiplayer.ff" | ||
const val ACTION_RR = "com.gulehri.emmiiplayer.rr" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.gulehri.emmiiplayer | ||
|
||
import android.app.Service | ||
import android.content.ComponentName | ||
import android.content.Intent | ||
import android.content.ServiceConnection | ||
import android.os.Bundle | ||
import android.os.IBinder | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.gulehri.emmiiplayer.databinding.ActivityMainBinding | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
private val binding by lazy(LazyThreadSafetyMode.NONE) { | ||
ActivityMainBinding.inflate(layoutInflater) | ||
} | ||
private lateinit var emmiPlayer: PlayerService | ||
private var isBind = false | ||
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(binding.root) | ||
|
||
binding.btnStart.setOnClickListener { | ||
startPlayerService(Actions.ACTION_PLAY) | ||
} | ||
|
||
|
||
if (isBind && emmiPlayer.mediaPlayer.isPlaying) | ||
binding.textView.text = SimpleDateFormat( | ||
"mm:ss", | ||
Locale.ENGLISH | ||
).format(emmiPlayer.mediaPlayer.currentPosition) | ||
|
||
} | ||
|
||
|
||
override fun onStart() { | ||
startPlayerService(Actions.ACTION_START) | ||
super.onStart() | ||
} | ||
|
||
private fun startPlayerService(operation: String) { | ||
Intent(this, PlayerService::class.java).apply { | ||
action = operation | ||
|
||
if (operation == Actions.ACTION_START) bindService( | ||
this, | ||
connection, | ||
Service.BIND_AUTO_CREATE | ||
) | ||
|
||
startService(this) | ||
} | ||
} | ||
|
||
|
||
private val connection = object : ServiceConnection { | ||
override fun onServiceConnected(p0: ComponentName?, p1: IBinder?) { | ||
emmiPlayer = (p1 as PlayerService.LocalBinder).getEmmiPlayer() | ||
isBind = true | ||
} | ||
|
||
override fun onServiceDisconnected(p0: ComponentName?) { | ||
isBind = false | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.gulehri.emmiiplayer | ||
|
||
import android.annotation.SuppressLint | ||
import android.app.Application | ||
import android.app.NotificationChannel | ||
import android.app.NotificationManager | ||
import android.os.Build | ||
import java.util.* | ||
|
||
|
||
// Created by Shahid Iqbal on 12/21/2022. | ||
|
||
class MyApp : Application() { | ||
|
||
companion object{ | ||
val version8OrAbove = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O | ||
val version12OrAbove = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R | ||
} | ||
|
||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
if (version8OrAbove) createChannel() | ||
|
||
} | ||
|
||
@SuppressLint("NewApi") | ||
private fun createChannel() { | ||
(getSystemService(NOTIFICATION_SERVICE) as NotificationManager).apply { | ||
createNotificationChannel(NotificationChannel( | ||
"12", | ||
"MyChannel", | ||
NotificationManager.IMPORTANCE_HIGH | ||
) | ||
.apply { | ||
setSound(null, null) | ||
}) | ||
} | ||
} | ||
|
||
|
||
} | ||
|
Oops, something went wrong.