Skip to content

Commit

Permalink
AJCBKVP 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFlyingToasterman authored and MrFlyingToasterman committed Apr 27, 2016
1 parent d2a139e commit bd8d770
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.1"
versionName "1.2"
}
buildTypes {
release {
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/dmusiolik/ajcbk_vp/LoginActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dmusiolik.ajcbk_vp;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
Expand All @@ -11,17 +12,45 @@ public class LoginActivity extends AppCompatActivity {
public static int counter = 0;
public static String benutzer = null;
public static String passwort = null;
//public static final String myPref = "username";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

TextView loginbox = (TextView) findViewById(R.id.email);
TextView passbox = (TextView) findViewById(R.id.password);

if (getPreferenceValue("username").equals("TheDefaultValueIfNoValueFoundOfThisKey")) {
//Nichts Unternemen
}else{
loginbox.setText(getPreferenceValue("username"));
}

if (getPreferenceValue("password").equals("TheDefaultValueIfNoValueFoundOfThisKey")) {
//Nichts Unternemen
}else{
passbox.setText(getPreferenceValue("password"));
}
}

public static void anmeldungalt(View v) {

}

public String getPreferenceValue(String myPref) {
SharedPreferences sp = getSharedPreferences(myPref,0);
String str = sp.getString("myStore","TheDefaultValueIfNoValueFoundOfThisKey");
return str;
}

public void writeToPreference(String thePreference, String myPref) {
SharedPreferences.Editor editor = getSharedPreferences(myPref,0).edit();
editor.putString("myStore", thePreference);
editor.commit();
}

public void anmeldung(View view) {

TextView loginbox = (TextView) findViewById(R.id.email);
Expand Down Expand Up @@ -62,7 +91,9 @@ public void anmeldung(View view) {

//Benutzername und Passwort einlesen und weitergeben
benutzer = loginbox.getText().toString();
writeToPreference(benutzer, "username");
passwort = passbox.getText().toString();
writeToPreference(passwort, "password");

//Zweite Activity öffnen
Intent myIntent=new Intent(view.getContext(),MainActivity.class);
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@
android:layout_height="wrap_content"
android:text="Diese Woche"
android:id="@+id/radioButton"
android:checked="true" />
android:checked="true"
android:enabled="true" />

<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nächste Woche"
android:id="@+id/radioButton2"
android:checked="false" />
android:checked="false"
android:enabled="false" />
</RadioGroup>

</LinearLayout>
Expand Down

0 comments on commit bd8d770

Please sign in to comment.