mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-08 23:45:38 +02:00
make string resources to be customazibe via gradle only, no code
This commit is contained in:
parent
dfd6593017
commit
1516033955
@ -62,7 +62,11 @@ android {
|
||||
buildConfigField "String", "GIT_HASH_SHORT", "\"${getGitHashShort()}\""
|
||||
buildConfigField "boolean", "INTERNET_ACCESS", "false"
|
||||
resValue "string", "pebble_content_provider", "com.getpebble.android.provider"
|
||||
resValue "string", "app_name", "@string/application_name"
|
||||
resValue "string", "app_name", "@string/application_name_generic"
|
||||
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_generic"
|
||||
resValue "string", "about_activity_title", "@string/about_activity_title_generic"
|
||||
resValue "string", "about_description", "@string/about_description_generic"
|
||||
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_generic"
|
||||
}
|
||||
signingConfigs {
|
||||
nightly {
|
||||
@ -93,6 +97,10 @@ android {
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
resValue "string", "pebble_content_provider", "com.getpebble.android.provider"
|
||||
resValue "string", "app_name", "@string/application_name_main_nightly"
|
||||
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_main_nightly"
|
||||
resValue "string", "about_activity_title", "@string/about_activity_title_main_nightly"
|
||||
resValue "string", "about_description", "@string/about_description_main_nightly"
|
||||
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_main_nightly"
|
||||
debuggable true
|
||||
}
|
||||
nopebble {
|
||||
@ -107,6 +115,10 @@ android {
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
resValue "string", "pebble_content_provider", "com.getpebble.android.nopebble.provider"
|
||||
resValue "string", "app_name", "@string/application_name_main_nopebble"
|
||||
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_main_nopebble"
|
||||
resValue "string", "about_activity_title", "@string/about_activity_title_main_nopebble"
|
||||
resValue "string", "about_description", "@string/about_description_main_nopebble"
|
||||
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_main_nopebble"
|
||||
debuggable true
|
||||
}
|
||||
|
||||
@ -144,6 +156,10 @@ android {
|
||||
// Disable pebble provider to allow Bangle.js Gadgetbridge to coexist with Gadgetbridge
|
||||
resValue "string", "pebble_content_provider", "com.getpebble.android.nopebble.provider"
|
||||
resValue "string", "app_name", "@string/application_name_banglejs_main"
|
||||
resValue "string", "title_activity_controlcenter", "@string/title_activity_controlcenter_banglejs_main"
|
||||
resValue "string", "about_activity_title", "@string/about_activity_title_banglejs_main"
|
||||
resValue "string", "about_description", "@string/about_description_banglejs_main"
|
||||
resValue "string", "gadgetbridge_running", "@string/gadgetbridge_running_banglejs_main"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1218,26 +1218,4 @@ 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) {
|
||||
// Since this class must not log to slf4j, we use plain android.util.Log
|
||||
Log.i(TAG, "Missing variation string: " + resString + "_" + variation);
|
||||
return getString(resIdNormal);
|
||||
} else {
|
||||
return getString(resIdVariation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,30 +20,17 @@ 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,8 +28,6 @@ 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,7 +151,6 @@ 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(GBApplication.app().getStringResourceByVariantName("gadgetbridge_running"), this));
|
||||
startForeground(GB.NOTIFICATION_ID, GB.createNotification(getString(R.string.gadgetbridge_running), this));
|
||||
mStarted = true;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
|
||||
<string name="application_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="application_name_generic">Gadgetbridge</string>
|
||||
<string name="title_activity_controlcenter_generic">Gadgetbridge</string>
|
||||
<string name="about_activity_title_generic">About Gadgetbridge</string>
|
||||
<string name="about_description_generic">Cloudless copylefted libre replacement for closed source Android gadget apps from vendors.</string>
|
||||
<string name="gadgetbridge_running_generic">Gadgetbridge running</string>
|
||||
|
||||
<string name="application_name_banglejs_main">Bangle.js Gadgetbridge</string>
|
||||
<string name="title_activity_controlcenter_banglejs_main">Bangle.js Gadgetbridge</string>
|
||||
|
Loading…
Reference in New Issue
Block a user