зеркало из https://github.com/mozilla/Jisort.git
Коммит
60df975610
|
@ -62,9 +62,6 @@ dependencies {
|
|||
compile "com.android.support:cardview-v7:${android_support_lib_version}"
|
||||
compile "com.android.support:support-v13:${android_support_lib_version}"
|
||||
|
||||
// Event pubSub
|
||||
compile 'com.squareup:otto:1.3.8'
|
||||
|
||||
compile files('../third_party/basic-http-client/libs/basic-http-client-android-0.88.jar')
|
||||
// JSON utility library.
|
||||
compile 'com.google.code.gson:gson:2.4'
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
android:windowSoftInputMode="stateHidden"></activity>
|
||||
<activity
|
||||
android:name=".activities.DashboardActivity"
|
||||
android:label="@string/app_name"
|
||||
android:label="Jisort - What would you like to do?"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/AppTheme.SplashTheme"
|
||||
android:windowSoftInputMode="stateHidden">
|
||||
|
@ -103,14 +103,6 @@
|
|||
<action android:name="android.intent.action.DEVICE_STORAGE_LOW" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".recievers.DSOInstalledBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_INSTALL" />
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".recievers.DSONetworkStateReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
|
|
|
@ -1,67 +1,25 @@
|
|||
package com.mozilla.hackathon.kiboko;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.ThreadEnforcer;
|
||||
import com.mozilla.hackathon.kiboko.recievers.DSOBatteryReceiver;
|
||||
|
||||
/**
|
||||
* Created by Brian Mwadime on 06/06/2016.
|
||||
*/
|
||||
public class App extends Application {
|
||||
public static String PACKAGE_NAME;
|
||||
protected class MainThreadBus extends Bus {
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
public MainThreadBus() {
|
||||
super(ThreadEnforcer.ANY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void post(final Object event) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
super.post(event);
|
||||
} else {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainThreadBus.super.post(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static Context context = null;
|
||||
|
||||
private static MainThreadBus mEventBus;
|
||||
|
||||
public static Bus getBus() {
|
||||
return mEventBus;
|
||||
}
|
||||
|
||||
public static boolean isServiceRunning() {
|
||||
ActivityManager manager = (ActivityManager)getContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)){
|
||||
if("com.mozilla.hackathon.kiboko.services.ChatHeadService".equals(service.service.getClassName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
context = getApplicationContext();
|
||||
PACKAGE_NAME = context.getPackageName();
|
||||
mEventBus = new MainThreadBus();
|
||||
// Battery receiver - Catches battery low system event
|
||||
// context.registerReceiver(new DSOBatteryReceiver(), new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
context.registerReceiver(new DSOBatteryReceiver(), new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
|
|
|
@ -3,35 +3,23 @@ package com.mozilla.hackathon.kiboko.activities;
|
|||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.Analytics;
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
import com.mozilla.hackathon.kiboko.events.ApplicationStateChanged;
|
||||
import com.mozilla.hackathon.kiboko.services.DataBootstrapService;
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
/**
|
||||
* Created by secretrobotron in July of 2016.
|
||||
*/
|
||||
public class DSOActivity extends AppCompatActivity {
|
||||
|
||||
Bus bus = App.getBus();
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
DataBootstrapService.startDataBootstrapIfNecessary(this);
|
||||
bus.register(this);
|
||||
|
||||
App.getBus().post(new ApplicationStateChanged(true));
|
||||
super.onResume();
|
||||
|
||||
Analytics.add("Resumed DSO Activity", this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
App.getBus().post(new ApplicationStateChanged(false));
|
||||
bus.unregister(this);
|
||||
super.onPause();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,12 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
import com.mozilla.hackathon.kiboko.events.AirplaneModeStateChanged;
|
||||
|
||||
public class DSOAirplaneModeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
boolean isAirplaneModeOn = intent.getBooleanExtra("state", false);
|
||||
if(isAirplaneModeOn){
|
||||
App.getBus().post(new AirplaneModeStateChanged(true));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.BatteryManager;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
import com.mozilla.hackathon.kiboko.events.BatteryStateChanged;
|
||||
|
||||
/**
|
||||
* Created by mwadime on 6/7/2016.
|
||||
*/
|
||||
|
@ -18,7 +15,6 @@ public class DSOBatteryReceiver extends BroadcastReceiver {
|
|||
int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||
|
||||
if(rawlevel <= 25){
|
||||
App.getBus().post(new BatteryStateChanged(true) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
import com.mozilla.hackathon.kiboko.events.BluetoothStateChanged;
|
||||
|
||||
/**
|
||||
* Created by mwadime on 6/7/2016.
|
||||
*/
|
||||
|
@ -19,7 +16,7 @@ public class DSOChangedBroadcastReceiver extends BroadcastReceiver {
|
|||
|
||||
switch(state){
|
||||
case BluetoothAdapter.STATE_ON:
|
||||
App.getBus().post(new BluetoothStateChanged(true) );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package com.mozilla.hackathon.kiboko.recievers;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.services.ChatHeadService;
|
||||
|
||||
/**
|
||||
* Created by mwadime on 6/7/2016.
|
||||
*/
|
||||
public class DSOInstalledBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = null;
|
||||
if (intent != null) {
|
||||
action = intent.getAction();
|
||||
}
|
||||
|
||||
if (action != null && Intent.ACTION_PACKAGE_ADDED.equals(action)) {
|
||||
String dataString = intent.getDataString();
|
||||
if (dataString != null
|
||||
&& dataString.equals("com.mozilla.hackathon.kiboko")) {
|
||||
|
||||
if(Build.VERSION.SDK_INT >= 23) {
|
||||
if (!Settings.canDrawOverlays(context)) {
|
||||
intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
Uri.parse("package:" + context.getPackageName()));
|
||||
context.getApplicationContext().startActivity(intent); //, 1234
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
intent = new Intent(context, ChatHeadService.class);
|
||||
context.startService(intent);
|
||||
}
|
||||
intent = new Intent(context, ChatHeadService.class);
|
||||
context.startService(intent);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,10 +3,6 @@ package com.mozilla.hackathon.kiboko.recievers;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
import com.mozilla.hackathon.kiboko.events.LocationStateChanged;
|
||||
|
||||
/**
|
||||
* Created by mwadime on 6/7/2016.
|
||||
|
@ -16,7 +12,6 @@ public class DSOLocationReceiver extends BroadcastReceiver {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (intent.getAction().matches("android.location.PROVIDERS_CHANGED")) {
|
||||
App.getBus().post(new LocationStateChanged(true) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,8 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import com.mozilla.hackathon.kiboko.utilities.NetworkUtils;
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.events.NetworkStateChanged;
|
||||
import com.mozilla.hackathon.kiboko.utilities.NetworkUtils;
|
||||
|
||||
/**
|
||||
* Created by mwadime on 6/7/2016.
|
||||
|
@ -21,15 +19,14 @@ import com.mozilla.hackathon.kiboko.events.NetworkStateChanged;
|
|||
NetworkInfo ni=(NetworkInfo) intent.getExtras().get(ConnectivityManager.EXTRA_NETWORK_INFO);
|
||||
if(ni!=null && ni.getState()==NetworkInfo.State.CONNECTED)
|
||||
{
|
||||
App.getBus().post(new NetworkStateChanged(true) );
|
||||
// there is Internet connection
|
||||
} else
|
||||
|
||||
App.getBus().post(new NetworkStateChanged(false) );
|
||||
|
||||
if(intent .getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,Boolean.FALSE))
|
||||
{
|
||||
// no Internet connection, send network state changed
|
||||
App.getBus().post(new NetworkStateChanged(false) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.mozilla.hackathon.kiboko.App;
|
||||
import com.mozilla.hackathon.kiboko.events.LowstorageStateChanged;
|
||||
|
||||
/**
|
||||
* Created by mwadime on 6/7/2016.
|
||||
*/
|
||||
|
@ -14,7 +11,7 @@ public class DSOStorageReceiver extends BroadcastReceiver {
|
|||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if(intent.getAction().matches(Intent.ACTION_DEVICE_STORAGE_LOW)){
|
||||
App.getBus().post(new LowstorageStateChanged(true));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Двоичные данные
app/src/main/res/drawable-nodpi/android_head.png
Двоичные данные
app/src/main/res/drawable-nodpi/android_head.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 59 KiB |
Двоичные данные
app/src/main/res/drawable-nodpi/android_head_suggestion.png
Двоичные данные
app/src/main/res/drawable-nodpi/android_head_suggestion.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 63 KiB |
Двоичные данные
app/src/main/res/drawable-nodpi/cell.png
Двоичные данные
app/src/main/res/drawable-nodpi/cell.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 554 B После Ширина: | Высота: | Размер: 15 KiB |
|
@ -5,5 +5,5 @@
|
|||
<solid android:color="@color/colorIcons"/>
|
||||
</shape>
|
||||
</item>
|
||||
<item android:drawable="@drawable/cell" android:top="10dp" android:bottom="10dp" android:left="10dp" android:right="10dp" />
|
||||
<item android:drawable="@drawable/cell" />
|
||||
</layer-list>
|
|
@ -38,9 +38,9 @@
|
|||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/result_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/activity_horizontal_margin"
|
||||
android:layout_margin="48dp"
|
||||
android:scaleType="fitXY"
|
||||
android:adjustViewBounds="true"
|
||||
android:src="@drawable/bmo"
|
||||
|
|
|
@ -27,15 +27,15 @@
|
|||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:textColor="@color/colorTextPrimary"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="@dimen/text_size_large"
|
||||
style="?android:textAppearanceLarge"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dashboard_question_text"/>
|
||||
<!--<TextView-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:textColor="@color/colorTextPrimary"-->
|
||||
<!--android:layout_gravity="center_horizontal"-->
|
||||
<!--android:gravity="center_horizontal"-->
|
||||
<!--android:textSize="@dimen/text_size_large"-->
|
||||
<!--style="?android:textAppearanceLarge"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:text="@string/dashboard_question_text"/>-->
|
||||
<fragment android:name="com.mozilla.hackathon.kiboko.fragments.TopicsFragment"
|
||||
android:id="@+id/list"
|
||||
android:background="@color/colorPrimary"
|
||||
|
|
Загрузка…
Ссылка в новой задаче