Added ongoing notification showing network status

- renamed packages to be more consistent
- somewhate refactored the way notifications are made
This commit is contained in:
2015-10-18 13:40:17 +02:00
parent 1659aaa1ee
commit 13cb804fc2
19 changed files with 262 additions and 82 deletions

View File

@ -0,0 +1,56 @@
/*
* Copyright 2015 Christian Basler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.dissem.apps.abit.util;
import android.content.Context;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
/**
* Helper class to work with Assets.
*/
public class Assets {
public static String readToString(Context ctx, String name) {
try {
InputStream in = ctx.getAssets().open(name);
return new Scanner(in, "UTF-8").useDelimiter("\\A").next();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static List<String> readSqlStatements(Context ctx, String name) {
try {
InputStream in = ctx.getAssets().open(name);
Scanner scanner = new Scanner(in, "UTF-8").useDelimiter(";");
List<String> result = new LinkedList<>();
while (scanner.hasNext()) {
String statement = scanner.next().trim();
if (!"".equals(statement)) {
result.add(statement);
}
}
return result;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright 2015 Christian Basler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.dissem.apps.abit.util;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.Menu;
import ch.dissem.apps.abit.Identicon;
import ch.dissem.apps.abit.R;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
/**
* Some helper methods to work with drawables.
*/
public class Drawables {
public static void addIcon(Context ctx, Menu menu, int menuItem, GoogleMaterial.Icon icon) {
menu.findItem(menuItem).setIcon(new IconicsDrawable(ctx, icon).colorRes(R.color.primary_text_default_material_dark).actionBar());
}
public static Bitmap toBitmap(Identicon identicon, int size) {
return toBitmap(identicon, size, size);
}
public static Bitmap toBitmap(Identicon identicon, int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
identicon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
identicon.draw(canvas);
return bitmap;
}
}