Notifications are now automatically expanded, release number 1.2.5

This commit is contained in:
Deniz Düzgören
2019-05-03 19:03:19 +02:00
parent 00c893380e
commit d5b5803ba2
8 changed files with 55 additions and 23 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
+2 -2
View File
@@ -16,8 +16,8 @@ android {
applicationId "com.denizd.substitutionplan"
minSdkVersion 21
targetSdkVersion 28
versionCode 9
versionName "1.2.4"
versionCode 10
versionName "1.2.5"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Binary file not shown.
@@ -634,6 +634,13 @@ public class FragmentSettings extends Fragment {
break;
}
case "@NOTIFICATION": {
edit.putString("time", "");
edit.apply();
Toast.makeText(getActivity(), "Dummy notification sent",
Toast.LENGTH_LONG).show();
break;
}
default:
Toast.makeText(getActivity(), getString(R.string.nothinghappened),
Toast.LENGTH_LONG).show();
@@ -171,18 +171,14 @@ public class MainActivity extends AppCompatActivity {
AlertDialog.Builder alertDialog;
View dialogView = LayoutInflater.from(context).inflate(R.layout.secret_dialog, null);
TextView secretText = dialogView.findViewById(R.id.secrettext);
if (prefs.getInt("themeInt", 0) == 1) {
secretText.setTextColor(getResources().getColor(R.color.hintdark));
alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomDark);
} else {
secretText.setTextColor(getResources().getColor(R.color.hint));
alertDialog = new AlertDialog.Builder(context, R.style.AlertDialogCustomLight);
}
alertDialog.setTitle(R.string.chinaTitle);
TextView dialogText = dialogView.findViewById(R.id.dialogtext);
dialogText.setText(R.string.chinaDialog);
secretText.setText(R.string.orbuy);
// Button searchbtn = dialogView.findViewById(R.id.searchbtn);
// searchbtn.setOnClickListener(new View.OnClickListener() {
// @Override
@@ -13,6 +13,8 @@ import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Build;
import android.preference.PreferenceManager;
import android.widget.RemoteViews;
import android.widget.TextView;
import com.madapps.prefrences.EasyPrefrences;
@@ -261,13 +263,19 @@ public class ScheduledJobService extends JobService {
openApp.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent openAppPending = PendingIntent.getActivity(mContext, 0, openApp, 0);
RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.notification);
notificationLayout.setTextViewText(R.id.notification_title, getString(R.string.subst));
notificationLayout.setTextViewText(R.id.notification_textview, notifText);
if (!notifText.isEmpty()) {
Notification notification = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notification = new NotificationCompat.Builder(mContext)
.setContentTitle(getString(R.string.subst))
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(notifText))
// .setContentTitle(getString(R.string.subst))
// .setStyle(new NotificationCompat.BigTextStyle()
// .bigText(notifText))
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
.setChannelId(channelId)
.setContentIntent(openAppPending)
@@ -275,9 +283,11 @@ public class ScheduledJobService extends JobService {
.build();
} else {
notification = new NotificationCompat.Builder(mContext)
.setContentTitle(getString(R.string.subst))
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(notifText))
// .setContentTitle(getString(R.string.subst))
// .setStyle(new NotificationCompat.BigTextStyle()
// .bigText(notifText))
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setSmallIcon(R.drawable.ic_avh)
.setContentIntent(openAppPending)
.setAutoCancel(true)
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/notification_title"
style="@style/TextAppearance.Compat.Notification.Title"/>
<TextView
android:layout_below="@+id/notification_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/notification_textview"
style="@style/TextAppearance.Compat.Notification"/>
</RelativeLayout>
+11 -10
View File
@@ -21,18 +21,19 @@
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingBottom="4dp"
android:paddingTop="8dp"/>
<TextView
android:id="@+id/secrettext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/colorText"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="3dp"
android:paddingTop="8dp"
android:layout_marginBottom="24dp"/>
<!--<TextView-->
<!--android:id="@+id/secrettext"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:textColor="?attr/colorText"-->
<!--android:paddingStart="24dp"-->
<!--android:paddingEnd="24dp"-->
<!--android:textSize="3dp"-->
<!--android:layout_marginBottom="24dp"/>-->
</LinearLayout>
</androidx.core.widget.NestedScrollView>