-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update example apps with custom aString
- Loading branch information
Showing
11 changed files
with
147 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<resources> | ||
|
||
<style name="AppTheme.NativeActionBar"> | ||
<item name="android:windowNoTitle">false</item> | ||
<item name="android:windowActionBar">true</item> | ||
<item name="android:actionBarTheme">@android:style/ThemeOverlay.Material.Dark.ActionBar</item> | ||
</style> | ||
|
||
<style name="DialogTheme"> | ||
<item name="android:windowActionBar">false</item> | ||
<item name="windowActionBar">false</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/shared/src/main/java/xyz/tynn/astring/app/shared/KotlinAString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2022 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring.app.shared; | ||
|
||
import static android.util.Log.w; | ||
import static xyz.tynn.astring.app.shared.KotlinAStringKt.kotlinAString; | ||
|
||
import android.content.Context; | ||
import android.os.Parcel; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import xyz.tynn.astring.AString; | ||
|
||
final class KotlinAString implements AString { | ||
|
||
@NonNull | ||
@Override | ||
public CharSequence invoke(@NonNull Context context) { | ||
try { | ||
return kotlinAString("Kotlin supported"); | ||
} catch (Throwable t) { | ||
w("KotlinAString", t); | ||
return "Java only"; | ||
} | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel dest, int flags) { | ||
} | ||
|
||
public static final Creator<KotlinAString> CREATOR = new Creator<KotlinAString>() { | ||
|
||
@Override | ||
public KotlinAString createFromParcel(Parcel source) { | ||
return new KotlinAString(); | ||
} | ||
|
||
@Override | ||
public KotlinAString[] newArray(int size) { | ||
return new KotlinAString[size]; | ||
} | ||
}; | ||
} |
45 changes: 45 additions & 0 deletions
45
app/shared/src/main/java/xyz/tynn/astring/app/shared/LocaleAString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2022 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring.app.shared; | ||
|
||
import static androidx.core.os.ConfigurationCompat.getLocales; | ||
|
||
import android.content.Context; | ||
import android.content.res.Configuration; | ||
import android.os.Parcel; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import java.util.Locale; | ||
|
||
import xyz.tynn.astring.AString; | ||
|
||
final class LocaleAString implements AString { | ||
|
||
@Nullable | ||
@Override | ||
public CharSequence invoke(@NonNull Context context) { | ||
Configuration configuration = context.getResources().getConfiguration(); | ||
Locale locale = getLocales(configuration).get(0); | ||
return locale == null ? null : locale.getDisplayName(locale); | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel dest, int flags) { | ||
} | ||
|
||
public static final Creator<LocaleAString> CREATOR = new Creator<LocaleAString>() { | ||
|
||
@Override | ||
public LocaleAString createFromParcel(Parcel source) { | ||
return new LocaleAString(); | ||
} | ||
|
||
@Override | ||
public LocaleAString[] newArray(int size) { | ||
return new LocaleAString[size]; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/shared/src/main/kotlin/xyz/tynn/astring/app/shared/KotlinAString.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2022 Christian Schmitz | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package xyz.tynn.astring.app.shared | ||
|
||
internal fun kotlinAString( | ||
message: String?, | ||
) = message!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters