reset hinzugefügt

weitere texte in strings verwandelt
This commit is contained in:
JG-Cody 2021-06-02 17:15:16 +02:00
parent c7201049c5
commit 316a04df19
18 changed files with 93 additions and 73 deletions

View File

@ -45,7 +45,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.0.1' implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.0.1'
} }
repositories { repositories {
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
} }

View File

@ -12,9 +12,12 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Teraplex"> android:theme="@style/Theme.Teraplex">
<activity <activity
android:screenOrientation="sensorPortrait"
android:resizeableActivity="false"
android:name=".IntroActivity" android:name=".IntroActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.Teraplex.NoActionBar"> android:theme="@style/Theme.Teraplex.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -22,6 +25,8 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:screenOrientation="sensorPortrait"
android:resizeableActivity="false"
android:name=".MainActivity" android:name=".MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.Teraplex.NoActionBar"> android:theme="@style/Theme.Teraplex.NoActionBar">

View File

@ -1,6 +1,8 @@
package de.jg_cody.Teraplex; package de.jg_cody.Teraplex;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -50,8 +52,8 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
.commit(); .commit();
NonDeveloperMessage.maybeShow(this);*/ NonDeveloperMessage.maybeShow(this);*/
} }
SharedPreferences p = getSharedPreferences("SETTINGS", Activity.MODE_PRIVATE); SharedPreferences p = getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Language = p.getString("My_Lang", ""); String Language = p.getString("Language", "");
Locale locale = new Locale(Language); Locale locale = new Locale(Language);
Locale.setDefault(locale); Locale.setDefault(locale);
Configuration config = new Configuration(); Configuration config = new Configuration();
@ -66,15 +68,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
addfab.setOnClickListener(new View.OnClickListener() { addfab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
openDialog1(); showChooseElement();
}
});
FloatingActionButton removefab = findViewById(R.id.removebutton_fab);
removefab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openDialog2();
} }
}); });
@ -201,5 +195,25 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
finishAndRemoveTask(); finishAndRemoveTask();
} }
} }
private void showChooseElement() {
final String[] listItems = {"SINGLE BUTTON", "DOUBLE BUTTON", "OPTION3"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
mBuilder.setTitle("CHOOSE ELEMENT");
mBuilder.setSingleChoiceItems(listItems, -5, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) {
openDialog1();
} else if (i == 1) {
openDialog2();
} else if (i == 2) {
}
dialogInterface.dismiss();
}
});
AlertDialog mDialog = mBuilder.create();
mDialog.show();
}
} }

View File

@ -1,11 +1,8 @@
package de.jg_cody.Teraplex.ui.Credits; package de.jg_cody.Teraplex.ui.Credits;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
public class CreditsViewModel extends ViewModel { public class CreditsViewModel extends ViewModel {
private MutableLiveData<String> mText;
} }

View File

@ -1,6 +1,7 @@
package de.jg_cody.Teraplex.ui.Einstellungen; package de.jg_cody.Teraplex.ui.Einstellungen;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -60,10 +61,41 @@ public class EinstellungenFragment extends Fragment {
} }
}); });
Button Reset = root.findViewById(R.id.button_reset);
Reset.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new AlertDialog.Builder(getContext())
.setTitle(R.string.reset_app)
.setMessage(R.string.are_you_sure_to_reset)
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE).edit().clear().commit();
startActivity(getActivity().getIntent());
getActivity().finish();
} catch (Exception e) {
}
// Continue with delete operation
}
})
// A null listener allows the button to dismiss the dialog and take no further action.
.setNegativeButton(android.R.string.no, null)
.show();
}
});
return root; return root;
} }
private void showChangeLanguageDialog() { private void showChangeLanguageDialog() {
final String[] listItems = {"GERMAN", "ENGLISCH", "KLINGONISCH"}; final String[] listItems = {"GERMAN", "ENGLISCH", "KLINGONISCH"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext()); AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext());
@ -97,8 +129,8 @@ public class EinstellungenFragment extends Fragment {
Configuration config = new Configuration(); Configuration config = new Configuration();
config.locale = locale; config.locale = locale;
getContext().getResources().updateConfiguration(config, getContext().getResources().getDisplayMetrics()); getContext().getResources().updateConfiguration(config, getContext().getResources().getDisplayMetrics());
SharedPreferences.Editor editor = getContext().getSharedPreferences("SETTINGS", MODE_PRIVATE).edit(); SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("My_Lang", lang); editor.putString("Language", lang);
editor.apply(); editor.apply();
} }
} }

View File

@ -1,11 +1,8 @@
package de.jg_cody.Teraplex.ui.Einstellungen; package de.jg_cody.Teraplex.ui.Einstellungen;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
public class EinstellungenViewModel extends ViewModel { public class EinstellungenViewModel extends ViewModel {
private MutableLiveData<String> mText;
} }

View File

@ -34,7 +34,7 @@ public class SchlafzimmerFragment extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
SharedPreferences prefs = getContext().getSharedPreferences("logindata", Context.MODE_PRIVATE); SharedPreferences prefs = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
user = prefs.getString("user", null); user = prefs.getString("user", null);
password = prefs.getString("password", null); password = prefs.getString("password", null);
ip = prefs.getString("ip", null); ip = prefs.getString("ip", null);

