Skip to content

Commit

Permalink
feat(shortcuts): add games shortcut
Browse files Browse the repository at this point in the history
This shortcut will open an activity which (should) display all games that the user has. (WIP)
  • Loading branch information
EdricChan03 committed Mar 23, 2018
1 parent 4f8c50a commit 66618e8
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 14 deletions.
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ android {
}

dependencies {
// Support Lib
// Support Lib
implementation 'com.android.support:support-v4:27.1.0'
// Support Annotations
implementation 'com.android.support:support-annotations:27.1.0'
implementation 'com.android.support:support-annotations:27.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// AppCompat
// AppCompat
implementation 'com.android.support:appcompat-v7:27.1.0'
// ConstraintLayout
// ConstraintLayout
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
// Design Support
// Design Support
implementation 'com.android.support:design:27.1.0'
// Card view
// Card view
implementation 'com.android.support:cardview-v7:27.1.0'
// Chrome Custom Tabs
implementation 'com.android.support:customtabs:27.1.0'
Expand Down
20 changes: 15 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.edricchan.studybuddy">

<application
android:allowBackup="true"
android:appCategory="productivity"
Expand All @@ -17,6 +17,7 @@
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

Expand All @@ -31,8 +32,10 @@
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />

<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />

<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity>
Expand Down Expand Up @@ -93,10 +96,17 @@
android:name=".DebugActivity"
android:label="@string/title_activity_debug"
android:theme="@style/AppTheme">
<!--<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.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity android:name=".GamesActivity"
android:label="@string/title_activity_games">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.edricchan.studybuddy.MainActivity" />
</activity>
</application>

Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/edricchan/studybuddy/GamesActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.edricchan.studybuddy;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;

public class GamesActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_games);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
RecyclerView recyclerView = findViewById(R.id.games_recycler_view);

}
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable-v26/ic_shortcut_game.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/lightGrey"/>
<foreground>
<inset
android:drawable="@drawable/ic_shortcut_game_foreground"
android:inset="30%" />
</foreground>
</adaptive-icon>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_shortcut_game.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="2dp"
android:drawable="@drawable/ic_app_shortcut_background"
android:left="2dp"
android:right="2dp"
android:top="2dp" />
<item android:drawable="@drawable/ic_shortcut_settings_foreground" />
</layer-list>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_shortcut_game_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="@color/colorPrimary"
android:pathData="M7,6H17A6,6 0 0,1 23,12A6,6 0 0,1 17,18C15.22,18 13.63,17.23 12.53,16H11.47C10.37,17.23 8.78,18 7,18A6,6 0 0,1 1,12A6,6 0 0,1 7,6M6,9V11H4V13H6V15H8V13H10V11H8V9H6M15.5,12A1.5,1.5 0 0,0 14,13.5A1.5,1.5 0 0,0 15.5,15A1.5,1.5 0 0,0 17,13.5A1.5,1.5 0 0,0 15.5,12M18.5,9A1.5,1.5 0 0,0 17,10.5A1.5,1.5 0 0,0 18.5,12A1.5,1.5 0 0,0 20,10.5A1.5,1.5 0 0,0 18.5,9Z" />
</vector>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/activity_games.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GamesActivity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/games_recycler_view"/>
</android.support.constraint.ConstraintLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="title_activity_help">Help</string>
<string name="title_activity_new_task">New Task</string>
<string name="title_activity_debug">Debug</string>
<string name="title_activity_games">Games</string>

<!-- Web client ID -->
<string name="web_client_id">713563449638-sc1up855asm687s55f8qi4bdrh0u18tc.apps.googleusercontent.com</string>
Expand Down Expand Up @@ -39,6 +40,8 @@
<string name="shortcut_todo_short_msg">New todo</string>
<string name="shortcut_settings_long_msg">Open settings</string>
<string name="shortcut_settings_short_msg">Settings</string>
<string name="shortcut_game_long_msg">Play a game</string>
<string name="shortcut_game_short_msg">Games</string>
<!-- Strings related to Settings -->
<!--
Experimental settings
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/res/xml/shortcuts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<!-- Each one of these intents needs an android:action, even if you don't
do anything with it. Otherwise you're in for a crash! -->
<intent
android:action="com.edricchan.studybuddy.shortcuts.ADD_NEW_TODO"
android:targetClass="com.edricchan.studybuddy.MainActivity"
android:action="android.intent.action.ACTION_VIEW"
android:targetClass="com.edricchan.studybuddy.NewTaskActivity"
android:targetPackage="com.edricchan.studybuddy"/>
</shortcut>
<shortcut
Expand All @@ -28,6 +28,17 @@
android:targetClass="com.edricchan.studybuddy.SettingsActivity"
android:targetPackage="com.edricchan.studybuddy" />
</shortcut>

<shortcut
android:enabled="true"
android:icon="@drawable/ic_shortcut_game"
android:shortcutId="play_game"
android:shortcutLongLabel="@string/shortcut_game_long_msg"
android:shortcutShortLabel="@string/shortcut_game_short_msg"
tools:targetsApi="n_mr1">
<intent
android:action="android.intent.action.ACTION_VIEW"
android:targetClass="com.edricchan.studybuddy.GamesActivity"
android:targetPackage="com.edricchan.studybuddy" />
</shortcut>

</shortcuts>

0 comments on commit 66618e8

Please sign in to comment.