Added optional XP-Notification (see ingame screenshots), lowered target sdk version to 20 to support coloured notification icon
This commit is contained in:
parent
9fd67ec061
commit
ecc4114860
|
@ -6,9 +6,9 @@ android {
|
|||
defaultConfig {
|
||||
applicationId "com.example.yink.amadeus"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 25
|
||||
targetSdkVersion 20
|
||||
versionCode 1
|
||||
versionName "0.8.4-beta.5"
|
||||
versionName "0.8.9-beta.7"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
|
|
@ -12,7 +12,11 @@
|
|||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:parentActivityName=".LaunchActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".LaunchActivity" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
|
@ -29,7 +33,12 @@
|
|||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="Preferences"
|
||||
android:theme="@style/PreferenceTheme" />
|
||||
android:parentActivityName=".LaunchActivity"
|
||||
android:theme="@style/PreferenceTheme">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".LaunchActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,15 +1,17 @@
|
|||
package com.example.yink.amadeus;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.TaskStackBuilder;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
@ -73,6 +75,11 @@ public class LaunchActivity extends AppCompatActivity {
|
|||
connect.setImageResource(R.drawable.connect_unselect);
|
||||
cancel.setImageResource(R.drawable.cancel_unselect);
|
||||
|
||||
if (sharedPreferences.getBoolean("show_notification", false)) {
|
||||
showNotification();
|
||||
}
|
||||
|
||||
|
||||
connect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -150,6 +157,20 @@ public class LaunchActivity extends AppCompatActivity {
|
|||
super.onResume();
|
||||
}
|
||||
|
||||
private void showNotification() {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(R.drawable.xp2)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(getString(R.string.notification_text));
|
||||
Intent resultIntent = new Intent(this, MainActivity.class);
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
|
||||
stackBuilder.addParentStack(MainActivity.class);
|
||||
stackBuilder.addNextIntent(resultIntent);
|
||||
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
builder.setContentIntent(resultPendingIntent);
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(0, builder.build());
|
||||
}
|
||||
/* Reported OOM on 2K+ resolution devices */
|
||||
/*
|
||||
@Override
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 695 B |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -6,6 +6,7 @@
|
|||
<string name="default_lang">en</string>
|
||||
<string name="default_recog_lang">en-US</string>
|
||||
<string name="google_app_error">Google App wasn\'t detected.</string>
|
||||
<string name="notification_text">Your waifu misses you.</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="pref_app_settings">Application settings</string>
|
||||
|
@ -15,6 +16,8 @@
|
|||
<string name="pref_lang_desc">Select app language (app restart required)</string>
|
||||
<string name="pref_subtitles">Show subtitles</string>
|
||||
<string name="pref_subtitles_desc">Shows subtitles for Amadeus\' answers</string>
|
||||
<string name="pref_notification">Show "XP"-Icon</string>
|
||||
<string name="pref_notification_desc">Shows Icon in the notification bar (app restart required)</string>
|
||||
|
||||
<string name="line_hello">Hello.</string>
|
||||
<string name="line_dont_call_me_like_that">Don\'t call me like that!</string>
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
android:key="show_subtitles"
|
||||
android:summary="@string/pref_subtitles_desc"
|
||||
android:title="@string/pref_subtitles" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="show_notification"
|
||||
android:summary="@string/pref_notification_desc"
|
||||
android:title="@string/pref_notification" />
|
||||
<ListPreference
|
||||
android:defaultValue="@string/default_recog_lang"
|
||||
android:entries="@array/languagesRecogArray"
|
||||
|
|
Loading…
Reference in New Issue