issues #560, #561 and password field on login activity implemented

parent a77e9b30
...@@ -344,7 +344,9 @@ public class Picto extends Img { ...@@ -344,7 +344,9 @@ public class Picto extends Img {
* @return true if current status is enabled. False in other case. * @return true if current status is enabled. False in other case.
*/ */
public boolean alter_status() { public boolean alter_status() {
String status=is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED : JSON_ATTTR_STATUS_VALUES.ENABLED; String status=is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED
: is_disabled() ? JSON_ATTTR_STATUS_VALUES.INVISIBLE
: JSON_ATTTR_STATUS_VALUES.ENABLED;
Log.i(this.getClass().getCanonicalName(),"Picto id. "+get_id()+" status enabled/disabled modified to "+is_enabled()); Log.i(this.getClass().getCanonicalName(),"Picto id. "+get_id()+" status enabled/disabled modified to "+is_enabled());
try { try {
this.attributes.put(JSON_ATTTRS.STATUS, status); this.attributes.put(JSON_ATTTRS.STATUS, status);
......
...@@ -39,23 +39,27 @@ public class LoginActivity extends FragmentActivity { ...@@ -39,23 +39,27 @@ public class LoginActivity extends FragmentActivity {
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
// Enable logout button // Enable logout button
final Button logoutButton = (Button) findViewById(R.id.loginTopbarLogout); final Button logoutButton = (Button) findViewById(R.id.loginTopbarLogout);
logoutButton.setEnabled(true); logoutButton.setEnabled(true);
logoutButton.setOnClickListener(new View.OnClickListener() { logoutButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent serialActivity = new Intent(getBaseContext(), SerialActivity.class); Intent serialActivity = new Intent(getBaseContext(), SerialActivity.class);
serialActivity.putExtra("resetPrevUser", true); serialActivity.putExtra("resetPrevUser", true);
startActivity(serialActivity); startActivity(serialActivity);
} }
}); });
}
@Override
protected void onStart() {
super.onStart();
// Set supervisor information on topbar // Set supervisor information on topbar
final TextView supervisorFullNameView = (TextView) findViewById(R.id.loginTopbarSupervisorFullName); final TextView supervisorFullNameView = (TextView) findViewById(R.id.loginTopbarSupervisorFullName);
......
...@@ -115,12 +115,9 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -115,12 +115,9 @@ public class StudentFragmentGrid extends Fragment{
PCBcontext.set_user(new_user, intent.getStringExtra("token"), new iImgDownloaderListener() { PCBcontext.set_user(new_user, intent.getStringExtra("token"), new iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
if (progressDialog.isShowing()) { if (progressDialog.isShowing()) progressDialog.dismiss();
progressDialog.dismiss();
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class); Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
startActivity(pictogramActivity); startActivity(pictogramActivity);
}
} }
@Override @Override
...@@ -128,7 +125,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -128,7 +125,7 @@ public class StudentFragmentGrid extends Fragment{
} }
public void error(Exception e) { public void error(Exception e) {
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
GUITools.show_alert(StudentFragmentGrid.this.getActivity(), R.string.serverError, e.getMessage()); GUITools.show_alert(StudentFragmentGrid.this.getActivity(), R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage());
} }
...@@ -168,7 +165,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -168,7 +165,7 @@ public class StudentFragmentGrid extends Fragment{
ImgDownloader downloader = new ImgDownloader(getActivity(), new iImgDownloaderListener() { ImgDownloader downloader = new ImgDownloader(getActivity(), new iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
if (downloaded_students.size() > 1) { if (downloaded_students.size() > 1) {
for (int i = 0; i < imgs.size(); i++) for (int i = 0; i < imgs.size(); i++)
try { try {
...@@ -188,7 +185,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -188,7 +185,7 @@ public class StudentFragmentGrid extends Fragment{
public void loadImg(Img image) { public void loadImg(Img image) {
} }
public void error(Exception e) { public void error(Exception e) {
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
GUITools.show_alert(PCBcontext.getContext(), R.string.serverError, e.getMessage()); GUITools.show_alert(PCBcontext.getContext(), R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage());
} }
...@@ -209,7 +206,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -209,7 +206,7 @@ public class StudentFragmentGrid extends Fragment{
@Override @Override
public void error(Exception e) { public void error(Exception e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage()); Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() { GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() {
@Override @Override
public void ok() { public void ok() {
...@@ -222,7 +219,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -222,7 +219,7 @@ public class StudentFragmentGrid extends Fragment{
} }
@Override @Override
public void result(JSONArray students) { public void result(JSONArray students) {
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
StudentFragmentGrid.this.downloaded_students=new Vector(); StudentFragmentGrid.this.downloaded_students=new Vector();
for (int i=0;i<students.length();i++) { for (int i=0;i<students.length();i++) {
JSONObject student; JSONObject student;
...@@ -261,8 +258,13 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -261,8 +258,13 @@ public class StudentFragmentGrid extends Fragment{
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setRetainInstance(true); setRetainInstance(true);
}
@Override
public void onStart() {
super.onStart();
Intent intent=getActivity().getIntent(); Intent intent=getActivity().getIntent();
Boolean offline = intent.getBooleanExtra("offline", false); Boolean offline = intent.getBooleanExtra("offline", false);
int sup_id=intent.getIntExtra("sup_id", 0); int sup_id=intent.getIntExtra("sup_id", 0);
...@@ -293,15 +295,17 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -293,15 +295,17 @@ public class StudentFragmentGrid extends Fragment{
} }
else else
download_students(sup_id); download_students(sup_id);
}
if (offline || onlineStudentsOK) showStudentsGrid();
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_new_student, container, false); View view = inflater.inflate(R.layout.fragment_new_student, container, false);
gridView = (GridView)view.findViewById(R.id.loginStudentGridView); gridView = (GridView) view.findViewById(R.id.loginStudentGridView);
Boolean offline = getActivity().getIntent().getBooleanExtra("offline", false); return view;
if (offline || onlineStudentsOK) showStudentsGrid();
return view;
} }
} }
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
<EditText <EditText
android:id="@+id/edittext" android:id="@+id/edittext"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:password="true" />
<!-- The "Translate!" button --> <!-- The "Translate!" button -->
<Button <Button
android:id="@+id/button" android:id="@+id/button"
...@@ -54,4 +55,4 @@ ...@@ -54,4 +55,4 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_weight="1"/> android:layout_weight="1"/>
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SerialActivity"> tools:context=".gui.SerialActivity">
<EditText <EditText
android:id="@+id/serialmail" android:id="@+id/serialmail"
...@@ -30,10 +30,11 @@ ...@@ -30,10 +30,11 @@
android:imeActionId="@+id/login" android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_entrar" android:imeActionLabel="@string/action_entrar"
android:imeOptions="actionUnspecified" android:imeOptions="actionUnspecified"
android:inputType="text" android:inputType="textPassword"
android:maxLines="1" android:maxLines="1"
android:singleLine="true" android:singleLine="true"
android:layout_below="@+id/serialmail"/> android:layout_below="@+id/serialmail"
/>
<Button <Button
android:id="@+id/entrar_button" style="?android:textAppearanceSmall" android:id="@+id/entrar_button" style="?android:textAppearanceSmall"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment