forked from didi/DoKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
439 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Android/doraemonkit/src/main/java/com/didichuxing/doraemonkit/config/TopActivityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.didichuxing.doraemonkit.config; | ||
|
||
import android.content.Context; | ||
|
||
import com.didichuxing.doraemonkit.constant.SharedPrefsKey; | ||
import com.didichuxing.doraemonkit.util.SharedPrefsUtil; | ||
|
||
/** | ||
* 项目名: Android | ||
* 包名 com.didichuxing.doraemonkit.config | ||
* 文件名: TopActivityConfig | ||
* 创建时间: 2019-04-29 on 12:27 | ||
* | ||
* @author 阿钟 | ||
*/ | ||
|
||
public class TopActivityConfig { | ||
public static boolean isTopActivityOpen(Context context) { | ||
return SharedPrefsUtil.getBoolean(context, SharedPrefsKey.TOP_ACTIVITY_OPEN, false); | ||
} | ||
|
||
public static void setTopActivityOpen(Context context, boolean open) { | ||
SharedPrefsUtil.putBoolean(context, SharedPrefsKey.TOP_ACTIVITY_OPEN, open); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...id/doraemonkit/src/main/java/com/didichuxing/doraemonkit/kit/topactivity/TopActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.didichuxing.doraemonkit.kit.topactivity; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
import com.didichuxing.doraemonkit.R; | ||
import com.didichuxing.doraemonkit.constant.BundleKey; | ||
import com.didichuxing.doraemonkit.constant.FragmentIndex; | ||
import com.didichuxing.doraemonkit.kit.Category; | ||
import com.didichuxing.doraemonkit.kit.IKit; | ||
import com.didichuxing.doraemonkit.ui.UniversalActivity; | ||
|
||
/** | ||
* 项目名: Android | ||
* 包名 com.didichuxing.doraemonkit.kit.topactivity | ||
* 文件名: TopActivity | ||
* 创建时间: 2019-04-29 on 12:13 | ||
* 描述: 当前栈顶的Activity信息 | ||
* | ||
* @author 阿钟 | ||
*/ | ||
|
||
public class TopActivity implements IKit { | ||
|
||
@Override | ||
public int getCategory() { | ||
return Category.TOOLS; | ||
} | ||
|
||
@Override | ||
public int getName() { | ||
return R.string.dk_kit_top_activity; | ||
} | ||
|
||
@Override | ||
public int getIcon() { | ||
return R.drawable.dk_view_check; | ||
} | ||
|
||
@Override | ||
public void onClick(Context context) { | ||
Intent intent = new Intent(context, UniversalActivity.class); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
intent.putExtra(BundleKey.FRAGMENT_INDEX, FragmentIndex.FRAGMENT_TOP_ACTIVITY); | ||
context.startActivity(intent); | ||
} | ||
|
||
@Override | ||
public void onAppInit(Context context) { | ||
|
||
} | ||
} |
155 changes: 155 additions & 0 deletions
155
...onkit/src/main/java/com/didichuxing/doraemonkit/kit/topactivity/TopActivityFloatPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
package com.didichuxing.doraemonkit.kit.topactivity; | ||
|
||
import android.app.Activity; | ||
import android.app.Application; | ||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.WindowManager; | ||
import android.widget.TextView; | ||
|
||
import com.didichuxing.doraemonkit.R; | ||
import com.didichuxing.doraemonkit.config.TopActivityConfig; | ||
import com.didichuxing.doraemonkit.ui.base.BaseFloatPage; | ||
import com.didichuxing.doraemonkit.ui.base.FloatPageManager; | ||
import com.didichuxing.doraemonkit.ui.base.TouchProxy; | ||
|
||
/** | ||
* 项目名: Android | ||
* 包名 com.didichuxing.doraemonkit.kit.topactivity | ||
* 文件名: TopActivityFloatPage | ||
* 创建时间: 2019-04-29 on 13:38 | ||
* 描述: | ||
* | ||
* @author 阿钟 | ||
*/ | ||
|
||
public class TopActivityFloatPage extends BaseFloatPage implements TouchProxy.OnTouchEventListener, | ||
Application.ActivityLifecycleCallbacks { | ||
|
||
private TouchProxy touchProxy = new TouchProxy(this); | ||
private WindowManager windowManager; | ||
private TextView className; | ||
private TextView pkgName; | ||
private TextView pathName; | ||
private Application app; | ||
|
||
@Override | ||
protected void onCreate(Context context) { | ||
super.onCreate(context); | ||
app = (Application) context.getApplicationContext(); | ||
app.registerActivityLifecycleCallbacks(this); | ||
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | ||
} | ||
|
||
@Override | ||
protected View onCreateView(Context context, ViewGroup view) { | ||
return LayoutInflater.from(context).inflate(R.layout.dk_float_view_top_activity, null); | ||
} | ||
|
||
@Override | ||
protected void onViewCreated(View view) { | ||
super.onViewCreated(view); | ||
getRootView().setOnTouchListener(new View.OnTouchListener() { | ||
@Override | ||
public boolean onTouch(View v, MotionEvent event) { | ||
return touchProxy.onTouchEvent(v, event); | ||
} | ||
}); | ||
findViewById(R.id.close).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
TopActivityConfig.setTopActivityOpen(getContext(), false); | ||
FloatPageManager.getInstance().removeAll(TopActivityFloatPage.class); | ||
} | ||
}); | ||
pkgName = findViewById(R.id.pkg_name); | ||
className = findViewById(R.id.class_name); | ||
pathName = findViewById(R.id.path_name); | ||
} | ||
|
||
@Override | ||
protected void onLayoutParamsCreated(WindowManager.LayoutParams params) { | ||
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; | ||
params.width = WindowManager.LayoutParams.MATCH_PARENT; | ||
params.height = WindowManager.LayoutParams.WRAP_CONTENT; | ||
params.x = 0; | ||
params.y = 0; | ||
} | ||
|
||
@Override | ||
public void onEnterForeground() { | ||
super.onEnterForeground(); | ||
getRootView().setVisibility(View.VISIBLE); | ||
} | ||
|
||
@Override | ||
public void onEnterBackground() { | ||
super.onEnterBackground(); | ||
getRootView().setVisibility(View.GONE); | ||
} | ||
|
||
@Override | ||
public void onMove(int x, int y, int dx, int dy) { | ||
getLayoutParams().x += dx; | ||
getLayoutParams().y += dy; | ||
windowManager.updateViewLayout(getRootView(), getLayoutParams()); | ||
} | ||
|
||
|
||
@Override | ||
public void onActivityResumed(Activity activity) { | ||
pkgName.setText(activity.getPackageName()); | ||
className.setText(activity.getClass().getSimpleName()); | ||
pathName.setText(activity.getClass().getName()); | ||
} | ||
|
||
@Override | ||
public void onUp(int x, int y) { | ||
|
||
} | ||
|
||
@Override | ||
public void onDown(int x, int y) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityStarted(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityPaused(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityStopped(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityDestroyed(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
app.unregisterActivityLifecycleCallbacks(this); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...monkit/src/main/java/com/didichuxing/doraemonkit/kit/topactivity/TopActivityFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.didichuxing.doraemonkit.kit.topactivity; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
|
||
import com.didichuxing.doraemonkit.R; | ||
import com.didichuxing.doraemonkit.config.TopActivityConfig; | ||
import com.didichuxing.doraemonkit.ui.base.BaseFragment; | ||
import com.didichuxing.doraemonkit.ui.base.FloatPageManager; | ||
import com.didichuxing.doraemonkit.ui.base.PageIntent; | ||
import com.didichuxing.doraemonkit.ui.setting.SettingItem; | ||
import com.didichuxing.doraemonkit.ui.setting.SettingItemAdapter; | ||
import com.didichuxing.doraemonkit.ui.widget.titlebar.HomeTitleBar; | ||
|
||
/** | ||
* 项目名: Android | ||
* 包名 com.didichuxing.doraemonkit.kit.topactivity | ||
* 文件名: TopActivityFragment | ||
* 创建时间: 2019-04-29 on 12:16 | ||
* 描述: | ||
* | ||
* @author 阿钟 | ||
*/ | ||
|
||
public class TopActivityFragment extends BaseFragment { | ||
@Override | ||
protected int onRequestLayout() { | ||
return R.layout.dk_fragment_top_activity; | ||
} | ||
|
||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
initView(); | ||
} | ||
|
||
private void initView() { | ||
HomeTitleBar titleBar = findViewById(R.id.title_bar); | ||
titleBar.setListener(new HomeTitleBar.OnTitleBarClickListener() { | ||
@Override | ||
public void onRightClick() { | ||
getActivity().finish(); | ||
} | ||
}); | ||
RecyclerView topActivityList = findViewById(R.id.top_activity_list); | ||
topActivityList.setLayoutManager(new LinearLayoutManager(getContext())); | ||
SettingItemAdapter topActivityAdapter = new SettingItemAdapter(getContext()); | ||
topActivityAdapter.append(new SettingItem(R.string.dk_kit_top_activity, TopActivityConfig.isTopActivityOpen(getContext()))); | ||
topActivityAdapter.setOnSettingItemSwitchListener(new SettingItemAdapter.OnSettingItemSwitchListener() { | ||
@Override | ||
public void onSettingItemSwitch(View view, SettingItem data, boolean on) { | ||
if (data.desc == R.string.dk_kit_top_activity) { | ||
if (on) { | ||
PageIntent intent = new PageIntent(TopActivityFloatPage.class); | ||
FloatPageManager.getInstance().add(intent); | ||
getActivity().finish(); | ||
} else { | ||
FloatPageManager.getInstance().removeAll(TopActivityFloatPage.class); | ||
} | ||
TopActivityConfig.setTopActivityOpen(getContext(), on); | ||
} | ||
} | ||
}); | ||
topActivityList.setAdapter(topActivityAdapter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.