mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 12:05:53 +01:00
provide app strings based on variants via code
This commit is contained in:
parent
367ad19205
commit
04a8d242c7
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="app_name">Bangle.js Gadgetbridge</string>
|
||||
<string name="title_activity_controlcenter">Bangle.js Gadgetbridge</string>
|
||||
<string name="about_activity_title">About Bangle.js Gadgetbridge</string>
|
||||
<string name="about_description">Android companion app for Bangle.js built on top of the Gadgetbridge project, with added Internet Access.</string>
|
||||
<string name="gadgetbridge_running">Bangle.js running</string>
|
||||
</resources>
|
@ -1218,4 +1218,25 @@ public class GBApplication extends Application {
|
||||
public void setAutoExportScheduledTimestamp(long autoExportScheduledTimestamp) {
|
||||
this.autoExportScheduledTimestamp = autoExportScheduledTimestamp;
|
||||
}
|
||||
/**
|
||||
* Provides either a string resource based on current variant
|
||||
* (main_debug, main_nightly...): "about_description_main_debug"
|
||||
* or just a universal string resource for "about_description"
|
||||
*
|
||||
* @param resString
|
||||
* @return string
|
||||
*/
|
||||
public String getStringResourceByVariantName(String resString) {
|
||||
String packageName = getPackageName();
|
||||
String variation = BuildConfig.FLAVOR + "_" + BuildConfig.BUILD_TYPE;
|
||||
int resIdVariation = getResources().getIdentifier(resString + "_" + variation, "string", packageName);
|
||||
int resIdNormal = getResources().getIdentifier(resString, "string", packageName);
|
||||
|
||||
if (resIdVariation == 0) {
|
||||
//LOG.warn("Missing variation string: " + aString + "_" + variation);
|
||||
return getString(resIdNormal);
|
||||
} else {
|
||||
return getString(resIdVariation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,17 +20,30 @@ package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
|
||||
public class AboutActivity extends AbstractGBActivity {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConfigureAlarms.class);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
TextView about_version = findViewById(R.id.about_version);
|
||||
TextView about_title = findViewById(R.id.about_title);
|
||||
TextView about_description = findViewById(R.id.about_description);
|
||||
|
||||
setTitle(GBApplication.app().getStringResourceByVariantName("about_activity_title"));
|
||||
about_title.setText(GBApplication.app().getStringResourceByVariantName("about_activity_title"));
|
||||
about_description.setText(GBApplication.app().getStringResourceByVariantName("about_description"));
|
||||
|
||||
TextView about_hash = findViewById(R.id.about_hash);
|
||||
String versionName = BuildConfig.VERSION_NAME;
|
||||
String versionHASH = BuildConfig.GIT_HASH_SHORT;
|
||||
|
@ -28,6 +28,8 @@ import java.util.Locale;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||
|
@ -151,6 +151,7 @@ public class ControlCenterv2 extends AppCompatActivity
|
||||
setContentView(R.layout.activity_controlcenterv2);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
setTitle(GBApplication.app().getStringResourceByVariantName("title_activity_controlcenter"));
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
|
@ -666,7 +666,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
private void start() {
|
||||
if (!mStarted) {
|
||||
GB.createNotificationChannels(this);
|
||||
startForeground(GB.NOTIFICATION_ID, GB.createNotification(getString(R.string.gadgetbridge_running), this));
|
||||
startForeground(GB.NOTIFICATION_ID, GB.createNotification(GBApplication.app().getStringResourceByVariantName("gadgetbridge_running"), this));
|
||||
mStarted = true;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
android:paddingRight="@dimen/about_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_desc"
|
||||
android:id="@+id/about_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_description" />
|
||||
|
@ -2,6 +2,28 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="app_name">Gadgetbridge</string>
|
||||
<string name="title_activity_controlcenter">Gadgetbridge</string>
|
||||
<string name="about_activity_title">About Gadgetbridge</string>
|
||||
<string name="about_description">Cloudless copylefted libre replacement for closed source Android gadget apps from vendors.</string>
|
||||
<string name="gadgetbridge_running">Gadgetbridge running</string>
|
||||
|
||||
<string name="app_name_main_banglejs">Bangle.js Gadgetbridge</string>
|
||||
<string name="title_activity_controlcenter_main_banglejs">Bangle.js Gadgetbridge</string>
|
||||
<string name="about_activity_title_main_banglejs">About Bangle.js Gadgetbridge</string>
|
||||
<string name="about_description_main_banglejs">Android companion app for Bangle.js built on top of the Gadgetbridge project, with added Internet Access.</string>
|
||||
<string name="gadgetbridge_running_main_banglejs">Bangle.js running</string>
|
||||
|
||||
<string name="app_name_main_nightly">Gadgetbridge (Nightly)</string>
|
||||
<string name="title_activity_controlcenter_main_nightly">Gadgetbridge Nightly</string>
|
||||
<string name="about_activity_title_main_nightly">About Gadgetbridge Nightly</string>
|
||||
<string name="about_description_main_nightly">Cloudless copylefted libre replacement for closed source Android gadget apps from vendors. Nightly releases of Gadgetbridge. It cannot be installed if you already have either the Gadgetbridge or the Pebble app installed, due to a conflict in the Pebble provider.</string>
|
||||
<string name="gadgetbridge_running_main_nightly">Nightly GB running</string>
|
||||
|
||||
<string name="app_name_main_nopebble">Gadgetbridge (Nightly, No Pebble provider)</string>
|
||||
<string name="title_activity_controlcenter_main_nopebble">Gadgetbridge Nightly No Pebble </string>
|
||||
<string name="about_activity_title_main_nopebble">About Gadgetbridge Nightly No Pebble</string>
|
||||
<string name="about_description_main_nopebble">Cloudless copylefted libre replacement for closed source Android gadget apps from vendors. Nightly releases of Gadgetbridge. This version has the Pebble provider renamed to prevent conflicts, so some Pebble related integrations will not work, but it can be installed alongside existing Gadgetbridge installation.</string>
|
||||
<string name="gadgetbridge_running_main_nopebble">Nightly NoPebble GB running</string>
|
||||
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="action_debug">Debug</string>
|
||||
<string name="action_quit">Quit</string>
|
||||
@ -368,7 +390,6 @@
|
||||
<string name="tap_connected_device_for_vibration">Tap connected device for vibration</string>
|
||||
<string name="tap_a_device_to_connect">Tap a device to connect</string>
|
||||
<string name="cannot_connect_bt_address_invalid_">Cannot connect. Bluetooth address invalid?</string>
|
||||
<string name="gadgetbridge_running">Gadgetbridge running</string>
|
||||
<string name="installing_binary_d_d">Installing binary %1$d/%2$d</string>
|
||||
<string name="installation_failed_">Installation failed</string>
|
||||
<string name="installation_successful">Installed</string>
|
||||
@ -1096,11 +1117,9 @@
|
||||
<string name="about_title">About</string>
|
||||
<string name="about_version">Version %s</string>
|
||||
<string name="about_hash">Commit %s</string>
|
||||
<string name="about_activity_title">About Gadgetbridge</string>
|
||||
<string name="gpx_receiver_activity_title">GPX Receiver Gadgetbridge</string>
|
||||
<string name="gpx_receiver_files_received">GPX file(s) received:</string>
|
||||
<string name="gpx_receiver_overwrite_some_files">Some file(s) already exist. Overwrite?</string>
|
||||
<string name="about_description">Cloudless copylefted libre replacement for closed source Android gadget apps from vendors.</string>
|
||||
<string name="about_core_team_title">Core Team (in order of first code contribution)</string>
|
||||
<string name="about_contributors">Contributors</string>
|
||||
<string name="about_core_team_members" translatable="false">Andreas Shimokawa\nCarsten Pfeiffer\nDaniele Gobbetti</string>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="app_name">Gadgetbridge (Nightly)</string>
|
||||
|
||||
</resources>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="app_name">Gadgetbridge (Nightly, No Pebble provider)</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user