org.telegram.messenger.ApplicationLoader Java Examples

The following examples show how to use org.telegram.messenger.ApplicationLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChatAttachAlertLocationLayout.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private Location getLastLocation() {
    if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        return null;
    } else {
        LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
        List<String> providers = lm.getProviders(true);
        Location l = null;
        for (int i = providers.size() - 1; i >= 0; i--) {
            l = lm.getLastKnownLocation(providers.get(i));
            if (l != null) {
                break;
            }
        }
        return l;
    }
}
 
Example #2
Source File: StatisticActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void recolorRecyclerItem(View child) {
    if (child instanceof ChartCell) {
        ((ChartCell) child).recolor();
    }

    if (child instanceof ShadowSectionCell) {
        Drawable shadowDrawable = Theme.getThemedDrawable(ApplicationLoader.applicationContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
        Drawable background = new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray));
        CombinedDrawable combinedDrawable = new CombinedDrawable(background, shadowDrawable, 0, 0);
        combinedDrawable.setFullsize(true);
        child.setBackground(combinedDrawable);
    }

    if (child instanceof OverviewCell) {
        ((OverviewCell) child).updateColors();
    }
}
 
Example #3
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isConnectionSlow()
{
    try
    {
        ConnectivityManager connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        if (connectivityManager == null)
            return false;

        NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
        if (netInfo.getType() == ConnectivityManager.TYPE_MOBILE)
        {
            switch (netInfo.getSubtype())
            {
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return true;
            }
        }
    }
    catch (Throwable ignore) {}
    return false;
}
 
Example #4
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isConnectedToWiFi()
{
    try
    {
        ConnectivityManager connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        if (connectivityManager == null)
            return false;

        NetworkInfo netInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED)
            return true;
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }

    return false;
}
 
Example #5
Source File: ActionIntroActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (currentType == ACTION_TYPE_NEARBY_LOCATION_ENABLED) {
        boolean enabled = true;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
            enabled = lm.isLocationEnabled();
        } else if (Build.VERSION.SDK_INT >= 19) {
            try {
                int mode = Settings.Secure.getInt(ApplicationLoader.applicationContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
                enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
            } catch (Throwable e) {
                FileLog.e(e);
            }
        }
        if (enabled) {
            presentFragment(new PeopleNearbyActivity(), true);
        }
    }
}
 
Example #6
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isRoaming()
{
    try
    {
        ConnectivityManager connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
        if (netInfo != null)
            return netInfo.isRoaming();
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }

    return false;
}
 
Example #7
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isConnectedToWiFi()
{
    try
    {
        ConnectivityManager connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        if (connectivityManager == null)
            return false;

        NetworkInfo netInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED)
            return true;
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }

    return false;
}
 
Example #8
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isRoaming()
{
    try
    {
        ConnectivityManager connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = connectivityManager != null ? connectivityManager.getActiveNetworkInfo() : null;
        if (netInfo != null)
            return netInfo.isRoaming();
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }

    return false;
}
 
Example #9
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void init(int version, int layer, int apiId, String deviceModel, String systemVersion,
                 String appVersion, String langCode, String systemLangCode, String configPath,
                 String logPath, int userId, boolean enablePushConnection)
{
    native_init(currentAccount, version, layer, apiId, deviceModel, systemVersion,
            appVersion, langCode, systemLangCode, configPath, logPath, userId,
            enablePushConnection, isNetworkOnline(), getCurrentNetworkType());

    checkConnection();
    BroadcastReceiver networkStateReceiver = new BroadcastReceiver()
    {
        @Override
        public void onReceive(Context context, Intent intent)
        {
            checkConnection();
            FileLoader.getInstance(currentAccount).onNetworkChanged(isConnectionSlow());
        }
    };
    IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
}
 
Example #10
Source File: PopupNotificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void openCurrentMessage() {
    if (currentMessageObject == null) {
        return;
    }
    Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
    long dialog_id = currentMessageObject.getDialogId();
    if ((int) dialog_id != 0) {
        int lower_id = (int) dialog_id;
        if (lower_id < 0) {
            intent.putExtra("chatId", -lower_id);
        } else {
            intent.putExtra("userId", lower_id);
        }
    } else {
        intent.putExtra("encId", (int) (dialog_id >> 32));
    }
    intent.putExtra("currentAccount", currentMessageObject.currentAccount);
    intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    startActivity(intent);
    onFinish();
    finish();
}
 
Example #11
Source File: IdenticonActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void fixLayout() {
    ViewTreeObserver obs = fragmentView.getViewTreeObserver();
    obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            if (fragmentView == null) {
                return true;
            }
            fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
            WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
            int rotation = manager.getDefaultDisplay().getRotation();

            if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
                linearLayout.setOrientation(LinearLayout.HORIZONTAL);
            } else {
                linearLayout.setOrientation(LinearLayout.VERTICAL);
            }

            fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(), fragmentView.getPaddingBottom());
            return true;
        }
    });
}
 
