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'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.0.1'
}
}
repositories {
maven { url "https://jitpack.io" }
}

View File

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

View File

@ -1,6 +1,8 @@
package de.jg_cody.Teraplex;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@ -50,8 +52,8 @@ 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", "");
SharedPreferences p = getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Language = p.getString("Language", "");
Locale locale = new Locale(Language);
Locale.setDefault(locale);
Configuration config = new Configuration();
@ -66,15 +68,7 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
addfab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openDialog1();
}
});
FloatingActionButton removefab = findViewById(R.id.removebutton_fab);
removefab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openDialog2();
showChooseElement();
}
});
@ -201,5 +195,25 @@ public class MainActivity extends AppCompatActivity implements AddButtonDialog.A
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;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class CreditsViewModel extends ViewModel {
private MutableLiveData<String> mText;
}

View File

@ -1,6 +1,7 @@
package de.jg_cody.Teraplex.ui.Einstellungen;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
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;
}
private void showChangeLanguageDialog() {
final String[] listItems = {"GERMAN", "ENGLISCH", "KLINGONISCH"};
AlertDialog.Builder mBuilder = new AlertDialog.Builder(getContext());
@ -97,8 +129,8 @@ public class EinstellungenFragment extends Fragment {
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);
SharedPreferences.Editor editor = getContext().getSharedPreferences("appsettings", MODE_PRIVATE).edit();
editor.putString("Language", lang);
editor.apply();
}
}

View File

@ -1,11 +1,8 @@
package de.jg_cody.Teraplex.ui.Einstellungen;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.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,
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);
password = prefs.getString("password", null);
ip = prefs.getString("ip", null);

View File

@ -12,9 +12,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import de.jg_cody.Teraplex.R;
@ -38,7 +36,7 @@ public class HomeFragment extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater,
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);
password = prefs.getString("password", 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 login_data = root.findViewById(R.id.login_data);
if (user == null || ip == null) {
login_data.setText("Please connect to your automationserver!");
login_data.setText(R.string.please_login);
} 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);
passwordInput = (EditText) root.findViewById(R.id.loginpasswordInput);
ipInput = (EditText) root.findViewById(R.id.ipInput);
@ -73,7 +64,7 @@ public class HomeFragment extends Fragment {
user = userInput.getText().toString();
password = passwordInput.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();
Toast.makeText(getContext(), "Login-Daten gespeichert...", Toast.LENGTH_SHORT).show();
if (user == null || ip == null) {

View File

@ -1,20 +1,7 @@
package de.jg_cody.Teraplex.ui.home;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.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: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
android:id="@+id/toolbar"

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/befehlInput"
app:layout_constraintBottom_toTopOf="@+id/befehlInput2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.506"
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="ok">OK</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="wlan">WLAN</string>
<string name="kodi">KODI</string>
@ -49,4 +49,6 @@
<string name="button_zurücksetzen">ZURÜCKSETZEN</string>
<string name="button_hintergrund_wählen">HINTERGRUND WÄHLEN</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>

View File

@ -13,7 +13,7 @@
<string name="ssh_remote">SSH-REMOTE</string>
//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_benutzername">USERNAME</string>
<string name="login_passwort">PASSWORD</string>
@ -22,6 +22,8 @@
<string name="kodi">KODI</string>
<string name="aus">OFF</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
<string name="konsole">CONSOLE</string>
@ -47,6 +49,8 @@
<string name="rot">RED</string>
<string name="grün">GREEN</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>