Skip to content

Commit

Permalink
Material 3 adoption (#46)
Browse files Browse the repository at this point in the history
* Change colors and themes to Material 3

* Simplify dialogs

* Adapt spacing and view tool texting

* Update Gradle and dependencies

* Use consistent input type for IPs

* Fixed some spacings, renaming and added scrolling for pair dialog (for landscape mode)

* Enable Material You colors

* Fix navigation bar color

---------

Co-authored-by: patri9ck <[email protected]>
  • Loading branch information
cyb3rko and patri9ck authored Aug 8, 2024
1 parent f18b7a5 commit c5f7c1a
Show file tree
Hide file tree
Showing 38 changed files with 647 additions and 317 deletions.
13 changes: 7 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ android {
}

compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
sourceCompatibility(JavaVersion.VERSION_17)
targetCompatibility(JavaVersion.VERSION_17)
}

buildFeatures {
viewBinding = true
buildConfig = true
}

val keystoreFile = rootProject.file("keystore.properties")
Expand Down Expand Up @@ -71,12 +72,12 @@ android {
}

dependencies {
implementation("com.google.code.gson:gson:2.9.1")
implementation("com.google.android.material:material:1.10.0")
implementation("com.google.code.gson:gson:2.10")
implementation("com.google.android.material:material:1.11.0")
implementation("org.zeromq:jeromq:0.5.2")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.navigation:navigation-fragment:2.7.4")
implementation("androidx.navigation:navigation-ui:2.7.4")
implementation("androidx.navigation:navigation-fragment:2.7.7")
implementation("androidx.navigation:navigation-ui:2.7.7")
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
implementation("me.xdrop:fuzzywuzzy:1.4.0")
implementation("net.jodah:expiringmap:0.5.11")
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name=".main.Application"
android:theme="@style/Theme">
<activity
android:name=".main.MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import dev.patri9ck.a2ln.R;
import dev.patri9ck.a2ln.databinding.DialogLogsBinding;

public class LogDialogBuilder extends MaterialAlertDialogBuilder {

public LogDialogBuilder(String log, LayoutInflater layoutInflater) {
super(layoutInflater.getContext(), R.style.Dialog);

DialogLogsBinding dialogLogsBinding = DialogLogsBinding.inflate(layoutInflater);

dialogLogsBinding.logsTextView.setText(log);

setTitle(R.string.log_dialog_title);
setView(dialogLogsBinding.getRoot());
setMessage(log);
setNegativeButton(R.string.cancel, null);
}

Expand Down
28 changes: 28 additions & 0 deletions app/src/main/java/dev/patri9ck/a2ln/main/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Android 2 Linux Notifications - A way to display Android phone notifications on Linux
* Copyright (C) 2024 patri9ck and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package dev.patri9ck.a2ln.main;

import com.google.android.material.color.DynamicColors;

public class Application extends android.app.Application {
@Override
public void onCreate() {
super.onCreate();
DynamicColors.applyToActivitiesIfAvailable(this);
}
}
12 changes: 5 additions & 7 deletions app/src/main/java/dev/patri9ck/a2ln/main/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.view.WindowCompat;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.AppBarConfiguration;
Expand All @@ -38,7 +39,6 @@

import dev.patri9ck.a2ln.R;
import dev.patri9ck.a2ln.databinding.ActivityMainBinding;
import dev.patri9ck.a2ln.databinding.DialogPermissionRequestBinding;

public class MainActivity extends AppCompatActivity {

Expand All @@ -50,12 +50,15 @@ protected void onCreate(Bundle savedInstanceState) {

activityMainBinding = ActivityMainBinding.inflate(getLayoutInflater());

setSupportActionBar(activityMainBinding.topAppBar);
setContentView(activityMainBinding.getRoot());

generateKeys();
loadNavigationBar();
requestPermission();
createNotificationChannel();

WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
}

private void generateKeys() {
Expand Down Expand Up @@ -91,14 +94,9 @@ private void requestPermission() {
if (NotificationManagerCompat.getEnabledListenerPackages(this).contains(getPackageName())) {
return;
}

DialogPermissionRequestBinding dialogPermissionRequestBinding = DialogPermissionRequestBinding.inflate(getLayoutInflater());

dialogPermissionRequestBinding.permissionRequestTextView.setText(R.string.permission_request_dialog_listener_information);

new MaterialAlertDialogBuilder(this, R.style.Dialog)
.setTitle(R.string.permission_request_dialog_title)
.setView(dialogPermissionRequestBinding.getRoot())
.setMessage(R.string.permission_request_dialog_listener_information)
.setPositiveButton(R.string.grant, (requestPermissionDialog, which) -> startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)))
.setNegativeButton(R.string.cancel, null)
.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@

import dev.patri9ck.a2ln.BuildConfig;
import dev.patri9ck.a2ln.R;
import dev.patri9ck.a2ln.databinding.DialogPermissionRequestBinding;
import dev.patri9ck.a2ln.databinding.FragmentSettingsBinding;
import dev.patri9ck.a2ln.log.LogDialogBuilder;
import dev.patri9ck.a2ln.notification.NotificationSender;
Expand Down Expand Up @@ -236,13 +235,9 @@ private void sendNotification() {
}

if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
DialogPermissionRequestBinding dialogPermissionRequestBinding = DialogPermissionRequestBinding.inflate(getLayoutInflater());

dialogPermissionRequestBinding.permissionRequestTextView.setText(R.string.permission_request_dialog_notification_information);

new MaterialAlertDialogBuilder(requireContext(), R.style.Dialog)
.setTitle(R.string.permission_request_dialog_title)
.setView(dialogPermissionRequestBinding.getRoot())
.setMessage(R.string.permission_request_dialog_notification_information)
.setPositiveButton(R.string.grant, (requestPermissionDialog, which) -> launcher.launch(Manifest.permission.POST_NOTIFICATIONS))
.setNegativeButton(R.string.cancel, (requestPermissionDialog, which) -> sendNotificationDirectly())
.show();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_apps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zM18,16v-5c0,-3.07 -1.63,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.64,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2zM16,17L8,17v-6c0,-2.48 1.51,-4.5 4,-4.5s4,2.02 4,4.5v6z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_pair.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/accent_text"
android:fillColor="@color/icon_color"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_permission.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M12,1L3,5v6c0,5.55 3.84,10.74 9,12 5.16,-1.26 9,-6.45 9,-12L21,5l-9,-4zM12,11.99h7c-0.53,4.12 -3.28,7.79 -7,8.94L12,12L5,12L5,6.3l7,-3.11v8.8z" />
</vector>
22 changes: 11 additions & 11 deletions app/src/main/res/drawable/ic_qr_code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,36 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M3,11h8V3H3V11zM5,5h4v4H5V5z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M3,21h8v-8H3V21zM5,15h4v4H5V15z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M13,3v8h8V3H13zM19,9h-4V5h4V9z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M19,19h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M13,13h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M15,15h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M13,17h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M15,19h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M17,17h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M17,13h2v2h-2z" />
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M19,15h2v2h-2z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_servers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M20,18c1.1,0 1.99,-0.9 1.99,-2L22,6c0,-1.1 -0.9,-2 -2,-2H4c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2H0v2h24v-2h-4zM4,6h16v10H4V6z" />
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/text"
android:fillColor="@color/icon_color"
android:pathData="M19.14,12.94c0.04,-0.3 0.06,-0.61 0.06,-0.94c0,-0.32 -0.02,-0.64 -0.07,-0.94l2.03,-1.58c0.18,-0.14 0.23,-0.41 0.12,-0.61l-1.92,-3.32c-0.12,-0.22 -0.37,-0.29 -0.59,-0.22l-2.39,0.96c-0.5,-0.38 -1.03,-0.7 -1.62,-0.94L14.4,2.81c-0.04,-0.24 -0.24,-0.41 -0.48,-0.41h-3.84c-0.24,0 -0.43,0.17 -0.47,0.41L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33c-0.22,-0.08 -0.47,0 -0.59,0.22L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48l2.03,1.58C4.84,11.36 4.8,11.69 4.8,12s0.02,0.64 0.07,0.94l-2.03,1.58c-0.18,0.14 -0.23,0.41 -0.12,0.61l1.92,3.32c0.12,0.22 0.37,0.29 0.59,0.22l2.39,-0.96c0.5,0.38 1.03,0.7 1.62,0.94l0.36,2.54c0.05,0.24 0.24,0.41 0.48,0.41h3.84c0.24,0 0.44,-0.17 0.47,-0.41l0.36,-2.54c0.59,-0.24 1.13,-0.56 1.62,-0.94l2.39,0.96c0.22,0.08 0.47,0 0.59,-0.22l1.92,-3.32c0.12,-0.22 0.07,-0.47 -0.12,-0.61L19.14,12.94zM12,15.6c-1.98,0 -3.6,-1.62 -3.6,-3.6s1.62,-3.6 3.6,-3.6s3.6,1.62 3.6,3.6S13.98,15.6 12,15.6z"
tools:ignore="VectorPath" />
</vector>
14 changes: 13 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
android:layout_height="match_parent"
android:orientation="vertical">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/top_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/app_name" />

</com.google.android.material.appbar.AppBarLayout>

<androidx.fragment.app.FragmentContainerView
android:id="@+id/main_fragment_container_view"
android:name="androidx.navigation.fragment.NavHostFragment"
Expand All @@ -33,7 +46,6 @@

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/main_bottom_navigation_view"
style="@style/BottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
Expand Down
64 changes: 41 additions & 23 deletions app/src/main/res/layout/dialog_edit_server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,51 @@
android:orientation="vertical"
android:padding="@dimen/dialog_space">

<EditText
android:id="@+id/edit_server_ip_edit_text"
style="@style/EditText"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dialog_space"
android:digits="0123456789."
android:hint="@string/ip"
android:importantForAutofill="no"
android:inputType="number" />

<EditText
android:id="@+id/edit_server_port_edit_text"
style="@style/EditText"
style="@style/TextInput">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_server_ip_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dialog_space"
android:digits="0123456789."
android:hint="@string/ip"
android:importantForAutofill="no"
android:inputType="number" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dialog_space"
android:hint="@string/port"
android:importantForAutofill="no"
android:inputType="number" />

<EditText
android:id="@+id/edit_server_alias_edit_text"
style="@style/EditText"
style="@style/TextInput">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_server_port_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dialog_space"
android:hint="@string/port"
android:importantForAutofill="no"
android:inputType="number" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/alias"
android:importantForAutofill="no"
android:inputType="textAutoCorrect" />
style="@style/TextInput">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_server_alias_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/alias"
android:importantForAutofill="no"
android:inputType="number" />

</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
23 changes: 0 additions & 23 deletions app/src/main/res/layout/dialog_logs.xml

This file was deleted.

Loading

0 comments on commit c5f7c1a

Please sign in to comment.