Skip to content

Commit 8914195

Browse files
authored
Merge pull request #9 from ISO53/london-font
Added Nothing font family and styling to app
2 parents d4bbc5b + c1cc31d commit 8914195

12 files changed

Lines changed: 194 additions & 109 deletions

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414
minSdk = 27
1515
targetSdk = 36
1616
versionCode = 1
17-
versionName = "1.0.0"
17+
versionName = "1.1.0"
1818

1919
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2020
}
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
package io.github.iso53.nothingcompass;
22

3+
import android.content.SharedPreferences;
4+
import android.graphics.Typeface;
35
import android.os.Bundle;
46
import android.widget.TextView;
57

68
import androidx.activity.EdgeToEdge;
79
import androidx.appcompat.app.AppCompatActivity;
8-
import androidx.core.graphics.Insets;
9-
import androidx.core.view.ViewCompat;
10-
import androidx.core.view.WindowInsetsCompat;
1110
import androidx.appcompat.app.AppCompatDelegate;
11+
import androidx.core.content.res.ResourcesCompat;
1212
import androidx.preference.PreferenceManager;
13-
import android.content.SharedPreferences;
13+
14+
import com.google.android.material.appbar.CollapsingToolbarLayout;
15+
1416
import io.github.iso53.nothingcompass.preference.PreferenceConstants;
1517

1618
public class AboutActivity extends AppCompatActivity {
@@ -26,15 +28,7 @@ protected void onCreate(Bundle savedInstanceState) {
2628
EdgeToEdge.enable(this);
2729
setContentView(R.layout.activity_about);
2830

29-
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.aboutToolbar), (v, insets) -> {
30-
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
31-
v.setPadding(systemBars.left, systemBars.top, systemBars.right, 0);
32-
return insets;
33-
});
34-
35-
findViewById(R.id.aboutToolbar).setOnClickListener(v -> finish());
36-
((androidx.appcompat.widget.Toolbar) findViewById(R.id.aboutToolbar))
37-
.setNavigationOnClickListener(v -> finish());
31+
setupToolbar();
3832

3933
TextView versionText = findViewById(R.id.textVersion);
4034
try {
@@ -45,4 +39,17 @@ protected void onCreate(Bundle savedInstanceState) {
4539
versionText.setText(getString(R.string.about_version, "1.0"));
4640
}
4741
}
42+
43+
private void setupToolbar() {
44+
// Add back button
45+
findViewById(R.id.aboutToolbar).setOnClickListener(v -> finish());
46+
((androidx.appcompat.widget.Toolbar) findViewById(R.id.aboutToolbar))
47+
.setNavigationOnClickListener(v -> finish());
48+
49+
// Change the font of the title
50+
CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapseToolbar);
51+
Typeface typeface = ResourcesCompat.getFont(this, R.font.ntype82headline);
52+
collapsingToolbar.setExpandedTitleTypeface(typeface);
53+
collapsingToolbar.setCollapsedTitleTypeface(typeface);
54+
}
4855
}

app/src/main/java/io/github/iso53/nothingcompass/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import androidx.activity.EdgeToEdge;
99
import androidx.annotation.NonNull;
1010
import androidx.appcompat.app.AppCompatActivity;
11+
import androidx.appcompat.app.AppCompatDelegate;
1112
import androidx.core.graphics.Insets;
1213
import androidx.core.view.ViewCompat;
1314
import androidx.core.view.WindowInsetsCompat;
1415
import androidx.fragment.app.Fragment;
15-
import androidx.appcompat.app.AppCompatDelegate;
1616
import androidx.preference.PreferenceManager;
1717
import androidx.viewpager2.adapter.FragmentStateAdapter;
1818
import androidx.viewpager2.widget.ViewPager2;

app/src/main/java/io/github/iso53/nothingcompass/OptionsActivity.java

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
import android.content.ActivityNotFoundException;
44
import android.content.Intent;
55
import android.content.SharedPreferences;
6+
import android.graphics.Typeface;
67
import android.net.Uri;
78
import android.os.Bundle;
89

910
import androidx.activity.EdgeToEdge;
1011
import androidx.appcompat.app.AppCompatActivity;
1112
import androidx.appcompat.app.AppCompatDelegate;
12-
import androidx.core.graphics.Insets;
13-
import androidx.core.view.ViewCompat;
14-
import androidx.core.view.WindowInsetsCompat;
13+
import androidx.core.content.res.ResourcesCompat;
1514
import androidx.preference.PreferenceManager;
1615
import androidx.recyclerview.widget.LinearLayoutManager;
1716
import androidx.recyclerview.widget.RecyclerView;
1817

