Compare commits

...

2 Commits

Author SHA1 Message Date
1154366024 Improvements BG 2018-11-28 01:31:36 +01:00
Adam Domagalski
cd3e058d51 dev to master enpoitn, fake validate to nomal, def functions removed 2018-11-27 21:22:57 +01:00
14 changed files with 158 additions and 140 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "com.uam.wmi.findmytutor"
minSdkVersion 22
targetSdkVersion 27
versionCode 3
versionCode 5
versionName "0.9.0-alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

View File

@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.uam.wmi.findmytutor">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@ -13,23 +14,21 @@
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-feature android:name="android.hardware.location.gps" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:fullBackupContent="@xml/backup_descriptor">
<activity
android:name=".activity.StartupActivity"
android:launchMode="singleInstance"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@ -47,12 +46,14 @@
<service
android:name=".service.BackgroundLocalizationService"
android:enabled="true"
android:exported="false"
android:launchMode="singleTop" />
android:exported="true"
/>
<activity
android:name=".activity.TutorTab"
android:theme="@style/AppTheme"></activity>
</application>
</manifest>

View File

@ -20,6 +20,7 @@ import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -52,7 +53,8 @@ public abstract class BaseActivity
protected static final int REQUEST_PERMISSIONS = 100;
private final static int REQUEST_CODE_ASK_PERMISSIONS = 1;
private static final String[] REQUIRED_SDK_PERMISSIONS = new String[]{
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS};
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
Manifest.permission.WAKE_LOCK};
public DrawerLayout drawerLayout;
protected BottomNavigationView navigationView;
protected NavigationView drawerNavigationView;
@ -193,7 +195,7 @@ public abstract class BaseActivity
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(startIntent);
} else {
startService(startIntent);
@ -202,6 +204,7 @@ public abstract class BaseActivity
public void handleBackgroundTaskLifeCycle() {
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext());
Log.e("shouldRUN", String.valueOf(shouldServiceRun));
if (shouldServiceRun) {
startBackgroundLocalizationTask();

View File

@ -153,9 +153,9 @@ public class LoginActivity extends AppCompatActivity {
private void loginProcess(String email, String password) {
ValidateUser user = new ValidateUser(email, password);
LdapUser fuser = new LdapUser(email,password,"tutor","tutor","mieszko","nocny","szmsdsdsdsdare@wmi.pl");
// disposable.add(ldapService.validate(user)
//ValidateUser user = new ValidateUser(email, password);
LdapUser fuser = new LdapUser(email,password,"tutor","tutor","mieszko","nocny",email);
disposable.add(ldapService.fakeValidate(fuser)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())

View File

@ -4,7 +4,6 @@ import android.Manifest;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
@ -46,9 +45,9 @@ import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.CoordinateService;
import com.uam.wmi.findmytutor.service.PredefinedStatusesService;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
import com.uam.wmi.findmytutor.utils.ManualLocationUtils;
import com.uam.wmi.findmytutor.utils.MapMarker;
import com.uam.wmi.findmytutor.utils.PowerManager;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel;
@ -60,6 +59,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.net.ssl.ManagerFactoryParameters;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableSingleObserver;
@ -130,6 +131,7 @@ public class MapActivity extends BaseActivity
//start background task
handleBackgroundTaskLifeCycle();
PowerManager.startPowerSaverIntent(getApplicationContext());
manualLocationUtils = new ManualLocationUtils(MapActivity.this);
}
@ -170,19 +172,7 @@ public class MapActivity extends BaseActivity
private void setToggleMapBoundsArea() {
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, true);
FloatingActionButton toggleBoundsAreaFab = findViewById(R.id.fab_toggle_bound_area);
toggleBoundsAreaFab.setOnClickListener(view -> {
if (toggleBoundsAreaFab.getTitle().equals("Bounds OFF")) {
toggleBoundsAreaFab.setTitle("Bounds ON");
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, false);
} else {
toggleBoundsAreaFab.setTitle("Bounds OFF");
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, true);
}
});
mapUtils.setMapBoundsArea(getApplicationContext(), mapboxMap, mapView, false);
}
private void updateUserHashMap(String userId, Long markerId) {
@ -248,53 +238,6 @@ public class MapActivity extends BaseActivity
Toast.makeText(MapActivity.this, message, Toast.LENGTH_SHORT).show();
}
/* private void setOnMapLongClickListener() {
mapboxMap.addOnMapLongClickListener((LatLng latLng) -> {
selectLocationButton.setVisibility(View.VISIBLE);
removeLocationButton.setVisibility(View.GONE);
if (tmpLocalMarker == null) {
String sharingLevel = SharingLevel.MANUAL.toString();
Icon defaultIcon = getMapIcon(sharingLevel, myId);
MarkerOptions markerOptions = new MarkerOptions()
.setIcon(defaultIcon)
.position(latLng);
tmpLocalMarker = mapboxMap.addMarker(markerOptions);
MapMarker marker = new MapMarker(tmpLocalMarker, markerOptions, defaultIcon, sharingLevel);
markerHash.put(myId, marker);
updateUserHashMap(myId, marker.getMarker().getId());
} else {
ValueAnimator markerAnimator = ObjectAnimator.ofObject(tmpLocalMarker, "position",
new mapUtils.LatLngEvaluator(), tmpLocalMarker.getPosition(), latLng);
markerAnimator.setDuration(2000);
markerAnimator.start();
}
selectLocationButton.setOnClickListener((View view) -> {
if (tmpLocalMarker != null) {
try {
manualLocationUtils.showLocationDialog("Name the location", latLng);
startBackgroundLocalizationTask();
} catch (IllegalArgumentException e) {
Timber.e(String.valueOf(e));
}
selectLocationButton.setVisibility(View.GONE);
mapboxMap.removeMarker(tmpLocalMarker);
tmpLocalMarker = null;
}
});
});
}*/
private void setOnMapLongClickListener() {
mapboxMap.addOnMapLongClickListener((LatLng latLng) -> {
@ -365,7 +308,7 @@ public class MapActivity extends BaseActivity
public void showLocationDialog(LatLng latLng) {
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.location_modal, null);
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.location_modal, null);
AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this);
alertDialogBuilderUserInput.setView(view).setPositiveButton(getApplicationContext().getString(R.string.modal_location_send), null);
@ -393,16 +336,13 @@ public class MapActivity extends BaseActivity
modalUserInput.requestFocus();
} else {
PrefUtils.putManualLocation(getApplicationContext(), latLng);
sendLocation(body,latLng);
sendLocation(body, latLng);
alertDialog.dismiss();
}
});
});
alertDialog.show();
}

