Registration process implemented
This commit is contained in:
7
.idea/dictionaries/Sebastian.xml
generated
Normal file
7
.idea/dictionaries/Sebastian.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="Sebastian">
|
||||
<words>
|
||||
<w>postgrachelor</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -3,7 +3,7 @@
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="LOCAL" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" />
|
||||
<option name="modules">
|
||||
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -37,7 +37,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8 (2)" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -24,7 +24,9 @@ dependencies {
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
compile 'com.android.support:appcompat-v7:25.2.0'
|
||||
compile 'com.android.support:design:25.2.0'
|
||||
compile 'com.android.support:gridlayout-v7:25.3.0'
|
||||
compile 'com.android.support:appcompat-v7:25.3.0'
|
||||
compile 'com.android.support:design:25.3.0'
|
||||
compile 'com.android.support:support-v4:25.3.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.hwr_berlin.it14.postgrachelor">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
@@ -11,11 +13,14 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<data android:scheme="postgrachelor"
|
||||
android:host="postgrachelor" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.hwr_berlin.it14.postgrachelor.Exceptions;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 25.03.17.
|
||||
* Exception to indicate a not instantiated service
|
||||
*/
|
||||
|
||||
public class NotInstantiatedException extends Exception {
|
||||
private static final long serialVersionUID = 1997753363232807009L;
|
||||
|
||||
public NotInstantiatedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NotInstantiatedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NotInstantiatedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public NotInstantiatedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package de.hwr_berlin.it14.postgrachelor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import de.hwr_berlin.it14.postgrachelor.Exceptions.NotInstantiatedException;
|
||||
import de.hwr_berlin.it14.postgrachelor.Services.LoginService;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link LoginFragment.OnLoginFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link LoginFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class LoginFragment extends Fragment {
|
||||
public static final String NAME = "LOGIN_FRAGMENT";
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private OnLoginFragmentInteractionListener mListener;
|
||||
|
||||
public LoginFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment LoginFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static LoginFragment newInstance(String param1, String param2) {
|
||||
LoginFragment fragment = new LoginFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View layout = inflater.inflate(R.layout.fragment_login, container, false);
|
||||
Button login_btn = (Button) layout.findViewById(R.id.login_btn);
|
||||
final EditText login_edit = (EditText) layout.findViewById(R.id.login_edit);
|
||||
login_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.d(NAME, "Button click: "+login_edit.getText().toString());
|
||||
|
||||
try {
|
||||
LoginService.doLogin(login_edit.getText().toString());
|
||||
} catch (NotInstantiatedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onLoginFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnLoginFragmentInteractionListener) {
|
||||
mListener = (OnLoginFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnLoginFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented by activities that contain this
|
||||
* fragment to allow an interaction in this fragment to be communicated
|
||||
* to the activity and potentially other fragments contained in that
|
||||
* activity.
|
||||
* <p>
|
||||
* See the Android Training lesson <a href=
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
interface OnLoginFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onLoginFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package de.hwr_berlin.it14.postgrachelor;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.View;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
@@ -12,34 +14,109 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.hwr_berlin.it14.postgrachelor.Exceptions.NotInstantiatedException;
|
||||
import de.hwr_berlin.it14.postgrachelor.Services.LoginService;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
implements NavigationView.OnNavigationItemSelectedListener,
|
||||
MainFragment.OnMainFragmentInteractionListener,
|
||||
LoginFragment.OnLoginFragmentInteractionListener,
|
||||
QuestionEndFragment.OnQuestionEndFragmentInteractionListener,
|
||||
QuestionFragment.OnQuestionFragmentInteractionListener,
|
||||
QuestionStartFragment.OnQuestionStartFragmentInteractionListener {
|
||||
|
||||
FragmentManager myFragmentManager;
|
||||
MainFragment mainFragment;
|
||||
LoginFragment loginFragment;
|
||||
QuestionStartFragment questionStartFragment;
|
||||
QuestionEndFragment questionEndFragment;
|
||||
QuestionFragment questionFragment;
|
||||
boolean listenerAdded;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d("Activity fragment", "create");
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
/*FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.setDrawerListener(toggle);
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
// content
|
||||
myFragmentManager = getFragmentManager();
|
||||
mainFragment = MainFragment.newInstance("a", "b");
|
||||
loginFragment = LoginFragment.newInstance("a", "b");
|
||||
questionEndFragment = QuestionEndFragment.newInstance("a", "b");
|
||||
questionStartFragment = QuestionStartFragment.newInstance("a", "b");
|
||||
questionFragment = QuestionFragment.newInstance("a", "b");
|
||||
|
||||
/*Log.d("Activity fragment", "test2");
|
||||
JsonRequestPG requester = new JsonRequestPG("register.php", null, this, new JsonRequestPG.AsyncResponse() {
|
||||
@Override
|
||||
public void processFinish(JSONObject output) {
|
||||
Log.d("Activity fragment", "output");
|
||||
Log.d("Activity fragment", output.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processError(int status, String message) {
|
||||
Log.d("Activity fragment", "error");
|
||||
Log.d("Activity fragment", "status: "+status+" - message: "+message);
|
||||
}
|
||||
});
|
||||
requester.execute();*/
|
||||
|
||||
LoginService.instantiate(this);
|
||||
listenerAdded = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
final MainActivity that = this;
|
||||
if (!listenerAdded) {
|
||||
LoginService.addLoginEventListener(new LoginService.OnLoginEventListener() {
|
||||
@Override
|
||||
public void onLoginEvent(String name, String uid) {
|
||||
Log.d("Activity fragment", "onLogin - name: " + name + " - uid: " + uid);
|
||||
NavigationView nav_view = (NavigationView) that.findViewById(R.id.nav_view);
|
||||
TextView user_uid = (TextView) nav_view.getHeaderView(0).findViewById(R.id.user_uid);
|
||||
TextView user_name = (TextView) nav_view.getHeaderView(0).findViewById(R.id.user_name);
|
||||
Log.d("Activity fragment", "user_name "+user_name);
|
||||
Log.d("Activity fragment", "user_uid "+user_uid);
|
||||
Log.d("Activity fragment", "nav_view "+nav_view);
|
||||
user_name.setText(name);
|
||||
user_uid.setText(uid);
|
||||
that.onNavigationItemSelectedID(R.id.nav_gallery);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLogoutEvent(int status, String message) {
|
||||
Log.d("Activity fragment", "onLogout - name: " + status + " - uid: " + message);
|
||||
that.onNavigationItemSelectedID(R.id.nav_camera);
|
||||
}
|
||||
});
|
||||
listenerAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,28 +151,96 @@ public class MainActivity extends AppCompatActivity
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
return this.onNavigationItemSelectedID(item.getItemId());
|
||||
}
|
||||
|
||||
public boolean onNavigationItemSelectedID(int item) {
|
||||
Log.d("Activity fragment", "itemselect"+item);
|
||||
// Handle navigation view item clicks here.
|
||||
int id = item.getItemId();
|
||||
try {
|
||||
boolean isLoggedIn = LoginService.isLoggedIn();
|
||||
if (!isLoggedIn && (item != R.id.nav_camera)) {
|
||||
return false;
|
||||
} else if (isLoggedIn && (item == R.id.nav_camera)) {
|
||||
return false;
|
||||
}
|
||||
} catch (NotInstantiatedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (id == R.id.nav_camera) {
|
||||
if (item == R.id.nav_camera) {
|
||||
// Handle the camera action
|
||||
} else if (id == R.id.nav_gallery) {
|
||||
|
||||
} else if (id == R.id.nav_slideshow) {
|
||||
|
||||
} else if (id == R.id.nav_manage) {
|
||||
|
||||
} else if (id == R.id.nav_share) {
|
||||
|
||||
} else if (id == R.id.nav_send) {
|
||||
|
||||
LoginFragment fragment = (LoginFragment) myFragmentManager.findFragmentByTag(LoginFragment.NAME);
|
||||
if (fragment == null) {
|
||||
FragmentTransaction fragmentTransaction = myFragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.relative_content, loginFragment, LoginFragment.NAME);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
} else if (item == R.id.nav_gallery) {
|
||||
MainFragment fragment = (MainFragment) myFragmentManager.findFragmentByTag(MainFragment.NAME);
|
||||
if (fragment == null) {
|
||||
FragmentTransaction fragmentTransaction = myFragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.relative_content, mainFragment, MainFragment.NAME);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
} else if (item == R.id.nav_slideshow) {
|
||||
QuestionEndFragment fragment = (QuestionEndFragment) myFragmentManager.findFragmentByTag(QuestionEndFragment.NAME);
|
||||
if (fragment == null) {
|
||||
FragmentTransaction fragmentTransaction = myFragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.relative_content, questionEndFragment, QuestionEndFragment.NAME);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
} else if (item == R.id.nav_manage) {
|
||||
QuestionFragment fragment = (QuestionFragment) myFragmentManager.findFragmentByTag(QuestionFragment.NAME);
|
||||
if (fragment == null) {
|
||||
FragmentTransaction fragmentTransaction = myFragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.relative_content, questionFragment, QuestionFragment.NAME);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
} else if (item == R.id.nav_share) {
|
||||
QuestionStartFragment fragment = (QuestionStartFragment) myFragmentManager.findFragmentByTag(QuestionStartFragment.NAME);
|
||||
if (fragment == null) {
|
||||
FragmentTransaction fragmentTransaction = myFragmentManager.beginTransaction();
|
||||
fragmentTransaction.replace(R.id.relative_content, questionStartFragment, QuestionStartFragment.NAME);
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
NavigationView navigation = (NavigationView) drawer.findViewById(R.id.nav_view);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMainFragmentInteraction(Uri uri) {
|
||||
System.out.print("fragment message");
|
||||
System.out.print(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginFragmentInteraction(Uri uri) {
|
||||
System.out.print("fragment message login");
|
||||
System.out.print(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuestionEndFragmentInteraction(Uri uri) {
|
||||
System.out.print("fragment message question end");
|
||||
System.out.print(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuestionFragmentInteraction(Uri uri) {
|
||||
System.out.print("fragment message question");
|
||||
System.out.print(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQuestionStartFragmentInteraction(Uri uri) {
|
||||
System.out.print("fragment message question");
|
||||
System.out.print(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package de.hwr_berlin.it14.postgrachelor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.hwr_berlin.it14.postgrachelor.Services.LoginService;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link MainFragment.OnMainFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link MainFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class MainFragment extends Fragment {
|
||||
public static final String NAME = "MAIN_FRAGMENT";
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private boolean listener = false;
|
||||
private OnMainFragmentInteractionListener mListener;
|
||||
|
||||
public MainFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment MainFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static MainFragment newInstance(String param1, String param2) {
|
||||
MainFragment fragment = new MainFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
this.listener = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View view = inflater.inflate(R.layout.fragment_main, container, false);
|
||||
if (!this.listener) {
|
||||
LoginService.addLoginEventListener(new LoginService.OnLoginEventListener() {
|
||||
@Override
|
||||
public void onLoginEvent(String name, String uid) {
|
||||
TextView textView = (TextView) view.findViewById(R.id.fragment_main_status).findViewById(R.id.fragment_user_name);
|
||||
textView.setText(name);
|
||||
Log.d(NAME, "onLogin");
|
||||
}
|
||||
|
||||
@Override public void onLogoutEvent(int status, String message) {}
|
||||
});
|
||||
this.listener = true;
|
||||
}
|
||||
// Inflate the layout for this fragment
|
||||
return view;
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onMainFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnMainFragmentInteractionListener) {
|
||||
mListener = (OnMainFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnMainFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented by activities that contain this
|
||||
* fragment to allow an interaction in this fragment to be communicated
|
||||
* to the activity and potentially other fragments contained in that
|
||||
* activity.
|
||||
* <p>
|
||||
* See the Android Training lesson <a href=
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
interface OnMainFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onMainFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package de.hwr_berlin.it14.postgrachelor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link QuestionEndFragment.OnQuestionEndFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link QuestionEndFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class QuestionEndFragment extends Fragment {
|
||||
public static final String NAME = "QUESTION_END_FRAGMENT";
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private OnQuestionEndFragmentInteractionListener mListener;
|
||||
|
||||
public QuestionEndFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment QuestionEndFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static QuestionEndFragment newInstance(String param1, String param2) {
|
||||
QuestionEndFragment fragment = new QuestionEndFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_question_end, container, false);
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onQuestionEndFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnQuestionEndFragmentInteractionListener) {
|
||||
mListener = (OnQuestionEndFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnQuestionEndFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented by activities that contain this
|
||||
* fragment to allow an interaction in this fragment to be communicated
|
||||
* to the activity and potentially other fragments contained in that
|
||||
* activity.
|
||||
* <p>
|
||||
* See the Android Training lesson <a href=
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
interface OnQuestionEndFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onQuestionEndFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package de.hwr_berlin.it14.postgrachelor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link QuestionFragment.OnQuestionFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link QuestionFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class QuestionFragment extends Fragment {
|
||||
public static final String NAME = "QUESTION_FRAGMENT";
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private OnQuestionFragmentInteractionListener mListener;
|
||||
|
||||
public QuestionFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment QuestionFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static QuestionFragment newInstance(String param1, String param2) {
|
||||
QuestionFragment fragment = new QuestionFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_question, container, false);
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onQuestionFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnQuestionFragmentInteractionListener) {
|
||||
mListener = (OnQuestionFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented by activities that contain this
|
||||
* fragment to allow an interaction in this fragment to be communicated
|
||||
* to the activity and potentially other fragments contained in that
|
||||
* activity.
|
||||
* <p>
|
||||
* See the Android Training lesson <a href=
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
interface OnQuestionFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onQuestionFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package de.hwr_berlin.it14.postgrachelor;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link QuestionStartFragment.OnQuestionStartFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link QuestionStartFragment#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class QuestionStartFragment extends Fragment {
|
||||
public static final String NAME = "QUESTION_START_FRAGMENT";
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private static final String ARG_PARAM2 = "param2";
|
||||
|
||||
// TODO: Rename and change types of parameters
|
||||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private OnQuestionStartFragmentInteractionListener mListener;
|
||||
|
||||
public QuestionStartFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this factory method to create a new instance of
|
||||
* this fragment using the provided parameters.
|
||||
*
|
||||
* @param param1 Parameter 1.
|
||||
* @param param2 Parameter 2.
|
||||
* @return A new instance of fragment QuestionStartFragment.
|
||||
*/
|
||||
// TODO: Rename and change types and number of parameters
|
||||
public static QuestionStartFragment newInstance(String param1, String param2) {
|
||||
QuestionStartFragment fragment = new QuestionStartFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_PARAM1, param1);
|
||||
args.putString(ARG_PARAM2, param2);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_question_start, container, false);
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onQuestionStartFragmentInteraction(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnQuestionStartFragmentInteractionListener) {
|
||||
mListener = (OnQuestionStartFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnQuestionStartFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface must be implemented by activities that contain this
|
||||
* fragment to allow an interaction in this fragment to be communicated
|
||||
* to the activity and potentially other fragments contained in that
|
||||
* activity.
|
||||
* <p>
|
||||
* See the Android Training lesson <a href=
|
||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||
* >Communicating with Other Fragments</a> for more information.
|
||||
*/
|
||||
interface OnQuestionStartFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onQuestionStartFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package de.hwr_berlin.it14.postgrachelor.Services;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import static android.content.ContentValues.TAG;
|
||||
|
||||
abstract class JsonRequest extends AsyncTask<Void, Void, JSONObject> {
|
||||
private final String connectionURL;
|
||||
protected final String path;
|
||||
private final HashMap<String, String> params;
|
||||
protected final Activity activity;
|
||||
private ProgressDialog pDialog;
|
||||
|
||||
JsonRequest(String path, HashMap<String, String> params, Activity activity) {
|
||||
this.connectionURL = getConnectionURL();
|
||||
this.path = path;
|
||||
this.params = params;
|
||||
this.activity = activity;
|
||||
Log.d("fragment, JSONRequest", connectionURL+path);
|
||||
}
|
||||
|
||||
protected abstract String getConnectionURL();
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
Log.d("fragment, JSONRequest", "onPre1");
|
||||
// Showing progress dialog
|
||||
pDialog = new ProgressDialog(this.activity);
|
||||
pDialog.setMessage("Please wait...");
|
||||
pDialog.setCancelable(false);
|
||||
pDialog.show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected JSONObject doInBackground(Void... arg0) {
|
||||
URL url = null;
|
||||
String jsonText = "";
|
||||
JSONObject jsonObj = null;
|
||||
try {
|
||||
url = new URL(parseURL(this.connectionURL+this.path, this.params));
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
HttpURLConnection urlConnection = null;
|
||||
if (url == null)
|
||||
return new JSONObject();
|
||||
try {
|
||||
urlConnection = (HttpURLConnection) url.openConnection();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (urlConnection == null)
|
||||
return new JSONObject();
|
||||
try {
|
||||
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
|
||||
java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A");
|
||||
jsonText = s.hasNext() ? s.next() : "";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
|
||||
//jsonText = "{\"meta\":{\"status\": 0, \"message\": \"Success\"}, \"data\": {}}";
|
||||
|
||||
// register
|
||||
// jsonText = "{\"meta\":{\"status\": 0, \"message\": \"Success\"}, \"data\": {}}";
|
||||
|
||||
if (!jsonText.equals("")) {
|
||||
try {
|
||||
jsonObj = new JSONObject(jsonText);
|
||||
} catch (final JSONException e) {
|
||||
Log.e(TAG, "Json parsing error: " + e.getMessage());
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(activity.getApplicationContext(),
|
||||
"Json parsing error: " + e.getMessage(),
|
||||
Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Couldn't get json from server.");
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(activity.getApplicationContext(),
|
||||
"Couldn't get json from server. Check LogCat for possible errors!",
|
||||
Toast.LENGTH_LONG)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(JSONObject result) {
|
||||
super.onPostExecute(result);
|
||||
if (pDialog.isShowing())
|
||||
pDialog.dismiss();
|
||||
}
|
||||
|
||||
private String parseURL(String url, Map<String, String> params)
|
||||
{
|
||||
Uri.Builder builder = Uri.parse(url).buildUpon();
|
||||
if (params != null) {
|
||||
for (String key : params.keySet()) {
|
||||
builder.appendQueryParameter(key, params.get(key));
|
||||
}
|
||||
}
|
||||
return builder.build().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package de.hwr_berlin.it14.postgrachelor.Services;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 19.03.17.
|
||||
* Implementation of JsonRequest
|
||||
*/
|
||||
|
||||
class JsonRequestPG extends JsonRequest {
|
||||
|
||||
private final AsyncResponse delegate;
|
||||
|
||||
interface AsyncResponse {
|
||||
void processFinish(JSONObject data);
|
||||
void processError(int status, String message);
|
||||
}
|
||||
|
||||
JsonRequestPG(String path, HashMap<String, String> params, Activity activity, AsyncResponse delegate) {
|
||||
super(path, params, activity);
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getConnectionURL() {
|
||||
return "http://leander.sebse.de/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(JSONObject result) {
|
||||
super.onPostExecute(result);
|
||||
if (result == null) {
|
||||
delegate.processError(-1, "Internal error occurred!");
|
||||
return;
|
||||
}
|
||||
JSONObject meta = result.optJSONObject("meta");
|
||||
if (meta==null) {
|
||||
delegate.processError(-2, "Invalid JSON: Meta tag not found!");
|
||||
return;
|
||||
}
|
||||
int status = meta.optInt("status", -3);
|
||||
String message = meta.optString("message", "");
|
||||
if (status != 0) {
|
||||
new AlertDialog.Builder(this.activity)
|
||||
.setTitle("Error "+status)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
delegate.processError(status, message);
|
||||
return;
|
||||
}
|
||||
JSONObject data = result.optJSONObject("data");
|
||||
delegate.processFinish(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package de.hwr_berlin.it14.postgrachelor.Services;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import de.hwr_berlin.it14.postgrachelor.Exceptions.NotInstantiatedException;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 25.03.17.
|
||||
* Login service
|
||||
*/
|
||||
|
||||
public class LoginService {
|
||||
private static final String PREFS_NAME = "PrefsLogin";
|
||||
private static SharedPreferences settings = null;
|
||||
private static boolean instantiated = false;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Activity activity = null;
|
||||
private static ArrayList<OnLoginEventListener> loginEventListeners = new ArrayList<>();
|
||||
|
||||
public interface OnLoginEventListener {
|
||||
void onLoginEvent(String name, String uid);
|
||||
void onLogoutEvent(int status, String message);
|
||||
}
|
||||
|
||||
public static void addLoginEventListener(OnLoginEventListener onLoginEventListener) {
|
||||
loginEventListeners.add(onLoginEventListener);
|
||||
if (isLoggedInSave()) {
|
||||
try {
|
||||
onLoginEventListener.onLoginEvent(getLoginName(), getLoginUID());
|
||||
} catch (NotInstantiatedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
onLoginEventListener.onLogoutEvent(-6, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void emitLoginEvent(String name, String uid) {
|
||||
for (OnLoginEventListener listener: loginEventListeners) {
|
||||
listener.onLoginEvent(name, uid);
|
||||
}
|
||||
}
|
||||
|
||||
private static void emitLogoutEvent(int status, String message) {
|
||||
for (OnLoginEventListener listener: loginEventListeners) {
|
||||
listener.onLogoutEvent(status, message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void instantiate(Activity activity) {
|
||||
settings = activity.getSharedPreferences(PREFS_NAME, 0);
|
||||
LoginService.activity = activity;
|
||||
instantiated = true;
|
||||
String name = null;
|
||||
String uid = null;
|
||||
try {
|
||||
name = getLoginName();
|
||||
uid = getLoginUID();
|
||||
} catch (NotInstantiatedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (isLoggedInSave()) {
|
||||
emitLoginEvent(name, uid);
|
||||
} else {
|
||||
emitLogoutEvent(-5, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLoggedIn() throws NotInstantiatedException {
|
||||
if (!instantiated)
|
||||
throw new NotInstantiatedException();
|
||||
return settings.getBoolean("isLoggedIn", false);
|
||||
}
|
||||
|
||||
private static boolean isLoggedInSave() {
|
||||
try {
|
||||
return isLoggedIn();
|
||||
} catch (NotInstantiatedException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getLoginName() throws NotInstantiatedException {
|
||||
if (!LoginService.isLoggedIn())
|
||||
return "";
|
||||
return settings.getString("loginName", "");
|
||||
}
|
||||
|
||||
private static String getLoginUID() throws NotInstantiatedException {
|
||||
if (!LoginService.isLoggedIn())
|
||||
return "";
|
||||
return settings.getString("loginUID", "");
|
||||
}
|
||||
|
||||
private static void setLogin(String name, String uid) throws NotInstantiatedException {
|
||||
if (!instantiated)
|
||||
throw new NotInstantiatedException();
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
editor.putString("loginName", name);
|
||||
editor.putString("loginUID", uid);
|
||||
editor.putBoolean("isLoggedIn", true);
|
||||
editor.apply();
|
||||
emitLoginEvent(name, uid);
|
||||
}
|
||||
|
||||
private static void setLogout(int status, String message) throws NotInstantiatedException {
|
||||
if (!instantiated)
|
||||
throw new NotInstantiatedException();
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
editor.clear();
|
||||
editor.apply();
|
||||
emitLogoutEvent(status, message);
|
||||
}
|
||||
|
||||
private static void setLoginSave(String name, String uid) {
|
||||
try {
|
||||
setLogin(name, uid);
|
||||
} catch (NotInstantiatedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setLogoutSave(int status, String message) {
|
||||
try {
|
||||
setLogout(status, message);
|
||||
} catch (NotInstantiatedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void doLogin(String name) throws NotInstantiatedException {
|
||||
if (!instantiated)
|
||||
throw new NotInstantiatedException();
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
JsonRequestPG requester = new JsonRequestPG("register.php", params, activity, new JsonRequestPG.AsyncResponse() {
|
||||
@Override
|
||||
public void processFinish(JSONObject output) {
|
||||
Log.d("Activity fragment", "output");
|
||||
Log.d("Activity fragment", output.toString());
|
||||
|
||||
// never reached if not instantiated
|
||||
LoginService.setLoginSave(output.optString("name", ""), output.optString("uid", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processError(int status, String message) {
|
||||
Log.d("Activity fragment", "error");
|
||||
Log.d("Activity fragment", "status: "+status+" - message: "+message);
|
||||
// never reached if not instantiated
|
||||
LoginService.setLogoutSave(status, message);
|
||||
}
|
||||
});
|
||||
requester.execute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:innerRadiusRatio="7"
|
||||
android:shape="ring"
|
||||
android:thickness="10dp" >
|
||||
<solid android:color="@color/colorPrimaryDark" />
|
||||
</shape>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<solid android:color="@color/colorPrimary" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<solid android:color="@color/colorPrimary" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<solid android:color="@color/colorPrimaryDark" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
10
app/src/main/res/drawable/ic_play_arrow.xml
Normal file
10
app/src/main/res/drawable/ic_play_arrow.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFF"
|
||||
android:pathData="M8 5v14l11-7z" />
|
||||
</vector>
|
||||
@@ -21,7 +21,23 @@
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_main" />
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/relative_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.MainActivity"
|
||||
tools:showIn="@layout/app_bar_main">
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
@@ -29,6 +45,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />-->
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/content_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.MainActivity"
|
||||
tools:showIn="@layout/app_bar_main">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!" />
|
||||
</RelativeLayout>
|
||||
53
app/src/main/res/layout/fragment_login.xml
Normal file
53
app/src/main/res/layout/fragment_login.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.LoginFragment">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingTop="50dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="100dp"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
android:contentDescription="@string/launcher_icon"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="40dp"
|
||||
android:textSize="40sp"
|
||||
android:text="@string/app_name" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_margin="20dp"
|
||||
android:text="@string/welcome_text" />
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:layout_margin="10dp"
|
||||
android:hint="@string/enter_user_name"
|
||||
android:id="@+id/login_edit"
|
||||
android:maxLines="1"
|
||||
android:inputType="textFilter|textNoSuggestions"
|
||||
android:background="@android:color/background_light" />
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/login_btn"
|
||||
android:text="@string/register_btn"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
64
app/src/main/res/layout/fragment_main.xml
Normal file
64
app/src/main/res/layout/fragment_main.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.MainFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/fragment_main_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/fragment_main_status"/>
|
||||
|
||||
<android.support.v7.widget.GridLayout
|
||||
xmlns:grid="http://schemas.android.com/apk/res-auto"
|
||||
|
||||
android:id="@+id/choice_grid"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
|
||||
grid:alignmentMode="alignBounds"
|
||||
grid:columnCount="2"
|
||||
grid:rowOrderPreserved="false"
|
||||
grid:useDefaultMargins="true">
|
||||
|
||||
|
||||
<include layout="@layout/fragment_main_category"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnWeight="1"
|
||||
grid:layout_gravity="fill"
|
||||
/>
|
||||
|
||||
<include layout="@layout/fragment_main_category"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnWeight="1"
|
||||
grid:layout_gravity="fill"
|
||||
/>
|
||||
|
||||
<include layout="@layout/fragment_main_category"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnWeight="1"
|
||||
grid:layout_gravity="fill"
|
||||
/>
|
||||
|
||||
<include layout="@layout/fragment_main_category"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
grid:layout_columnWeight="1"
|
||||
grid:layout_gravity="fill"
|
||||
/>
|
||||
|
||||
</android.support.v7.widget.GridLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
35
app/src/main/res/layout/fragment_main_category.xml
Normal file
35
app/src/main/res/layout/fragment_main_category.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:showIn="@layout/fragment_main"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:gravity="start"
|
||||
android:background="#FF33B5E6" >
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
<ProgressBar
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:progressDrawable="@drawable/circular_progress_drawable_red"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingTop="10dp"
|
||||
android:minHeight="70dp"
|
||||
android:maxWidth="70dp"
|
||||
android:indeterminate="false"
|
||||
android:max="100"
|
||||
android:progress="75"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:paddingTop="10dp"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:text="@string/_1337"/>
|
||||
</RelativeLayout>
|
||||
40
app/src/main/res/layout/fragment_main_status.xml
Normal file
40
app/src/main/res/layout/fragment_main_status.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:showIn="@layout/fragment_main"
|
||||
android:padding="5dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:progressDrawable="@drawable/horizontal_progress_drawable_red"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:indeterminate="false"
|
||||
android:max="100"
|
||||
android:minHeight="90dp"
|
||||
android:maxHeight="90dp"
|
||||
android:progress="20"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fragment_user_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
|
||||
android:textColor="@android:color/white"
|
||||
android:padding="10dp"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
|
||||
android:textColor="@android:color/white"
|
||||
android:padding="20dp"
|
||||
android:textSize="55sp"
|
||||
android:text="@string/_1337" />
|
||||
</RelativeLayout>
|
||||
61
app/src/main/res/layout/fragment_question.xml
Normal file
61
app/src/main/res/layout/fragment_question.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.QuestionFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_margin="20dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:text="@string/welcome_text" />
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="245sp"
|
||||
android:height="75sp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:background="@color/colorPrimary"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/welcome_text"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="165sp"
|
||||
android:height="75sp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:background="@color/colorPrimary"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/welcome_text"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="85sp"
|
||||
android:height="75sp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:background="@color/colorPrimary"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/welcome_text"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5sp"
|
||||
android:height="75sp"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:background="@color/colorPrimary"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/welcome_text"/>
|
||||
|
||||
</RelativeLayout>
|
||||
33
app/src/main/res/layout/fragment_question_end.xml
Normal file
33
app/src/main/res/layout/fragment_question_end.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.QuestionEndFragment"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="40dp"
|
||||
android:textSize="40sp"
|
||||
android:text="@string/test_completed" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="40dp"
|
||||
android:textSize="80sp"
|
||||
android:text="@string/_1337"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textStyle="bold"/>
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/colorPrimary"
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/return_btn"/>
|
||||
|
||||
</LinearLayout>
|
||||
25
app/src/main/res/layout/fragment_question_start.xml
Normal file
25
app/src/main/res/layout/fragment_question_start.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="de.hwr_berlin.it14.postgrachelor.QuestionStartFragment"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="60dp"
|
||||
android:textSize="40sp"
|
||||
android:text="@string/start_test" />
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:scaleX="2"
|
||||
android:scaleY="2"
|
||||
android:src="@drawable/ic_play_arrow" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -17,19 +17,22 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||
app:srcCompat="@android:drawable/sym_def_app_icon" />
|
||||
android:contentDescription="@string/launcher_icon"
|
||||
app:srcCompat="@mipmap/ic_launcher" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||
android:text="Android Studio"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
|
||||
android:text="@string/android_studio"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:id="@+id/user_uid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="android.studio@android.com" />
|
||||
android:textSize="12sp"
|
||||
android:text="@string/android_studio_email" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/nav_camera"
|
||||
android:icon="@drawable/ic_menu_camera"
|
||||
android:title="Import" />
|
||||
android:title="Login"
|
||||
tools:ignore="HardcodedText" />
|
||||
<item
|
||||
android:id="@+id/nav_gallery"
|
||||
android:icon="@drawable/ic_menu_gallery"
|
||||
android:title="Gallery" />
|
||||
android:title="Gallery"
|
||||
tools:ignore="HardcodedText" />
|
||||
<item
|
||||
android:id="@+id/nav_slideshow"
|
||||
android:icon="@drawable/ic_menu_slideshow"
|
||||
android:title="Slideshow" />
|
||||
android:title="Slideshow"
|
||||
tools:ignore="HardcodedText" />
|
||||
<item
|
||||
android:id="@+id/nav_manage"
|
||||
android:icon="@drawable/ic_menu_manage"
|
||||
android:title="Tools" />
|
||||
android:title="Tools"
|
||||
tools:ignore="HardcodedText" />
|
||||
</group>
|
||||
|
||||
<item android:title="Communicate">
|
||||
<item android:title="Communicate"
|
||||
tools:ignore="HardcodedText">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/nav_share"
|
||||
android:icon="@drawable/ic_menu_share"
|
||||
android:title="Share" />
|
||||
<item
|
||||
android:id="@+id/nav_send"
|
||||
android:icon="@drawable/ic_menu_send"
|
||||
android:title="Send" />
|
||||
android:title="Share"
|
||||
tools:ignore="HardcodedText" />
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
|
||||
@@ -5,4 +5,18 @@
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
|
||||
<string name="action_settings">Settings</string>
|
||||
|
||||
<string name="enter_user_name">Enter User Name…</string>
|
||||
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
<string name="hello_login_fragment">Hello login fragment</string>
|
||||
<string name="welcome_text">Welcome to our stupid app. Prove that you are smarter than we are and answer our questions!</string>
|
||||
<string name="register_btn">Register</string>
|
||||
<string name="start_test">Start Test!</string>
|
||||
<string name="test_completed">Test completed!</string>
|
||||
<string name="_1337">1337</string>
|
||||
<string name="return_btn">Return</string>
|
||||
<string name="launcher_icon">Launcher Icon</string>
|
||||
<string name="android_studio">Android Studio</string>
|
||||
<string name="android_studio_email">android.studio@android.com</string>
|
||||
</resources>
|
||||
|
||||
@@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
classpath 'com.android.tools.build:gradle:2.3.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Mon Dec 28 10:00:20 PST 2015
|
||||
#Fri Mar 03 08:16:04 CET 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
|
||||
Reference in New Issue
Block a user