forked from organicmaps/organicmaps
[anrd] Cleanup
This commit is contained in:
parent
0e8bdb8e49
commit
ccadbde98f
4 changed files with 47 additions and 44 deletions
|
@ -648,7 +648,11 @@ public class DownloadUI extends MapsWithMeBaseListActivity implements MapStorage
|
|||
setSelection(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.onBackPressed();
|
||||
// Always show map as parent
|
||||
startActivity(new Intent(this, MWMActivity.class));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.mapswithme.maps.background;
|
||||
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.SimpleLogger;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -11,8 +8,6 @@ import android.net.NetworkInfo;
|
|||
|
||||
public class ConnectivityChangedReceiver extends BroadcastReceiver
|
||||
{
|
||||
private final static Logger l = SimpleLogger.get("MWMConnect");
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
|
@ -30,7 +25,6 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver
|
|||
|
||||
public void onWiFiConnectionChanged(boolean isConnected, Context context)
|
||||
{
|
||||
l.d("WiFi Connected", isConnected);
|
||||
if (isConnected)
|
||||
{
|
||||
WorkerService.startActionCheckUpdate(context);
|
||||
|
|
|
@ -1,22 +1,17 @@
|
|||
package com.mapswithme.maps.background;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.SimpleLogger;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.DownloadUI;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
public class Notifier
|
||||
{
|
||||
private Logger l = SimpleLogger.get("MWMNotification");
|
||||
|
||||
private final static int ID_DEF = 0x0;
|
||||
private final static int ID_UPDATE_AVAIL = 0x1;
|
||||
|
||||
private NotificationManager mNotificationManager;
|
||||
|
@ -28,37 +23,30 @@ public class Notifier
|
|||
mContext = context;
|
||||
}
|
||||
|
||||
public void placeNotification(String text)
|
||||
public void placeUpdateAvailable(String forWhat)
|
||||
{
|
||||
l.d("Noti", text);
|
||||
|
||||
final Notification notification = getBuilder()
|
||||
.setContentText(text)
|
||||
.setTicker(text)
|
||||
.setContentTitle(text)
|
||||
.build();
|
||||
|
||||
mNotificationManager.notify(ID_DEF, notification);
|
||||
}
|
||||
|
||||
public void placeUpdateAvailable(List<CharSequence> forItems)
|
||||
{
|
||||
// TODO add real resources
|
||||
final String forItemsStr = TextUtils.join(",", forItems);
|
||||
// TODO: add real resources
|
||||
final String title = "Map Update Available ";
|
||||
final String text = "New data available for " + forItemsStr;
|
||||
final String text = "Updated maps: " + forWhat;
|
||||
|
||||
// Intent to start DownloadUI
|
||||
final Intent i = new Intent(mContext, DownloadUI.class);
|
||||
final PendingIntent pi = PendingIntent.getActivity(mContext, 0, i, Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
final Notification notification = getBuilder()
|
||||
.setContentTitle(title)
|
||||
.setSubText(text)
|
||||
.setContentText(text)
|
||||
.setTicker(title + text)
|
||||
.setContentIntent(pi)
|
||||
.build();
|
||||
|
||||
mNotificationManager.notify(ID_UPDATE_AVAIL, notification);
|
||||
}
|
||||
|
||||
|
||||
public NotificationCompat.Builder getBuilder()
|
||||
{
|
||||
// TODO add default initialization
|
||||
// TODO: add default initialization
|
||||
return new NotificationCompat.Builder(mContext)
|
||||
.setAutoCancel(true)
|
||||
.setSmallIcon(R.drawable.ic_launcher);
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.mapswithme.maps.background;
|
||||
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.SimpleLogger;
|
||||
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.StubLogger;
|
||||
|
||||
/**
|
||||
* An {@link IntentService} subclass for handling asynchronous task requests in
|
||||
|
@ -17,7 +19,7 @@ public class WorkerService extends IntentService
|
|||
private static final String ACTION_PUSH_STATISTICS = "com.mapswithme.maps.action.stat";
|
||||
private static final String ACTION_CHECK_UPDATE = "com.mapswithme.maps.action.update";
|
||||
|
||||
private Logger l = SimpleLogger.get("MWMWorkerService");
|
||||
private Logger mLogger = StubLogger.get();//SimpleLogger.get("MWMWorkerService");
|
||||
private Notifier mNotifier;
|
||||
|
||||
|
||||
|
@ -50,6 +52,12 @@ public class WorkerService extends IntentService
|
|||
public WorkerService()
|
||||
{
|
||||
super("WorkerService");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate()
|
||||
{
|
||||
super.onCreate();
|
||||
mNotifier = new Notifier(this);
|
||||
}
|
||||
|
||||
|
@ -69,13 +77,22 @@ public class WorkerService extends IntentService
|
|||
|
||||
private void handleActionCheckUpdate()
|
||||
{
|
||||
// TODO: Handle check for update
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
mLogger.d("Trying to update");
|
||||
if (!Framework.isDataVersionChanged()) return;
|
||||
|
||||
final String countriesToUpdate = Framework.getOutdatedCountriesString();
|
||||
if (!TextUtils.isEmpty(countriesToUpdate))
|
||||
{
|
||||
mLogger.d("Update available! " + countriesToUpdate);
|
||||
mNotifier.placeUpdateAvailable(countriesToUpdate);
|
||||
}
|
||||
// We are done with current version
|
||||
Framework.updateSavedDataVersion();
|
||||
mLogger.d("Version updated");
|
||||
}
|
||||
|
||||
private void handleActionPushStat()
|
||||
{
|
||||
// TODO: Handle stat push
|
||||
throw new UnsupportedOperationException("Not yet implemented");
|
||||
// TODO: add server call here
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue