Skip to content

Commit c7daf7b

Browse files
committed
Updated icons to current drawables, some optimizations, layout fixes
1 parent 09c022f commit c7daf7b

File tree

68 files changed

+201
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+201
-156
lines changed

app/src/main/java/ru/meefik/linuxdeploy/PrefStore.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,15 +789,13 @@ public static void showNotification(Context context, Intent intent) {
789789
startReceive.setAction("ru.meefik.linuxdeploy.BROADCAST_ACTION");
790790
startReceive.putExtra("start", true);
791791
PendingIntent pendingIntentStart = PendingIntent.getBroadcast(context, 3, startReceive, PendingIntent.FLAG_UPDATE_CURRENT);
792-
int startIcon = SETTINGS.get(context, "theme").equals("dark") ? R.drawable.ic_action_start_dark : R.drawable.ic_action_start_light;
793-
notificationBuilder.addAction(startIcon, context.getString(R.string.menu_start), pendingIntentStart);
792+
notificationBuilder.addAction(R.drawable.ic_play_arrow_24dp, context.getString(R.string.menu_start), pendingIntentStart);
794793

795794
Intent stopReceive = new Intent();
796795
stopReceive.setAction("ru.meefik.linuxdeploy.BROADCAST_ACTION");
797796
stopReceive.putExtra("stop", true);
798797
PendingIntent pendingIntentStop = PendingIntent.getBroadcast(context, 4, stopReceive, PendingIntent.FLAG_UPDATE_CURRENT);
799-
int stopIcon = SETTINGS.get(context, "theme").equals("dark") ? R.drawable.ic_action_stop_dark : R.drawable.ic_action_stop_light;
800-
notificationBuilder.addAction(stopIcon, context.getString(R.string.menu_stop), pendingIntentStop);
798+
notificationBuilder.addAction(R.drawable.ic_stop_24dp, context.getString(R.string.menu_stop), pendingIntentStop);
801799
}
802800
notificationBuilder.setOngoing(true);
803801
notificationBuilder.setWhen(0);

app/src/main/java/ru/meefik/linuxdeploy/activity/MainActivity.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class MainActivity extends AppCompatActivity implements
5656
private static WifiLock wifiLock;
5757
private static PowerManager.WakeLock wakeLock;
5858

59+
private DrawerLayout drawer;
60+
5961
private NetworkReceiver networkReceiver;
6062
private PowerReceiver powerReceiver;
6163

@@ -102,7 +104,7 @@ public void onCreate(Bundle savedInstanceState) {
102104
actionBar.setDisplayHomeAsUpEnabled(true);
103105
}
104106

105-
DrawerLayout drawer = findViewById(R.id.drawer_layout);
107+
drawer = findViewById(R.id.drawer_layout);
106108
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
107109
this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
108110
drawer.addDrawerListener(toggle);
@@ -203,7 +205,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
203205
clearLog();
204206
break;
205207
case android.R.id.home:
206-
DrawerLayout drawer = findViewById(R.id.drawer_layout);
207208
if (drawer.isDrawerOpen(GravityCompat.START)) {
208209
drawer.closeDrawer(GravityCompat.START);
209210
} else {
@@ -219,7 +220,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
219220

220221
@Override
221222
public void onBackPressed() {
222-
DrawerLayout drawer = findViewById(R.id.drawer_layout);
223223
if (drawer != null && drawer.isDrawerOpen(GravityCompat.START)) {
224224
drawer.closeDrawer(GravityCompat.START);
225225
} else {
@@ -268,7 +268,6 @@ public boolean onNavigationItemSelected(MenuItem item) {
268268
break;
269269
}
270270

271-
DrawerLayout drawer = findViewById(R.id.drawer_layout);
272271
drawer.closeDrawer(GravityCompat.START);
273272
return true;
274273
}
@@ -350,8 +349,10 @@ public void containerStart(View view) {
350349
} else {
351350
EnvUtils.execService(getBaseContext(), "start", "-m");
352351
}
353-
}).setNegativeButton(android.R.string.no,
354-
(dialog, id) -> dialog.cancel()).show();
352+
})
353+
.setNegativeButton(android.R.string.no,
354+
(dialog, id) -> dialog.cancel())
355+
.show();
355356
}
356357

