Skip to content

Commit

Permalink
deeplink
Browse files Browse the repository at this point in the history
  • Loading branch information
sachin2dehury committed Jul 19, 2023
1 parent 2581490 commit af5f2e4
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 18 deletions.
23 changes: 22 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".OwlMailApp"
Expand All @@ -21,9 +23,24 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="github.owlmail.mail"
android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mail.nitrkl.ac.in"
android:scheme="https" />
</intent-filter>
</activity>

<provider
Expand All @@ -42,6 +59,10 @@
<meta-data
android:name="github.owlmail.app.initializer.StethoInitializer"
android:value="androidx.startup" />
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package github.owlmail.auth.api

object AuthNavigationDeeplink {
const val AUTH_FRAGMENT = "android-app://github.owlmail.mail/authFragment"
const val AUTH_FRAGMENT = "https://mail.nitrkl.ac.in"
}
2 changes: 1 addition & 1 deletion auth/src/main/res/navigation/auth_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:name="github.owlmail.auth.AuthFragment"
android:label="AuthFragment">

<deepLink app:uri="android-app://github.owlmail.mail/authFragment" />
<deepLink app:uri="https://mail.nitrkl.ac.in" />

</fragment>

Expand Down
8 changes: 4 additions & 4 deletions benchmark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ plugins {

android {
namespace 'github.owlmail.benchmark'
compileSdk 33
compileSdk AppConfig.CompileSdk

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = AppConfig.JvmTargetVersion
}

defaultConfig {
minSdk 23
targetSdk 33
minSdk AppConfig.MinSdk
targetSdk AppConfig.TargetSdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package github.owlmail.benchmark

import androidx.benchmark.macro.CompilationMode
import androidx.benchmark.macro.StartupMode
import androidx.benchmark.macro.StartupTimingMetric
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
Expand All @@ -26,11 +27,17 @@ class ExampleStartupBenchmark {
val benchmarkRule = MacrobenchmarkRule()

@Test
fun startup() = benchmarkRule.measureRepeated(
fun startUpCompilationModeNone() = startup(CompilationMode.None())

@Test
fun startUpCompilationModePartial() = startup(CompilationMode.Partial())

private fun startup(mode: CompilationMode) = benchmarkRule.measureRepeated(
packageName = "github.owlmail.app",
metrics = listOf(StartupTimingMetric()),
iterations = 5,
startupMode = StartupMode.COLD
startupMode = StartupMode.COLD,
compilationMode = mode,
) {
pressHome()
startActivityAndWait()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package github.owlmail.contacts.api

object ContactsNavigationDeeplink {
const val CONTACTS_FRAGMENT = "android-app://github.owlmail.mail/contactListFragment"
const val CONTACTS_FRAGMENT = "https://github.owlmail.mail/contactListFragment"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.navArgs
import dagger.hilt.android.AndroidEntryPoint
import github.owlmail.contacts.databinding.ContactListBinding
import javax.inject.Inject
Expand All @@ -21,6 +22,8 @@ class ContactListFragment : Fragment(), MenuProvider {

@Inject
lateinit var contactAdapter: ContactAdapter

private val args: ContactListFragmentArgs by navArgs()
private val viewModel: ContactViewModel by viewModels()
override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -33,6 +36,7 @@ class ContactListFragment : Fragment(), MenuProvider {

private fun setUpRecyclerView() {
binding?.recyclerView?.adapter = contactAdapter
println("Preeti ${args.uid}")
}

private fun subscribeToObservers() {
Expand Down
5 changes: 4 additions & 1 deletion contacts/src/main/res/navigation/contact_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
android:id="@+id/contactListFragment"
android:name="github.owlmail.contacts.ContactListFragment"
android:label="ContactListFragment">
<deepLink app:uri="android-app://github.owlmail.mail/contactListFragment" />
<deepLink app:uri="https://github.owlmail.mail/contactListFragment/{uid}" />
<argument
android:name="uid"
app:argType="string" />
</fragment>
</navigation>
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MailBoxHostFragment : Fragment(), MenuProvider {

R.id.contacts -> {
val request = NavDeepLinkRequest.Builder
.fromUri(ContactsNavigationDeeplink.CONTACTS_FRAGMENT.toUri())
.fromUri((ContactsNavigationDeeplink.CONTACTS_FRAGMENT+"/abc").toUri())
.build()
findNavController()
.navigate(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,46 @@ package github.owlmail.mail.manager

import android.app.Notification
import android.app.NotificationChannel
import android.app.PendingIntent
import android.content.Context
import android.content.Context.NOTIFICATION_SERVICE
import android.content.Intent
import android.graphics.Color
import android.os.Build
import androidx.core.app.NotificationManagerCompat
import androidx.core.net.toUri
import github.owlmail.networking.ResponseState.Empty.data

class NotificationManager(private val context: Context) {
init {
registerNotificationChannel()
createPendingIntent()
}

private val notificationManager = NotificationManagerCompat.from(context)

fun showNotification(notificationId: Int, notification: Notification) {
notification.contentIntent = getPendingIntent()
notificationManager.notify(notificationId, notification)
}

private fun createPendingIntent() {
// Intent(context,)
private fun getPendingIntent(): PendingIntent? {
val intent = Intent(Intent.ACTION_VIEW).apply {
data = "https://mail.nitrkl.ac.in/".toUri()
}
return PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
}

private fun registerNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
"owlmail_notification_id",
"owlmail_notification_channel",
android.app.NotificationManager.IMPORTANCE_DEFAULT
android.app.NotificationManager.IMPORTANCE_DEFAULT,
).apply {
lightColor = Color.BLUE
enableLights(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class UnreadMailNotificationWorker @AssistedInject constructor(
)
)
val timeStamp = System.currentTimeMillis()
val previousTimeStamp =
dataStoreManager.readFromDataStore().first().get(NOTIFICATION_TIME_STAMP) ?: 0
val previousTimeStamp = 0
// dataStoreManager.readFromDataStore().first()[NOTIFICATION_TIME_STAMP] ?: 0

val response = mailRepository.getMailList(inboxSearchRequest).mapToResponseState()
when (response) {
Expand Down

0 comments on commit af5f2e4

Please sign in to comment.