Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
package com.teamll.expectlauncher.activities;

import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;

import com.teamll.expectlauncher.R;
import com.teamll.expectlauncher.adapters.AppListAdapter;
import com.teamll.expectlauncher.config.AppItemConfig;
import com.teamll.expectlauncher.fragments.AppDrawerFragment;
import com.teamll.expectlauncher.fragments.MainScreenFragment;
import com.teamll.expectlauncher.ultilities.Tool;


public class MainActivity extends AppCompatActivity implements Tool.WallpaperChangedNotifier {
private Toolbar toolbarResizeIcon;
private AppDrawerFragment appDrawerFragment;

private final int SMALL_ICON_WIDTH = 45;
private final int SMALL_ICON_HEIGHT = 45;
private final int MEDIUM_ICON_WIDTH = 55;
private final int MEDIUM_ICON_HEIGHT = 55;
private final int LARGE_ICON_WIDTH = 65;
private final int LARGE_ICON_HEIGHT = 65;
@Override
protected void onResume() {
super.onResume();
Expand Down Expand Up @@ -49,6 +65,15 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().getDecorView()
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
}

toolbarResizeIcon = findViewById(R.id.toolbarResizeIcon);
setSupportActionBar(toolbarResizeIcon);
getSupportActionBar().hide();
//toolbarResizeIcon.setVisibility(View.INVISIBLE);

appDrawerFragment = new AppDrawerFragment();


}

@Override
Expand Down Expand Up @@ -76,9 +101,10 @@ protected void onNewIntent(Intent intent) {

public void openAppDrawer() {
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, new AppDrawerFragment())
.replace(R.id.container, appDrawerFragment)
.commitNow();
mode = 1;
getSupportActionBar().show();
}