357358
/**
@@ -365,8 +366,10 @@ public void containerStop(View view) {
365366
.setIcon(android.R.drawable.ic_dialog_alert)
366367
.setCancelable(false)
367368
.setPositiveButton(android.R.string.yes,
368-
(dialog, id) -> EnvUtils.execService(getBaseContext(), "stop", "-u")).setNegativeButton(android.R.string.no,
369-
(dialog, id) -> dialog.cancel()).show();
369+
(dialog, id) -> EnvUtils.execService(getBaseContext(), "stop", "-u"))
370+
.setNegativeButton(android.R.string.no,
371+
(dialog, id) -> dialog.cancel())
372+
.show();
370373
}
371374

372375
/**
@@ -391,7 +394,8 @@ private void containerDeploy() {
391394
.setPositiveButton(android.R.string.yes,
392395
(dialog, id) -> EnvUtils.execService(getApplicationContext(), "deploy", null))
393396
.setNegativeButton(android.R.string.no,
394-
(dialog, id) -> dialog.cancel()).show();
397+
(dialog, id) -> dialog.cancel())
398+
.show();
395399
}
396400

397401
/**
@@ -405,7 +409,8 @@ private void containerConfigure() {
405409
.setPositiveButton(android.R.string.yes,
406410
(dialog, id) -> EnvUtils.execService(getBaseContext(), "deploy", "-m -n bootstrap"))
407411
.setNegativeButton(android.R.string.no,
408-
(dialog, id) -> dialog.cancel()).show();
412+
(dialog, id) -> dialog.cancel())
413+
.show();
409414
}
410415

411416
/**
@@ -422,7 +427,8 @@ private void containerExport() {
422427
.setPositiveButton(android.R.string.yes,
423428
(dialog, id) -> EnvUtils.execService(getBaseContext(), "export", input.getText().toString()))
424429
.setNegativeButton(android.R.string.no,
425-
(dialog, id) -> dialog.cancel()).show();
430+
(dialog, id) -> dialog.cancel())
431+
.show();
426432
}
427433

428434
/**

app/src/main/java/ru/meefik/linuxdeploy/activity/MountsActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void deleteDialog(Mount mount) {
7979
new AlertDialog.Builder(this)
8080
.setTitle(R.string.confirm_mount_discard_title)
8181
.setMessage(R.string.confirm_mount_discard_message)
82-
.setIcon(R.drawable.ic_warning_white_24dp)
82+
.setIcon(R.drawable.ic_warning_24dp)
8383
.setPositiveButton(android.R.string.yes,
8484
(dialog, whichButton) -> adapter.removeMount(mount))
8585
.setNegativeButton(android.R.string.no,

app/src/main/java/ru/meefik/linuxdeploy/activity/ProfilesActivity.java

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package ru.meefik.linuxdeploy.activity;
22

33
import android.content.Context;
4-
import android.content.DialogInterface;
54
import android.os.Bundle;
65
import android.view.GestureDetector;
6+
import android.view.LayoutInflater;
77
import android.view.Menu;
88
import android.view.MenuItem;
99
import android.view.MotionEvent;
@@ -66,17 +66,19 @@ public static boolean removeConf(Context c, String name) {
6666
public static List<String> getProfiles(Context c) {
6767
List<String> profiles = new ArrayList<>();
6868
File confDir = new File(PrefStore.getEnvDir(c) + "/config");
69-
File[] listOfFiles = confDir.listFiles();
70-
if (listOfFiles != null) {
71-
for (File listOfFile : listOfFiles) {
72-
if (listOfFile.isFile()) {
73-
String filename = listOfFile.getName();
69+
File[] profileFiles = confDir.listFiles();
70+
71+
if (profileFiles != null) {
72+
for (File profileFile : profileFiles) {
73+
if (profileFile.isFile()) {
74+
String filename = profileFile.getName();
7475
int index = filename.lastIndexOf('.');
7576
if (index != -1) filename = filename.substring(0, index);
7677
profiles.add(filename);
7778
}
7879
}
7980
}
81+
8082
return profiles;
8183
}
8284

@@ -87,45 +89,51 @@ public static List<String> getProfiles(Context c) {
8789
* @return position
8890
*/
8991
private int getPosition(String key) {
90-
int pos = 0;
91-
for (String item : listItems) {
92-
if (item.equals(key)) return pos;
93-
pos++;
92+
for (int i = 0; i < listItems.size(); i++) {
93+
if (listItems.get(i).equals(key))
94+
return i;
9495
}
96+
9597
return -1;
9698
}
9799

98100
private void addDialog() {
99-
final EditText input = new EditText(this);
101+
View view = LayoutInflater.from(this).inflate(R.layout.edit_text_dialog, null);
102+
EditText input = view.findViewById(R.id.edit_text);
103+
100104
new AlertDialog.Builder(this)
101105
.setTitle(R.string.new_profile_title)
102-
.setView(input)
106+
.setView(view)
103107
.setPositiveButton(android.R.string.ok,
104108
(dialog, whichButton) -> {
105109
String text = input.getText().toString();
106-
if (text.length() > 0) {
110+
if (!text.isEmpty()) {
107111
listItems.add(text.replaceAll("[^A-Za-z0-9_\\-]", "_"));
108112
adapter.notifyDataSetChanged();
109113
}
110114
})
111115
.setNegativeButton(android.R.string.cancel,
112-
(dialog, whichButton) -> dialog.cancel()).show();
116+
(dialog, whichButton) -> dialog.cancel())
117+
.show();
113118
}
114119

115120
private void editDialog() {
116-
final EditText input = new EditText(this);
117-
final int pos = listView.getCheckedItemPosition();
121+
int pos = listView.getCheckedItemPosition();
118122
if (pos >= 0 && pos < listItems.size()) {
119-
final String profileOld = listItems.get(pos);
123+
String profileOld = listItems.get(pos);
124+
125+
View view = LayoutInflater.from(this).inflate(R.layout.edit_text_dialog, null);
126+
EditText input = view.findViewById(R.id.edit_text);
120127
input.setText(profileOld);
121128
input.setSelection(input.getText().length());
129+
122130
new AlertDialog.Builder(this)
123131
.setTitle(R.string.edit_profile_title)
124-
.setView(input)
132+
.setView(view)
125133
.setPositiveButton(android.R.string.ok,
126134
(dialog, whichButton) -> {
127135
String text = input.getText().toString();
128-
if (text.length() > 0) {
136+
if (!text.isEmpty()) {
129137
String profileNew = text.replaceAll("[^A-Za-z0-9_\\-]", "_");
130138
if (!profileOld.equals(profileNew)) {
131139
renameConf(getApplicationContext(), profileOld, profileNew);
@@ -135,7 +143,8 @@ private void editDialog() {
135143
}
136144
})
137145
.setNegativeButton(android.R.string.cancel,
138-
(dialog, whichButton) -> dialog.cancel()).show();
146+
(dialog, whichButton) -> dialog.cancel())
147+
.show();
139148
}
140149
}
141150

@@ -145,12 +154,10 @@ private void deleteDialog() {
145154
new AlertDialog.Builder(this)
146155
.setTitle(R.string.confirm_profile_discard_title)
147156
.setMessage(R.string.confirm_profile_discard_message)
148-
.setIcon(android.R.drawable.ic_dialog_alert)
149-
.setCancelable(false)
157+
.setIcon(R.drawable.ic_warning_24dp)
150158
.setPositiveButton(android.R.string.yes,
151159
(dialog, whichButton) -> {
152-
String key = listItems.get(pos);
153-
listItems.remove(pos);
160+
String key = listItems.remove(pos);
154161
int last = listItems.size() - 1;
155162
if (last < 0) listItems.add(getString(R.string.profile));
156163
if (last >= 0 && pos > last)
@@ -159,7 +166,8 @@ private void deleteDialog() {
159166
removeConf(getApplicationContext(), key);
160167
})
161168
.setNegativeButton(android.R.string.no,
162-
(dialog, whichButton) -> dialog.cancel()).show();
169+
(dialog, whichButton) -> dialog.cancel())
170+
.show();
163171
}
164172
}
165173

@@ -210,13 +218,17 @@ public boolean onOptionsItemSelected(MenuItem item) {
210218
case R.id.menu_delete:
211219
deleteDialog();
212220
break;
221+
default:
222+
return super.onOptionsItemSelected(item);
213223
}
214-
return false;
224+
225+
return true;
215226
}
216227

217228
@Override
218229
public void onPause() {
219230
super.onPause();
231+
220232
int pos = listView.getCheckedItemPosition();
221233
if (pos >= 0 && pos < listItems.size()) {
222234
String profile = listItems.get(pos);

app/src/main/java/ru/meefik/linuxdeploy/activity/RepositoryActivity.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import android.content.pm.PackageManager;
66
import android.net.Uri;
77
import android.os.Bundle;
8+
import android.view.LayoutInflater;
89
import android.view.Menu;
910
import android.view.MenuItem;
11+
import android.view.View;
1012
import android.widget.EditText;
1113
import android.widget.Toast;
1214

@@ -71,12 +73,14 @@ private void importDialog(final RepositoryProfile repositoryProfile) {
7173
}
7274

7375
private void changeUrlDialog() {
74-
final EditText input = new EditText(this);
76+
View view = LayoutInflater.from(this).inflate(R.layout.edit_text_dialog, null);
77+
EditText input = view.findViewById(R.id.edit_text);
7578
input.setText(PrefStore.getRepositoryUrl(this));
7679
input.setSelection(input.getText().length());
80+
7781
new AlertDialog.Builder(this)
7882
.setTitle(R.string.repository_change_url_title)
79-
.setView(input)
83+
.setView(view)
8084
.setPositiveButton(android.R.string.ok,
8185
(dialog, whichButton) -> {
8286
String text = input.getText().toString();
@@ -242,12 +246,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
242246
switch (item.getItemId()) {
243247
case R.id.menu_refresh:
244248
retrieveIndex();
245-
return true;
249+
break;
246250
case R.id.menu_change_url:
247251
changeUrlDialog();
248-
return true;
252+
break;
249253
default:
250254
return super.onOptionsItemSelected(item);
251255
}
256+
257+
return true;
252258
}
253259
}
-215 Bytes
Binary file not shown.
-241 Bytes
Binary file not shown.
-298 Bytes
Binary file not shown.
-326 Bytes
Binary file not shown.
-329 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)