Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
uses: actions/setup-java@v3
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: gradle

Expand Down
36 changes: 16 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 33
namespace = "com.hewgill.android.nzsldict"
compileSdk 36

defaultConfig {
applicationId "com.hewgill.android.nzsldict"
minSdkVersion 14
targetSdkVersion 33
minSdk 23
targetSdk 36
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionCode 47
versionName "47"
Expand All @@ -15,31 +16,26 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}

beta {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
versionNameSuffix "-beta"
}
}

dependencies {
implementation 'com.google.android.material:material:1.1.0'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.1.1'
androidTestImplementation 'androidx.test:core:1.6.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test:runner:1.6.2'
androidTestImplementation 'androidx.test:rules:1.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.6.1'
}
}

dependencies {
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.android.material:material:1.14.0'
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.1.1'
androidTestImplementation 'androidx.test:core:1.7.0'
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test:runner:1.7.0'
androidTestImplementation 'androidx.test:rules:1.7.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.7.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.7.0'
}

5 changes: 1 addition & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.hewgill.android.nzsldict"
android:installLocation="preferExternal">

<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -30,9 +29,7 @@
<activity
android:name=".WordActivity"
android:screenOrientation="portrait" />
<activity
android:name=".FavouritesActivity"
android:theme="@style/WindowedAppTheme" />
<activity android:name=".FavouritesActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void onCreate() {
.addInterceptor(new CalligraphyInterceptor(
new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Montserrat-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.setFontAttrId(io.github.inflationx.calligraphy3.R.attr.fontPath)
.build()))
.build());
}
Expand Down
41 changes: 33 additions & 8 deletions app/src/main/java/com/hewgill/android/nzsldict/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.hewgill.android.nzsldict;

import android.app.Activity;
import android.content.Context;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import android.content.Intent;
import android.view.MenuItem;
import android.view.View;

import io.github.inflationx.viewpump.ViewPumpContextWrapper;

Expand All @@ -20,19 +25,39 @@ protected void setupAppToolbar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
applySystemBarInsets(this);
}

