Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/ActivityPrincipal.java
/* | |||||
BusTO - Arrival times for Turin public transport. | |||||
Copyright (C) 2021 Fabio Mazza | |||||
This program is free software: you can redistribute it and/or modify | |||||
it under the terms of the GNU General Public License as published by | |||||
the Free Software Foundation, either version 3 of the License, or | |||||
(at your option) any later version. | |||||
This program is distributed in the hope that it will be useful, | |||||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
GNU General Public License for more details. | |||||
You should have received a copy of the GNU General Public License | |||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
*/ | |||||
package it.reyboz.bustorino; | package it.reyboz.bustorino; | ||||
import android.Manifest; | import android.Manifest; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.content.SharedPreferences; | import android.content.SharedPreferences; | ||||
import android.content.pm.PackageManager; | import android.content.pm.PackageManager; | ||||
import android.content.res.Configuration; | import android.content.res.Configuration; | ||||
Show All 9 Lines | |||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.appcompat.app.ActionBarDrawerToggle; | import androidx.appcompat.app.ActionBarDrawerToggle; | ||||
import androidx.appcompat.widget.Toolbar; | import androidx.appcompat.widget.Toolbar; | ||||
import androidx.core.view.GravityCompat; | import androidx.core.view.GravityCompat; | ||||
import androidx.drawerlayout.widget.DrawerLayout; | import androidx.drawerlayout.widget.DrawerLayout; | ||||
import androidx.fragment.app.Fragment; | import androidx.fragment.app.Fragment; | ||||
import androidx.fragment.app.FragmentManager; | import androidx.fragment.app.FragmentManager; | ||||
import androidx.fragment.app.FragmentTransaction; | import androidx.fragment.app.FragmentTransaction; | ||||
import androidx.preference.PreferenceManager; | |||||
import androidx.work.BackoffPolicy; | import androidx.work.BackoffPolicy; | ||||
import androidx.work.Constraints; | import androidx.work.Constraints; | ||||
import androidx.work.ExistingPeriodicWorkPolicy; | import androidx.work.ExistingPeriodicWorkPolicy; | ||||
import androidx.work.NetworkType; | import androidx.work.NetworkType; | ||||
import androidx.work.PeriodicWorkRequest; | import androidx.work.PeriodicWorkRequest; | ||||
import androidx.work.WorkInfo; | import androidx.work.WorkInfo; | ||||
import androidx.work.WorkManager; | import androidx.work.WorkManager; | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Lines | public void onConfigurationChanged(@NonNull Configuration newConfig) { | ||||
super.onConfigurationChanged(newConfig); | super.onConfigurationChanged(newConfig); | ||||
// Pass any configuration change to the drawer toggles | // Pass any configuration change to the drawer toggles | ||||
drawerToggle.onConfigurationChanged(newConfig); | drawerToggle.onConfigurationChanged(newConfig); | ||||
} | } | ||||
@Override | @Override | ||||
public boolean onCreateOptionsMenu(Menu menu) { | public boolean onCreateOptionsMenu(Menu menu) { | ||||
getMenuInflater().inflate(R.menu.extra_menu_items, menu); | getMenuInflater().inflate(R.menu.principal_menu, menu); | ||||
MenuItem experimentsMenuItem = menu.findItem(R.id.action_experiments); | |||||
SharedPreferences shPr = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); | |||||
boolean exper_On = shPr.getBoolean(getString(R.string.pref_key_experimental), false); | |||||
experimentsMenuItem.setVisible(exper_On); | |||||
return super.onCreateOptionsMenu(menu); | return super.onCreateOptionsMenu(menu); | ||||
} | } | ||||
@Override | @Override | ||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||||
if (requestCode==STORAGE_PERMISSION_REQ){ | if (requestCode==STORAGE_PERMISSION_REQ){ | ||||
final String storagePerm = Manifest.permission.WRITE_EXTERNAL_STORAGE; | final String storagePerm = Manifest.permission.WRITE_EXTERNAL_STORAGE; | ||||
▲ Show 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | class ToolbarItemClickListener implements Toolbar.OnMenuItemClickListener{ | ||||
openIceweasel(getString(R.string.hack_url), activityContext); | openIceweasel(getString(R.string.hack_url), activityContext); | ||||
return true; | return true; | ||||
case R.id.action_source: | case R.id.action_source: | ||||
openIceweasel("https://gitpull.it/source/libre-busto/", activityContext); | openIceweasel("https://gitpull.it/source/libre-busto/", activityContext); | ||||
return true; | return true; | ||||
case R.id.action_licence: | case R.id.action_licence: | ||||
openIceweasel("https://www.gnu.org/licenses/gpl-3.0.html", activityContext); | openIceweasel("https://www.gnu.org/licenses/gpl-3.0.html", activityContext); | ||||
return true; | return true; | ||||
case R.id.action_experiments: | |||||
startActivity(new Intent(ActivityPrincipal.this, ActivityExperiments.class)); | |||||
default: | default: | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register