working on #63, #64

parent 34c610d3
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.supervisor_tablet">
<!-- The app has the permission to receive the RECEIVE_BOOT_COMPLETED broadcast -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- For kiosk mode -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- For the service that restarts the app when another app go to foreground -->
......@@ -20,6 +19,7 @@
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
......@@ -40,7 +40,7 @@
android:label="@string/app_name"
android:screenOrientation="landscape" />
<activity
android:name=".gui.Supervisor_SerialActivity"
android:name="com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity"
android:label="@string/title_activity_serial"
android:screenOrientation="landscape" />
<activity
......
package com.yottacode.pictogram.supervisor_tablet.gui;
import android.app.Activity;
import com.yottacode.pictogram.supervisor_tablet.R;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.tools.GUITools;
/**
* Created by Fernando on 21/11/2016.
*/
public final class Supervisor_SerialActivity extends SerialActivity {
@Override
protected boolean is_legal_user(String user_name, Activity activity) {
boolean legal_user=com.yottacode.pictogram.dao.UserLogin.isSupervisorLoginPattern(user_name);
if (!legal_user)
GUITools.show_alert(activity, R.string.ilegal_user, user_name);
return legal_user;
}
}
......@@ -8,7 +8,7 @@ android {
targetSdkVersion 22
versionCode 1
versionName "1.0"
resValue "string", "SerialClass", "com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity"
resValue "bool","NotifyAllwaysVisible", "false"
resValue "integer", "rows", "5"
resValue "integer", "columns", "10"
resValue "integer", "rows_big", "4"
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.tabletlibrary">
<application
android:allowBackup="true"
android:label="@string/app_name"
......
......@@ -52,7 +52,6 @@ import com.yottacode.pictogram.net.websockets.ActionTalk;
import com.yottacode.pictogram.net.websockets.VocabularyTalk;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity;
import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import com.yottacode.pictogram.tools.Img;
......@@ -389,7 +388,8 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override
protected void onStop() {
super.onStop();
Log.i(LOG_TAG, "Closing app");
Log.i(LOG_TAG, "Closing Pictogram Activity");
PCBcontext.setActivityContext(null);
PCBcontext.getNetService().closeNotifyStatus();
}
......@@ -1010,14 +1010,7 @@ protected void showOnlyTape(boolean onlyTape) {
e.printStackTrace();
}
}
Class serialClass;
try {
serialClass = Class.forName(getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(), "S:" + getString(R.string.SerialClass));
serialClass = SerialActivity.class;
}
Intent serialActivity = new Intent(getBaseContext(), serialClass);
Intent serialActivity = new Intent(getBaseContext(), com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
if (lastUserName != null) {
Log.i(this.getClass().getCanonicalName(), "Switch user to " + lastUserName);
serialActivity.putExtra("switch_usr", lastUserName);
......
......@@ -51,14 +51,8 @@ public class LoginActivity extends FragmentActivity {
logoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Class serialClass;
try {
serialClass=Class.forName(getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(),"S:"+getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(getBaseContext(), serialClass);
Intent serialActivity = new Intent(getBaseContext(), com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", true);
startActivity(serialActivity);
}
......
......@@ -25,14 +25,7 @@ public class MainActivity extends Activity {
// For deactivating the lock screen (just before setContentView)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
Class serialClass;
try {
serialClass=Class.forName(getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(),"S:"+getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(this, serialClass);
Intent serialActivity = new Intent(this, com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", false);
startActivity(serialActivity);
}
......
......@@ -43,7 +43,6 @@ public class SerialActivity extends Activity {
LinearLayout stuList;
LinearLayout supList;
protected boolean is_legal_user(String user_name, Activity activity) {return true;}
/**
* Return the default user+pwd when login.The policy is
......@@ -155,7 +154,7 @@ public class SerialActivity extends Activity {
@Override
public void onClick(View view) {
String username = mSerialViewMail.getText().toString();
if (is_legal_user(username,SerialActivity.this)) {
String password = mSerialViewPass.getText().toString();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
......@@ -164,7 +163,7 @@ public class SerialActivity extends Activity {
editor.commit();
if (!username.equals("") && !password.equals(""))
new UserLogin().login(username, password, SerialActivity.this, PictogramActivity.class, LoginActivity.class);
}
}
});
}
......
......@@ -13,7 +13,6 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity;
import com.yottacode.pictogram.tools.PCBcontext;
/**
......@@ -36,19 +35,22 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addNextIntent(resultIntent);
if (PCBcontext.getContext().getResources().getBoolean(R.bool.NotifyAllwaysVisible)){
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(resultPendingIntent);
}
}
public void notifyStatus(boolean updated) {
String user="";
if (PCBcontext.getPcbdb()!=null) {
if (PCBcontext.getPcbdb()!=null ) {
user=PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_stu();
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor())
user += " (" + PCBcontext.getPcbdb().getCurrentUser().get_name_sup() + ")";
}
if (PCBcontext.getActivityContext()!=null) {
if (updated)
builder.setSmallIcon(R.drawable.application_online)
.setContentTitle(PCBcontext.getContext().getResources().getString(R.string.pictogram_online))
......@@ -62,7 +64,9 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
(NotificationManager) PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE);
mNotificationManager.notify(notifyID, builder.build());
}
}
public void closeNotifyStatus(){
Log.i(LOG_TAG,"Closing notify");
NotificationManager mNotificationManager =
(NotificationManager) PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE);
mNotificationManager.cancel(notifyID);
......@@ -75,13 +79,7 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
Log.i(LOG_TAG,"App restarting");
Context context=activity.getBaseContext();
Class serialClass;
try {
serialClass=Class.forName(context.getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(LOG_TAG,"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(context, serialClass);
Intent serialActivity = new Intent(context, com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", false);
serialActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(serialActivity);
......@@ -94,14 +92,7 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
Context context=PCBcontext.getContext();
Class serialClass;
try {
serialClass=Class.forName(PCBcontext.getContext().getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(LOG_TAG,"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
Intent serialActivity = new Intent(context, serialClass);
Intent serialActivity = new Intent(context, com.yottacode.pictogram.tabletlibrary.gui.login.SerialActivity.class);
serialActivity.putExtra("resetPrevUser", direct_login);
context.startActivity(serialActivity);
......
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