Sprachauswahl funktioniert jetzt
This commit is contained in:
parent
e673ca3fb0
commit
ba63df8864
@ -1,53 +1,41 @@
|
||||
package de.jg_cody.Teraplex;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Menu;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import de.jg_cody.Teraplex.ui.Credits.CreditsFragment;
|
||||
import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment;
|
||||
import de.jg_cody.Teraplex.ui.Konsole.KonsoleFragment;
|
||||
import de.jg_cody.Teraplex.ui.home.HomeFragment;
|
||||
|
||||
import static java.security.AccessController.getContext;
|
||||
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements AddButtonDialog.AddButtonDialogListener {
|
||||
|
||||
@ -62,6 +50,14 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
.commit();
|
||||
NonDeveloperMessage.maybeShow(this);*/
|
||||
}
|
||||
SharedPreferences p = getSharedPreferences("SETTINGS", Activity.MODE_PRIVATE);
|
||||
String Language = p.getString("My_Lang", "");
|
||||
Locale locale = new Locale(Language);
|
||||
Locale.setDefault(locale);
|
||||
Configuration config = new Configuration();
|
||||
config.locale = locale;
|
||||
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
@ -73,6 +69,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
openDialog1();
|
||||
}
|
||||
});
|
||||
|
||||
FloatingActionButton removefab = findViewById(R.id.removebutton_fab);
|
||||
removefab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -106,6 +103,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*static public class DemoPreferenceFragment extends PreferenceFragmentCompat {
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
@ -159,6 +157,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
|
||||
AddButtonsDialog AddButtonsDialog = new AddButtonsDialog();
|
||||
AddButtonsDialog.show(getSupportFragmentManager(), "example dialog");
|
||||
}
|
||||
|
||||
public void openDialog2() {
|
||||
AddButtonDialog AddButtonDialog = new AddButtonDialog();
|
||||
AddButtonDialog.show(getSupportFragmentManager(), "example dialog");
|
||||
|
@ -2,6 +2,8 @@ package de.jg_cody.Teraplex.ui.Einstellungen;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -18,8 +20,12 @@ import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.rarepebble.colorpicker.ColorPickerView;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import de.jg_cody.Teraplex.R;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
public class EinstellungenFragment extends Fragment {
|
||||
|
||||
private EinstellungenViewModel einstellungenViewModel;
|
||||
@ -56,7 +62,53 @@ public class EinstellungenFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
});
|
||||
Button Language = root.findViewById(R.id.button_language);
|
||||
Language.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showChangeLanguageDialog();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
private void showChangeLanguageDialog() {
|
||||
final String[] listItems = {"GERMAN", "ENGLISCH", "KLINGONISCH"};
|
||||
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext());
|
||||
mBuilder.setTitle("CHOOSE LANGUAGE");
|
||||
mBuilder.setSingleChoiceItems(listItems, -5, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 0) {
|
||||
setLocale("de");
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
} else if (i == 1) {
|
||||
setLocale("en");
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
} else if (i == 2) {
|
||||
setLocale("tlh");
|
||||
startActivity(getActivity().getIntent());
|
||||
getActivity().finish();
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
AlertDialog mDialog = mBuilder.create();
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
private void setLocale(String lang) {
|
||||
Locale locale = new Locale(lang);
|
||||
Locale.setDefault(locale);
|
||||
Configuration config = new Configuration();
|
||||
config.locale = locale;
|
||||
getContext().getResources().updateConfiguration(config, getContext().getResources().getDisplayMetrics());
|
||||
SharedPreferences.Editor editor = getContext().getSharedPreferences("SETTINGS", MODE_PRIVATE).edit();
|
||||
editor.putString("My_Lang", lang);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
@ -15,10 +15,10 @@
|
||||
android:src="@drawable/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_einstellungen"
|
||||
@ -38,7 +38,7 @@
|
||||
android:id="@+id/background"
|
||||
android:layout_width="193dp"
|
||||
android:layout_height="33dp"
|
||||
android:layout_marginTop="100dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="HINTERGRUND"
|
||||
android:textAlignment="center"
|
||||
@ -66,12 +66,12 @@
|
||||
android:id="@+id/sprache"
|
||||
android:layout_width="193dp"
|
||||
android:layout_height="33dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="SPRACHE"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/reset_settings"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/background" />
|
||||
@ -80,15 +80,15 @@
|
||||
android:id="@+id/reset_settings"
|
||||
android:layout_width="225dp"
|
||||
android:layout_height="51dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="EINSTELLUNGEN ZURÜCKSETZEN"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="20dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/spSprachen" />
|
||||
app:layout_constraintTop_toTopOf="@+id/Background" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nightmode"
|
||||
@ -104,33 +104,6 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/button_reset" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spThemes"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@color/purple_200"
|
||||
android:entries="@array/theme_array"
|
||||
android:spinnerMode="dialog"
|
||||
android:textSize="20dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/colors" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spSprachen"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="35dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@color/purple_200"
|
||||
android:entries="@array/language_array"
|
||||
android:spinnerMode="dialog"
|
||||
android:textSize="20dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sprache" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_reset"
|
||||
android:layout_width="wrap_content"
|
||||
@ -148,13 +121,23 @@
|
||||
android:text="COLORPICKER"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/spThemes" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/colors" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_pickimage"
|
||||
android:id="@+id/button_language"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="SPRACHE"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sprache" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_pickimage2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="GRAFIK WÄHLEN"
|
||||
app:layout_constraintBottom_toTopOf="@+id/sprache"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
4
app/src/main/res/values-b+tlh/strings.xml
Normal file
4
app/src/main/res/values-b+tlh/strings.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Teraplex</string>
|
||||
</resources>
|
26
app/src/main/res/values-de-rDE/strings.xml
Normal file
26
app/src/main/res/values-de-rDE/strings.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Teraplex</string>
|
||||
<string name="navigation_drawer_open">NAVIGATION ÖFFNEN</string>
|
||||
<string name="navigation_drawer_close">NAVIGATION SCHLIESSEN</string>
|
||||
<string name="nav_header_title">ANDROID STUDIO</string>
|
||||
<string name="login_ipadresse">IP-ADRESSE</string>
|
||||
<string name="login_benutzername">BENUTZERNAME</string>
|
||||
<string name="login_passwort">PASSWORT</string>
|
||||
<string name="menu_home">HOME</string>
|
||||
<string name="menu_konsole">KONSOLE</string>
|
||||
<string name="menu_kueche">KÜCHE</string>
|
||||
<string name="menu_zeitsteuerung">AUSLOGGEN</string>
|
||||
<string name="menu_schlafzimmer">SCHLAFZIMMER</string>
|
||||
<string name="menu_flur">FLUR</string>
|
||||
<string name="menu_küche">KÜCHE</string>
|
||||
<string name="menu_einstellungen">EINSTELLUNG</string>
|
||||
<string name="menu_frage">FRAGE</string>
|
||||
<string name="menu_credits">CREDITS</string>
|
||||
<string name="menu_logout">AUSLOGGEN</string>
|
||||
<string name="menu_sprache">SPRACHE</string>
|
||||
<string name="menu_schliessen">SCHLIESSEN</string>
|
||||
<string name="colorpicker">WÄHLE DEINE FARBE</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="action_logout">AUSLOGGEN</string>
|
||||
</resources>
|
@ -11,26 +11,26 @@
|
||||
<string name="SSH_Command">Navigation header</string>
|
||||
<string name="action_logout">logout</string>
|
||||
|
||||
<string name="login_ipadresse">IP-ADRESSE</string>
|
||||
<string name="login_benutzername">BENUTZERNAME</string>
|
||||
<string name="login_passwort">PASSWORT</string>
|
||||
<string name="login_ipadresse">IP-ADDRESS</string>
|
||||
<string name="login_benutzername">USERNAME</string>
|
||||
<string name="login_passwort">PASSWORD</string>
|
||||
|
||||
<string name="menu_home">HOME</string>
|
||||
<string name="menu_konsole">KONSOLE</string>
|
||||
<string name="menu_kueche">KÜCHE</string>
|
||||
<string name="menu_zeitsteuerung">ZEITSTEUERUNG</string>
|
||||
<string name="menu_schlafzimmer">SCHLAFZIMMER</string>
|
||||
<string name="menu_flur">FLUR</string>
|
||||
<string name="menu_küche">KÜCHE</string>
|
||||
<string name="menu_konsole">CONSOLE</string>
|
||||
<string name="menu_kueche">KITCHEN</string>
|
||||
<string name="menu_zeitsteuerung">TIME-CONTROL</string>
|
||||
<string name="menu_schlafzimmer">BEDROOM</string>
|
||||
<string name="menu_flur">HALL</string>
|
||||
<string name="menu_küche">KITCHEN</string>
|
||||
|
||||
<string name="menu_einstellungen">EINSTELLUNGEN</string>
|
||||
<string name="menu_frage">FRAGE</string>
|
||||
<string name="menu_einstellungen">SETTINGS</string>
|
||||
<string name="menu_frage">QUESTION</string>
|
||||
<string name="menu_credits">CREDITS</string>
|
||||
<string name="menu_logout">LOGOUT</string>
|
||||
<string name="menu_sprache">SPRACHE</string>
|
||||
<string name="menu_schliessen">SCHLIESSEN</string>
|
||||
<string name="menu_sprache">LANGUAGE</string>
|
||||
<string name="menu_schliessen">CLOSE</string>
|
||||
|
||||
<string name="colorpicker">WÄHLE DEINE FARBE</string>
|
||||
<string name="colorpicker">CHOOSE YOUR COLOR</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
<string-array name="theme_array">
|
||||
|
Loading…
Reference in New Issue
Block a user