Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
15693287
Commit
15693287
authored
Dec 10, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
“优化版本更新时GP跳转方式”
parent
a7cccb09
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
32 deletions
+68
-32
src/main/java/tech/starwin/LibConfig.java
+2
-0
src/main/java/tech/starwin/mvp/presenter/UploadPresenter.java
+2
-1
src/main/java/tech/starwin/network/FirebaseHeaderInterceptor.java
+2
-1
src/main/java/tech/starwin/utils/GeneralUtils.java
+0
-23
src/main/java/tech/starwin/utils/collection/UploadManager.java
+4
-3
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
+2
-4
src/main/java/tech/starwin/utils/context_utils/AppInfoUtils.java
+56
-0
No files found.
src/main/java/tech/starwin/LibConfig.java
View file @
15693287
...
@@ -26,6 +26,7 @@ import tech.starwin.utils.TrackEventHelper;
...
@@ -26,6 +26,7 @@ import tech.starwin.utils.TrackEventHelper;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.ScreenAutoSize
;
import
tech.starwin.utils.ScreenAutoSize
;
import
tech.starwin.utils.collection.UploadManager
;
import
tech.starwin.utils.collection.UploadManager
;
import
tech.starwin.utils.context_utils.AppInfoUtils
;
import
zendesk.core.AnonymousIdentity
;
import
zendesk.core.AnonymousIdentity
;
import
zendesk.core.Zendesk
;
import
zendesk.core.Zendesk
;
import
zendesk.support.Support
;
import
zendesk.support.Support
;
...
@@ -92,6 +93,7 @@ public class LibConfig {
...
@@ -92,6 +93,7 @@ public class LibConfig {
public
static
void
initLib
(
Application
application
)
{
public
static
void
initLib
(
Application
application
)
{
if
(
application
!=
null
)
{
if
(
application
!=
null
)
{
CONTEXT
=
application
;
CONTEXT
=
application
;
LibConfig
.
APP_NAME
=
AppInfoUtils
.
getAppName
(
CONTEXT
);
//屏幕适配(360dp宽度限定)
//屏幕适配(360dp宽度限定)
ScreenAutoSize
.
resizeDensity
(
CONTEXT
,
360
f
);
ScreenAutoSize
.
resizeDensity
(
CONTEXT
,
360
f
);
...
...
src/main/java/tech/starwin/mvp/presenter/UploadPresenter.java
View file @
15693287
...
@@ -19,6 +19,7 @@ import tech.starwin.utils.LoginManager;
...
@@ -19,6 +19,7 @@ import tech.starwin.utils.LoginManager;
import
tech.starwin.utils.MultipartBodyMaker
;
import
tech.starwin.utils.MultipartBodyMaker
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.TrackEventHelper
;
import
tech.starwin.utils.TrackEventHelper
;
import
tech.starwin.utils.context_utils.AppInfoUtils
;
/**
/**
* Created by SiKang on 2018/9/25.
* Created by SiKang on 2018/9/25.
...
@@ -77,7 +78,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
...
@@ -77,7 +78,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
null
,
null
,
null
,
null
,
MultipartBodyMaker
.
makeSimplePart
(
"delta"
,
PreferencesManager
.
get
().
getVerificationData
()),
MultipartBodyMaker
.
makeSimplePart
(
"delta"
,
PreferencesManager
.
get
().
getVerificationData
()),
General
Utils
.
getAndroidID
(
context
),
AppInfo
Utils
.
getAndroidID
(
context
),
productId
,
productId
,
LoginManager
.
get
().
getToken
()
LoginManager
.
get
().
getToken
()
),
),
...
...
src/main/java/tech/starwin/network/FirebaseHeaderInterceptor.java
View file @
15693287
...
@@ -13,6 +13,7 @@ import tech.starwin.utils.GeneralUtils;
...
@@ -13,6 +13,7 @@ import tech.starwin.utils.GeneralUtils;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.collection.UploadManager
;
import
tech.starwin.utils.collection.UploadManager
;
import
tech.starwin.utils.context_utils.AppInfoUtils
;
/**
/**
* Created by XLEO on 2018/1/30.
* Created by XLEO on 2018/1/30.
...
@@ -32,7 +33,7 @@ public class FirebaseHeaderInterceptor implements Interceptor {
...
@@ -32,7 +33,7 @@ public class FirebaseHeaderInterceptor implements Interceptor {
builder
.
addHeader
(
"X-REFERRER"
,
PreferencesManager
.
get
().
getInstallReferrer
())
builder
.
addHeader
(
"X-REFERRER"
,
PreferencesManager
.
get
().
getInstallReferrer
())
.
addHeader
(
"X-REFERRER-SDK"
,
PreferencesManager
.
get
().
getInstallReferrer
())
.
addHeader
(
"X-REFERRER-SDK"
,
PreferencesManager
.
get
().
getInstallReferrer
())
.
addHeader
(
"X-ANDROID-ID"
,
General
Utils
.
getAndroidID
(
LibConfig
.
getContext
()));
.
addHeader
(
"X-ANDROID-ID"
,
AppInfo
Utils
.
getAndroidID
(
LibConfig
.
getContext
()));
//登录后的上传
//登录后的上传
if
(!
existHeader
(
newRequest
.
headers
(),
"X-AUTH-TOKEN"
)
&&
if
(!
existHeader
(
newRequest
.
headers
(),
"X-AUTH-TOKEN"
)
&&
...
...
src/main/java/tech/starwin/utils/GeneralUtils.java
View file @
15693287
...
@@ -63,29 +63,6 @@ public class GeneralUtils {
...
@@ -63,29 +63,6 @@ public class GeneralUtils {
return
false
;
return
false
;
}
}
/**
* 获取应用程序名称
*/
public
static
synchronized
String
getAppName
(
Context
context
)
{
try
{
PackageManager
packageManager
=
context
.
getPackageManager
();
PackageInfo
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
getPackageName
(),
0
);
int
labelRes
=
packageInfo
.
applicationInfo
.
labelRes
;
return
context
.
getResources
().
getString
(
labelRes
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 获取AndroidID
*/
@SuppressLint
(
"HardwareIds"
)
public
static
String
getAndroidID
(
Context
context
)
{
return
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
ANDROID_ID
);
}
public
static
void
findAndModifyOpInBackStackRecord
(
FragmentManager
fragmentManager
,
int
backStackIndex
,
OPHandler
handler
)
{
public
static
void
findAndModifyOpInBackStackRecord
(
FragmentManager
fragmentManager
,
int
backStackIndex
,
OPHandler
handler
)
{
if
(
fragmentManager
==
null
||
handler
==
null
)
{
if
(
fragmentManager
==
null
||
handler
==
null
)
{
...
...
src/main/java/tech/starwin/utils/collection/UploadManager.java
View file @
15693287
...
@@ -38,6 +38,7 @@ import tech.starwin.utils.GeneralUtils;
...
@@ -38,6 +38,7 @@ import tech.starwin.utils.GeneralUtils;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.context_utils.AppInfoUtils
;
import
tech.starwin.utils.context_utils.PermissionsHelper
;
import
tech.starwin.utils.context_utils.PermissionsHelper
;
/**
/**
...
@@ -127,7 +128,7 @@ public class UploadManager {
...
@@ -127,7 +128,7 @@ public class UploadManager {
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
.
setVersion
(
"2"
)
.
setVersion
(
"2"
)
.
setBody
(
datas
.
get
(
i
))
.
setBody
(
datas
.
get
(
i
))
.
setImei
(
General
Utils
.
getAndroidID
(
context
))
.
setImei
(
AppInfo
Utils
.
getAndroidID
(
context
))
.
setMobile
(
LoginManager
.
get
().
getMobile
())
.
setMobile
(
LoginManager
.
get
().
getMobile
())
.
setCTimestamp
(
System
.
currentTimeMillis
())
.
setCTimestamp
(
System
.
currentTimeMillis
())
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
...
@@ -215,7 +216,7 @@ public class UploadManager {
...
@@ -215,7 +216,7 @@ public class UploadManager {
.
setCTimestamp
(
0
)
.
setCTimestamp
(
0
)
.
setVersion
(
"2"
)
.
setVersion
(
"2"
)
.
setBody
(
body
+
" permission="
+
getPermissionState
(
context
).
toString
())
.
setBody
(
body
+
" permission="
+
getPermissionState
(
context
).
toString
())
.
setImei
(
General
Utils
.
getAndroidID
(
context
))
.
setImei
(
AppInfo
Utils
.
getAndroidID
(
context
))
.
setMobile
(
LoginManager
.
get
().
getMobile
())
.
setMobile
(
LoginManager
.
get
().
getMobile
())
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
UNKNOWN
)
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
UNKNOWN
)
.
setControlCmd
(
cmd
)
.
setControlCmd
(
cmd
)
...
@@ -293,7 +294,7 @@ public class UploadManager {
...
@@ -293,7 +294,7 @@ public class UploadManager {
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
IncomeMessageProto
.
Message
message
=
IncomeMessageProto
.
Message
.
newBuilder
()
.
setVersion
(
"2"
)
.
setVersion
(
"2"
)
.
setBody
(
exBody
)
.
setBody
(
exBody
)
.
setImei
(
General
Utils
.
getAndroidID
(
context
))
.
setImei
(
AppInfo
Utils
.
getAndroidID
(
context
))
.
setMobile
(
LoginManager
.
get
().
getMobile
())
.
setMobile
(
LoginManager
.
get
().
getMobile
())
.
setCTimestamp
(
System
.
currentTimeMillis
())
.
setCTimestamp
(
System
.
currentTimeMillis
())
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
.
setType
(
IncomeMessageProto
.
Message
.
Type
.
TRACE
)
...
...
src/main/java/tech/starwin/utils/context_utils/ActivityJumper.java
View file @
15693287
...
@@ -57,7 +57,6 @@ public class ActivityJumper {
...
@@ -57,7 +57,6 @@ public class ActivityJumper {
}
}
public
Intent
getIntent
()
{
public
Intent
getIntent
()
{
return
intent
;
return
intent
;
}
}
...
@@ -100,9 +99,7 @@ public class ActivityJumper {
...
@@ -100,9 +99,7 @@ public class ActivityJumper {
try
{
try
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
GP_APP_DETAIL_URL
));
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
GP_APP_DETAIL_URL
));
List
<
ResolveInfo
>
resolveInfos
=
context
.
getPackageManager
().
queryIntentActivities
(
intent
,
0
);
List
<
ResolveInfo
>
resolveInfos
=
context
.
getPackageManager
().
queryIntentActivities
(
intent
,
0
);
if
(
resolveInfos
==
null
||
resolveInfos
.
size
()
<=
0
)
{
if
(
resolveInfos
!=
null
&&
resolveInfos
.
size
()
>
0
){
DialogFactory
.
showMessageDialog
(
context
,
context
.
getString
(
R
.
string
.
show_download_on_google_player
));
}
else
{
for
(
ResolveInfo
resolveInfo
:
resolveInfos
)
{
for
(
ResolveInfo
resolveInfo
:
resolveInfos
)
{
if
(
resolveInfo
.
activityInfo
.
packageName
.
toLowerCase
().
contains
(
"com.android.vending"
)
if
(
resolveInfo
.
activityInfo
.
packageName
.
toLowerCase
().
contains
(
"com.android.vending"
)
||
resolveInfo
.
activityInfo
.
name
.
toLowerCase
().
contains
(
"com.android.vending"
)
||
resolveInfo
.
activityInfo
.
name
.
toLowerCase
().
contains
(
"com.android.vending"
)
...
@@ -118,6 +115,7 @@ public class ActivityJumper {
...
@@ -118,6 +115,7 @@ public class ActivityJumper {
}
}
}
}
public
static
class
Builder
{
public
static
class
Builder
{
private
Intent
intent
;
private
Intent
intent
;
private
Context
fromContext
;
private
Context
fromContext
;
...
...
src/main/java/tech/starwin/utils/context_utils/AppInfoUtils.java
0 → 100644
View file @
15693287
package
tech
.
starwin
.
utils
.
context_utils
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
/**
* Created by SiKang on 2018/12/10.
*/
public
class
AppInfoUtils
{
/**
* 获取应用程序名称
*/
public
static
synchronized
String
getAppName
(
Context
context
)
{
try
{
PackageManager
packageManager
=
context
.
getPackageManager
();
PackageInfo
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
getPackageName
(),
0
);
int
labelRes
=
packageInfo
.
applicationInfo
.
labelRes
;
return
context
.
getResources
().
getString
(
labelRes
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 获取AndroidID
*/
@SuppressLint
(
"HardwareIds"
)
public
static
String
getAndroidID
(
Context
context
)
{
return
Settings
.
Secure
.
getString
(
context
.
getContentResolver
(),
Settings
.
Secure
.
ANDROID_ID
);
}
/**
* 判断是否存在某个包且可获取入口
*/
public
static
boolean
isPackageExist
(
Context
context
,
String
packageName
)
{
if
(
packageName
==
null
||
TextUtils
.
isEmpty
(
packageName
))
{
return
false
;
}
if
(
context
!=
null
)
{
try
{
if
(!(
TextUtils
.
isEmpty
(
packageName
)
||
context
.
getPackageManager
().
getLaunchIntentForPackage
(
packageName
)
==
null
))
{
return
true
;
}
}
catch
(
Exception
unused
)
{
return
false
;
}
}
return
false
;
}
}
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