Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
c5f7e373
Commit
c5f7e373
authored
Jan 14, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New DebugSettings activity, DebugSettingsFragment and CacheClearDialog.
parent
81682f05
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
117 additions
and
98 deletions
+117
-98
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+9
-0
CacheClearDialog.java
...a/com/xabber/android/ui/preferences/CacheClearDialog.java
+34
-0
DebugSettings.java
...java/com/xabber/android/ui/preferences/DebugSettings.java
+25
-0
DebugSettingsFragment.java
.../xabber/android/ui/preferences/DebugSettingsFragment.java
+20
-0
PreferenceEditor.java
...a/com/xabber/android/ui/preferences/PreferenceEditor.java
+9
-64
PreferencesFragment.java
...om/xabber/android/ui/preferences/PreferencesFragment.java
+3
-23
preference_debug.xml
app/src/main/res/xml/preference_debug.xml
+12
-0
preference_editor.xml
app/src/main/res/xml/preference_editor.xml
+5
-11
No files found.
app/src/main/AndroidManifest.xml
View file @
c5f7e373
...
...
@@ -361,6 +361,15 @@
android:value=
"com.xabber.android.ui.preferences.PreferenceEditor"
/>
</activity>
<activity
android:name=
"com.xabber.android.ui.preferences.DebugSettings"
android:parentActivityName=
"com.xabber.android.ui.preferences.PreferenceEditor"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name=
"android.support.PARENT_ACTIVITY"
android:value=
"com.xabber.android.ui.preferences.PreferenceEditor"
/>
</activity>
<service
android:name=
"com.xabber.android.service.XabberService"
/>
<service
android:name=
"com.xabber.android.service.SyncAdapterService"
...
...
app/src/main/java/com/xabber/android/ui/preferences/CacheClearDialog.java
0 → 100644
View file @
c5f7e373
package
com
.
xabber
.
android
.
ui
.
preferences
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.preference.DialogPreference
;
import
android.util.AttributeSet
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.StatusMode
;
import
com.xabber.androiddev.R
;
public
class
CacheClearDialog
extends
DialogPreference
{
public
CacheClearDialog
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
}
@Override
protected
void
onDialogClosed
(
boolean
positiveResult
)
{
super
.
onDialogClosed
(
positiveResult
);
if
(
positiveResult
)
{
AccountManager
.
getInstance
().
setStatus
(
StatusMode
.
unavailable
,
null
);
Application
.
getInstance
().
requestToClear
();
Application
.
getInstance
().
requestToClose
();
ProgressDialog
progressDialog
=
new
ProgressDialog
(
getContext
());
progressDialog
.
setMessage
(
getContext
().
getString
(
R
.
string
.
application_state_closing
));
progressDialog
.
setCancelable
(
false
);
progressDialog
.
setIndeterminate
(
true
);
progressDialog
.
show
();
}
}
}
app/src/main/java/com/xabber/android/ui/preferences/DebugSettings.java
0 → 100644
View file @
c5f7e373
package
com
.
xabber
.
android
.
ui
.
preferences
;
import
android.os.Bundle
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
public
class
DebugSettings
extends
ManagedActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
isFinishing
())
return
;
setContentView
(
R
.
layout
.
activity_preferences
);
getActionBar
().
setDisplayHomeAsUpEnabled
(
true
);
if
(
savedInstanceState
==
null
)
{
getFragmentManager
().
beginTransaction
()
.
add
(
R
.
id
.
preferences_activity_container
,
new
DebugSettingsFragment
()).
commit
();
}
}
}
app/src/main/java/com/xabber/android/ui/preferences/DebugSettingsFragment.java
0 → 100644
View file @
c5f7e373
package
com
.
xabber
.
android
.
ui
.
preferences
;
import
android.os.Bundle
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.ui.helper.PreferenceSummaryHelper
;
import
com.xabber.androiddev.R
;
public
class
DebugSettingsFragment
extends
android
.
preference
.
PreferenceFragment
{
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
addPreferencesFromResource
(
R
.
xml
.
preference_debug
);
getPreferenceScreen
().
findPreference
(
getString
(
R
.
string
.
debug_log_key
)).
setEnabled
(
LogManager
.
isDebugable
());
PreferenceSummaryHelper
.
updateSummary
(
getPreferenceScreen
());
}
}
app/src/main/java/com/xabber/android/ui/preferences/PreferenceEditor.java
View file @
c5f7e373
...
...
@@ -14,28 +14,17 @@
*/
package
com
.
xabber
.
android
.
ui
.
preferences
;
import
android.app.Dialog
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.preference.Preference
;
import
com.xabber.android.data.Application
;
import
com.xabber.android.data.SettingsManager
;
import
com.xabber.android.data.account.AccountManager
;
import
com.xabber.android.data.account.StatusMode
;
import
com.xabber.android.data.connection.CertificateManager
;
import
com.xabber.android.data.connection.ConnectionManager
;
import
com.xabber.android.ui.dialog.ConfirmDialogBuilder
;
import
com.xabber.android.ui.dialog.ConfirmDialogListener
;
import
com.xabber.android.ui.dialog.DialogBuilder
;
import
com.xabber.android.ui.helper.ManagedActivity
;
import
com.xabber.androiddev.R
;
public
class
PreferenceEditor
extends
ManagedActivity
implements
PreferencesFragment
.
OnPreferencesFragmentInteractionListener
,
Preference
.
OnPreferenceClickListener
,
ConfirmDialogListener
{
implements
PreferencesFragment
.
OnPreferencesFragmentInteractionListener
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -57,61 +46,17 @@ public class PreferenceEditor extends ManagedActivity
SettingsManager
.
chatsAttentionSound
();
}
@Override
public
boolean
onPreferenceClick
(
Preference
preference
)
{
if
(
preference
.
getKey
().
equals
(
getString
(
R
.
string
.
cache_clear_key
)))
{
showDialog
(
R
.
string
.
cache_clear_warning
);
}
return
false
;
}
@Override
protected
Dialog
onCreateDialog
(
int
id
)
{
super
.
onCreateDialog
(
id
);
switch
(
id
)
{
case
R
.
string
.
cache_clear_warning
:
return
new
ConfirmDialogBuilder
(
this
,
R
.
string
.
cache_clear_warning
,
this
).
setMessage
(
R
.
string
.
cache_clear_warning
).
create
();
case
R
.
string
.
application_state_closing
:
ProgressDialog
progressDialog
=
new
ProgressDialog
(
this
);
progressDialog
.
setMessage
(
getString
(
R
.
string
.
application_state_closing
));
progressDialog
.
setCancelable
(
false
);
progressDialog
.
setIndeterminate
(
true
);
return
progressDialog
;
default
:
return
null
;
}
}
@Override
public
void
onAccept
(
DialogBuilder
dialogBuilder
)
{
switch
(
dialogBuilder
.
getDialogId
())
{
case
R
.
string
.
cache_clear_warning
:
AccountManager
.
getInstance
()
.
setStatus
(
StatusMode
.
unavailable
,
null
);
((
Application
)
getApplication
()).
requestToClear
();
Application
.
getInstance
().
requestToClose
();
showDialog
(
R
.
string
.
application_state_closing
);
break
;
}
}
@Override
public
void
onDecline
(
DialogBuilder
dialogBuilder
)
{
}
@Override
public
void
onCancel
(
DialogBuilder
dialogBuilder
)
{
}
public
static
Intent
createIntent
(
Context
context
)
{
return
new
Intent
(
context
,
PreferenceEditor
.
class
);
}
@Override
public
Preference
.
OnPreferenceClickListener
getOnPreferenceClickListener
()
{
return
this
;
public
String
getVersionName
()
{
try
{
return
getPackageManager
().
getPackageInfo
(
getPackageName
(),
0
).
versionName
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
}
app/src/main/java/com/xabber/android/ui/preferences/PreferencesFragment.java
View file @
c5f7e373
...
...
@@ -2,12 +2,9 @@ package com.xabber.android.ui.preferences;
import
android.app.Activity
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.preference.Preference
;
import
com.xabber.android.data.LogManager
;
import
com.xabber.android.ui.helper.PreferenceSummaryHelper
;
import
com.xabber.androiddev.R
;
...
...
@@ -22,28 +19,11 @@ public class PreferencesFragment extends android.preference.PreferenceFragment {
addPreferencesFromResource
(
R
.
xml
.
preference_editor
);
Preference
about
=
getPreferenceScreen
().
findPreference
(
getString
(
R
.
string
.
preference_about_key
));
about
.
setSummary
(
getString
(
R
.
string
.
application_name
)
+
"\n"
+
getVersionName
());
getPreferenceScreen
().
findPreference
(
getString
(
R
.
string
.
cache_clear_key
))
.
setOnPreferenceClickListener
(
mListener
.
getOnPreferenceClickListener
());
getPreferenceScreen
().
findPreference
(
getString
(
R
.
string
.
debug_log_key
))
.
setEnabled
(
LogManager
.
isDebugable
());
about
.
setSummary
(
getString
(
R
.
string
.
application_name
)
+
"\n"
+
mListener
.
getVersionName
());
PreferenceSummaryHelper
.
updateSummary
(
getPreferenceScreen
());
}
private
String
getVersionName
()
{
try
{
PackageInfo
pInfo
=
getActivity
().
getPackageManager
().
getPackageInfo
(
getActivity
().
getPackageName
(),
0
);
return
pInfo
.
versionName
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
@Override
public
void
onAttach
(
Activity
activity
)
{
super
.
onAttach
(
activity
);
...
...
@@ -62,6 +42,6 @@ public class PreferencesFragment extends android.preference.PreferenceFragment {
}
public
interface
OnPreferencesFragmentInteractionListener
{
Preference
.
OnPreferenceClickListener
getOnPreferenceClickListener
();
}
String
getVersionName
();
}
}
app/src/main/res/xml/preference_debug.xml
0 → 100644
View file @
c5f7e373
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<CheckBoxPreference
android:title=
"@string/debug_log"
android:key=
"@string/debug_log_key"
android:defaultValue=
"@bool/debug_log_default"
/>
<com.xabber.android.ui.preferences.CacheClearDialog
android:title=
"@string/cache_clear"
android:key=
"@string/cache_clear_key"
android:dialogMessage=
"@string/cache_clear_warning"
/>
</PreferenceScreen>
\ No newline at end of file
app/src/main/res/xml/preference_editor.xml
View file @
c5f7e373
...
...
@@ -70,20 +70,14 @@
android:targetPackage=
"@string/application_package"
android:targetClass=
"com.xabber.android.ui.preferences.SecuritySettings"
/>
</Preference>
<Preference
Screen
<Preference
android:title=
"@string/preference_debug"
android:key=
"@string/preference_debug"
>
<CheckBoxPreference
android:title=
"@string/debug_log"
android:key=
"@string/debug_log_key"
android:defaultValue=
"@bool/debug_log_default"
/>
<PreferenceScreen
android:title=
"@string/cache_clear"
android:key=
"@string/cache_clear_key"
/>
</PreferenceScreen>
<intent
android:targetPackage=
"@string/application_package"
android:targetClass=
"com.xabber.android.ui.preferences.DebugSettings"
/>
</Preference>
<Preference
android:title=
"@string/preference_about"
android:key=
"@string/preference_about_key"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment