-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAboutActivity.java
More file actions
55 lines (44 loc) · 2.1 KB
/
AboutActivity.java
File metadata and controls
55 lines (44 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package io.github.iso53.nothingcompass;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.content.res.ResourcesCompat;
import androidx.preference.PreferenceManager;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import io.github.iso53.nothingcompass.preference.PreferenceConstants;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Apply theme before super.onCreate
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
int themeMode = prefs.getInt(PreferenceConstants.THEME, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
AppCompatDelegate.setDefaultNightMode(themeMode);
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_about);
setupToolbar();
TextView versionText = findViewById(R.id.textVersion);
try {
String versionName = getPackageManager()
.getPackageInfo(getPackageName(), 0).versionName;
versionText.setText(getString(R.string.about_version, versionName));
} catch (Exception e) {
versionText.setText(getString(R.string.about_version, "1.0"));
}
}
private void setupToolbar() {
// Add back button
findViewById(R.id.aboutToolbar).setOnClickListener(v -> finish());
((androidx.appcompat.widget.Toolbar) findViewById(R.id.aboutToolbar))
.setNavigationOnClickListener(v -> finish());
// Change the font of the title
CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapseToolbar);
Typeface typeface = ResourcesCompat.getFont(this, R.font.ntype82headline);
collapsingToolbar.setExpandedTitleTypeface(typeface);
collapsingToolbar.setCollapsedTitleTypeface(typeface);
}
}