Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history


# Conflicts:
#	app/src/main/ic_launcher-playstore.png
#	app/src/main/res/drawable-v24/ic_launcher_foreground.xml
#	app/src/main/res/mipmap-hdpi/ic_launcher.png
#	app/src/main/res/mipmap-hdpi/ic_launcher_round.png
#	app/src/main/res/mipmap-mdpi/ic_launcher.png
#	app/src/main/res/mipmap-mdpi/ic_launcher_round.png
#	app/src/main/res/mipmap-xhdpi/ic_launcher.png
#	app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
#	app/src/main/res/mipmap-xxhdpi/ic_launcher.png
#	app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
#	app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
#	app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
#	app/src/main/res/values/ic_launcher_background.xml
  • Loading branch information
胡晟昊 committed Nov 1, 2020
2 parents 13fff6f + 8ca7902 commit d6a5d5b
Show file tree
Hide file tree
Showing 88 changed files with 3,678 additions and 290 deletions.
12 changes: 2 additions & 10 deletions N/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Copyright (C) 2016 The Android Open Source Project
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android_n.egg">

<!-- <uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />-->
<!-- <uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application>
<activity
Expand Down Expand Up @@ -67,14 +68,5 @@ Copyright (C) 2016 The Android Open Source Project
</intent-filter>
</service>

<provider
android:authorities="${applicationId}.fileprovider"
android:name="androidx.core.content.FileProvider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
3 changes: 2 additions & 1 deletion N/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Copyright (C) 2016 The Android Open Source Project
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<string name="n_app_name">Neko</string>
<string name="notification_name" translatable="false">Android Neko</string>
<string name="notification_name" translatable="false">Android N Neko</string>
<string name="notification_channel_name" translatable="false">New cats(N)</string>
<string name="default_tile_name" translatable="false">\????</string>
<string name="notification_title" translatable="false">A cat is here.</string>
<string name="default_cat_name" translatable="false">Cat #%s</string>
Expand Down
9 changes: 0 additions & 9 deletions N/res/xml/file_paths.xml

This file was deleted.

2 changes: 1 addition & 1 deletion N/src/com/android_n/egg/neko/Cat.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public Notification.Builder buildNotification(Context context) {
.setVibrate(PURR)
.addExtras(extras);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(NekoService.CAT_NOTIFICATION_CHANNEL_ID);
builder.setChannelId(NekoService.CHAN_ID);
}
return builder;
}
Expand Down
40 changes: 3 additions & 37 deletions N/src/com/android_n/egg/neko/NekoLand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -40,17 +37,13 @@
import android.widget.TextView;

import androidx.annotation.RequiresApi;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.android_n.egg.R;
import com.android_n.egg.neko.PrefState.PrefsListener;
import com.dede.basic.ShareCatUtils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -273,37 +266,10 @@ public int getItemCount() {
}

private void shareCat(Cat cat) {
final File dir = new File(
getCacheDir(),
getString(R.string.directory_name));
if (!dir.exists() && !dir.mkdirs()) {
Log.e("NekoLand", "save: error: can't create Pictures directory");
return;
}
final File png = new File(dir, cat.getName().replaceAll("[/ #:]+", "_") + ".png");
Bitmap bitmap = cat.createBitmap(EXPORT_BITMAP_SIZE, EXPORT_BITMAP_SIZE);
if (bitmap != null) {
try {
OutputStream os = new FileOutputStream(png);
bitmap.compress(Bitmap.CompressFormat.PNG, 0, os);
os.close();
Uri uri = FileProvider.getUriForFile(this, this.getPackageName() + ".fileprovider", png);
// MediaScannerConnection.scanFile(
// this,
// new String[]{png.toString()},
// new String[]{"image/png"},
// null);
// Uri uri = Uri.fromFile(png);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(Intent.EXTRA_SUBJECT, cat.getName());
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/png");
startActivity(Intent.createChooser(intent, null));
cat.logShare(this);
} catch (IOException e) {
Log.e("NekoLand", "save: error: " + e);
}
ShareCatUtils.share(this, bitmap, cat.getName());
cat.logShare(this);
}
}

Expand Down
16 changes: 11 additions & 5 deletions N/src/com/android_n/egg/neko/NekoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.app.job.JobService;
import android.content.ComponentName;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -37,12 +38,14 @@
@RequiresApi(Build.VERSION_CODES.N)
public class NekoService extends JobService {

public static final long[] PURR = {0, 40, 20, 40, 20, 40, 20, 40, 20, 40, 20, 40};

private static final String TAG = "NekoService";

public static int JOB_ID = 42;

public static int CAT_NOTIFICATION = 1;
public static final String CAT_NOTIFICATION_CHANNEL_ID = "CAT_CHANNEL";
public static final String CHAN_ID = "EGG_N";

public static float CAT_CAPTURE_PROB = 1.0f; // generous

Expand Down Expand Up @@ -129,9 +132,12 @@ public static void registerJob(Context context, long intervalMinutes) {

NotificationManager noman = context.getSystemService(NotificationManager.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(CAT_NOTIFICATION_CHANNEL_ID,
context.getString(R.string.notification_name), NotificationManager.IMPORTANCE_DEFAULT);
channel.setShowBadge(true);
NotificationChannel channel = new NotificationChannel(CHAN_ID,
context.getString(R.string.notification_channel_name), NotificationManager.IMPORTANCE_DEFAULT);
channel.setSound(Uri.EMPTY, Notification.AUDIO_ATTRIBUTES_DEFAULT); // cats are quiet
channel.setVibrationPattern(PURR); // not totally quiet though
//eggChan.setBlockableSystem(true); // unlike a real cat, you can push this one off your lap
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); // cats sit in the window
noman.createNotificationChannel(channel);
}
if (NekoLand.DEBUG_NOTIFICATIONS) {
Expand All @@ -143,7 +149,7 @@ public static void registerJob(Context context, long intervalMinutes) {
.setCategory(Notification.CATEGORY_SERVICE)
.setShowWhen(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder.setChannelId(CAT_NOTIFICATION_CHANNEL_ID);
builder.setChannelId(CHAN_ID);
}
noman.notify(500, builder
.build());
Expand Down
5 changes: 0 additions & 5 deletions P/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ android {
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
Expand Down Expand Up @@ -46,10 +45,6 @@ dependencies {
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
// implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}"
implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
implementation project(path: ':basic')
}

7 changes: 1 addition & 6 deletions Q/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ android {
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
Expand Down Expand Up @@ -43,13 +42,9 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
// implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6'
implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}"
implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation "androidx.annotation:annotation:${ANDROID_X_VERSION}"
implementation project(path: ':basic')
}

Loading

0 comments on commit d6a5d5b

Please sign in to comment.