@Override
Expand Down Expand Up @@ -110,4 +136,39 @@ public void onDetachedFromWindow() {
public boolean dispatchKeyEvent(KeyEvent event) {
return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.popupmenu_resize_icon, menu);

return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// action with ID action_refresh was selected
case R.id.small_size:
((AppListAdapter)appDrawerFragment.recyclerView.getAdapter()).setNewIconSize(SMALL_ICON_WIDTH, SMALL_ICON_HEIGHT);
appDrawerFragment.recyclerView.removeAllViewsInLayout();
((AppListAdapter)appDrawerFragment.recyclerView.getAdapter()).notifyDataSetChanged();
break;
// action with ID action_settings was selected
case R.id.medium_size:
((AppListAdapter)appDrawerFragment.recyclerView.getAdapter()).setNewIconSize(MEDIUM_ICON_WIDTH,MEDIUM_ICON_HEIGHT);
appDrawerFragment.recyclerView.removeAllViewsInLayout();
((AppListAdapter)appDrawerFragment.recyclerView.getAdapter()).notifyDataSetChanged();
break;
case R.id.large_size:
((AppListAdapter)appDrawerFragment.recyclerView.getAdapter()).setNewIconSize(LARGE_ICON_WIDTH,LARGE_ICON_HEIGHT);
appDrawerFragment.recyclerView.removeAllViewsInLayout();
((AppListAdapter)appDrawerFragment.recyclerView.getAdapter()).notifyDataSetChanged();
break;
default:
break;
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,46 @@

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;


import com.teamll.expectlauncher.R;
import com.teamll.expectlauncher.config.AppItemConfig;
import com.teamll.expectlauncher.others.AppModel;
import com.teamll.expectlauncher.helper.ItemTouchHelperAdapter;
import com.teamll.expectlauncher.helper.ItemTouchHelperViewHolder;
import com.teamll.expectlauncher.helper.OnStartDragListener;
import com.teamll.expectlauncher.ultilities.Tool;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;



public class AppListAdapter extends RecyclerView.Adapter<AppListAdapter.ViewHolder> implements ItemTouchHelperAdapter {
private Context mContext;
private List<AppModel> mData = new ArrayList<>();
private final OnStartDragListener mDragStartListener;
private int iconDefaultWidth = 55;
private int iconDefaultHeight = 55;

private ItemClickListener mClickListener;
public static int iconWidth;
public static int iconHeight;

public static float oneDp;


public AppListAdapter(Context context, List<AppModel> data, OnStartDragListener dragStartListener) {
Expand All @@ -38,6 +50,10 @@ public AppListAdapter(Context context, List<AppModel> data, OnStartDragListener

if(data!=null)
this.mData = data;

oneDp = Tool.getOneDps(context);
iconWidth = (int)(iconDefaultWidth*oneDp);
iconHeight = (int)(iconDefaultHeight*oneDp);
}
public void setData(ArrayList<AppModel> data) {
mData.clear();
Expand Down Expand Up @@ -90,6 +106,12 @@ public void onItemDismiss(int position) {
notifyItemRemoved(position);
}

public void setNewIconSize(int width, int height){

AppListAdapter.iconWidth = (int)(width*oneDp);
AppListAdapter.iconHeight = (int)(height*oneDp);
}

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, ItemTouchHelperViewHolder {
ImageView icon;
TextView text;
Expand All @@ -98,9 +120,9 @@ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickL
ViewHolder(View itemView) {
super(itemView);
root = itemView;
icon = itemView.findViewById(R.id.icon);
text = itemView.findViewById(R.id.text);
itemView.setOnClickListener(this);
icon = itemView.findViewById(R.id.icon);
text = itemView.findViewById(R.id.text);
itemView.setOnClickListener(this);
}

@Override
Expand All @@ -111,8 +133,12 @@ public void onClick(View view) {
}
}
void bind(AppModel appModel) {

text.setText(appModel.getLabel());
icon.setImageDrawable(appModel.getIcon());
icon.getLayoutParams().width = AppListAdapter.iconWidth;
icon.getLayoutParams().height = AppListAdapter.iconHeight;
//Toast.makeText(mContext, String.format("%s - %dx%d",text.getText().toString(), icon.getLayoutParams().width, icon.getLayoutParams().height).toString(), Toast.LENGTH_SHORT).show();
/*
icon.setOnTouchListener(new View.OnTouchListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.teamll.expectlauncher.config;

public class AppItemConfig {
public static int iconWidth = 80;
public static int iconHeight = 80;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
import android.support.v4.content.Loader;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.PopupMenu;

import com.teamll.expectlauncher.R;
import com.teamll.expectlauncher.adapters.AppListAdapter;
Expand All @@ -33,8 +38,9 @@ public class AppDrawerFragment extends Fragment implements AppListAdapter.ItemCl
View rootView;
Activity activity;
AppListAdapter mAdapter;
RecyclerView recyclerView;
public RecyclerView recyclerView;
ItemTouchHelper mItemTouchHelper;
ImageButton popupMenu;

float statusBarHeight = 0;
float navigationHeight = 0;
Expand All @@ -54,6 +60,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
activity = getActivity();
rootView = inflater.inflate(R.layout.app_drawer_fragment,container,false);
recyclerView = rootView.findViewById(R.id.appListRecyclerView);
//popupMenu = rootView.findViewById(R.id.popupMenu);
// setEmptyText("No Applications");
setScreenProperties();
setAdapterForRecyclerView();
Expand Down
Binary file added app/src/main/res/drawable/popup_menu_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/transparent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>
16 changes: 8 additions & 8 deletions app/src/main/res/layout/app_drawer_fragment.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.teamll.expectlauncher.fragments.AppDrawerFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/appListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>

<android.support.v7.widget.RecyclerView
android:id="@+id/appListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</android.support.constraint.ConstraintLayout>
4 changes: 2 additions & 2 deletions app/src/main/res/layout/list_item_icon_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
>
<ImageView
android:id="@+id/icon"
android:layout_width="62dp"
android:layout_height="62dp"
android:layout_width="@dimen/default_icon_width"
android:layout_height="@dimen/default_icon_height"

android:layout_gravity="center_horizontal"/>
<TextView android:id="@+id/text"
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.MainActivity"
android:background="@android:color/transparent">
android:background="@android:color/transparent"
android:fitsSystemWindows="true">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
Expand All @@ -17,5 +19,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:layout_marginTop="50dp"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarResizeIcon"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorPrimaryDark"
android:layout_marginTop="20dp">

</android.support.v7.widget.Toolbar>
</FrameLayout>
12 changes: 12 additions & 0 deletions app/src/main/res/menu/popupmenu_resize_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/small_size"
android:title="Small" />
<item
android:id="@+id/medium_size"
android:title="Medium"/>
<item
android:id="@+id/large_size"
android:title="Large"/>
</menu>
4 changes: 4 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
<dimen name="app_width">62dp</dimen>
<dimen name="app_height">82dp</dimen>
<dimen name="padding">20dp</dimen>
<dimen name="default_icon_width">62dp</dimen>
<dimen name="default_icon_height">62dp</dimen>
<dimen name="popup_menu_width">40dp</dimen>
<dimen name="popup_menu_height">40dp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fitsSystemWindows">true</item>
</style>

<style name="AppTheme.Wallpaper" parent="@style/Theme.AppCompat.Light.NoActionBar">
Expand Down