Example #12
Source File: ShareAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void copyLink(Context context)
{
    if (exportedMessageLink == null && linkToCopy == null)
        return;

    try
    {
        android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
        android.content.ClipData clip = android.content.ClipData.newPlainText("label", linkToCopy != null ? linkToCopy : exportedMessageLink.link);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(context, LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT).show();
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example #13
Source File: ShareAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void copyLink(Context context)
{
    if (exportedMessageLink == null && linkToCopy == null)
        return;

    try
    {
        android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
        android.content.ClipData clip = android.content.ClipData.newPlainText("label", linkToCopy != null ? linkToCopy : exportedMessageLink.link);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(context, LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT).show();
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example #14
Source File: StickersAlert.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void onSubItemClick(int id) {
    if (stickerSet == null) {
        return;
    }
    String stickersUrl = "https://" + MessagesController.getInstance(currentAccount).linkPrefix + "/addstickers/" + stickerSet.set.short_name;
    if (id == 1) {
        ShareAlert alert = new ShareAlert(getContext(), null, stickersUrl, false, stickersUrl, false);
        if (parentFragment != null) {
            parentFragment.showDialog(alert);
        } else {
            alert.show();
        }
    } else if (id == 2) {
        try {
            AndroidUtilities.addToClipboard(stickersUrl);
            Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT).show();
        } catch (Exception e) {
            FileLog.e(e);
        }
    }
}
 
Example #15
Source File: IdenticonActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void fixLayout() {
    ViewTreeObserver obs = fragmentView.getViewTreeObserver();
    obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            if (fragmentView == null) {
                return true;
            }
            fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
            WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
            int rotation = manager.getDefaultDisplay().getRotation();

            if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
                linearLayout.setOrientation(LinearLayout.HORIZONTAL);
            } else {
                linearLayout.setOrientation(LinearLayout.VERTICAL);
            }

            fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(), fragmentView.getPaddingBottom());
            return true;
        }
    });
}
 
Example #16
Source File: ActionIntroActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (currentType == ACTION_TYPE_NEARBY_LOCATION_ENABLED) {
        boolean enabled = true;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
            enabled = lm.isLocationEnabled();
        } else if (Build.VERSION.SDK_INT >= 19) {
            try {
                int mode = Settings.Secure.getInt(ApplicationLoader.applicationContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
                enabled = (mode != Settings.Secure.LOCATION_MODE_OFF);
            } catch (Throwable e) {
                FileLog.e(e);
            }
        }
        if (enabled) {
            presentFragment(new PeopleNearbyActivity(), true);
        }
    }
}
 
Example #17
Source File: LocationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private Location getLastLocation() {
    if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && getParentActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        return null;
    } else {
        LocationManager lm = (LocationManager) ApplicationLoader.applicationContext.getSystemService(Context.LOCATION_SERVICE);
        List<String> providers = lm.getProviders(true);
        Location l = null;
        for (int i = providers.size() - 1; i >= 0; i--) {
            l = lm.getLastKnownLocation(providers.get(i));
            if (l != null) {
                break;
            }
        }
        return l;
    }
}
 
Example #18
Source File: InstantCameraView.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void saveLastCameraBitmap() {
    Bitmap bitmap = textureView.getBitmap();
    if (bitmap != null && bitmap.getPixel(0, 0) != 0) {
        lastBitmap = Bitmap.createScaledBitmap(textureView.getBitmap(), 80, 80, true);
        if (lastBitmap != null) {
            Utilities.blurBitmap(lastBitmap, 7, 1, lastBitmap.getWidth(), lastBitmap.getHeight(), lastBitmap.getRowBytes());
            try {
                File file = new File(ApplicationLoader.getFilesDirFixed(), "icthumb.jpg");
                FileOutputStream stream = new FileOutputStream(file);
                lastBitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
            } catch (Throwable ignore) {

            }
        }
    }
}
 
Example #19
Source File: WallpapersListActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void fixLayoutInternal() {
    if (getParentActivity() == null) {
        return;
    }
    WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
    int rotation = manager.getDefaultDisplay().getRotation();

    if (AndroidUtilities.isTablet()) {
        columnsCount = 3;
    } else {
        if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
            columnsCount = 5;
        } else {
            columnsCount = 3;
        }
    }
    updateRows();
}
 
Example #20
Source File: EmbedBottomSheet.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void exitFromPip() {
    if (webView == null || pipVideoView == null) {
        return;
    }
    if (ApplicationLoader.mainInterfacePaused) {
        try {
            parentActivity.startService(new Intent(ApplicationLoader.applicationContext, BringAppForegroundService.class));
        } catch (Throwable e) {
            FileLog.e(e);
        }
    }
    if (isYouTube) {
        runJsCode("showControls();");
    }
    ViewGroup parent = (ViewGroup) webView.getParent();
    if (parent != null) {
        parent.removeView(webView);
    }
    containerLayout.addView(webView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48 + 36 + (hasDescription ? 22 : 0)));
    setShowWithoutAnimation(true);
    show();
    pipVideoView.close();
    pipVideoView = null;
}
 
