Skip to content

Commit f861116

Browse files
committed
Added sort menu icon on logs screen
1 parent d1fd6b0 commit f861116

File tree

8 files changed

+136
-19
lines changed

8 files changed

+136
-19
lines changed

Diff for: app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ dependencies {
180180
implementation 'com.google.android.material:material:1.8.0'
181181
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
182182
implementation 'androidx.annotation:annotation:1.5.0'
183-
implementation "androidx.car.app:app:1.4.0-alpha01"
183+
implementation "androidx.car.app:app:1.3.0-rc01"
184184
implementation 'org.reactivestreams:reactive-streams:1.0.3'
185185
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
186186
implementation 'com.revenuecat.purchases:purchases:5.6.3'

Diff for: app/src/main/java/nl/hnogames/domoticz/LogsActivity.java

+42-2
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,22 @@
2222
package nl.hnogames.domoticz;
2323

2424
import android.os.Bundle;
25+
import android.util.Log;
26+
import android.view.Menu;
27+
import android.view.MenuItem;
2528

2629
import androidx.appcompat.widget.Toolbar;
2730

2831
import com.ftinc.scoop.Scoop;
2932

3033
import nl.hnogames.domoticz.app.AppCompatPermissionsActivity;
3134
import nl.hnogames.domoticz.fragments.Logs;
35+
import nl.hnogames.domoticz.ui.SortDialog;
3236
import nl.hnogames.domoticz.utils.SharedPrefUtil;
3337
import nl.hnogames.domoticz.utils.UsefulBits;
3438

3539
public class LogsActivity extends AppCompatPermissionsActivity {
40+
private Logs fragment;
3641

3742
@Override
3843
protected void onCreate(Bundle savedInstanceState) {
@@ -42,7 +47,8 @@ protected void onCreate(Bundle savedInstanceState) {
4247
Scoop.getInstance().apply(this);
4348
super.onCreate(savedInstanceState);
4449

45-
setContentView(R.layout.activity_graph);
50+
setContentView(R.layout.activity_logs);
51+
4652
Toolbar toolbar = findViewById(R.id.toolbar);
4753
setSupportActionBar(toolbar);
4854
this.setTitle(getString(R.string.title_logs));
@@ -53,9 +59,43 @@ protected void onCreate(Bundle savedInstanceState) {
5359
if (getSupportActionBar() != null)
5460
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
5561

56-
Logs fragment = new Logs();
62+
fragment = new Logs();
5763
getSupportFragmentManager().beginTransaction()
5864
.replace(R.id.main, fragment)
5965
.commit();
6066
}
67+
68+
@Override
69+
public boolean onCreateOptionsMenu(Menu menu) {
70+
getMenuInflater().inflate(R.menu.menu_logs_sort, menu);
71+
return super.onCreateOptionsMenu(menu);
72+
}
73+
74+
@Override
75+
76+
public boolean onOptionsItemSelected(MenuItem item) {
77+
try {
78+
switch (item.getItemId()) {
79+
case R.id.action_sort:
80+
SortDialog infoDialog = new SortDialog(
81+
this,
82+
R.layout.dialog_switch_logs,
83+
new String[]{getString(R.string.filter_all), getString(R.string.filter_normal), getString(R.string.filter_status), getString(R.string.filter_error)});
84+
85+
infoDialog.onDismissListener(selectedSort -> {
86+
Log.i("Logs", "Sorting: " + selectedSort);
87+
fragment.sortFragment(selectedSort);
88+
});
89+
90+
infoDialog.show();
91+
return true;
92+
default:
93+
break;
94+
}
95+
} catch (Exception ex) {
96+
ex.printStackTrace();
97+
}
98+
99+
return super.onOptionsItemSelected(item);
100+
}
61101
}

Diff for: app/src/main/java/nl/hnogames/domoticz/fragments/Graph.java

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public void onActivityCreated(Bundle savedInstanceState) {
110110
}
111111

112112
@Override
113-
114113
public void onCreate(Bundle savedInstanceState) {
115114
super.onCreate(savedInstanceState);
116115

Diff for: app/src/main/java/nl/hnogames/domoticz/fragments/Logs.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import android.view.View;
2929
import android.view.ViewGroup;
3030

31-
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
32-
3331
import java.util.ArrayList;
3432

3533
import nl.hnogames.domoticz.R;
@@ -71,6 +69,12 @@ public void onAttach(Context context) {
7169
setSortFab(true);
7270
}
7371

72+
@Override
73+
public void onCreate(Bundle savedInstanceState) {
74+
super.onCreate(savedInstanceState);
75+
setHasOptionsMenu(true);
76+
}
77+
7478
@Override
7579
public View onCreateView(LayoutInflater inflater,
7680
ViewGroup container,
@@ -130,13 +134,7 @@ private void createListView(ArrayList<LogInfo> mLogInfos) {
130134
itemDecorationAdded = true;
131135
}
132136
mSwipeRefreshLayout.setRefreshing(false);
133-
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
134-
@Override
135-
136-
public void onRefresh() {
137-
processLogs();
138-
}
139-
});
137+
mSwipeRefreshLayout.setOnRefreshListener(() -> processLogs());
140138
}
141139
super.showSpinner(false);
142140
this.Filter(filter);
@@ -152,7 +150,6 @@ public void onPause() {
152150

153151
public void errorHandling(Exception error) {
154152
if (error != null) {
155-
// Let's check if were still attached to an activity
156153
if (isAdded()) {
157154
if (mSwipeRefreshLayout != null)
158155
mSwipeRefreshLayout.setRefreshing(false);

Diff for: app/src/main/res/layout/activity_logs.xml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!--
2+
~ Copyright (C) 2015 Domoticz - Mark Heinis
3+
~
4+
~ Licensed to the Apache Software Foundation (ASF) under one
5+
~ or more contributor license agreements. See the NOTICE file
6+
~ distributed with this work for additional information
7+
~ regarding copyright ownership. The ASF licenses this file
8+
~ to you under the Apache License, Version 2.0 (the
9+
~ "License"); you may not use this file except in compliance
10+
~ with the License. You may obtain a copy of the License at
11+
~
12+
~ http://www.apache.org/licenses/LICENSE-2.0
13+
~
14+
~ Unless required by applicable law or agreed to in writing,
15+
~ software distributed under the License is distributed on an
16+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
~ KIND, either express or implied. See the License for the
18+
~ specific language governing permissions and limitations
19+
~ under the License.
20+
-->
21+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
22+
xmlns:tools="http://schemas.android.com/tools"
23+
android:layout_width="match_parent"
24+
android:layout_height="match_parent"
25+
android:orientation="vertical"
26+
tools:context=".GraphActivity">
27+
28+
<LinearLayout
29+
android:id="@+id/phoneLayoutWrapper"
30+
android:layout_width="match_parent"
31+
android:layout_height="match_parent"
32+
android:background="?attr/recyclerBackground"
33+
android:orientation="vertical">
34+
35+
<androidx.appcompat.widget.Toolbar
36+
android:id="@+id/toolbar"
37+
android:layout_width="match_parent"
38+
android:layout_height="?attr/actionBarSize"
39+
android:background="?attr/toolbarBackground"
40+
android:theme="@style/AppThemeToolbarStyle" />
41+
42+
<FrameLayout
43+
android:id="@+id/main"
44+
android:layout_width="match_parent"
45+
android:layout_height="match_parent" />
46+
</LinearLayout>
47+
</RelativeLayout>

Diff for: app/src/main/res/menu/menu_logs_sort.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--
2+
~ Copyright (C) 2015 Domoticz - Mark Heinis
3+
~
4+
~ Licensed to the Apache Software Foundation (ASF) under one
5+
~ or more contributor license agreements. See the NOTICE file
6+
~ distributed with this work for additional information
7+
~ regarding copyright ownership. The ASF licenses this file
8+
~ to you under the Apache License, Version 2.0 (the
9+
~ "License"); you may not use this file except in compliance
10+
~ with the License. You may obtain a copy of the License at
11+
~
12+
~ http://www.apache.org/licenses/LICENSE-2.0
13+
~
14+
~ Unless required by applicable law or agreed to in writing,
15+
~ software distributed under the License is distributed on an
16+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
~ KIND, either express or implied. See the License for the
18+
~ specific language governing permissions and limitations
19+
~ under the License.
20+
-->
21+
22+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
23+
xmlns:app="http://schemas.android.com/apk/res-auto"
24+
xmlns:tools="http://schemas.android.com/tools"
25+
tools:context=".GraphActivity">
26+
27+
<item
28+
android:id="@+id/action_sort"
29+
android:icon="@drawable/baseline_filter_list_white_24"
30+
android:orderInCategory="100"
31+
android:title="@string/action_filter"
32+
app:showAsAction="always" />
33+
34+
</menu>

Diff for: app/version.properties

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Tue May 02 16:35:06 CEST 2023
2-
VERSION_BUILD=9322
3-
VERSION_CODE=668
4-
VERSION_PATCH=357
1+
#Tue May 02 16:54:24 CEST 2023
2+
VERSION_BUILD=9328
3+
VERSION_CODE=669
4+
VERSION_PATCH=358

Diff for: domoticzapi/version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Tue May 02 16:35:06 CEST 2023
1+
#Tue May 02 16:54:24 CEST 2023
22
VERSION_BUILD=3675
33
VERSION_CODE=254
44
VERSION_PATCH=254

0 commit comments

Comments
 (0)