diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 9c96b2b..4ea7061 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -3,7 +3,20 @@ - + + + + + + + + + + + + + + diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1bdbdee..28a967a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "uk.kagurach.android101" minSdk = 31 targetSdk = 34 - versionCode = 1 - versionName = "1.0" + versionCode = 101 + versionName = "1.0.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/uk/kagurach/android101/MainActivity2.java b/app/src/main/java/uk/kagurach/android101/MainActivity2.java index d45ed9d..2ba5d30 100644 --- a/app/src/main/java/uk/kagurach/android101/MainActivity2.java +++ b/app/src/main/java/uk/kagurach/android101/MainActivity2.java @@ -4,7 +4,6 @@ import android.content.Context; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; -import android.util.Log; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; @@ -65,24 +64,28 @@ public class MainActivity2 extends AppCompatActivity { EditText b_edit = (EditText) findViewById(R.id.B); int _r,_g,_b; + // Here we are testing toast + if( r_edit.getText().toString().isEmpty() || + g_edit.getText().toString().isEmpty()|| + b_edit.getText().toString().isEmpty() ){ + ToastHelper.SmartToast.ShowToast(""" + Please input R,G,B within 0-255 + 请在大小选择下方输入0-255的RGB""", + this); + } + try { _r = Integer.parseInt(r_edit.getText().toString()); _g = Integer.parseInt(g_edit.getText().toString()); _b = Integer.parseInt(b_edit.getText().toString()); } catch (NumberFormatException e){ - NotificationHelper helper = new NotificationHelper(this); - helper.createNotificationChannel(); - helper.pushNotification("Page 2: Error Setting Color", - e.toString()); + ToastHelper.SmartToast.ShowToast(e.toString(),this); return; } if (_r>=0&&_g>=0&&_b>=0&&_r<=255&&_g<=255&&_b<=255){ t.setTextColor(Color.rgb(_r,_g,_b)); }else{ - NotificationHelper helper = new NotificationHelper(this); - helper.createNotificationChannel(); - helper.pushNotification("Page 2: Error Setting Color", - "The color: R="+_r+" G="+_g+" B="+_b+" is invalid!"); + ToastHelper.SmartToast.ShowToast("The color: R="+_r+" G="+_g+" B="+_b+" is invalid!",this); } } @@ -93,10 +96,7 @@ public class MainActivity2 extends AppCompatActivity { try { s = editText.getText().toString(); }catch (Exception e){ - NotificationHelper helper = new NotificationHelper(this); - helper.createNotificationChannel(); - helper.pushNotification("Page 2: Error Setting Test Text", - e.toString()); + ToastHelper.SmartToast.ShowToast(e.toString(),this); return; } textView.setText(s); @@ -122,10 +122,7 @@ public class MainActivity2 extends AppCompatActivity { try { size = Integer.parseInt(ed.getText().toString()); }catch (Exception e){ - NotificationHelper helper = new NotificationHelper(this); - helper.createNotificationChannel(); - helper.pushNotification("Page 2: Error Setting Text Size", - e.toString()); + ToastHelper.SmartToast.ShowToast(e.toString(),this); return; } _text_size = size; diff --git a/app/src/main/java/uk/kagurach/android101/ToastHelper.kt b/app/src/main/java/uk/kagurach/android101/ToastHelper.kt new file mode 100644 index 0000000..782ccea --- /dev/null +++ b/app/src/main/java/uk/kagurach/android101/ToastHelper.kt @@ -0,0 +1,27 @@ +package uk.kagurach.android101 + +import android.content.Context +import android.widget.Toast + +class ToastHelper(text: String,ctx: Context) { + val _text = text + val _ctx = ctx + + companion object SmartToast { + fun ShowToast(text: String,ctx: Context){ + val helper = ToastHelper(text,ctx) + helper.autoShow() + } + } + fun autoShow(){ + if (_text.contains('\n')){ + for (line in _text.split('\n')){ + Toast.makeText(_ctx,line,Toast.LENGTH_SHORT).show() + Thread.sleep(Toast.LENGTH_SHORT.toLong()+5) + } + }else{ + Toast.makeText(_ctx,_text,Toast.LENGTH_LONG).show() + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main2.xml b/app/src/main/res/layout/activity_main2.xml index b2b85fe..794678d 100644 --- a/app/src/main/res/layout/activity_main2.xml +++ b/app/src/main/res/layout/activity_main2.xml @@ -23,7 +23,7 @@ android:layout_height="350dp"> diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/app/src/main/res/mipmap-anydpi/ic_launcher.xml deleted file mode 100644 index 6f3b755..0000000 --- a/app/src/main/res/mipmap-anydpi/ic_launcher.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml deleted file mode 100644 index 6f3b755..0000000 --- a/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..bfb7c26 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp deleted file mode 100644 index c209e78..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..d98503c Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp deleted file mode 100644 index b2dfe3d..0000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..464a86c Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp deleted file mode 100644 index 4f0f1d6..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..99a840a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp deleted file mode 100644 index 62b611d..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..8998681 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp deleted file mode 100644 index 948a307..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..cbf466a Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp deleted file mode 100644 index 1b9a695..0000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..e9ac990 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp deleted file mode 100644 index 28d4b77..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..c72f815 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp deleted file mode 100644 index 9287f50..0000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..cf934a2 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp deleted file mode 100644 index aa7d642..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..44d6f2e Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp deleted file mode 100644 index 9126ae3..0000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp and /dev/null differ