124 lines
3.5 KiB
Java
124 lines
3.5 KiB
Java
|
/*
|
||
|
* Copyright 2018 Stefan Schüller <sschueller@techdroid.com>
|
||
|
*
|
||
|
* License: GPL-3.0+
|
||
|
* 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 net.schueller.peertube.activity;
|
||
|
|
||
|
import android.app.SearchManager;
|
||
|
import android.content.Context;
|
||
|
import android.content.Intent;
|
||
|
import android.content.ServiceConnection;
|
||
|
import android.content.SharedPreferences;
|
||
|
import android.os.Bundle;
|
||
|
import android.preference.PreferenceManager;
|
||
|
import android.util.Log;
|
||
|
import android.view.Menu;
|
||
|
import android.view.MenuInflater;
|
||
|
import android.view.MenuItem;
|
||
|
|
||
|
import com.mikepenz.fontawesome_typeface_library.FontAwesome;
|
||
|
import com.mikepenz.iconics.IconicsDrawable;
|
||
|
|
||
|
import net.schueller.peertube.R;
|
||
|
import net.schueller.peertube.network.Session;
|
||
|
|
||
|
import androidx.appcompat.app.AppCompatActivity;
|
||
|
import androidx.appcompat.widget.SearchView;
|
||
|
import androidx.appcompat.widget.Toolbar;
|
||
|
|
||
|
import static net.schueller.peertube.helper.Constants.DEFAULT_THEME;
|
||
|
import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY;
|
||
|
|
||
|
public class AccountActivity extends AppCompatActivity {
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||
|
MenuInflater inflater = getMenuInflater();
|
||
|
inflater.inflate(R.menu.menu_top_user, menu);
|
||
|
|
||
|
// Set an icon in the ActionBar
|
||
|
menu.findItem(R.id.action_logout).setIcon(
|
||
|
new IconicsDrawable(this, FontAwesome.Icon.faw_sign_out_alt).actionBar());
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||
|
|
||
|
switch (item.getItemId()) {
|
||
|
// action with ID action_refresh was selected
|
||
|
|
||
|
case R.id.action_logout:
|
||
|
Session.getInstance().invalidate();
|
||
|
Intent intent = new Intent(this, LoginActivity.class);
|
||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||
|
this.startActivity(intent);
|
||
|
return true;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return super.onOptionsItemSelected(item);
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
protected void onCreate(Bundle savedInstanceState) {
|
||
|
super.onCreate(savedInstanceState);
|
||
|
|
||
|
// Set theme
|
||
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
||
|
setTheme(getResources().getIdentifier(
|
||
|
sharedPref.getString(THEME_PREF_KEY, DEFAULT_THEME),
|
||
|
"style",
|
||
|
getPackageName())
|
||
|
);
|
||
|
|
||
|
setContentView(R.layout.activity_account);
|
||
|
|
||
|
// Attaching the layout to the toolbar object
|
||
|
Toolbar toolbar = findViewById(R.id.tool_bar_user);
|
||
|
// Setting toolbar as the ActionBar with setSupportActionBar() call
|
||
|
setSupportActionBar(toolbar);
|
||
|
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
private void init() {
|
||
|
// try to get user data
|
||
|
getUserData();
|
||
|
}
|
||
|
|
||
|
private boolean getUserData() {
|
||
|
|
||
|
// TODO
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void onResume() {
|
||
|
super.onResume();
|
||
|
|
||
|
init();
|
||
|
|
||
|
}
|
||
|
}
|