View File

@ -12,9 +12,7 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
@ -38,7 +36,7 @@ public class HomeFragment extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
SharedPreferences prefs = getContext().getSharedPreferences("logindata", Context.MODE_PRIVATE); SharedPreferences prefs = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
user = prefs.getString("user", null); user = prefs.getString("user", null);
password = prefs.getString("password", null); password = prefs.getString("password", null);
ip = prefs.getString("ip", null); ip = prefs.getString("ip", null);
@ -49,17 +47,10 @@ public class HomeFragment extends Fragment {
final TextView textView = root.findViewById(R.id.text_home); final TextView textView = root.findViewById(R.id.text_home);
final TextView login_data = root.findViewById(R.id.login_data); final TextView login_data = root.findViewById(R.id.login_data);
if (user == null || ip == null) { if (user == null || ip == null) {
login_data.setText("Please connect to your automationserver!"); login_data.setText(R.string.please_login);
} else { } else {
login_data.setText("Sie sind als " + user + " bei " + ip + " angemeldet!"); login_data.setText(getString(R.string.sie_sind_als_angemeldet).replace("{IP}", ip ).replace("{USERNAME}", user ));
} }
homeViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
textView.setText(s);
}
});
userInput = (EditText) root.findViewById(R.id.loginuserInput); userInput = (EditText) root.findViewById(R.id.loginuserInput);
passwordInput = (EditText) root.findViewById(R.id.loginpasswordInput); passwordInput = (EditText) root.findViewById(R.id.loginpasswordInput);
ipInput = (EditText) root.findViewById(R.id.ipInput); ipInput = (EditText) root.findViewById(R.id.ipInput);
@ -73,7 +64,7 @@ public class HomeFragment extends Fragment {
user = userInput.getText().toString(); user = userInput.getText().toString();
password = passwordInput.getText().toString(); password = passwordInput.getText().toString();
ip = ipInput.getText().toString(); ip = ipInput.getText().toString();
SharedPreferences p = getContext().getSharedPreferences("logindata", Context.MODE_PRIVATE); SharedPreferences p = getContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
p.edit().putString("user", user).putString("password", password).putString("ip", ip).apply(); p.edit().putString("user", user).putString("password", password).putString("ip", ip).apply();
Toast.makeText(getContext(), "Login-Daten gespeichert...", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Login-Daten gespeichert...", Toast.LENGTH_SHORT).show();
if (user == null || ip == null) { if (user == null || ip == null) {

View File

@ -1,20 +1,7 @@
package de.jg_cody.Teraplex.ui.home; package de.jg_cody.Teraplex.ui.home;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
public class HomeViewModel extends ViewModel { public class HomeViewModel extends ViewModel {
private MutableLiveData<String> mText;
public HomeViewModel() {
mText = new MutableLiveData<>();
mText.setValue("R.string.Welcome_to_your_HOMEAUTOMATION_APP");
}
public LiveData<String> getText() {
return mText;
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 MiB

View File

@ -36,16 +36,6 @@
android:hapticFeedbackEnabled="true" android:hapticFeedbackEnabled="true"
android:src="@drawable/add_black_24dp" /> android:src="@drawable/add_black_24dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/removebutton_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="140dp"
android:hapticFeedbackEnabled="true"
android:src="@drawable/add_black_24dp"/>
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"

View File

@ -130,7 +130,7 @@
app:layout_constraintTop_toBottomOf="@+id/background" /> app:layout_constraintTop_toBottomOf="@+id/background" />
<Button <Button
android:id="@+id/button_reset2" android:id="@+id/button_green"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="75dp" android:layout_marginStart="75dp"
@ -138,12 +138,12 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:text="@string/grün" android:text="@string/grün"
app:backgroundTint="#00FF0A" app:backgroundTint="#00FF0A"
app:layout_constraintEnd_toStartOf="@+id/button_reset3" app:layout_constraintEnd_toStartOf="@+id/button_yellow"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button_reset4" /> app:layout_constraintTop_toBottomOf="@+id/button_blue" />
<Button <Button
android:id="@+id/button_reset3" android:id="@+id/button_yellow"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
@ -153,11 +153,11 @@
android:textColor="#000000" android:textColor="#000000"
app:backgroundTint="#FFE500" app:backgroundTint="#FFE500"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button_reset2" app:layout_constraintStart_toEndOf="@+id/button_green"
app:layout_constraintTop_toBottomOf="@+id/button_reset6" /> app:layout_constraintTop_toBottomOf="@+id/button_red" />
<Button <Button
android:id="@+id/button_reset6" android:id="@+id/button_red"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="75dp" android:layout_marginEnd="75dp"
@ -165,18 +165,18 @@
android:text="@string/rot" android:text="@string/rot"
app:backgroundTint="#FF0000" app:backgroundTint="#FF0000"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button_reset4" app:layout_constraintStart_toEndOf="@+id/button_blue"
app:layout_constraintTop_toBottomOf="@+id/nightmode" /> app:layout_constraintTop_toBottomOf="@+id/nightmode" />
<Button <Button
android:id="@+id/button_reset4" android:id="@+id/button_blue"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="75dp" android:layout_marginStart="75dp"
android:layout_marginLeft="75dp" android:layout_marginLeft="75dp"
android:text="@string/blau" android:text="@string/blau"
app:backgroundTint="#008EFF" app:backgroundTint="#008EFF"
app:layout_constraintEnd_toStartOf="@+id/button_reset6" app:layout_constraintEnd_toStartOf="@+id/button_red"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nightmode" /> app:layout_constraintTop_toBottomOf="@+id/nightmode" />

View File

@ -25,6 +25,7 @@
android:layout_width="309dp" android:layout_width="309dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/Welcome_to_your_HOMEAUTOMATION_APP"
android:textAlignment="center" android:textAlignment="center"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="20sp" android:textSize="20sp"

View File

@ -97,9 +97,9 @@
<ImageView <ImageView
android:id="@+id/imageView2" android:id="@+id/imageView2"
android:layout_width="0dp" android:layout_width="209dp"
android:layout_height="0dp" android:layout_height="223dp"
android:src="@drawable/teraplex_sidebar" android:src="@drawable/spinning_logo"
app:layout_constraintBottom_toTopOf="@+id/textView6" app:layout_constraintBottom_toTopOf="@+id/textView6"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@ -43,7 +43,7 @@
android:textAlignment="center" android:textAlignment="center"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="20sp" android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/befehlInput" app:layout_constraintBottom_toTopOf="@+id/befehlInput2"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506" app:layout_constraintHorizontal_bias="0.506"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

Binary file not shown.

View File

@ -23,7 +23,7 @@
<string name="colorpicker">WÄHLE DEINE FARBE</string> <string name="colorpicker">WÄHLE DEINE FARBE</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="action_logout">AUSLOGGEN</string> <string name="action_logout">AUSLOGGEN</string>
<string name="Welcome_to_your_HOMEAUTOMATION_APP">Willkommen in ihrer Homeautomation-App</string> <string name="Welcome_to_your_HOMEAUTOMATION_APP">WILLKOMMEN BEI TERAPLEX</string>
<string name="login">EINLOGGEN</string> <string name="login">EINLOGGEN</string>
<string name="wlan">WLAN</string> <string name="wlan">WLAN</string>
<string name="kodi">KODI</string> <string name="kodi">KODI</string>
@ -49,4 +49,6 @@
<string name="button_zurücksetzen">ZURÜCKSETZEN</string> <string name="button_zurücksetzen">ZURÜCKSETZEN</string>
<string name="button_hintergrund_wählen">HINTERGRUND WÄHLEN</string> <string name="button_hintergrund_wählen">HINTERGRUND WÄHLEN</string>
<string name="ssh_remote">SSH-FERNBEDIENUNG</string> <string name="ssh_remote">SSH-FERNBEDIENUNG</string>
<string name="please_login">BITTE VERBINDE DICH MIT DEINEM SERVER</string>
<string name="sie_sind_als_angemeldet">DU BIST ALS {USERNAME} AUF {IP}</string>
</resources> </resources>

View File

@ -13,7 +13,7 @@
<string name="ssh_remote">SSH-REMOTE</string> <string name="ssh_remote">SSH-REMOTE</string>
//home //home
<string name="Welcome_to_your_HOMEAUTOMATION_APP">Welcome to your HOMEAUTOMATION-APP</string> <string name="Welcome_to_your_HOMEAUTOMATION_APP">WELCOME TO TERAPLEX</string>
<string name="login_ipadresse">IP-ADDRESS</string> <string name="login_ipadresse">IP-ADDRESS</string>
<string name="login_benutzername">USERNAME</string> <string name="login_benutzername">USERNAME</string>
<string name="login_passwort">PASSWORD</string> <string name="login_passwort">PASSWORD</string>
@ -22,6 +22,8 @@
<string name="kodi">KODI</string> <string name="kodi">KODI</string>
<string name="aus">OFF</string> <string name="aus">OFF</string>
<string name="an">ON</string> <string name="an">ON</string>
<string name="please_login">PLEASE CONNECT TO YOUR SERVER</string>
<string name="sie_sind_als_angemeldet">YOU ARE LOGGED IN ON {IP} AS {USERNAME}</string>
//konsole //konsole
<string name="konsole">CONSOLE</string> <string name="konsole">CONSOLE</string>
@ -47,6 +49,8 @@
<string name="rot">RED</string> <string name="rot">RED</string>
<string name="grün">GREEN</string> <string name="grün">GREEN</string>
<string name="gelb">YELLOW</string> <string name="gelb">YELLOW</string>
<string name="reset_app">RESET APP</string>
<string name="are_you_sure_to_reset">ARE YOU SURE YOU WANT TO RESET THE APP AND DELETE ALL YOUR SETTINGS?</string>
<string name="menu_home">HOME</string> <string name="menu_home">HOME</string>