mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-07 16:06:18 +00:00
Now require Android 4.1 or greater. Also better feed back on restore messages for Android 4.3 or lesser versions
This commit is contained in:
parent
e06377d64b
commit
09ab64044d
@ -20,9 +20,9 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId "fr.unix_experience.owncloud_sms"
|
||||
minSdkVersion 14
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 25
|
||||
maxSdkVersion 24
|
||||
maxSdkVersion 25
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
@ -46,10 +46,6 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_restore_messages);
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
|
||||
// @TODO Change message to define Android 4.4 or greated is required
|
||||
return;
|
||||
}
|
||||
|
||||
assert getIntent().getExtras() != null;
|
||||
|
||||
@ -58,16 +54,6 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
// accountName cannot be null, devel error
|
||||
assert accountName != null;
|
||||
AccountManager accountManager = AccountManager.get(getBaseContext());
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED) {
|
||||
// TODO: Consider calling
|
||||
// ActivityCompat#requestPermissions
|
||||
// here to request the missing permissions, and then overriding
|
||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||
// int[] grantResults)
|
||||
// to handle the case where the user grants the permission. See the documentation
|
||||
// for ActivityCompat#requestPermissions for more details.
|
||||
return;
|
||||
}
|
||||
Account[] accountList = accountManager.getAccountsByType(getString(R.string.account_type));
|
||||
for (Account element : accountList) {
|
||||
if (element.name.equals(accountName)) {
|
||||
@ -79,13 +65,19 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
throw new IllegalStateException(getString(R.string.err_didnt_find_account_restore));
|
||||
}
|
||||
|
||||
_defaultSmsApp = Telephony.Sms.getDefaultSmsPackage(this);
|
||||
TextView tv = (TextView) findViewById(R.id.tv_error_default_smsapp);
|
||||
tv.setText(R.string.error_make_default_sms_app);
|
||||
Button fix_button = (Button) findViewById(R.id.button_fix_permissions);
|
||||
final Button launch_restore = (Button) findViewById(R.id.button_launch_restore);
|
||||
final ProgressBar pb = (ProgressBar) findViewById(R.id.progressbar_restore);
|
||||
pb.setVisibility(View.INVISIBLE);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
|
||||
notifyIncompatibleVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
_defaultSmsApp = Telephony.Sms.getDefaultSmsPackage(this);
|
||||
if (!Telephony.Sms.getDefaultSmsPackage(this).equals(getPackageName())) {
|
||||
_defaultSmsApp = Telephony.Sms.getDefaultSmsPackage(getBaseContext());
|
||||
tv.setVisibility(View.VISIBLE);
|
||||
@ -101,7 +93,7 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
fix_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
|
||||
// @TODO Change message to define Android 4.4 or greated is required
|
||||
notifyIncompatibleVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -128,11 +120,21 @@ public class RestoreMessagesActivity extends AppCompatActivity {
|
||||
startActivity(finalIntent);*/
|
||||
}
|
||||
|
||||
private void notifyIncompatibleVersion() {
|
||||
TextView tv = (TextView) findViewById(R.id.tv_error_default_smsapp);
|
||||
Button fix_button = (Button) findViewById(R.id.button_fix_permissions);
|
||||
Button launch_restore = (Button) findViewById(R.id.button_launch_restore);
|
||||
ProgressBar pb = (ProgressBar) findViewById(R.id.progressbar_restore);
|
||||
tv.setText(R.string.err_kitkat_required);
|
||||
fix_button.setVisibility(View.INVISIBLE);
|
||||
launch_restore.setVisibility(View.INVISIBLE);
|
||||
pb.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case RestoreMessagesActivity.REQUEST_DEFAULT_SMSAPP:
|
||||
Log.i(RestoreMessagesActivity.TAG, "RC: " + Integer.toString(resultCode));
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
TextView tv = (TextView) findViewById(R.id.tv_error_default_smsapp);
|
||||
Button fix_button = (Button) findViewById(R.id.button_fix_permissions);
|
||||
|
@ -175,5 +175,7 @@
|
||||
<string name="feature_not_already_implemented">This feature is not already implemented and will be available soon.</string>
|
||||
<string name="pref_title_minimum_sync_chars">Minimum phonenumber length</string>
|
||||
<string name="err_didnt_find_account_restore">We didn\'t find your account to restore your message, this is a very strange situation.</string>
|
||||
<string name="err_kitkat_required">Android 4.4 or greater is required to use this feature.</string>
|
||||
<string name="error_make_default_sms_app">Please make this application default SMS application to permit restore your messages. This limitation has been introduced by Android 4.4.</string>
|
||||
|
||||
</resources>
|
||||
|
@ -162,4 +162,7 @@
|
||||
<string name="feature_not_already_implemented">Cette fonctionnalité n\'est pas implémentée mais elle sera disponible bientôt.</string>
|
||||
<string name="pref_title_minimum_sync_chars">Longueur minimale du numéro de téléphone</string>
|
||||
<string name="err_didnt_find_account_restore">Nous n\'avons pas retrouvé le compte que nous souhaitions utiliser pour la restauration. Cette situation est vraiment étrange.</string>
|
||||
<string name="err_kitkat_required">Android 4.4 ou plus est requis pour utiliser cette fonctionnalité.</string>
|
||||
<string name="err_sync_get_smslist">Erreur #1: Données invalides reçues lors de l\'obtention des messages précédents.</string>
|
||||
<string name="error_make_default_sms_app">Merci de bien vouloir mettre cette application en application SMS par défaut le temps de restaurer les messages. Cette limitation a été ajoutée depuis Android 4.4.</string>
|
||||
</resources>
|
||||
|
@ -248,6 +248,7 @@
|
||||
<string name="pref_title_minimum_sync_chars">Minimum phonenumber length</string>
|
||||
<string name="err_didnt_find_account_restore">We didn\'t find your account to restore your message, this is a very strange situation.</string>
|
||||
<string name="launch_restore">Restore my SMS</string>
|
||||
<string name="error_make_default_sms_app">Please make this application default SMS application to permit restore your messages.</string>
|
||||
<string name="error_make_default_sms_app">Please make this application default SMS application to permit restore your messages. This limitation has been introduced by Android 4.4.</string>
|
||||
<string name="fix_permissions">Fix permissions</string>
|
||||
<string name="err_kitkat_required">Android 4.4 or greater is required to use this feature.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user