Add GPLAY flavour

Badge + theme
master
Piotro 2023-07-10 17:19:44 +02:00
rodzic 6ac9be8a60
commit 0a857ef76f
8 zmienionych plików z 98 dodań i 5 usunięć

Wyświetl plik

@ -10,7 +10,7 @@
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.22" />
<option name="scale" value="0.2" />
</ProjectState>
</option>
</component>

Wyświetl plik

@ -28,8 +28,23 @@ android {
debuggable true
applicationIdSuffix ".debug"
buildConfigField("String", "VERSION_SUFF", "\"[beta-DEBUG]\"")
}
}
flavorDimensions "channel"
productFlavors {
dist {
dimension "channel"
buildConfigField("boolean", "GPLAY", "false")
}
gplay {
dimension "channel"
buildConfigField("boolean", "GPLAY", "true")
applicationIdSuffix ".paid"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

Wyświetl plik

@ -3,9 +3,11 @@ package eu.piotro.sondechaser;
import android.Manifest;
import android.app.AlertDialog;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.Menu;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.google.android.material.snackbar.Snackbar;
@ -38,7 +40,6 @@ public class MainActivity extends AppCompatActivity {
// TODO: Main activity get destroyed on task-switch.
// It probably should be there (but where?), we need further separation of tasks and UI (could help loading times also)
// It should be created in app constructor (notification about running in backgroud?) and non re-crated on UI crate!!!!
// main activy is destroyed and then recreated - kill all other threads on destroy
dataCollector = new DataCollector(this);
@ -61,8 +62,13 @@ public class MainActivity extends AppCompatActivity {
NavigationUI.setupWithNavController(navigationView, navController);
View headerView = navigationView.getHeaderView(0);
TextView navUsername = (TextView) headerView.findViewById(R.id.nav_version);
TextView navUsername = headerView.findViewById(R.id.nav_version);
FrameLayout nav_badge = headerView.findViewById(R.id.nav_badge);
navUsername.setText("v"+BuildConfig.VERSION_NAME + BuildConfig.VERSION_SUFF + " " + getString(R.string.nav_header_subtitle));
if(BuildConfig.GPLAY) {
nav_badge.setVisibility(View.VISIBLE);
setTheme(R.style.Theme_SondeChaser_GPLAY);
}
// Map configurations
Configuration.getInstance().setUserAgentValue(getApplicationContext().getPackageName());
@ -80,6 +86,14 @@ public class MainActivity extends AppCompatActivity {
dataCollectorThread.start();
}
@Override
public Resources.Theme getTheme() {
Resources.Theme theme = super.getTheme();
if(BuildConfig.GPLAY)
theme.applyStyle(R.style.Theme_SondeChaser_GPLAY, true);
return theme;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.

Wyświetl plik

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<solid android:color="#236761"/>
<corners android:radius="10dp"/>
</shape>

Wyświetl plik

@ -31,5 +31,30 @@
android:id="@+id/nav_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nav_header_subtitle" />
android:text="@string/nav_header_subtitle"
android:textSize="12dp" />
<FrameLayout
android:id="@+id/nav_badge"
android:layout_width="match_parent"
android:layout_height="23dp"
android:layout_marginTop="5px"
android:visibility="gone">
<ImageView
android:id="@+id/imageView16"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/badge_bg" />
<TextView
android:id="@+id/nav_badge_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="❤Google Play version. Thanks for support!"
android:textSize="12dp" />
</FrameLayout>
</LinearLayout>

Wyświetl plik

@ -13,4 +13,20 @@
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
<style name="Theme.SondeChaser.GPLAY" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/teal_200</item>
<item name="colorPrimaryVariant">@color/teal_200</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/purple_200</item>
<item name="colorSecondaryVariant">@color/purple_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

Wyświetl plik

@ -3,6 +3,6 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="nav_header_height">200dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>

Wyświetl plik

@ -14,6 +14,22 @@
<!-- Customize your theme here. -->
</style>
<style name="Theme.SondeChaser.GPLAY" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/teal_200</item>
<item name="colorPrimaryVariant">@color/teal_700</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/purple_500</item>
<item name="colorSecondaryVariant">@color/purple_700</item>
<item name="colorOnSecondary">@color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Theme.SondeChaser.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>