/**
* Apps targeting API 35+ draw edge-to-edge. Push the toolbar below the status bar (so its
* background extends behind it) and keep the content clear of the navigation bar, display
* cutouts and the keyboard. Call after setContentView, for layouts that include R.layout.toolbar.
*/
static void applySystemBarInsets(Activity activity) {
View content = activity.findViewById(android.R.id.content);
View toolbar = activity.findViewById(R.id.app_toolbar);
int toolbarPaddingTop = toolbar.getPaddingTop();
ViewCompat.setOnApplyWindowInsetsListener(content, (view, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()
| WindowInsetsCompat.Type.displayCutout()
| WindowInsetsCompat.Type.ime());
view.setPadding(insets.left, 0, insets.right, insets.bottom);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbarPaddingTop + insets.top,
toolbar.getPaddingRight(), toolbar.getPaddingBottom());
return WindowInsetsCompat.CONSUMED;
});
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the toolbar's NavigationIcon as up/home button
case android.R.id.home:
finish();
return true;
case R.id.action_favourites:
startActivity(new Intent(this, FavouritesActivity.class));
break;
int itemId = item.getItemId();
// Respond to the toolbar's NavigationIcon as up/home button
if (itemId == android.R.id.home) {
finish();
return true;
} else if (itemId == R.id.action_favourites) {
startActivity(new Intent(this, FavouritesActivity.class));
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.net.NetworkInfo;
import android.widget.Toast;

import androidx.core.content.ContextCompat;

public class DownloadReceiver {
private DownloadCallback callback;

Expand Down Expand Up @@ -36,7 +38,8 @@ public void registerContext(Context context, DownloadCallback callback) {
IntentFilter filter = new IntentFilter();
filter.addAction(DownloadManager.ACTION_NOTIFICATION_CLICKED);
filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
context.registerReceiver(receiver, filter);
// DownloadManager sends these broadcasts from another app, so the receiver must be exported.
ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_EXPORTED);
}

public void unregisterContext(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class FavouritesActivity extends BaseActivity implements DictionaryAdapte
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setTitle("Favourites");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.activity_favourites);
setupAppToolbar();
getSupportActionBar().setTitle("Favourites");
mListView = (ListView) findViewById(R.id.favourites);
repo = new FavouritesRepository(this);
adapter = new DictionaryAdapter(R.layout.list_item, this, repo.all());
Expand Down Expand Up @@ -79,13 +79,11 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_favourites_clear:
clearFavourites();
break;
case R.id.action_favourites_download:
enqueueFavouritesDownload();
break;
int itemId = item.getItemId();
if (itemId == R.id.action_favourites_clear) {
clearFavourites();
} else if (itemId == R.id.action_favourites_download) {
enqueueFavouritesDownload();
}

invalidateOptionsMenu();
Expand Down
34 changes: 16 additions & 18 deletions app/src/main/java/com/hewgill/android/nzsldict/NZSLDictionary.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public void onCreate(Bundle savedInstanceState) {
mSearchResultsList.setOnItemClickListener(this);
mToolbar = (Toolbar) findViewById(R.id.app_toolbar);
setSupportActionBar(mToolbar);
BaseActivity.applySystemBarInsets(this);

View header = LayoutInflater.from(this).inflate(R.layout.handshape, null);
getListView().addHeaderView(header, null, false);
Expand Down Expand Up @@ -381,24 +382,21 @@ public boolean onPrepareOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this just a style thing...?

it's been years since I've written Java, but if this was working previously I'm not seeing a change to suggest why this is needed beyond style?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the original switch/case had no default case? So I think that makes the one on the right better? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R.id values used to be final, and are not final anymore, so without this we run into compiler issues since the expressions are dynamic

case R.id.action_search_mode_handshape:
filterText.setText("(handshape search)");
filterText.setEnabled(false);
filterTextContainer.setVisibility(View.GONE);
handshapeHeader.setVisibility(View.VISIBLE);
updateHandshapeList();
break;
case R.id.action_search_mode_keyword:
filterText.setText("");
filterText.setEnabled(true);
filterTextContainer.setVisibility(View.VISIBLE);
handshapeHeader.setVisibility(View.GONE);
adapter.getFilter().filter(null);
break;
case R.id.action_favourites:
startActivity(new Intent(this, FavouritesActivity.class));
break;
int itemId = item.getItemId();
if (itemId == R.id.action_search_mode_handshape) {
filterText.setText("(handshape search)");
filterText.setEnabled(false);
filterTextContainer.setVisibility(View.GONE);
handshapeHeader.setVisibility(View.VISIBLE);
updateHandshapeList();
} else if (itemId == R.id.action_search_mode_keyword) {
filterText.setText("");
filterText.setEnabled(true);
filterTextContainer.setVisibility(View.VISIBLE);
handshapeHeader.setVisibility(View.GONE);
adapter.getFilter().filter(null);
} else if (itemId == R.id.action_favourites) {
startActivity(new Intent(this, FavouritesActivity.class));
}

invalidateOptionsMenu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import androidx.core.content.ContextCompat;

public class NetworkManager {

protected boolean connected;
Expand All @@ -32,7 +34,7 @@ private void updateStatus(Context context) {
public void registerContext(Context context, NetworkCallback callback) {
this.callback = callback;
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
context.registerReceiver(receiver, filter);
ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED);
updateStatus(context);
}

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/activity_favourites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<androidx.appcompat.widget.Toolbar
android:id="@+id/app_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primary"
android:elevation="4dp"
app:titleTextColor="@android:color/white" />

<ListView
android:id="@+id/favourites"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ImageButton
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/action_favourite_item_download"
android:layout_width="24dp"
android:layout_height="24dp"
Expand All @@ -9,4 +10,4 @@
android:contentDescription="Download this sign"
android:src="@android:drawable/stat_sys_download"
android:background="@android:color/transparent"
android:tint="@color/accent" />
app:tint="@color/accent" />
22 changes: 0 additions & 22 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,4 @@
<item name="android:actionMenuTextColor">@android:color/white</item>
</style>

<style name="WindowedAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorControlNormal">@android:color/white</item>
<!-- darker variant for the status bar and contextual app bars -->
<!-- theme UI controls like checkboxes and text fields -->
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:actionBarStyle">@style/WindowedAppTheme.ActionBarStyle</item>
<item name="actionMenuTextColor">@android:color/white</item>
<item name="android:actionMenuTextColor">@android:color/white</item>
</style>

<style name="WindowedAppTheme.ActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/WindowedAppTheme.ActionBar.TitleTextStyle</item>
<item name="android:actionMenuTextColor">@android:color/white</item>
</style>


<style name="WindowedAppTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
</style>

</resources>
8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'com.android.tools.build:gradle:9.5.0'
}
}

allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}


1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
android.enableJetifier=true
android.useAndroidX=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 5 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading