Skip to content

Commit

Permalink
Merge branch 'master' into 0415_add_rpc_event
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinpan1 committed May 20, 2024
2 parents aec7ebf + 37af39c commit 9ce69df
Show file tree
Hide file tree
Showing 25 changed files with 1,069 additions and 248 deletions.
5 changes: 4 additions & 1 deletion examples/tv-app/android/App/platform-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {

defaultConfig {
applicationId "com.matter.tv.server"
minSdk 24
minSdk 26
targetSdk 30
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -57,6 +57,9 @@ android {
// ]
}
}
buildFeatures {
viewBinding = true
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<application
android:allowBackup="true"
Expand All @@ -36,6 +37,7 @@
android:theme="@style/Theme.MatterTVSlave">

<activity android:name="com.matter.tv.server.MainActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.matter.tv.server;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.matter.tv.server.fragments.ContentAppFragment;
import com.matter.tv.server.fragments.QrCodeFragment;
import com.matter.tv.server.fragments.TerminalFragment;
import com.matter.tv.server.service.MatterServant;
import java.util.LinkedHashMap;

public class MainActivity extends AppCompatActivity {
Expand Down Expand Up @@ -41,16 +44,32 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// MainActivity is needed to launch dialog prompt
// in UserPrompter
MatterServant.get().setActivity(this);

BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnItemSelectedListener(navListener);

getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container_view, new QrCodeFragment())
.commit();
checkOverlayPermission();
}

private void checkOverlayPermission() {
if (!Settings.canDrawOverlays(this)) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setMessage("Allow permission to display over other apps")
.setTitle("Request overlay permission")
.setPositiveButton(
"Ok",
(dialog, which) -> {
dialog.dismiss();
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivity(intent);
})
.create()
.show();
}
}
}
Loading

0 comments on commit 9ce69df

Please sign in to comment.