Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Widget and minor app updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tkarakilic committed Jan 17, 2017
1 parent 55d7288 commit fdc6a67
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 42 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.arastta"
minSdkVersion 15
targetSdkVersion 23
versionCode 10
versionName "1.1.0"
versionCode 11
versionName "1.1.1"
}
buildTypes {
release {
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
<activity android:name=".AppSettingsActivity" />
<activity android:name=".ManageStoresActivity" />

<receiver android:name=".AppWidget">
<receiver android:name=".AppWidget"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
Expand All @@ -51,6 +52,10 @@
</intent-filter>
</activity>





</application>

</manifest>
39 changes: 17 additions & 22 deletions app/src/main/java/com/arastta/AppWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class AppWidget extends AppWidgetProvider
boolean Working = false;

static String APPWIDGET_UPDATE = "android.appwidget.action.APPWIDGET_UPDATE";
static String SETTING = "Setting";
static String REFRESH = "Refresh";

static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId)
Expand All @@ -42,12 +43,13 @@ static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,

Intent setting = new Intent(context, AppWidgetSettings.class);
setting.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
setting.setAction(String.valueOf(appWidgetId));
PendingIntent setting_ = PendingIntent.getActivity(context, 0, setting, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.WidgetSettings, setting_);

Intent refresh = new Intent(context, AppWidget.class);
refresh.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
refresh.setAction(REFRESH);
refresh.setAction(REFRESH+String.valueOf(appWidgetId));
PendingIntent refresh_ = PendingIntent.getBroadcast(context, 0, refresh, PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.WidgetRefresh, refresh_);

Expand All @@ -64,6 +66,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
for (int i=0; i<appWidgetIds.length; i++)
{
int appWidgetId = appWidgetIds[i];
Log.e("onUpdate","appWidgetId:"+String.valueOf(appWidgetId));
updateAppWidget(context, appWidgetManager, appWidgetId);
}
}
Expand All @@ -78,22 +81,29 @@ public void onReceive(Context context, Intent intent)
{
Log.e("onReceive",APPWIDGET_UPDATE);
if(intent.getExtras() != null) {

ComponentName componentName = new ComponentName(context, AppWidget.class);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
ComponentName thisAppWidget = new ComponentName(context.getPackageName(), AppWidget.class.getName());
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(componentName);

//AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
//ComponentName thisAppWidget = new ComponentName(context.getPackageName(), AppWidget.class.getName());
//int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisAppWidget);

onUpdate(context, appWidgetManager, appWidgetIds);
}
}

if(intent.getAction().equals(REFRESH))
if(intent.getAction().startsWith(REFRESH))
{
Log.e("onReceive",REFRESH);
if (intent.getExtras() != null)
{
ctx = context;
wid = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
Log.e("mAppWidgetId",String.valueOf(wid));
//wid = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
Log.e("mAppWidgetIdXX",intent.getAction());
wid = Integer.parseInt(intent.getAction().substring(REFRESH.length()));
Log.e("mAppWidgetIdX",String.valueOf(wid));
Log.e("mAppWidgetId2",String.valueOf(intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID)));
if(!Working)new getDashboard().execute();
}
Expand All @@ -104,22 +114,7 @@ public void onReceive(Context context, Intent intent)
public void onDeleted(Context context, int[] appWidgetIds)
{
Log.e("AppWidget","onDeleted");
/*
for (int appWidgetId : appWidgetIds)
{
AppWidgetSettings.deleteTitlePref(context, "title", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "order_count", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "user_count", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "total", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "periodText", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "period", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "listIDs", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "statusIDs", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "username", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "password", appWidgetId);
AppWidgetSettings.deleteTitlePref(context, "url", appWidgetId);
}
*/
super.onDeleted(context, appWidgetIds);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/arastta/AppWidgetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public void onCreate(Bundle icicle)
if (extras != null)
{
mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
Log.e("mAppWidgetId",String.valueOf(mAppWidgetId));
//mAppWidgetId = Integer.parseInt(intent.getAction());
Log.e("mAppWidgetId1",String.valueOf(mAppWidgetId));
Log.e("mAppWidgetId2",String.valueOf(extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID)));
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/arastta/DashboardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ protected void onPostExecute(String result)
totalValue += daily.getJSONObject(i).getInt("price");

if(maxValue < daily.getJSONObject(i).getInt("price"))
{
maxValue = daily.getJSONObject(i).getInt("price");
Log.i("maxValue"+String.valueOf(i),String.valueOf(maxValue));
}
}
catch (JSONException e)
{
Expand Down Expand Up @@ -343,6 +346,8 @@ protected void onPostExecute(String result)
graphView.getViewport().setXAxisBoundsManual(true);
graphView.getViewport().setMinX(0);
graphView.getViewport().setMaxX(daily.length());
graphView.getViewport().setMinY(0);
graphView.getViewport().setMaxY(maxValue);
graphView.getGridLabelRenderer().setGridColor(context.getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setVerticalLabelsColor(context.getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setHorizontalLabelsColor(context.getResources().getColor(R.color.colorAccent));
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/MenuButton"
android:layout_toLeftOf="@+id/TopButtons"
android:ellipsize="end"
android:layout_centerVertical="true"
android:textColor="@android:color/white"
android:textSize="18dp"/>
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_master2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
android:id="@+id/MenuTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/BackButton"
android:layout_marginRight="8dp"
android:maxLines="1"
android:ellipsize="end"
android:layout_toRightOf="@+id/BackButton"
android:layout_centerVertical="true"
android:textColor="@android:color/white"
android:textSize="18dp"/>

Expand Down
17 changes: 12 additions & 5 deletions app/src/main/res/layout/item_customers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null" >
<RelativeLayout

<RelativeLayout
android:id="@+id/CustomerItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:background="@drawable/shadow_bg" >
android:background="@drawable/shadow_bg"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/LinearLayout2"
android:orientation="vertical">

<TextView
android:id="@+id/CustomerFullname"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/colorPrimary"
android:textSize="21dp"/>

Expand All @@ -45,6 +51,7 @@
</LinearLayout>

<LinearLayout
android:id="@+id/LinearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/layout/item_history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
android:id="@+id/HistoryItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shadow_bg">
android:background="@drawable/shadow_bg"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">

<TextView
android:id="@+id/HistoryDate"
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/res/layout/item_orders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null" >
<RelativeLayout

<RelativeLayout
android:id="@+id/OrdersItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:background="@drawable/shadow_bg" >
android:background="@drawable/shadow_bg">

<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/LinearLayout2"
android:orientation="vertical">

<TextView
android:id="@+id/OrderFullname"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textColor="@color/colorText"
android:textSize="21dp"/>

Expand All @@ -45,6 +48,7 @@
</LinearLayout>

<LinearLayout
android:id="@+id/LinearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_products.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<TextView
android:id="@+id/ProductName"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/item_stores.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

<TextView
android:id="@+id/StoreTitle"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/StoreButton"
android:ellipsize="end"
android:layout_marginLeft="8dp"
android:gravity="center_vertical"
android:textColor="@color/colorPrimary"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/app_widget_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="40dp"
android:minWidth="250dp"
android:updatePeriodMillis="86400000"
android:updatePeriodMillis="3600000"
android:configure="com.arastta.AppWidgetSettings"
android:previewImage="@drawable/widget_preview"
android:initialLayout="@layout/app_widget"
Expand Down

0 comments on commit fdc6a67

Please sign in to comment.