Drawer, Toolbar and minor UI optimizations (#145)
* initial add of toolbar and hamburger menu to main activity * toolbar added to preferences and accounts screens * fixed original string (name) * Layout fix for content * initial add of toolbar and hamburger menu to main activity * remove unnecessary padding bottom * fix styling and paint login activity in blue * toolbar added to preferences and accounts screens * Layout fix for content * remove unnecessary padding bottom * fix styling and paint login activity in blue * fixes after rebase * consolidate style since minVersion=16, make drawer to be behind the systembar * optimize drawer header * add back navigation to login activity, fix spinner background * add back navigation * more launcher icon to mipmap folders * fix identation * fix license header * revert code style deletion, change identation * proper notification icon * proper resolution for login logo * fix large notification icon * removed unused Eclair switch since support is v16+ * only use small notification icon * spaces->tabs * fix toolbar style for Android 4.x
51
notification_icon.svg
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
enable-background="new 0 0 595.275 311.111"
|
||||
xml:space="preserve"
|
||||
height="546.13336"
|
||||
width="546.13336"
|
||||
version="1.1"
|
||||
y="0px"
|
||||
x="0px"
|
||||
id="svg2"
|
||||
viewBox="0 0 512 512"
|
||||
inkscape:version="0.92.1 r15371"
|
||||
sodipodi:docname="notification_icon.svg"
|
||||
inkscape:export-filename="C:\DEV\src\Android\Nextcloud\ownCloud-SMS-App\src\main\res\drawable-xxxhdpi\notification_icon.png"
|
||||
inkscape:export-xdpi="16.879999"
|
||||
inkscape:export-ydpi="16.879999"><metadata
|
||||
id="metadata10"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs8" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1005"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.4739747"
|
||||
inkscape:cx="140.31712"
|
||||
inkscape:cy="253.09893"
|
||||
inkscape:window-x="-9"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg2" /><path
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.30745259;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0"
|
||||
d="m 76.647972,90.431718 c -24.788364,0 -44.743887,15.887432 -44.743887,35.621852 v 161.78969 c 0,19.73444 19.955523,35.62188 44.743887,35.62188 H 128.01232 L 332.84234,465.77569 266.5124,323.46514 h 168.83961 c 24.7884,0 44.7439,-15.88744 44.7439,-35.62188 V 126.05357 c 0,-19.73442 -19.9555,-35.621852 -44.7439,-35.621852 z M 88.80753,121.0557 h 334.38495 c 12.20514,0 22.03089,6.58929 22.03089,14.77376 v 9.61145 c 0,8.1845 -9.82575,14.77187 -22.03089,14.77187 H 88.80753 c -12.205149,0 -22.030913,-6.58737 -22.030913,-14.77187 v -9.61145 c 0,-8.18447 9.825764,-14.77376 22.030913,-14.77376 z m 0,68.10616 h 334.38495 c 12.20514,0 22.03089,6.5893 22.03089,14.77378 v 9.60954 c 0,8.18448 -9.82575,14.77377 -22.03089,14.77377 H 88.80753 c -12.205149,0 -22.030913,-6.58929 -22.030913,-14.77377 v -9.60954 c 0,-8.18448 9.825764,-14.77378 22.030913,-14.77378 z m 0,67.54597 h 120.79949 c 12.20514,0 22.03088,8.99072 22.03088,17.17521 v 7.20812 c 0,8.18446 -9.82574,14.77376 -22.03088,14.77376 H 88.80753 c -12.205149,0 -22.030913,-6.5893 -22.030913,-14.77376 v -7.20812 c 0,-8.18449 9.825764,-17.17521 22.030913,-17.17521 z"
|
||||
id="rect3350"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="sssscccssssssssssssssssssssssssssssssss" /></svg>
|
After Width: | Height: | Size: 3.1 KiB |
@ -124,7 +124,8 @@
|
||||
|
||||
<activity
|
||||
android:name=".activities.LoginActivity"
|
||||
android:label="@string/title_activity_login">
|
||||
android:label="@string/title_activity_login"
|
||||
android:theme="@style/OcSmsTheme.Login">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.remote_account.AccountListActivity"
|
||||
@ -136,7 +137,8 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.MainActivity"
|
||||
android:label="@string/app_name">
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/OcSmsTheme.Drawer">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
|
@ -29,10 +29,12 @@ import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@ -65,7 +67,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
private EditText _loginView;
|
||||
private EditText _passwordView;
|
||||
private EditText _serverView;
|
||||
private ActionProcessButton _signInButton;
|
||||
private ActionProcessButton _signInButton;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
@ -74,6 +76,9 @@ public class LoginActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// Set up the login form.
|
||||
_protocolView = (Spinner) findViewById(R.id.oc_protocol);
|
||||
_serverView = (EditText) findViewById(R.id.oc_server);
|
||||
@ -84,7 +89,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int id,
|
||||
KeyEvent keyEvent) {
|
||||
KeyEvent keyEvent) {
|
||||
if ((id == R.id.oc_login) || (id == EditorInfo.IME_NULL)) {
|
||||
attemptLogin();
|
||||
return true;
|
||||
@ -93,7 +98,7 @@ public class LoginActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
_signInButton = (ActionProcessButton) findViewById(R.id.oc_signin_button);
|
||||
_signInButton = (ActionProcessButton) findViewById(R.id.oc_signin_button);
|
||||
_signInButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@ -105,6 +110,19 @@ public class LoginActivity extends AppCompatActivity {
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to sign in or register the account specified by the login form.
|
||||
* If there are form errors (invalid email, missing fields, etc.), the
|
||||
@ -127,12 +145,12 @@ public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
|
||||
// Check for a valid server address.
|
||||
if (TextUtils.isEmpty(protocol)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
|
||||
// Check for a valid server address.
|
||||
if (TextUtils.isEmpty(serverAddr)) {
|
||||
_serverView.setError(getString(R.string.error_field_required));
|
||||
@ -146,14 +164,14 @@ public class LoginActivity extends AppCompatActivity {
|
||||
focusView = _loginView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
|
||||
// Check for a valid password
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
_passwordView.setError(getString(R.string.error_field_required));
|
||||
focusView = _passwordView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
|
||||
if (!isPasswordValid(password)) {
|
||||
_passwordView.setError(getString(R.string.error_invalid_password));
|
||||
focusView = _passwordView;
|
||||
@ -163,15 +181,15 @@ public class LoginActivity extends AppCompatActivity {
|
||||
if (cancel) {
|
||||
// There was an error; don't attempt login and focus the first
|
||||
// form field with an error.
|
||||
// reset the button progress
|
||||
_signInButton.setProgress(0);
|
||||
if (focusView != null) {
|
||||
focusView.requestFocus();
|
||||
}
|
||||
} else {
|
||||
// reset the button progress
|
||||
_signInButton.setProgress(0);
|
||||
if (focusView != null) {
|
||||
focusView.requestFocus();
|
||||
}
|
||||
} else {
|
||||
// Show a progress spinner, and kick off a background task to
|
||||
// perform the user login attempt.
|
||||
_signInButton.setProgress(25);
|
||||
_signInButton.setProgress(25);
|
||||
showProgress(true);
|
||||
String serverURL = protocol + serverAddr;
|
||||
mAuthTask = new UserLoginTask(serverURL, login, password);
|
||||
@ -229,10 +247,10 @@ public class LoginActivity extends AppCompatActivity {
|
||||
* Represents an asynchronous login/registration task used to authenticate
|
||||
* the user.
|
||||
*/
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
UserLoginTask(String serverURI, String login, String password) {
|
||||
Log.i(TAG, "_serverURI = " + serverURI);
|
||||
Log.i(TAG, "_serverURI = " + serverURI);
|
||||
_serverURI = Uri.parse(serverURI);
|
||||
_login = login;
|
||||
_password = password;
|
||||
@ -259,47 +277,47 @@ public class LoginActivity extends AppCompatActivity {
|
||||
protected void onPostExecute(Boolean success) {
|
||||
mAuthTask = null;
|
||||
showProgress(false);
|
||||
_signInButton.setProgress(90);
|
||||
_signInButton.setProgress(90);
|
||||
|
||||
if (success) {
|
||||
_signInButton.setProgress(100);
|
||||
_signInButton.setProgress(100);
|
||||
String accountType = getIntent().getStringExtra(UserLoginTask.PARAM_AUTHTOKEN_TYPE);
|
||||
if (accountType == null) {
|
||||
accountType = getString(R.string.account_type);
|
||||
}
|
||||
|
||||
if (accountType == null) {
|
||||
accountType = getString(R.string.account_type);
|
||||
}
|
||||
|
||||
// Generate a label
|
||||
String accountLabel = _login + "@" + _serverURI.getHost();
|
||||
|
||||
|
||||
// We create the account
|
||||
Account account = new Account(accountLabel, accountType);
|
||||
Bundle accountBundle = new Bundle();
|
||||
accountBundle.putString("ocLogin", _login);
|
||||
accountBundle.putString("ocURI", _serverURI.toString());
|
||||
|
||||
|
||||
// And we push it to Android
|
||||
AccountManager accMgr = AccountManager.get(getApplicationContext());
|
||||
accMgr.addAccountExplicitly(account, _password, accountBundle);
|
||||
|
||||
accMgr.addAccountExplicitly(account, _password, accountBundle);
|
||||
|
||||
// Set sync options
|
||||
ContentResolver.setSyncAutomatically(account, getString(R.string.account_authority), true);
|
||||
|
||||
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("synctype", 1);
|
||||
|
||||
|
||||
ContentResolver.addPeriodicSync(account, getString(R.string.account_authority), b, DefaultPrefs.syncInterval * 60);
|
||||
// Then it's finished
|
||||
finish();
|
||||
|
||||
|
||||
// Start sync settings, we have finished to configure account
|
||||
Intent settingsIntent = new Intent(Settings.ACTION_SYNC_SETTINGS);
|
||||
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getApplicationContext().startActivity(settingsIntent);
|
||||
} else {
|
||||
boolean serverViewRequestFocus = true;
|
||||
boolean serverViewRequestFocus = true;
|
||||
switch (_returnCode) {
|
||||
case 0:
|
||||
_serverView.setError("UNK");
|
||||
_serverView.setError("UNK");
|
||||
break;
|
||||
case 404:
|
||||
_serverView.setError(getString(R.string.error_connection_failed_not_found));
|
||||
@ -312,24 +330,24 @@ public class LoginActivity extends AppCompatActivity {
|
||||
_serverView.setError(getString(R.string.error_http_connection_failed));
|
||||
break;
|
||||
case 401:
|
||||
case 403:
|
||||
_passwordView.setError(getString(R.string.error_invalid_login));
|
||||
_passwordView.requestFocus();
|
||||
// Warning, there is no break here to disable serverViewRequestFocus too
|
||||
case 200:
|
||||
default:
|
||||
serverViewRequestFocus = false;
|
||||
break;
|
||||
case 403:
|
||||
_passwordView.setError(getString(R.string.error_invalid_login));
|
||||
_passwordView.requestFocus();
|
||||
// Warning, there is no break here to disable serverViewRequestFocus too
|
||||
case 200:
|
||||
default:
|
||||
serverViewRequestFocus = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (serverViewRequestFocus) {
|
||||
_serverView.requestFocus();
|
||||
}
|
||||
if (serverViewRequestFocus) {
|
||||
_serverView.requestFocus();
|
||||
}
|
||||
|
||||
// If not ok, reset the progress
|
||||
if (_returnCode != 200) {
|
||||
_signInButton.setProgress(0);
|
||||
}
|
||||
// If not ok, reset the progress
|
||||
if (_returnCode != 200) {
|
||||
_signInButton.setProgress(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,8 +361,8 @@ public class LoginActivity extends AppCompatActivity {
|
||||
private final String _login;
|
||||
private final String _password;
|
||||
private int _returnCode;
|
||||
|
||||
|
||||
static final String PARAM_AUTHTOKEN_TYPE = "auth.token";
|
||||
private final String TAG = UserLoginTask.class.getCanonicalName();
|
||||
}
|
||||
private final String TAG = UserLoginTask.class.getCanonicalName();
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
@ -59,107 +60,174 @@ import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_MAX;
|
||||
import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_SMS;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener{
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
|
||||
private ConnectivityMonitor _ConnectivityMonitor = null;
|
||||
|
||||
private DrawerLayout drawer;
|
||||
|
||||
private ConnectivityMonitor _ConnectivityMonitor = null;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (_ConnectivityMonitor == null) {
|
||||
_ConnectivityMonitor = new ConnectivityMonitor(getApplicationContext());
|
||||
}
|
||||
if (_ConnectivityMonitor == null) {
|
||||
_ConnectivityMonitor = new ConnectivityMonitor(getApplicationContext());
|
||||
}
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
assert drawer != null;
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
assert navigationView != null;
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
setupToolbar();
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
setupDrawer();
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
assert drawer != null;
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
protected void setupToolbar() {
|
||||
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
boolean res = true;
|
||||
private void setupDrawer() {
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
assert drawer != null;
|
||||
drawer.addDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
toggle.setDrawerIndicatorEnabled(true);
|
||||
|
||||
switch (id) {
|
||||
case R.id.nav_sync: syncAllMessages(); break;
|
||||
case R.id.nav_manage: res = openAppSettings(); break;
|
||||
case R.id.nav_rateus: res = openGooglePlayStore(); break;
|
||||
case R.id.nav_add_account: res = openAddAccount(); break;
|
||||
case R.id.nav_my_accounts: res = openMyAccounts(); break;
|
||||
case R.id.nav_appinfo_perms: res = openAppInfos(); break;
|
||||
}
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
assert drawer != null;
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return res;
|
||||
}
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
assert navigationView != null;
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
}
|
||||
|
||||
private boolean openAppSettings () {
|
||||
/**
|
||||
* checks if the drawer exists and is opened.
|
||||
*
|
||||
* @return <code>true</code> if the drawer is open, else <code>false</code>
|
||||
*/
|
||||
public boolean isDrawerOpen() {
|
||||
return drawer != null && drawer.isDrawerOpen(GravityCompat.START);
|
||||
}
|
||||
|
||||
/**
|
||||
* closes the drawer.
|
||||
*/
|
||||
public void closeDrawer() {
|
||||
if (drawer != null) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* opens the drawer.
|
||||
*/
|
||||
public void openDrawer() {
|
||||
if (drawer != null) {
|
||||
drawer.openDrawer(GravityCompat.START);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home: {
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
openDrawer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
boolean res = true;
|
||||
|
||||
switch (id) {
|
||||
case R.id.nav_sync:
|
||||
syncAllMessages();
|
||||
break;
|
||||
case R.id.nav_manage:
|
||||
res = openAppSettings();
|
||||
break;
|
||||
case R.id.nav_rateus:
|
||||
res = openGooglePlayStore();
|
||||
break;
|
||||
case R.id.nav_add_account:
|
||||
res = openAddAccount();
|
||||
break;
|
||||
case R.id.nav_my_accounts:
|
||||
res = openMyAccounts();
|
||||
break;
|
||||
case R.id.nav_appinfo_perms:
|
||||
res = openAppInfos();
|
||||
break;
|
||||
}
|
||||
closeDrawer();
|
||||
return res;
|
||||
}
|
||||
|
||||
private boolean openAppSettings() {
|
||||
startActivity(new Intent(this, OCSMSSettingsActivity.class));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean openAddAccount () {
|
||||
private boolean openAddAccount() {
|
||||
startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void syncAllMessages () {
|
||||
Log.v(MainActivity.TAG, "Launch syncAllMessages()");
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.READ_SMS,
|
||||
REQUEST_SMS)) {
|
||||
return;
|
||||
}
|
||||
public void syncAllMessages() {
|
||||
Log.v(MainActivity.TAG, "Launch syncAllMessages()");
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.READ_SMS,
|
||||
REQUEST_SMS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Context ctx = getApplicationContext();
|
||||
if (_ConnectivityMonitor.isValid()) {
|
||||
// Now fetch messages since last stored date
|
||||
JSONArray smsList = new JSONArray();
|
||||
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||
new AndroidSmsFetcher(ctx).bufferMessagesSinceDate(smsList, (long) 0);
|
||||
|
||||
if (smsList.length() > 0) {
|
||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||
ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
OCSMSNotificationUI.notify(ctx, ctx.getString(R.string.sync_title),
|
||||
ctx.getString(R.string.sync_inprogress), OCSMSNotificationType.SYNC.ordinal());
|
||||
new SyncTask(getApplicationContext(), smsList).execute();
|
||||
} else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.nothing_to_sync), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Toast.makeText(ctx, ctx.getString(R.string.err_sync_no_connection_available), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages()");
|
||||
Log.v(MainActivity.TAG, "Finish syncAllMessages()");
|
||||
}
|
||||
|
||||
private boolean openMyAccounts () {
|
||||
private boolean openMyAccounts() {
|
||||
startActivity(new Intent(this, AccountListActivity.class));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean openGooglePlayStore () {
|
||||
private boolean openGooglePlayStore() {
|
||||
Intent intent;
|
||||
try {
|
||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()));
|
||||
@ -168,45 +236,45 @@ public class MainActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean openAppInfos () {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
private boolean openAppInfos() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Permissions
|
||||
*/
|
||||
/*
|
||||
* Permissions
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
PermissionID requestCodeID = REQUEST_MAX;
|
||||
if ((requestCode > 0) || (requestCode < REQUEST_MAX.ordinal())) {
|
||||
requestCodeID = PermissionID.values()[requestCode];
|
||||
}
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
PermissionID requestCodeID = REQUEST_MAX;
|
||||
if ((requestCode > 0) || (requestCode < REQUEST_MAX.ordinal())) {
|
||||
requestCodeID = PermissionID.values()[requestCode];
|
||||
}
|
||||
|
||||
switch (requestCodeID) {
|
||||
case REQUEST_SMS:
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
syncAllMessages();
|
||||
} else {
|
||||
// Permission Denied
|
||||
Toast.makeText(this, getString(R.string.err_cannot_read_sms) + " " +
|
||||
getString(R.string.please_fix_it), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
switch (requestCodeID) {
|
||||
case REQUEST_SMS:
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
syncAllMessages();
|
||||
} else {
|
||||
// Permission Denied
|
||||
Toast.makeText(this, getString(R.string.err_cannot_read_sms) + " " +
|
||||
getString(R.string.please_fix_it), Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ import android.content.ContentResolver;
|
||||
import android.content.PeriodicSync;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -37,82 +40,104 @@ import fr.unix_experience.owncloud_sms.prefs.PermissionChecker;
|
||||
import static fr.unix_experience.owncloud_sms.enums.PermissionID.REQUEST_ACCOUNTS;
|
||||
|
||||
public class OCSMSSettingsActivity extends VirtualSettingsActivity {
|
||||
private static final String TAG = OCSMSSettingsActivity.class.getSimpleName();
|
||||
private static final String TAG = OCSMSSettingsActivity.class.getSimpleName();
|
||||
|
||||
private static AccountManager _accountMgr;
|
||||
private static String _accountAuthority;
|
||||
private static String _accountType;
|
||||
private static AccountManager _accountMgr;
|
||||
private static String _accountAuthority;
|
||||
private static String _accountType;
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
OCSMSSettingsActivity._accountMgr = AccountManager.get(getBaseContext());
|
||||
OCSMSSettingsActivity._accountAuthority = getString(R.string.account_authority);
|
||||
OCSMSSettingsActivity._accountType = getString(R.string.account_type);
|
||||
VirtualSettingsActivity._prefsRessourceFile = R.xml.pref_data_sync;
|
||||
private AppCompatDelegate mDelegate;
|
||||
|
||||
// Bind our boolean preferences
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("push_on_receive", DefaultPrefs.pushOnReceive));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_wifi", DefaultPrefs.syncWifi));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_4g", DefaultPrefs.sync4G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_3g", DefaultPrefs.sync3G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_gprs", DefaultPrefs.syncGPRS));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_2g", DefaultPrefs.sync2G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_others", DefaultPrefs.syncOthers));
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Bind our string preferences
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_frequency", "15"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_bulk_messages", "-1"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("minimum_sync_chars", "1"));
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
// Must be at the end, after preference bind
|
||||
super.onPostCreate(savedInstanceState);
|
||||
}
|
||||
private AppCompatDelegate getDelegate() {
|
||||
if (mDelegate == null) {
|
||||
mDelegate = AppCompatDelegate.create(this, null);
|
||||
}
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
protected void handleCheckboxPreference(String key, Boolean value) {
|
||||
// Network types allowed for sync
|
||||
if ("push_on_receive".equals(key) ||
|
||||
"sync_wifi".equals(key) || "sync_2g".equals(key) ||
|
||||
"sync_3g".equals(key) || "sync_gprs".equals(key) ||
|
||||
"sync_4g".equals(key) || "sync_others".equals(key)) {
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
Log.i(OCSMSSettingsActivity.TAG, "OCSMSSettingsActivity.handleCheckboxPreference: set " + key + " to "
|
||||
+ value.toString());
|
||||
prefs.putBoolean(key, value);
|
||||
}
|
||||
}
|
||||
public ActionBar getSupportActionBar() {
|
||||
return getDelegate().getSupportActionBar();
|
||||
}
|
||||
|
||||
protected void handleListPreference(String key, String value,
|
||||
ListPreference preference) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
int index = preference.findIndexOfValue(value);
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
OCSMSSettingsActivity._accountMgr = AccountManager.get(getBaseContext());
|
||||
OCSMSSettingsActivity._accountAuthority = getString(R.string.account_authority);
|
||||
OCSMSSettingsActivity._accountType = getString(R.string.account_type);
|
||||
VirtualSettingsActivity._prefsRessourceFile = R.xml.pref_data_sync;
|
||||
|
||||
// Set the summary to reflect the new value.
|
||||
preference
|
||||
.setSummary((index >= 0) ? preference.getEntries()[index]
|
||||
: null);
|
||||
// Bind our boolean preferences
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("push_on_receive", DefaultPrefs.pushOnReceive));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_wifi", DefaultPrefs.syncWifi));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_4g", DefaultPrefs.sync4G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_3g", DefaultPrefs.sync3G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_gprs", DefaultPrefs.syncGPRS));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_2g", DefaultPrefs.sync2G));
|
||||
VirtualSettingsActivity._boolPrefs.add(new BindObjectPref("sync_others", DefaultPrefs.syncOthers));
|
||||
|
||||
Log.i(OCSMSSettingsActivity.TAG, "Modifying listPreference " + key);
|
||||
// Bind our string preferences
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_frequency", "15"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("sync_bulk_messages", "-1"));
|
||||
VirtualSettingsActivity._stringPrefs.add(new BindObjectPref("minimum_sync_chars", "1"));
|
||||
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
// Must be at the end, after preference bind
|
||||
super.onPostCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
// Handle sync frequency change
|
||||
if ("sync_frequency".equals(key)) {
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.GET_ACCOUNTS,
|
||||
REQUEST_ACCOUNTS)) {
|
||||
return;
|
||||
}
|
||||
protected void handleCheckboxPreference(String key, Boolean value) {
|
||||
// Network types allowed for sync
|
||||
if ("push_on_receive".equals(key) ||
|
||||
"sync_wifi".equals(key) || "sync_2g".equals(key) ||
|
||||
"sync_3g".equals(key) || "sync_gprs".equals(key) ||
|
||||
"sync_4g".equals(key) || "sync_others".equals(key)) {
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
Log.i(OCSMSSettingsActivity.TAG, "OCSMSSettingsActivity.handleCheckboxPreference: set " + key + " to "
|
||||
+ value.toString());
|
||||
prefs.putBoolean(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
Account[] myAccountList = OCSMSSettingsActivity._accountMgr.getAccountsByType(OCSMSSettingsActivity._accountType);
|
||||
long syncFreq = Long.parseLong(value);
|
||||
protected void handleListPreference(String key, String value,
|
||||
ListPreference preference) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
int index = preference.findIndexOfValue(value);
|
||||
|
||||
// Set the summary to reflect the new value.
|
||||
preference
|
||||
.setSummary((index >= 0) ? preference.getEntries()[index]
|
||||
: null);
|
||||
|
||||
Log.i(OCSMSSettingsActivity.TAG, "Modifying listPreference " + key);
|
||||
|
||||
OCSMSSharedPrefs prefs = new OCSMSSharedPrefs(VirtualSettingsActivity._context);
|
||||
|
||||
// Handle sync frequency change
|
||||
if ("sync_frequency".equals(key)) {
|
||||
if (!PermissionChecker.checkPermission(this, Manifest.permission.GET_ACCOUNTS,
|
||||
REQUEST_ACCOUNTS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Account[] myAccountList = OCSMSSettingsActivity._accountMgr.getAccountsByType(OCSMSSettingsActivity._accountType);
|
||||
long syncFreq = Long.parseLong(value);
|
||||
|
||||
// Get ownCloud SMS account list
|
||||
for (Account acct: myAccountList) {
|
||||
for (Account acct : myAccountList) {
|
||||
// And get all authorities for this account
|
||||
List<PeriodicSync> syncList = ContentResolver.getPeriodicSyncs(acct, OCSMSSettingsActivity._accountAuthority);
|
||||
|
||||
boolean foundSameSyncCycle = false;
|
||||
for (PeriodicSync ps: syncList) {
|
||||
for (PeriodicSync ps : syncList) {
|
||||
if ((ps.period == syncFreq) && (ps.extras.getInt("synctype") == 1)) {
|
||||
foundSameSyncCycle = true;
|
||||
}
|
||||
@ -123,16 +148,29 @@ public class OCSMSSettingsActivity extends VirtualSettingsActivity {
|
||||
b.putInt("synctype", 1);
|
||||
|
||||
ContentResolver.removePeriodicSync(acct, OCSMSSettingsActivity._accountAuthority, b);
|
||||
if (syncFreq > 0) {
|
||||
ContentResolver.addPeriodicSync(acct, OCSMSSettingsActivity._accountAuthority, b, syncFreq * 60);
|
||||
}
|
||||
if (syncFreq > 0) {
|
||||
ContentResolver.addPeriodicSync(acct, OCSMSSettingsActivity._accountAuthority, b, syncFreq * 60);
|
||||
}
|
||||
}
|
||||
|
||||
prefs.putLong(key, syncFreq);
|
||||
prefs.putLong(key, syncFreq);
|
||||
}
|
||||
} else if ("sync_bulk_messages".equals(key) || "minimum_sync_chars".equals(key)) {
|
||||
prefs.putInteger(key, Integer.parseInt(value));
|
||||
}
|
||||
else if ("sync_bulk_messages".equals(key) || "minimum_sync_chars".equals(key)) {
|
||||
prefs.putInteger(key, Integer.parseInt(value));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||
super.onMenuItemSelected(featureId, item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package fr.unix_experience.owncloud_sms.activities.remote_account;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
@ -19,6 +21,9 @@ public class AccountActionsActivity extends AppCompatListActivity {
|
||||
|
||||
setContentView(R.layout.activity_account_actions);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
ArrayList<String> itemList = new ArrayList<>();
|
||||
ArrayAdapter<String> adp = new ArrayAdapter<>(getBaseContext(),
|
||||
android.R.layout.simple_dropdown_item_1line, itemList);
|
||||
@ -33,20 +38,33 @@ public class AccountActionsActivity extends AppCompatListActivity {
|
||||
_accountName = getIntent().getStringExtra("account");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
Intent intent = new Intent(this, RestoreMessagesActivity.class);
|
||||
intent.putExtra("account", _accountName);
|
||||
try {
|
||||
startActivity(intent);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
Log.e(AccountActionsActivity.TAG, e.getMessage());
|
||||
}
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.e(AccountActionsActivity.TAG, e.getMessage());
|
||||
}
|
||||
break;
|
||||
default: break; // Unhandled
|
||||
default:
|
||||
break; // Unhandled
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@ package fr.unix_experience.owncloud_sms.activities.remote_account;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import fr.unix_experience.owncloud_sms.adapters.AndroidAccountAdapter;
|
||||
import fr.unix_experience.android_lib.AppCompatListActivity;
|
||||
import fr.unix_experience.owncloud_sms.R;
|
||||
import fr.unix_experience.owncloud_sms.adapters.AndroidAccountAdapter;
|
||||
|
||||
public class AccountListActivity extends AppCompatListActivity {
|
||||
|
||||
@ -21,21 +22,35 @@ public class AccountListActivity extends AppCompatListActivity {
|
||||
|
||||
setContentView(R.layout.restore_activity_accountlist);
|
||||
|
||||
ArrayList<Account> itemList = new ArrayList<>();
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
AndroidAccountAdapter adapter = new AndroidAccountAdapter(this,
|
||||
ArrayList<Account> itemList = new ArrayList<>();
|
||||
|
||||
AndroidAccountAdapter adapter = new AndroidAccountAdapter(this,
|
||||
android.R.layout.simple_list_item_1,
|
||||
itemList,
|
||||
itemList,
|
||||
R.layout.account_list_item,
|
||||
R.id.accountname, AccountActionsActivity.class);
|
||||
setListAdapter(adapter);
|
||||
|
||||
Account[] accountList =
|
||||
_accountMgr.getAccountsByType(getString(R.string.account_type));
|
||||
Collections.addAll(itemList, accountList);
|
||||
Collections.addAll(itemList, accountList);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,10 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Telephony;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
@ -49,6 +51,9 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_restore_messages);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
assert getIntent().getExtras() != null;
|
||||
|
||||
String accountName = getIntent().getExtras().getString("account");
|
||||
@ -111,6 +116,19 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private void initInterface() {
|
||||
TextView tv_error = (TextView) findViewById(R.id.tv_error_default_smsapp);
|
||||
tv_error.setText(R.string.error_make_default_sms_app);
|
||||
@ -132,8 +150,7 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
tv_error.setVisibility(View.VISIBLE);
|
||||
fix_button.setVisibility(View.VISIBLE);
|
||||
launch_restore.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tv_error.setVisibility(View.INVISIBLE);
|
||||
fix_button.setVisibility(View.INVISIBLE);
|
||||
launch_restore.setVisibility(View.VISIBLE);
|
||||
|
@ -3,13 +3,10 @@ package fr.unix_experience.owncloud_sms.notifications;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
@ -40,7 +37,7 @@ public class OCSMSNotificationUI {
|
||||
|
||||
// This image is used as the notification's large icon (thumbnail).
|
||||
// TODO: Remove this if your notification has no relevant thumbnail.
|
||||
Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_launcher);
|
||||
Bitmap picture = BitmapFactory.decodeResource(res, R.mipmap.ic_launcher);
|
||||
|
||||
|
||||
String ticker = (titleString.length() > 20) ? titleString.substring(0, 20) : titleString;
|
||||
@ -50,31 +47,28 @@ public class OCSMSNotificationUI {
|
||||
|
||||
// Set appropriate defaults for the notification light, sound,
|
||||
// and vibration.
|
||||
.setSmallIcon(R.drawable.ic_launcher)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentTitle(title)
|
||||
.setContentText(contentString)
|
||||
|
||||
// All fields below this line are optional.
|
||||
// All fields below this line are optional.
|
||||
|
||||
// Use a default priority (recognized on devices running Android
|
||||
// 4.1 or later)
|
||||
// Use a default priority (recognized on devices running Android
|
||||
// 4.1 or later)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
|
||||
// Provide a large icon, shown with the notification in the
|
||||
// notification drawer on devices running Android 3.0 or later.
|
||||
.setLargeIcon(picture)
|
||||
|
||||
// Set ticker text (preview) information for this notification.
|
||||
// Set ticker text (preview) information for this notification.
|
||||
//.setTicker(ticker)
|
||||
|
||||
// Show a number. This is useful when stacking notifications of
|
||||
// a single type.
|
||||
// Show a number. This is useful when stacking notifications of
|
||||
// a single type.
|
||||
.setNumber(number)
|
||||
.setStyle(new NotificationCompat.BigTextStyle()
|
||||
.bigText(contentString)
|
||||
.setBigContentTitle(title)
|
||||
.setSummaryText(titleString))
|
||||
.setAutoCancel(true);
|
||||
.setAutoCancel(true)
|
||||
.setColor(context.getResources().getColor(R.color.oc_primary));
|
||||
|
||||
OCSMSNotificationUI.notify(context, builder.build());
|
||||
}
|
||||
@ -83,25 +77,17 @@ public class OCSMSNotificationUI {
|
||||
private static void notify(Context context, Notification notification) {
|
||||
NotificationManager nm = (NotificationManager) context
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG, 0, notification);
|
||||
} else {
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG.hashCode(), notification);
|
||||
}
|
||||
nm.notify(OCSMSNotificationUI.NOTIFICATION_TAG, 0, notification);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels any notifications of this type previously shown using
|
||||
* {@link #notify(Context, String, int)}.
|
||||
* {@link #notify(Context, String, String, int)}.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.ECLAIR)
|
||||
public static void cancel(Context context) {
|
||||
NotificationManager nm = (NotificationManager) context
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG, 0);
|
||||
} else {
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG.hashCode());
|
||||
}
|
||||
nm.cancel(OCSMSNotificationUI.NOTIFICATION_TAG, 0);
|
||||
}
|
||||
}
|
||||
|
BIN
src/main/res/drawable-hdpi/logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src/main/res/drawable-hdpi/notification_icon.png
Normal file
After Width: | Height: | Size: 586 B |
BIN
src/main/res/drawable-mdpi/logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/main/res/drawable-mdpi/notification_icon.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
src/main/res/drawable-xhdpi/logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/main/res/drawable-xhdpi/notification_icon.png
Normal file
After Width: | Height: | Size: 701 B |
BIN
src/main/res/drawable-xxhdpi/logo.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
src/main/res/drawable-xxhdpi/notification_icon.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
src/main/res/drawable-xxxhdpi/logo.png
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
src/main/res/drawable-xxxhdpi/notification_icon.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
@ -61,7 +61,9 @@
|
||||
android:id="@+id/ocsms_logo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/login_logo"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingBottom="36dp"
|
||||
android:src="@drawable/logo"
|
||||
android:contentDescription="@string/login_logo" />
|
||||
|
||||
<LinearLayout
|
||||
@ -73,8 +75,9 @@
|
||||
android:id="@+id/oc_protocol"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/protocol_array">
|
||||
</Spinner>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:popupBackground="@color/oc_primary"
|
||||
android:entries="@array/protocol_array" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -84,6 +87,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/prompt_serverURI"
|
||||
android:textColor="@color/oc_white"
|
||||
android:inputType="textUri" >
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
@ -99,9 +103,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/prompt_login"
|
||||
android:textColor="@color/oc_white"
|
||||
android:inputType="textEmailAddress"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
android:maxLines="1" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
@ -117,7 +121,7 @@
|
||||
android:imeOptions="actionUnspecified"
|
||||
android:inputType="textPassword"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
android:textColor="@color/oc_white" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<com.dd.processbutton.iml.ActionProcessButton
|
||||
|
@ -34,9 +34,14 @@
|
||||
android:fitsSystemWindows="true"
|
||||
tools:openDrawer="start"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<RelativeLayout
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/toolbar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/main_title_welcome"
|
||||
@ -44,7 +49,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ma_title_welcome"
|
||||
android:gravity="top"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
@ -53,26 +57,9 @@
|
||||
android:paddingRight="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@+id/main_title_welcome"
|
||||
android:text="@string/ma_content_welcome"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/main_tv_swipe"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@+id/main_tv_welcome"
|
||||
android:text="@string/ma_content_swipeaction"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.NavigationView
|
||||
android:id="@+id/nav_view"
|
||||
@ -81,5 +68,5 @@
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/nav_header_main"
|
||||
app:menu="@menu/activity_main_drawer"
|
||||
android:fitsSystemWindows="false"/>
|
||||
android:fitsSystemWindows="true"/>
|
||||
</android.support.v4.widget.DrawerLayout>
|
@ -3,24 +3,21 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/nav_header_height"
|
||||
android:background="@drawable/side_nav_bar"
|
||||
android:gravity="top"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:padding="@dimen/activity_horizontal_margin"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||
android:src="@drawable/ic_launcher"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||
android:paddingTop="@dimen/standard_half_padding"
|
||||
android:text="@string/app_name"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
|
||||
|
||||
|
@ -6,6 +6,6 @@
|
||||
android:id="@+id/recovery_phone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:textSize="18sp" />
|
||||
android:padding="@dimen/activity_vertical_margin"
|
||||
android:textSize="18sp"/>
|
||||
</RelativeLayout>
|
@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2017, Andy Scherzinger
|
||||
* Copyright (c) 2014-2015, Loic Blot <loic.blot@unix-experience.fr>
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -24,11 +26,28 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
-->
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<resources>
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
|
||||
|
||||
<style name="OcSmsTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
</style>
|
||||
</resources>
|
||||
<ProgressBar
|
||||
android:id="@+id/login_progress"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
@ -97,7 +97,7 @@
|
||||
<string name="ma_title_rate_us">Rate us !</string>
|
||||
<string name="ma_title_add_account">Add an account</string>
|
||||
<string name="ma_title_welcome">Welcome</string>
|
||||
<string name="ma_content_welcome">Welcome to ownCloud SMS application. This application let you synchronize your SMS to your ownCloud instance using SMS app.</string>
|
||||
<string name="ma_content_welcome">Welcome to Nextcloud SMS application. This application let you synchronize your SMS to your Nextcloud instance using SMS app.</string>
|
||||
|
||||
<!-- Notifications -->
|
||||
<string name="sync_title">Sync process</string>
|
||||
|
@ -1,23 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="android:navigationBarColor">@color/oc_primary</item>
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
</style>
|
||||
|
||||
<style name="OcSmsTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<item name="colorAccent">@color/oc_accent</item>
|
||||
<item name="android:navigationBarColor">@color/oc_primary</item>
|
||||
</style>
|
||||
>
|
||||
|
||||
<style name="OcSmsTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<style name="OcSmsTheme.Drawer" parent="OcSmsTheme.NoActionBar">
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="OcSmsTheme.NoActionBar">
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
<item name="colorAccent">@color/oc_accent</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
</style>
|
||||
</resources>
|
@ -6,5 +6,5 @@
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
|
||||
<dimen name="nav_drawer_header_height">164dp</dimen>
|
||||
</resources>
|
||||
|
@ -2,4 +2,7 @@
|
||||
<resources>
|
||||
<color name="oc_primary">#0082C9</color>
|
||||
<color name="oc_primary_dark">#006AA3</color>
|
||||
<color name="oc_accent">#007CC2</color>
|
||||
<color name="oc_login_hint">#7fC0E3</color>
|
||||
<color name="oc_white">#ffffff</color>
|
||||
</resources>
|
@ -6,7 +6,8 @@
|
||||
<dimen name="arrow_max_height">22dp</dimen>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="nav_header_vertical_spacing">16dp</dimen>
|
||||
<dimen name="nav_header_height">120dp</dimen>
|
||||
<dimen name="standard_half_padding">8dp</dimen>
|
||||
<dimen name="nav_header_height">140dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
@ -27,15 +27,39 @@
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<style name="OcSmsTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
</style>
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<item name="colorAccent">@color/oc_accent</item>
|
||||
</style>
|
||||
|
||||
<!-- separate style for Drawer activities needed for v21+ theming -->
|
||||
<style name="OcSmsTheme.Drawer" parent="OcSmsTheme.NoActionBar">
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
<item name="colorAccent">@color/oc_accent</item>
|
||||
</style>
|
||||
|
||||
<style name="OcSmsTheme.NoActionbar" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimaryDark">@color/oc_primary_dark</item>
|
||||
<item name="colorPrimary">@color/oc_primary</item>
|
||||
<item name="colorAccent">@color/oc_accent</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
</style>
|
||||
|
||||
<style name="OcSmsTheme.Login" parent="OcSmsTheme">
|
||||
<item name="android:windowBackground">@color/oc_primary</item>
|
||||
<item name="colorControlNormal">@color/oc_login_hint</item>
|
||||
<item name="colorControlActivated">@color/oc_white</item>
|
||||
<item name="colorControlHighlight">@color/oc_login_hint</item>
|
||||
<item name="colorAccent">@color/oc_login_hint</item>
|
||||
<item name="android:textColorHint">@color/oc_login_hint</item>
|
||||
<item name="android:textColor">@color/oc_white</item>
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="StandardButton">
|
||||
<item name="android:background">@color/oc_primary</item>
|
||||
<item name="android:layout_marginTop">15dp</item>
|
||||
@ -52,7 +76,7 @@
|
||||
<item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
|
||||
</style>
|
||||
|
||||
<style name="OcSmsTheme.NoActionBar">
|
||||
<style name="OcSmsTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|