mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
6a84e4d897
Extend CI workflows (-> https://codeberg.org/gitnex/GitNex/issues/1099) 1. pull translations and push them again on every pull @mmarif this needs the secrets and `BOT_TOKEN` the code for this comes from tea4j-autodeploy 2. add a **template** for a check workflow which only does some static checks right now. It is disabled because it requires some investigation and discussion on how we should deal with these issues. The checks are currently (if we would enable it): 1. check code style and formatting according to the project file in `.idea/` 2. make sure every Java file has an `@author` annotation I would wait until you reviewed with enabling them because we have to reformat all the files which results in changes with a few thousand changed lines (tried this once). Closes https://codeberg.org/gitnex/GitNex/issues/141 Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1155 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
98 lines
3.2 KiB
Java
98 lines
3.2 KiB
Java
package org.mian.gitnex.activities;
|
|
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import org.mian.gitnex.R;
|
|
import org.mian.gitnex.databinding.ActivitySettingsTranslationBinding;
|
|
import org.mian.gitnex.fragments.SettingsFragment;
|
|
import org.mian.gitnex.helpers.AppUtil;
|
|
import org.mian.gitnex.helpers.Toasty;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Locale;
|
|
|
|
/**
|
|
* @author M M Arif
|
|
*/
|
|
|
|
public class SettingsTranslationActivity extends BaseActivity {
|
|
|
|
private View.OnClickListener onClickListener;
|
|
|
|
private static int langSelectedChoice = 0;
|
|
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
LinkedHashMap<String, String> langs = new LinkedHashMap<>();
|
|
langs.put("", getString(R.string.settingsLanguageSystem));
|
|
for(String langCode : getResources().getStringArray(R.array.languages)) {
|
|
langs.put(langCode, getLanguageDisplayName(langCode));
|
|
}
|
|
|
|
ActivitySettingsTranslationBinding activitySettingsTranslationBinding = ActivitySettingsTranslationBinding.inflate(getLayoutInflater());
|
|
setContentView(activitySettingsTranslationBinding.getRoot());
|
|
|
|
ImageView closeActivity = activitySettingsTranslationBinding.close;
|
|
|
|
initCloseListener();
|
|
closeActivity.setOnClickListener(onClickListener);
|
|
|
|
final TextView tvLanguageSelected = activitySettingsTranslationBinding.tvLanguageSelected; // setter for en, fr
|
|
TextView helpTranslate = activitySettingsTranslationBinding.helpTranslate;
|
|
|
|
LinearLayout langFrame = activitySettingsTranslationBinding.langFrame;
|
|
|
|
helpTranslate.setOnClickListener(v12 -> {
|
|
AppUtil.openUrlInBrowser(this, getResources().getString(R.string.crowdInLink));
|
|
});
|
|
|
|
langSelectedChoice = tinyDB.getInt("langId");
|
|
tvLanguageSelected.setText(langs.get(langs.keySet().toArray(new String[0])[langSelectedChoice]));
|
|
|
|
// language dialog
|
|
langFrame.setOnClickListener(view -> {
|
|
|
|
AlertDialog.Builder lBuilder = new AlertDialog.Builder(SettingsTranslationActivity.this);
|
|
|
|
lBuilder.setTitle(R.string.settingsLanguageSelectorDialogTitle);
|
|
lBuilder.setCancelable(langSelectedChoice != -1);
|
|
|
|
lBuilder.setSingleChoiceItems(langs.values().toArray(new String[0]), langSelectedChoice, (dialogInterface, i) -> {
|
|
|
|
String selectedLanguage = langs.keySet().toArray(new String[0])[i];
|
|
tinyDB.putInt("langId", i);
|
|
tinyDB.putString("locale", selectedLanguage);
|
|
|
|
SettingsFragment.refreshParent = true;
|
|
this.overridePendingTransition(0, 0);
|
|
dialogInterface.dismiss();
|
|
Toasty.success(appCtx, getResources().getString(R.string.settingsSave));
|
|
this.recreate();
|
|
});
|
|
|
|
lBuilder.setNeutralButton(getString(R.string.cancelButton), null);
|
|
|
|
AlertDialog lDialog = lBuilder.create();
|
|
lDialog.show();
|
|
});
|
|
}
|
|
|
|
private void initCloseListener() {
|
|
|
|
onClickListener = view -> finish();
|
|
}
|
|
|
|
private static String getLanguageDisplayName(String langCode) {
|
|
Locale english = new Locale("en");
|
|
Locale translated = new Locale(langCode);
|
|
return String.format("%s (%s)", translated.getDisplayName(translated), translated.getDisplayName(english));
|
|
}
|
|
|
|
}
|