Skip to content

Commit

Permalink
Added in-app instruction activity. After the module is activated, the…
Browse files Browse the repository at this point in the history
… activity is disabled and the app icon is removed from the app drawer.
  • Loading branch information
DavidBerdik committed Sep 12, 2022
1 parent 6b3088b commit c503f3c
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 5 deletions.
10 changes: 10 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ android {
versionName "1.0.1"
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion "1.3.1"
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -35,6 +43,8 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.github.kyuubiran:EzXHelper:1.0.1'
implementation 'com.github.kyuubiran:EzXHelper:1.0.1:sources'
implementation 'com.github.mukeshsolanki:MarkdownView-Android:2.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'de.robv.android.xposed:api:82:sources'
}
25 changes: 20 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
package="com.berdik.letmedowngrade">

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher">
android:theme="@style/Theme.AppCompat">
<activity
android:name=".InstructionsActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="xposedmodule"
android:value="true" />
Expand All @@ -18,16 +29,20 @@
android:name="xposedscope"
android:resource="@array/xposed_scope" />

<service android:name="com.berdik.letmedowngrade.QuickTile"
<service
android:name=".QuickTile"
android:exported="true"
android:icon="@drawable/ic_baseline_arrow_downward_24"
android:label="@string/tile_label"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
<meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"

<meta-data
android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true" />
</service>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.berdik.letmedowngrade

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import com.mukesh.MarkDown
import java.io.File

class InstructionsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_instructions)

// Create a temporary file copy of the embedded instructions markdown file.
val markdownSource: File = File.createTempFile(R.string.app_name.toString(), "tmp")
markdownSource.writeBytes(resources.openRawResource(R.raw.setup_instructions).readBytes())

// Load the temporary file copy of the instructions in the activity.
findViewById<ComposeView>(R.id.instructions_md_renderer).apply {
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent {
MaterialTheme {
MarkDown(
file = markdownSource,
modifier = Modifier.fillMaxSize()
)
}
}
}
}
}
12 changes: 12 additions & 0 deletions app/src/main/java/com/berdik/letmedowngrade/PrefManager.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.berdik.letmedowngrade

import android.annotation.SuppressLint
import android.content.ComponentName
import android.content.Context
import android.content.SharedPreferences
import android.content.pm.PackageManager

class PrefManager {
companion object {
Expand All @@ -23,6 +25,7 @@ class PrefManager {
Context.MODE_WORLD_READABLE
)
markTileRevealAsDone()
hideModuleIcon(context)
}
} catch (e: SecurityException) {
noXposed = true
Expand Down Expand Up @@ -56,5 +59,14 @@ class PrefManager {
prefEdit.apply()
}
}

private fun hideModuleIcon(context: Context) {
if (!noXposed) {
context.packageManager.setComponentEnabledSetting(ComponentName(context,
InstructionsActivity::class.java),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP)
}
}
}
}
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_instructions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".InstructionsActivity">

<androidx.compose.ui.platform.ComposeView
android:id="@+id/instructions_md_renderer"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
37 changes: 37 additions & 0 deletions app/src/main/res/raw/setup_instructions.md

Large diffs are not rendered by default.

0 comments on commit c503f3c

Please sign in to comment.