Skip to content

Commit

Permalink
Preview images for widgets. Some fixes for widgets. Move App to the m…
Browse files Browse the repository at this point in the history
…ost top package (for acra to find BuildConfig).
  • Loading branch information
David Graeff committed May 15, 2015
1 parent 3c3848e commit 57c840b
Show file tree
Hide file tree
Showing 47 changed files with 96 additions and 90 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
defaultConfig {
minSdkVersion 17
targetSdkVersion 22
versionCode 121
versionName "8.1"
versionCode 122
versionName "8.2"
applicationId appID
testApplicationId "oly.netpowerctrl.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
Expand Down
23 changes: 7 additions & 16 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<uses-sdk />

<application
android:name=".main.App"
android:name=".App"
android:allowBackup="true"
android:icon="@drawable/netpowerctrl"
android:label="@string/app_name"
Expand Down Expand Up @@ -76,9 +76,6 @@
android:launchMode="singleInstance"
android:noHistory="true"
android:theme="@style/Theme.AppCompat.Translucent">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
Expand All @@ -89,7 +86,8 @@
<activity
android:name="oly.netpowerctrl.widget.ConfigExecutableActivity"
android:configChanges="orientation|screenSize|keyboardHidden|layoutDirection"
android:theme="@style/Theme.StartTheme">
android:launchMode="singleInstance"
android:theme="@style/Theme.CustomLightThemeDialog">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand All @@ -98,7 +96,8 @@
<activity
android:name="oly.netpowerctrl.widget.ConfigGroupActivity"
android:configChanges="orientation|screenSize|keyboardHidden|layoutDirection"
android:theme="@style/Theme.StartTheme">
android:launchMode="singleInstance"
android:theme="@style/Theme.CustomLightThemeDialog">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand Down Expand Up @@ -129,7 +128,8 @@
android:description="@string/shortcut_existing_executable_desc"
android:icon="@drawable/netpowerctrl"
android:label="@string/shortcut_existing_executable"
android:theme="@android:style/Theme.Dialog"
android:launchMode="singleInstance"
android:theme="@style/Theme.CustomLightThemeDialog"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
Expand Down Expand Up @@ -176,14 +176,5 @@
<service
android:name=".status_bar.AndroidStatusBarService"
android:exported="false" />

<receiver
android:name=".timer.BootCompletedReceiver"
android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package oly.netpowerctrl.main;
package oly.netpowerctrl;

import android.app.Application;
import android.os.Build;
Expand All @@ -12,9 +12,9 @@
import org.acra.annotation.ReportsCrashes;
import org.acra.sender.HttpSender;

import oly.netpowerctrl.BuildConfig;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.graphic.LoadStoreIconData;
import oly.netpowerctrl.main.GuiThreadHandler;
import oly.netpowerctrl.main.LifecycleHandler;

/**
* Application:
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/oly/netpowerctrl/data/DataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Map;
import java.util.WeakHashMap;

import oly.netpowerctrl.App;
import oly.netpowerctrl.data.query.DataQueryCompletedObserver;
import oly.netpowerctrl.data.query.DataQueryRefreshObserver;
import oly.netpowerctrl.data.query.onDataQueryCompleted;
Expand All @@ -27,7 +28,6 @@
import oly.netpowerctrl.ioconnection.DeviceIOConnections;
import oly.netpowerctrl.ioconnection.IOConnection;
import oly.netpowerctrl.ioconnection.IOConnectionsCollection;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.main.GuiThreadHandler;
import oly.netpowerctrl.main.MainActivity;
import oly.netpowerctrl.network.NetworkChangedBroadcastReceiver;
Expand Down Expand Up @@ -229,13 +229,16 @@ public void onDestroy() {
loadStoreCollections.finish(this);
loadStoreCollections = null;

deviceQuery.finish();
UDPSend.killSendThread();

// Clean up
for (AbstractBasePlugin abstractBasePlugin : plugins)
abstractBasePlugin.onDestroy();
plugins.clear();

clearDataStorage();

weakHashMap.clear();
mDiscoverService = null;

Expand Down Expand Up @@ -323,10 +326,7 @@ public void setLoadStoreController(LoadStoreCollections loadStoreCollections) {
/**
* Tidy up all lists and references.
*/
public void clear() {
// There shouldn't be any device-listen observers anymore,
// but we clear the list here nevertheless.
deviceQuery.finish();
public void clearDataStorage() {
connections.storage.clear();
credentials.storage.clear();
groups.storage.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import java.io.FileOutputStream;
import java.io.IOException;

import oly.netpowerctrl.App;
import oly.netpowerctrl.data.storage_container.CollectionStorage;
import oly.netpowerctrl.devices.Credentials;
import oly.netpowerctrl.executables.ExecutableFabric;
import oly.netpowerctrl.groups.Group;
import oly.netpowerctrl.ioconnection.IOConnectionFabric;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.preferences.SharedPrefs;
import oly.netpowerctrl.status_bar.FavItem;
import oly.netpowerctrl.ui.notifications.InAppNotifications;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import java.io.FileOutputStream;
import java.io.IOException;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.executables.Executable;
import oly.netpowerctrl.executables.ExecutableType;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.preferences.SharedPrefs;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class CollectionStorage<ITEM extends IOInterface> {
// if (storage == null)
// return;
//
// storage.clear(this);
// storage.clearDataStorage(this);
// for (ITEM item : items.values())
// storage.save(this, item);
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import java.util.ArrayList;
import java.util.List;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.AbstractBasePlugin;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.data.onServiceReady;
import oly.netpowerctrl.executables.Executable;
import oly.netpowerctrl.groups.Group;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.utils.AnimationController;
import oly.netpowerctrl.utils.ObserverUpdateActions;
import oly.netpowerctrl.utils.onCollectionUpdated;
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/oly/netpowerctrl/devices/DeviceQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import java.util.List;
import java.util.Map;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.AbstractBasePlugin;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.ioconnection.DeviceIOConnections;
import oly.netpowerctrl.ioconnection.IOConnection;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.network.ReachabilityStates;

/**
Expand All @@ -31,6 +31,7 @@ public class DeviceQuery {
private static final int MSG_RESPONSE = 3;
private static final int MSG_ADD_OBSERVER = 4;
private static final int MSG_RECHECK_MINIMUM_TIME = 5;
private static final int MSG_EXIT = 6;
@SuppressWarnings("unused")
private static final String TAG = "DeviceQuery";
private static int instances = 0;
Expand All @@ -47,6 +48,7 @@ public void run() {
Looper.prepare();
handler = new RepeatHandler(Looper.myLooper());
Looper.loop();
--instances;
}
};

Expand All @@ -60,7 +62,14 @@ public DeviceQuery(DataService dataService) {
* Will call onObserverJobFinished in the gui thread.
*/
public void finish() {
Looper.myLooper().quit();
if (thread.isAlive()) {
handler.sendEmptyMessage(MSG_EXIT);
}
try {
thread.join(2000);
thread.interrupt();
} catch (InterruptedException ignored) {
}
}

protected void doAction(Credentials credentials, int attempt) {
Expand Down Expand Up @@ -304,6 +313,10 @@ public void handleMessage(Message msg) {
deviceSuccess(credentials);
break;
}
case MSG_EXIT: {
Looper.myLooper().quit();
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import java.util.List;

import oly.netpowerctrl.App;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.executables.Executable;
import oly.netpowerctrl.executables.ExecutableCollection;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.utils.ObserverUpdateActions;
import oly.netpowerctrl.utils.onCollectionUpdated;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.widget.PopupMenu;
import android.widget.TextView;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.data.graphic.IconCacheCleared;
Expand All @@ -46,7 +47,6 @@
import oly.netpowerctrl.executables.adapter.InputGroupChanges;
import oly.netpowerctrl.groups.GroupListFragment;
import oly.netpowerctrl.groups.GroupUtilities;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.main.EditActivity;
import oly.netpowerctrl.main.FeedbackFragment;
import oly.netpowerctrl.main.MainActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import android.support.v4.content.ContextCompat;
import android.widget.SeekBar;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.graphic.IconDeferredLoadingThread;
import oly.netpowerctrl.executables.Executable;
import oly.netpowerctrl.main.App;

public class ExecutablesEditableAdapter extends ExecutablesAdapter implements
SeekBar.OnSeekBarChangeListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import java.util.ArrayList;
import java.util.List;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.data.onServiceReady;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.ui.EmptyListener;
import oly.netpowerctrl.utils.ObserverUpdateActions;
import oly.netpowerctrl.utils.onCollectionUpdated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.net.UnknownHostException;
import java.util.UUID;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.network.HttpThreadPool;
import oly.netpowerctrl.ui.FragmentUtils;
import oly.netpowerctrl.ui.ThemeHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.TreeMap;
import java.util.TreeSet;

import oly.netpowerctrl.App;
import oly.netpowerctrl.data.AbstractBasePlugin;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.data.storage_container.CollectionManipulation;
Expand All @@ -22,7 +23,6 @@
import oly.netpowerctrl.data.storage_container.CollectionStorage;
import oly.netpowerctrl.devices.Credentials;
import oly.netpowerctrl.executables.Executable;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.network.ReachabilityStates;
import oly.netpowerctrl.utils.ObserverUpdateActions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.lang.ref.WeakReference;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.AbstractBasePlugin;
import oly.netpowerctrl.data.DataService;
Expand All @@ -34,7 +35,6 @@
import oly.netpowerctrl.ioconnection.adapter.AdapterItemConnection;
import oly.netpowerctrl.ioconnection.adapter.AdapterItemHeader;
import oly.netpowerctrl.ioconnection.adapter.IOConnectionAdapter;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.network.ReachabilityStates;
import oly.netpowerctrl.ui.EmptyListener;
import oly.netpowerctrl.ui.FragmentUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.ioconnection.IOConnection;
import oly.netpowerctrl.ioconnection.IOConnectionsCollection;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.network.ReachabilityStates;
import oly.netpowerctrl.utils.ObserverUpdateActions;
import oly.netpowerctrl.utils.onCollectionUpdated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.devices.Credentials;
import oly.netpowerctrl.devices.CredentialsCollection;
import oly.netpowerctrl.main.App;
import oly.netpowerctrl.utils.ObserverUpdateActions;
import oly.netpowerctrl.utils.onCollectionUpdated;

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/oly/netpowerctrl/main/EditActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Set;
import java.util.TreeSet;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.data.graphic.IconSelected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.util.Log;
import android.widget.Toast;

import oly.netpowerctrl.App;
import oly.netpowerctrl.R;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.utils.Logging;
Expand All @@ -20,7 +21,7 @@ public class GuiThreadHandler extends Handler {
public static final int SERVICE_DELAYED_CHECK_REACHABILITY = 1818;
private static final String TAG = "GuiThreadHandler";

GuiThreadHandler() {
public GuiThreadHandler() {
super(Looper.getMainLooper());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.lang.ref.WeakReference;

import oly.netpowerctrl.App;
import oly.netpowerctrl.data.DataService;
import oly.netpowerctrl.preferences.SharedPrefs;
import oly.netpowerctrl.status_bar.AndroidStatusBarService;
Expand Down
Loading

0 comments on commit 57c840b

Please sign in to comment.