Example #21
Source File: LocationActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void showPermissionAlert(boolean byButton) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    if (byButton) {
        builder.setMessage(LocaleController.getString("PermissionNoLocationPosition", R.string.PermissionNoLocationPosition));
    } else {
        builder.setMessage(LocaleController.getString("PermissionNoLocation", R.string.PermissionNoLocation));
    }
    builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialog, which) -> {
        if (getParentActivity() == null) {
            return;
        }
        try {
            Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
            getParentActivity().startActivity(intent);
        } catch (Exception e) {
            FileLog.e(e);
        }
    });
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    showDialog(builder.create());
}
 
Example #22
Source File: VoIPHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static File getLogsDir() {
	//File logsDir=new File(ApplicationLoader.applicationContext.getExternalCacheDir(), "voip_logs");
	File logsDir = new File(ApplicationLoader.applicationContext.getCacheDir(), "voip_logs");
	if (!logsDir.exists())
		logsDir.mkdirs();
	return logsDir;
}
 
Example #23
Source File: CameraScanActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public CameraScanActivity(int type) {
    super();
    CameraController.getInstance().initCamera(() -> {
        if (cameraView != null) {
            cameraView.initCamera();
        }
    });
    currentType = type;
    if (currentType == TYPE_QR) {
        qrReader = new QRCodeReader();
        visionQrReader = new BarcodeDetector.Builder(ApplicationLoader.applicationContext).setBarcodeFormats(Barcode.QR_CODE).build();
    }
}
 
Example #24
Source File: ExternalActionActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onPause() {
    super.onPause();
    actionBarLayout.onPause();
    if (AndroidUtilities.isTablet()) {
        layersActionBarLayout.onPause();
    }
    ApplicationLoader.externalInterfacePaused = true;
    onPasscodePause();
    if (passcodeView != null) {
        passcodeView.onPause();
    }
}
 
Example #25
Source File: ThemeActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void showPermissionAlert(boolean byButton) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    if (byButton) {
        builder.setMessage(LocaleController.getString("PermissionNoLocationPosition", R.string.PermissionNoLocationPosition));
    } else {
        builder.setMessage(LocaleController.getString("PermissionNoLocation", R.string.PermissionNoLocation));
    }
    builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.GINGERBREAD)
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (getParentActivity() == null) {
                return;
            }
            try {
                Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
                getParentActivity().startActivity(intent);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    });
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    showDialog(builder.create());
}
 
Example #26
Source File: ChatAttachAlertDocumentLayout.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
void onDestroy() {
    try {
        if (receiverRegistered) {
            ApplicationLoader.applicationContext.unregisterReceiver(receiver);
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    parentAlert.actionBar.closeSearchField();
    ActionBarMenu menu = parentAlert.actionBar.createMenu();
    menu.removeView(sortItem);
    menu.removeView(searchItem);
}
 
Example #27
Source File: PhotoPickerActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void saveRecentSearch() {
    SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("web_recent_search", Activity.MODE_PRIVATE).edit();
    editor.clear();
    editor.putInt("count", recentSearches.size());
    for (int a = 0, N = recentSearches.size(); a < N; a++) {
        editor.putString("recent" + a, recentSearches.get(a));
    }
    editor.commit();
}
 
Example #28
Source File: PhotoPickerActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void loadRecentSearch() {
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("web_recent_search", Activity.MODE_PRIVATE);
    int count = preferences.getInt("count", 0);
    for (int a = 0; a < count; a++) {
        String str = preferences.getString("recent" + a, null);
        if (str == null) {
            break;
        }
        recentSearches.add(str);
    }
}
 
Example #29
Source File: VoIPHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static File getLogFile(long callID) {
	if (BuildVars.DEBUG_VERSION) {
		File debugLogsDir = new File(ApplicationLoader.applicationContext.getExternalFilesDir(null), "logs");
		String[] logs = debugLogsDir.list();
		if (logs != null) {
			for (String log : logs) {
				if (log.endsWith("voip" + callID + ".txt")) {
					return new File(debugLogsDir, log);
				}
			}
		}
	}
	return new File(getLogsDir(), callID + ".log");
}
 
Example #30
Source File: VoIPController.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private String getLogFilePath(String name){
	Calendar c=Calendar.getInstance();
	return new File(ApplicationLoader.applicationContext.getExternalFilesDir(null),
			String.format(Locale.US, "logs/%02d_%02d_%04d_%02d_%02d_%02d_%s.txt",
					c.get(Calendar.DATE), c.get(Calendar.MONTH)+1, c.get(Calendar.YEAR),
					c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), c.get(Calendar.SECOND), name)).getAbsolutePath();
}