Adaptation of the GameActivity and Manifest.xml to include deeplinking

Links of the following format
"http://sudoku" also accepted and loaded as game field
This commit is contained in:
ErikWaegerle 2020-06-13 20:16:51 +02:00
parent bf9aee31ed
commit c8a6385e64
2 changed files with 17 additions and 2 deletions

View file

@ -44,12 +44,21 @@
android:label="@string/title_activity_game_view"
android:theme="@style/AppTheme.NoActionBar">
<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:scheme="http"
android:host="sudoku" />
</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:scheme="sudoku" />
</intent-filter>
</activity>
<activity android:name="org.secuso.privacyfriendlysudoku.ui.AboutActivity" />
<activity android:name="org.secuso.privacyfriendlysudoku.ui.LoadGameActivity" />

View file

@ -115,8 +115,13 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
(extras.containsKey("gameType") || extras.containsKey("loadLevel"));
if (data != null && !intentReceivedFromMainActivity) {
String input = data.toString();
input = input.replace("sudoku://", "");
String input = "";
if (data.getScheme().equals("sudoku")){
input = data.getHost();
} else if (data.getScheme().equals("http") && data.getHost().equals("sudoku")){
input = data.getPath();
input =input.replace("/", "");
}
int sectionSize = (int)Math.sqrt(input.length());
int boardSize = sectionSize * sectionSize;
@ -364,6 +369,7 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
case R.id.menu_share:
String codeForClipboard = "sudoku://" + gameController.getCodeOfField();
String codeForClipboard1 = "http://sudoku" + gameController.getCodeOfField();
ShareBoardDialog shareDialog = new ShareBoardDialog();
shareDialog.setDisplayCode(codeForClipboard);
shareDialog.setCopyClickListener(new View.OnClickListener() {