DT @07.01.2016: Ein wenig refactoring
This commit is contained in:
@@ -39,8 +39,6 @@ import java.util.Map;
|
|||||||
public class LoginActivity extends AppCompatActivity implements FacebookButtonFragment.OnFragmentInteractionListener, GooglePlusButtonFragment.OnFragmentInteractionListener, TwitterButtonFragment.OnFragmentInteractionListener{
|
public class LoginActivity extends AppCompatActivity implements FacebookButtonFragment.OnFragmentInteractionListener, GooglePlusButtonFragment.OnFragmentInteractionListener, TwitterButtonFragment.OnFragmentInteractionListener{
|
||||||
|
|
||||||
private final static String TAG = LoginActivity.class.getSimpleName();
|
private final static String TAG = LoginActivity.class.getSimpleName();
|
||||||
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
|
||||||
private final static String mActivityTitle = "RiskAhead";
|
|
||||||
|
|
||||||
private String msg_intent;
|
private String msg_intent;
|
||||||
|
|
||||||
@@ -59,23 +57,30 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
|
|
||||||
session = new SessionManager(getApplicationContext());
|
session = new SessionManager(getApplicationContext());
|
||||||
|
|
||||||
pDialog = new ProgressDialog(this);
|
initProgressDialog();
|
||||||
pDialog.setMessage("Sending data...");
|
handleIntentAndInitView();
|
||||||
pDialog.setCancelable(false);
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
|
||||||
msg_intent = intent.getStringExtra(LoginActivity.EXTRA_MESSAGE);
|
|
||||||
|
|
||||||
if(msg_intent.equals("login")){
|
|
||||||
initLoginView();
|
|
||||||
}else if(msg_intent.equals("register")){
|
|
||||||
initRegisterView();
|
|
||||||
}
|
|
||||||
|
|
||||||
initSocialLoginButtons();
|
initSocialLoginButtons();
|
||||||
initMyLoginButton();
|
initMyLoginButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleIntentAndInitView() {
|
||||||
|
Intent intent = getIntent();
|
||||||
|
msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
|
||||||
|
|
||||||
|
if(msg_intent.equals(AppConfig.INTENT_NORMALLOGIN)){
|
||||||
|
initLoginView();
|
||||||
|
}else if(msg_intent.equals(AppConfig.INTENT_REGISTER)){
|
||||||
|
initRegisterView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initProgressDialog() {
|
||||||
|
pDialog = new ProgressDialog(this);
|
||||||
|
pDialog.setMessage(getString(R.string.progress_getdata_text));
|
||||||
|
pDialog.setCancelable(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void initLoginView() {
|
private void initLoginView() {
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
|
|
||||||
@@ -201,14 +206,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
LoginActivity.this,
|
LoginActivity.this,
|
||||||
MainActivity.class);
|
MainActivity.class);
|
||||||
intent.putExtra(EXTRA_MESSAGE, "Social Media Login");
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_SOCIALMEDIALOGIN);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
String tag_string_req = "sociallogin";
|
|
||||||
session.removeUser();
|
session.removeUser();
|
||||||
showDialog();
|
showDialog();
|
||||||
|
|
||||||
|
String tag_string_req = "sociallogin";
|
||||||
StringRequest strReq = getStringRequestSocialMediaLogin(key, providerType, username, email);
|
StringRequest strReq = getStringRequestSocialMediaLogin(key, providerType, username, email);
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
}
|
}
|
||||||
@@ -274,7 +280,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
LoginActivity.this,
|
LoginActivity.this,
|
||||||
MainActivity.class);
|
MainActivity.class);
|
||||||
intent.putExtra(EXTRA_MESSAGE, "Social Media Login");
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_SOCIALMEDIALOGIN);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
@@ -362,8 +368,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
.show();
|
.show();
|
||||||
}else {
|
}else {
|
||||||
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token);
|
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token);
|
||||||
|
|
||||||
session.setLogin(true);
|
session.setLogin(true);
|
||||||
|
|
||||||
hideDialog();
|
hideDialog();
|
||||||
|
|
||||||
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
|
||||||
@@ -422,7 +428,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
LoginActivity.this,
|
LoginActivity.this,
|
||||||
LoginActivity.class);
|
LoginActivity.class);
|
||||||
intent.putExtra(EXTRA_MESSAGE, "login");
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_NORMALLOGIN);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -500,7 +506,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
@Override
|
@Override
|
||||||
protected Map<String, String> getParams() {
|
protected Map<String, String> getParams() {
|
||||||
// Posting params to register url
|
// Posting params to register url
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("tag", "requestpwreset");
|
params.put("tag", "requestpwreset");
|
||||||
params.put("email", email);
|
params.put("email", email);
|
||||||
|
|
||||||
@@ -568,7 +574,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
if (pDialog.isShowing())
|
if (pDialog.isShowing())
|
||||||
pDialog.dismiss();
|
pDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_common, menu);
|
getMenuInflater().inflate(R.menu.menu_common, menu);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class MainActivity extends BaseActivity{
|
|||||||
|
|
||||||
private final static String mActivityTitle = "RiskAhead";
|
private final static String mActivityTitle = "RiskAhead";
|
||||||
private final static String TAG = MainActivity.class.getSimpleName();
|
private final static String TAG = MainActivity.class.getSimpleName();
|
||||||
|
|
||||||
public String msg_input;
|
public String msg_input;
|
||||||
|
|
||||||
public static FragmentManager fragmentManager;
|
public static FragmentManager fragmentManager;
|
||||||
|
|||||||
@@ -3,16 +3,17 @@ package org.deke.risk.riskahead;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import org.deke.risk.riskahead.helper.AppConfig;
|
||||||
import org.deke.risk.riskahead.helper.SessionManager;
|
import org.deke.risk.riskahead.helper.SessionManager;
|
||||||
|
|
||||||
public class StartActivity extends AppCompatActivity {
|
public class StartActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
|
||||||
private final static String TAG = StartActivity.class.getSimpleName();
|
private final static String TAG = StartActivity.class.getSimpleName();
|
||||||
|
|
||||||
Button btnLogin;
|
Button btnLogin;
|
||||||
@@ -22,6 +23,8 @@ public class StartActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
Log.d(TAG,"RiskAhead started.");
|
||||||
|
|
||||||
setContentView(R.layout.activity_start);
|
setContentView(R.layout.activity_start);
|
||||||
|
|
||||||
btnLogin = (Button) findViewById(R.id.btn_start_login);
|
btnLogin = (Button) findViewById(R.id.btn_start_login);
|
||||||
@@ -29,6 +32,7 @@ public class StartActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
SessionManager session = new SessionManager(getApplicationContext());
|
SessionManager session = new SessionManager(getApplicationContext());
|
||||||
if (session.isLoggedIn()) {
|
if (session.isLoggedIn()) {
|
||||||
|
Log.d(TAG,"User found in sharedPrefs and is therefore logged in. Continue to internal Area.");
|
||||||
Intent intent = new Intent(StartActivity.this, MainActivity.class);
|
Intent intent = new Intent(StartActivity.this, MainActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
@@ -37,13 +41,13 @@ public class StartActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void gotoLogin(View view) {
|
public void gotoLogin(View view) {
|
||||||
Intent intent = new Intent(this, LoginActivity.class);
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
intent.putExtra(EXTRA_MESSAGE, "login");
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_LOGIN);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gotoRegister(View view) {
|
public void gotoRegister(View view) {
|
||||||
Intent intent = new Intent(this, LoginActivity.class);
|
Intent intent = new Intent(this, LoginActivity.class);
|
||||||
intent.putExtra(EXTRA_MESSAGE, "register");
|
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_REGISTER);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +59,7 @@ public class StartActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int id = item.getItemId();
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,10 @@ public class AppConfig {
|
|||||||
public static String URL_ENCRYPTED = "https://www.riskahead.de/helper/rest/";
|
public static String URL_ENCRYPTED = "https://www.riskahead.de/helper/rest/";
|
||||||
|
|
||||||
public static String URL_DEFAULT = "http://www.riskahead.de/helper/rest/";
|
public static String URL_DEFAULT = "http://www.riskahead.de/helper/rest/";
|
||||||
|
|
||||||
|
public final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||||
|
public final static String INTENT_LOGIN = "login";
|
||||||
|
public final static String INTENT_REGISTER = "register";
|
||||||
|
public final static String INTENT_NORMALLOGIN = "normallogin";
|
||||||
|
public final static String INTENT_SOCIALMEDIALOGIN = "socialmedialogin";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user