Add a toolbar menu with back and refresh buttons
Change theme just to make the refresh button visible without changing its color.
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.AppCompat.Light">
|
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".UpdatesActivity"
|
android:name=".UpdatesActivity"
|
||||||
|
|||||||
11
res/drawable/ic_menu_refresh.xml
Normal file
11
res/drawable/ic_menu_refresh.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" />
|
||||||
|
</vector>
|
||||||
9
res/menu/menu_toolbar.xml
Normal file
9
res/menu/menu_toolbar.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_refresh"
|
||||||
|
android:icon="@drawable/ic_menu_refresh"
|
||||||
|
android:title="@string/menu_refresh"
|
||||||
|
app:showAsAction="always" />
|
||||||
|
</menu>
|
||||||
@@ -48,4 +48,6 @@
|
|||||||
<string name="preparing_ota_first_boot">Preparing for first boot</string>
|
<string name="preparing_ota_first_boot">Preparing for first boot</string>
|
||||||
|
|
||||||
<string name="reboot">Reboot</string>
|
<string name="reboot">Reboot</string>
|
||||||
|
|
||||||
|
<string name="menu_refresh">Refresh</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -25,15 +25,19 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.preference.PreferenceManager;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.SimpleItemAnimator;
|
import android.support.v7.widget.SimpleItemAnimator;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.lineageos.updater.controller.UpdaterController;
|
import org.lineageos.updater.controller.UpdaterController;
|
||||||
import org.lineageos.updater.controller.UpdaterControllerInt;
|
import org.lineageos.updater.controller.UpdaterControllerInt;
|
||||||
import org.lineageos.updater.controller.UpdaterService;
|
import org.lineageos.updater.controller.UpdaterService;
|
||||||
|
import org.lineageos.updater.misc.Constants;
|
||||||
import org.lineageos.updater.misc.Utils;
|
import org.lineageos.updater.misc.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -77,6 +81,8 @@ public class UpdatesActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,6 +108,28 @@ public class UpdatesActivity extends AppCompatActivity {
|
|||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.menu_toolbar, menu);
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_refresh:
|
||||||
|
downloadUpdatesList();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSupportNavigateUp() {
|
||||||
|
onBackPressed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,6 +202,11 @@ public class UpdatesActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
Log.d(TAG, "List downloaded");
|
Log.d(TAG, "List downloaded");
|
||||||
loadUpdatesList();
|
loadUpdatesList();
|
||||||
|
long millis = System.currentTimeMillis();
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(UpdatesActivity.this)
|
||||||
|
.edit()
|
||||||
|
.putLong(Constants.PREF_LAST_UPDATE_CHECK, millis)
|
||||||
|
.apply();
|
||||||
jsonFileTmp.renameTo(jsonFile);
|
jsonFileTmp.renameTo(jsonFile);
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
Log.e(TAG, "Could not read json", e);
|
Log.e(TAG, "Could not read json", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user