-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from tasomaniac/remove-duplicate-vr-activities
resolve VR activities and remove them.
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/tasomaniac/openwith/resolver/ResolveListDuplicateRemover.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,26 @@ | ||
package com.tasomaniac.openwith.resolver | ||
|
||
import android.content.Intent | ||
import android.content.pm.PackageManager | ||
import android.content.pm.ResolveInfo | ||
import android.os.Build.VERSION.SDK_INT | ||
import android.os.Build.VERSION_CODES.M | ||
import com.tasomaniac.openwith.util.isEqualTo | ||
import javax.inject.Inject | ||
|
||
class ResolveListDuplicateRemover @Inject constructor( | ||
private val packageManager: PackageManager | ||
) { | ||
|
||
fun process(currentResolveList: MutableList<ResolveInfo>) { | ||
val flag = if (SDK_INT >= M) PackageManager.MATCH_ALL else PackageManager.MATCH_DEFAULT_ONLY | ||
val vr = Intent(Intent.ACTION_MAIN).addCategory("com.google.intent.category.DAYDREAM") | ||
val vrList = packageManager.queryIntentActivities(vr, flag) | ||
|
||
currentResolveList.removeAll { info -> | ||
vrList.any { vr -> | ||
vr.activityInfo isEqualTo info.activityInfo | ||
} | ||
} | ||
} | ||
} |
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