1918
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
19+
import com.google.android.material.appbar.CollapsingToolbarLayout;
2020
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
2121

2222
import java.util.ArrayList;
@@ -40,29 +40,23 @@ protected void onCreate(Bundle savedInstanceState) {
4040
EdgeToEdge.enable(this);
4141
setContentView(R.layout.activity_options);
4242

43-
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.optionsToolbar),
44-
(v, insets) -> {
45-
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
46-
v.setPadding(systemBars.left, systemBars.top, systemBars.right, 0);
47-
return insets;
48-
});
49-
50-
// Handle bottom padding for RecyclerView to avoid navigation bar overlap
51-
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.optionsRecyclerView), (v,
52-
insets) -> {
53-
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
54-
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(),
55-
systemBars.bottom + v.getPaddingBottom());
56-
return insets;
57-
});
58-
59-
// Setup Toolbar
60-
findViewById(R.id.optionsToolbar).setOnClickListener(v -> finish());
61-
((androidx.appcompat.widget.Toolbar) findViewById(R.id.optionsToolbar)).setNavigationOnClickListener(v -> finish());
62-
43+
setupToolbar();
6344
setupRecyclerView();
6445
}
6546

47+
private void setupToolbar() {
48+
// Add back button
49+
findViewById(R.id.optionsToolbar).setOnClickListener(v -> finish());
50+
((androidx.appcompat.widget.Toolbar) findViewById(R.id.optionsToolbar))
51+
.setNavigationOnClickListener(v -> finish());
52+
53+
// Change the font of the title
54+
CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapseToolbar);
55+
Typeface typeface = ResourcesCompat.getFont(this, R.font.ntype82headline);
56+
collapsingToolbar.setExpandedTitleTypeface(typeface);
57+
collapsingToolbar.setCollapsedTitleTypeface(typeface);
58+
}
59+
6660
private void setupRecyclerView() {
6761
RecyclerView recyclerView = findViewById(R.id.optionsRecyclerView);
6862
recyclerView.setLayoutManager(new LinearLayoutManager(this));
@@ -114,26 +108,29 @@ private void showThemeSelectionDialog() {
114108
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
115109

116110
int checkedItem = 2; // Default to System
117-
if (currentTheme == AppCompatDelegate.MODE_NIGHT_NO) checkedItem = 0;
118-
else if (currentTheme == AppCompatDelegate.MODE_NIGHT_YES) checkedItem = 1;
119-
120-
new MaterialAlertDialogBuilder(this).setTitle(R.string.item_theme).setSingleChoiceItems(themes, checkedItem, (dialog, which) -> {
121-
int mode;
122-
switch (which) {
123-
case 0:
124-
mode = AppCompatDelegate.MODE_NIGHT_NO;
125-
break;
126-
case 1:
127-
mode = AppCompatDelegate.MODE_NIGHT_YES;
128-
break;
129-
default:
130-
mode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
131-
break;
132-
}
133-
prefs.edit().putInt(PreferenceConstants.THEME, mode).apply();
134-
AppCompatDelegate.setDefaultNightMode(mode);
135-
dialog.dismiss();
136-
}).show();
111+
if (currentTheme == AppCompatDelegate.MODE_NIGHT_NO)
112+
checkedItem = 0;
113+
else if (currentTheme == AppCompatDelegate.MODE_NIGHT_YES)
114+
checkedItem = 1;
115+
116+
new MaterialAlertDialogBuilder(this).setTitle(R.string.item_theme)
117+
.setSingleChoiceItems(themes, checkedItem, (dialog, which) -> {
118+
int mode;
119+
switch (which) {
120+
case 0:
121+
mode = AppCompatDelegate.MODE_NIGHT_NO;
122+
break;
123+
case 1:
124+
mode = AppCompatDelegate.MODE_NIGHT_YES;
125+
break;
126+
default:
127+
mode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
128+
break;
129+
}
130+
prefs.edit().putInt(PreferenceConstants.THEME, mode).apply();
131+
AppCompatDelegate.setDefaultNightMode(mode);
132+
dialog.dismiss();
133+
}).show();
137134
}
138135

139136
private void showHapticFeedbackSelectionDialog() {
@@ -145,11 +142,12 @@ private void showHapticFeedbackSelectionDialog() {
145142

146143
int checkedItem = currentHaptic ? 0 : 1;
147144

148-
new MaterialAlertDialogBuilder(this).setTitle(R.string.item_haptic_feedback).setSingleChoiceItems(options, checkedItem, (dialog, which) -> {
149-
boolean enabled = (which == 0);
150-
prefs.edit().putBoolean(PreferenceConstants.HAPTIC_FEEDBACK, enabled).apply();
151-
dialog.dismiss();
152-
}).show();
145+
new MaterialAlertDialogBuilder(this).setTitle(R.string.item_haptic_feedback)
146+
.setSingleChoiceItems(options, checkedItem, (dialog, which) -> {
147+
boolean enabled = (which == 0);
148+
prefs.edit().putBoolean(PreferenceConstants.HAPTIC_FEEDBACK, enabled).apply();
149+
dialog.dismiss();
150+
}).show();
153151
}
154152

155153
private void openPlayStore() {
@@ -184,7 +182,10 @@ private void sendFeedbackEmail() {
184182

185183
String deviceInfo = "\n\n\n------------------------------" + "\nDevice Diagnostics " +
186184
"(Please do not delete):" + "\nApp Version: " + appVersion + "\nAndroid Version: "
187-
+ android.os.Build.VERSION.RELEASE + " (SDK " + android.os.Build.VERSION.SDK_INT + ")" + "\nManufacturer: " + android.os.Build.MANUFACTURER + "\nModel: " + android.os.Build.MODEL + "\nProduct: " + android.os.Build.PRODUCT;
185+
+ android.os.Build.VERSION.RELEASE + " (SDK " + android.os.Build.VERSION.SDK_INT + ")"
186+
+ "\nManufacturer: " + android.os.Build.MANUFACTURER + "\nModel: "
187+
+ android.os.Build.MODEL
188+
+ "\nProduct: " + android.os.Build.PRODUCT;
188189

189190
Intent intent = new Intent(Intent.ACTION_SENDTO);
190191
intent.setData(Uri.parse("mailto:"));

app/src/main/java/io/github/iso53/nothingcompass/view/InclinometerView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Context;
44
import android.graphics.Canvas;
55
import android.graphics.Paint;
6-
import android.os.Build;
76
import android.os.VibrationEffect;
87
import android.os.Vibrator;
98
import android.util.AttributeSet;

app/src/main/java/io/github/iso53/nothingcompass/view/LevelMeterView.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
import android.graphics.Paint;
66
import android.graphics.PorterDuff;
77
import android.graphics.PorterDuffXfermode;
8-
import android.os.Build;
98
import android.os.VibrationEffect;
109
import android.os.Vibrator;
1110
import android.util.AttributeSet;
1211
import android.view.Gravity;
1312
import android.widget.FrameLayout;
1413
import android.widget.TextView;
1514

15+
import androidx.core.content.res.ResourcesCompat;
16+
1617
import com.google.android.material.R;
1718
import com.google.android.material.color.MaterialColors;
1819

@@ -88,6 +89,8 @@ private TextView initializeDegreeTextView(Context context) {
8889
textView.setTextSize(DEGREE_TEXT_SIZE_SP);
8990
textView.setText(" 0°");
9091
textView.setGravity(Gravity.CENTER);
92+
textView.setTypeface(ResourcesCompat.getFont(context,
93+
io.github.iso53.nothingcompass.R.font.ndot57));
9194
return textView;
9295
}
9396

@@ -241,7 +244,8 @@ private void updateOrientation() {
241244
// Determine if the rotating line is closer to horizontal or vertical
242245
// The line orientation switches every 90 degrees
243246
float normalizedAngle = normalizeAngle(spin, 180f);
244-
isHorizontal = normalizedAngle < ORIENTATION_THRESHOLD || normalizedAngle > (180f - ORIENTATION_THRESHOLD);
247+
isHorizontal =
248+
normalizedAngle < ORIENTATION_THRESHOLD || normalizedAngle > (180f - ORIENTATION_THRESHOLD);
245249
}
246250

247251
private void updateDegreeDisplay() {

app/src/main/res/font/ndot57.otf

14.7 KB
Binary file not shown.
31 KB
Binary file not shown.
30.8 KB
Binary file not shown.

app/src/main/res/layout/activity_about.xml

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,70 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
77
android:background="?android:attr/colorBackground"
88
tools:context=".AboutActivity">
99

10-
<com.google.android.material.appbar.MaterialToolbar
11-
android:id="@+id/aboutToolbar"
10+
<!-- AppBar with collapsing toolbar -->
11+
<com.google.android.material.appbar.AppBarLayout
12+
android:id="@+id/appBar"
1213
android:layout_width="match_parent"
1314
android:layout_height="wrap_content"
1415
android:background="?android:attr/colorBackground"
15-
android:elevation="0dp"
16-
app:layout_constraintTop_toTopOf="parent"
17-
app:navigationIcon="@drawable/ic_back"
18-
app:title="@string/about_title"
19-
app:titleTextAppearance="@style/TextAppearance.Material3.TitleLarge" />
16+
android:fitsSystemWindows="true"
17+
app:liftOnScrollColor="?android:attr/colorBackground">
2018

19+
<com.google.android.material.appbar.CollapsingToolbarLayout
20+
android:id="@+id/collapseToolbar"
21+
android:layout_width="match_parent"
22+
android:layout_height="112dp"
23+
app:collapsedTitleTextAppearance="@style/TextAppearance.Material3.TitleLarge"
24+
app:collapsedTitleTextColor="?android:attr/textColorPrimary"
25+
app:contentScrim="?android:attr/colorBackground"
26+
app:expandedTitleMarginBottom="16dp"
27+
app:expandedTitleMarginStart="24dp"
28+
app:expandedTitleTextAppearance="@style/TextAppearance.Material3.HeadlineLarge"
29+
app:expandedTitleTextColor="?android:attr/textColorPrimary"
30+
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
31+
app:title="@string/about_title"
32+
app:titleEnabled="true">
33+
34+
<!-- Transparent background for the expanded state -->
35+
<View
36+
android:layout_width="match_parent"
37+
android:layout_height="match_parent"
38+
android:background="@android:color/transparent"
39+
app:layout_collapseMode="parallax" />
40+
41+
<com.google.android.material.appbar.MaterialToolbar
42+
android:id="@+id/aboutToolbar"
43+
android:layout_width="match_parent"
44+
android:layout_height="?attr/actionBarSize"
45+
android:background="@android:color/transparent"
46+
android:elevation="0dp"
47+
app:layout_collapseMode="pin"
48+
app:navigationIcon="@drawable/ic_back" />
49+
50+
</com.google.android.material.appbar.CollapsingToolbarLayout>
51+
52+
</com.google.android.material.appbar.AppBarLayout>
53+
54+
<!-- Main scrolling content -->
2155
<androidx.core.widget.NestedScrollView
56+
android:id="@+id/scrollView"
2257
android:layout_width="match_parent"
23-
android:layout_height="0dp"
24-
app:layout_constraintBottom_toTopOf="@id/textDisclaimer"
25-
app:layout_constraintTop_toBottomOf="@id/aboutToolbar">
58+
android:layout_height="match_parent"
59+
app:layout_behavior="@string/appbar_scrolling_view_behavior">
2660

2761
<LinearLayout
2862
android:layout_width="match_parent"
2963
android:layout_height="wrap_content"
3064
android:gravity="center_horizontal"
3165
android:orientation="vertical"
32-
android:padding="24dp">
66+
android:padding="24dp"
67+
android:paddingBottom="80dp">
3368

3469
<com.google.android.material.card.MaterialCardView
3570
android:layout_width="120dp"
@@ -87,18 +122,17 @@
87122
android:text="@string/about_developed_by"
88123
android:textColor="?android:attr/textColorSecondary" />
89124

125+
<TextView
126+
android:id="@+id/textDisclaimer"
127+
style="@style/TextAppearance.Material3.LabelSmall"
128+
android:layout_width="match_parent"
129+
android:layout_height="wrap_content"
130+
android:layout_marginTop="32dp"
131+
android:gravity="center"
132+
android:text="@string/about_legal_disclaimer"
133+
android:textColor="?android:attr/textColorSecondary" />
134+
90135
</LinearLayout>
91136
</androidx.core.widget.NestedScrollView>
92137

93-
<TextView
94-
android:id="@+id/textDisclaimer"
95-
style="@style/TextAppearance.Material3.LabelSmall"
96-
android:layout_width="match_parent"
97-
android:layout_height="wrap_content"
98-
android:gravity="center"
99-
android:padding="24dp"
100-
android:text="@string/about_legal_disclaimer"
101-
android:textColor="?android:attr/textColorSecondary"
102-
app:layout_constraintBottom_toBottomOf="parent" />
103-
104-
</androidx.constraintlayout.widget.ConstraintLayout>
138+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)