View File

@ -10,7 +10,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClientInstance {
private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
private static final String BASE_URL = "https://s416084.projektstudencki.pl/master/";
private static Retrofit.Builder builder
= new Retrofit.Builder()

View File

@ -2,6 +2,9 @@ package com.uam.wmi.findmytutor.service;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.IntentService;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
@ -18,10 +21,13 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.PowerManager;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
@ -72,6 +78,11 @@ public class BackgroundLocalizationService extends Service {
private Runnable mStatusChecker;
private FusedLocationProviderClient mFusedLocationClient;
PowerManager pm;
PowerManager.WakeLock wl;
public Handler handler = null;
public static Runnable runnable = null;
public BackgroundLocalizationService() {
providers.add(LocationManager.GPS_PROVIDER);
@ -91,15 +102,30 @@ public class BackgroundLocalizationService extends Service {
return null;
}
@SuppressLint({"MissingPermission", "InvalidWakeLockTag"})
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand");
super.onStartCommand(intent, flags, startId);
try {
pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
wl.acquire();
wl.release();
} catch (Exception ignored) {
}
if (intent != null) {
stopService = intent.getBooleanExtra("request_stop", false);
}
if (stopService) {
handler.removeCallbacksAndMessages(null);
storeBackgroundLocationStatus(getApplication(), false);
stopForeground(true);
stopSelf();
@ -111,8 +137,10 @@ public class BackgroundLocalizationService extends Service {
@Override
public void onCreate() {
Log.e(TAG, "onCreate");
storeBackgroundLocationStatus(getApplication(), true);
// when you done
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
startMyOwnForeground();
@ -147,23 +175,22 @@ public class BackgroundLocalizationService extends Service {
}
if (!stopService) {
storeBackgroundLocationStatus(getApplication(), true);
handler = new Handler();
runnable = () -> {
fn_getlocation();
fn_getlocation();
handler.postDelayed(runnable, 10000);
};
Timer mTimer = new Timer();
mTimer.schedule(new TimerTaskToGetLocation(), 20, notify_interval);
intent = new Intent(str_receiver);
handler.postDelayed(runnable, 15000);
fn_getlocation();
}
}
private class TimerTaskToGetLocation extends TimerTask {
@Override
public void run() {
mHandler.post(BackgroundLocalizationService.this::fn_getlocation);
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void startMyOwnForeground() {

View File

@ -1,7 +1,26 @@
package com.uam.wmi.findmytutor.utils;
import android.content.ComponentName;
import android.content.Intent;
import java.util.Arrays;
import java.util.List;
public class Consts {
public final static Double presenceLatitude = 65.600244;
public final static Double presencelongitude = 480.032153;
public final static String presenceApproximatedName = "unknown";
public static List<Intent> POWERMANAGER_INTENTS = Arrays.asList(
new Intent().setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")),
new Intent().setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")),
new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.startupapp.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")),
new Intent().setComponent(new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
new Intent().setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")),
new Intent().setComponent(new ComponentName("com.asus.mobilemanager", "com.asus.mobilemanager.entry.FunctionActivity")).setData(android.net.Uri.parse("mobilemanager://function/entry/AutoStart"))
);
}

View File

@ -0,0 +1,62 @@
package com.uam.wmi.findmytutor.utils;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.support.v7.widget.AppCompatCheckBox;
import android.widget.CompoundButton;
import java.util.List;
public class PowerManager {
public static void startPowerSaverIntent(Context context) {
SharedPreferences settings = context.getSharedPreferences("ProtectedApps", Context.MODE_PRIVATE);
boolean skipMessage = settings.getBoolean("skipProtectedAppCheck", false);
if (!skipMessage) {
final SharedPreferences.Editor editor = settings.edit();
boolean foundCorrectIntent = false;
for (Intent intent : Consts.POWERMANAGER_INTENTS) {
if (isCallable(context, intent)) {
foundCorrectIntent = true;
final AppCompatCheckBox dontShowAgain = new AppCompatCheckBox(context);
dontShowAgain.setText("Do not show again");
dontShowAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
editor.putBoolean("skipProtectedAppCheck", isChecked);
editor.apply();
}
});
new AlertDialog.Builder(context)
.setTitle(Build.MANUFACTURER + " Protected Apps")
.setMessage(String.format("%s requires to be enabled in 'Protected Apps' to function properly.%n", ""))
.setView(dontShowAgain)
.setPositiveButton("Go to settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
context.startActivity(intent);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
break;
}
}
if (!foundCorrectIntent) {
editor.putBoolean("skipProtectedAppCheck", true);
editor.apply();
}
}
}
private static boolean isCallable(Context context, Intent intent) {
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
}

View File

@ -38,11 +38,11 @@ public class mapUtils {
mapboxMap.setLatLngBoundsForCameraTarget(WMI_BOUNDS);
makeNewCamera(mapboxMap, 52.466799, 16.927002, 17, 0, 0, 4000);
mapboxMap.setMinZoomPreference(16); // TODO export to map config
drawBoundsArea(context, mapboxMap, mapView, check);
// drawBoundsArea(context, mapboxMap, mapView, check);
} else {
mapboxMap.setLatLngBoundsForCameraTarget(null);
mapboxMap.setMinZoomPreference(2);
drawBoundsArea(context, mapboxMap, mapView, check);
// drawBoundsArea(context, mapboxMap, mapView, check);
}
}

View File

@ -58,47 +58,6 @@
app:fab_colorNormal="@color/mapboxGray"
app:pressedTranslationZ="12dp" />
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions_parent_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
fab:fab_addButtonColorNormal="@color/mapboxRed"
fab:fab_addButtonColorPressed="@color/mapboxWhite"
fab:fab_addButtonPlusIconColor="@color/mapboxWhite"
fab:fab_labelStyle="@style/menu_labels_style"
tools:layout_editor_absoluteX="200dp"
tools:layout_editor_absoluteY="255dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_hotels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxBlue"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_hotels" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_parks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxGreen"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_parks" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_bound_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxRed"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_bound_area" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
<Button
android:id="@+id/select_location_button"

View File

@ -4,10 +4,10 @@
android:layout_height="match_parent">
<PreferenceCategory android:title="@string/settings_category_general">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_notifications_enabled"
android:title="@string/title_notification" />
<!--<SwitchPreference-->
<!--android:defaultValue="true"-->
<!--android:key="@string/key_notifications_enabled"-->
<!--android:title="@string/title_notification"/>-->
<ListPreference
android:defaultValue="0"

View File

@ -26,7 +26,6 @@
<string name="lang_eng">Angielski</string>
<string name="lang_pol">Polski</string>
<string name="settings_language">Wybierz język</string>
<string name="mockup_location_string">\"\"</string>
<string name="pref_header_about">O aplikacji</string>
<string name="summary_about">
Jesteśmy grupą studentów, która chce pomoć w rozwoju naszego wydziału.\nDziękujemy za używanie naszej aplikacji.\nZespół FMT.!</string>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- TODO Remove the following "exclude" elements to make them a part of the auto backup -->
<!-- Exclude the shared preferences file that contains the GCM registrationId -->
<exclude
domain="sharedpref"
path="com.uam.wmi.findmytutor_preferences.xml" />
</full-backup-content>